1 /* $NetBSD: machdep.h,v 1.20 2026/08/21 14:01:16 tls Exp $ */ 2 3 /* 4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Matthew Fredette. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * Definitions for the hppa that are completely private 34 * to the machine-dependent code. Anything needed by 35 * machine-independent code is covered in cpu.h or in 36 * other headers. 37 */ 38 39 /* 40 * XXX there is a lot of stuff in various headers under 41 * hppa/include, and a lot of one-off `extern's in C files 42 * that could probably be moved here. 43 */ 44 45 #ifdef _KERNEL 46 47 #ifdef _KERNEL_OPT 48 #include "opt_useleds.h" 49 #endif 50 51 /* The primary (aka monarch) CPU HPA */ 52 extern hppa_hpa_t hppa_mcpuhpa; 53 54 /* 55 * cache configuration, for most machines is the same 56 * numbers, so it makes sense to do defines w/ numbers depending 57 * on configured CPU types in the kernel. 58 */ 59 extern int icache_stride, icache_line_mask; 60 extern int dcache_stride, dcache_line_mask; 61 62 extern vaddr_t vmmap; /* XXX - See mem.c */ 63 64 /* Kernel virtual address space available: */ 65 extern vaddr_t virtual_start, virtual_end; 66 67 /* Total physical pages, and low reserved physical pages. */ 68 extern int totalphysmem; 69 extern int availphysmem; 70 extern int resvmem; 71 72 /* BTLB minimum and maximum sizes, in pages. */ 73 extern u_int hppa_btlb_size_min; 74 extern u_int hppa_btlb_size_max; 75 76 /* FPU variables and functions. */ 77 extern int fpu_present; 78 extern u_int fpu_version; 79 extern u_int fpu_csw; 80 void hppa_fpu_bootstrap(u_int); 81 void hppa_fpu_flush(struct lwp *); 82 void hppa_fpu_emulate(struct trapframe *, struct lwp *, u_int); 83 void hppa_fpu_commit(struct lwp *); 84 85 /* Set up of space registers and protection IDs */ 86 void hppa_setvmspace(struct lwp *); 87 88 /* Interrupt dispatching. */ 89 void hppa_intr(struct trapframe *); 90 91 /* Special pmap functions. */ 92 void pmap_redzone(vaddr_t, vaddr_t, int); 93 94 /* Functions to write low memory and the kernel text. */ 95 void hppa_ktext_stw(vaddr_t, int); 96 void hppa_ktext_stb(vaddr_t, char); 97 98 /* Machine check handling. */ 99 extern u_int os_hpmc[8]; 100 extern u_int os_hpmc_cont; 101 extern u_int os_hpmc_cont_end; 102 extern u_int os_hpmc_checksum[1]; 103 104 int os_toc(void); 105 extern u_int os_toc_end; 106 extern u_int os_toc_checksum[1]; 107 108 void hppa_machine_check(int); 109 110 /* BTLB handling. */ 111 int hppa_btlb_insert(pa_space_t, vaddr_t, paddr_t, vsize_t *, u_int); 112 int hppa_btlb_reload(void); 113 int hppa_btlb_purge(pa_space_t, vaddr_t, vsize_t *); 114 115 /* The LEDs. */ 116 #define HPPA_LED_NETSND (0) 117 #define HPPA_LED_NETRCV (1) 118 #define HPPA_LED_DISK (2) 119 #define HPPA_LED_HEARTBEAT (3) 120 #define _HPPA_LEDS_BLINKABLE (4) 121 #define _HPPA_LEDS_COUNT (8) 122 123 /* This forcefully reboots the machine. */ 124 void cpu_die(void); 125 126 /* These map and unmap page zero. */ 127 int hppa_pagezero_map(void); 128 void hppa_pagezero_unmap(int); 129 130 /* Blinking the LEDs. */ 131 #ifdef USELEDS 132 #define _HPPA_LED_FREQ (16) 133 extern volatile uint8_t *machine_ledaddr; 134 extern int machine_ledword, machine_leds; 135 extern int _hppa_led_on_cycles[]; 136 #define hppa_led_blink(i) \ 137 do { \ 138 if (_hppa_led_on_cycles[i] == -1) \ 139 _hppa_led_on_cycles[i] = 1; \ 140 } while (/* CONSTCOND */ 0) 141 #define hppa_led_on(i, ms) \ 142 do { \ 143 _hppa_led_on_cycles[i] = (((ms) * _HPPA_LED_FREQ) / 1000); \ 144 } while (/* CONSTCOND */ 0) 145 void hppa_led_ctl(int, int, int); 146 #else /* !USELEDS */ 147 #define hppa_led_blink(i) 148 #define hppa_led_on(i, ms) 149 #define hppa_led_ctl(off, on, toggle) 150 #endif /* !USELEDS */ 151 152 #endif /* _KERNEL */ 153