1 /* $NetBSD: machdep.h,v 1.19 2020/09/14 16:11:00 skrll 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 84 /* Set up of space registers and protection IDs */ 85 void hppa_setvmspace(struct lwp *); 86 87 /* Interrupt dispatching. */ 88 void hppa_intr(struct trapframe *); 89 90 /* Special pmap functions. */ 91 void pmap_redzone(vaddr_t, vaddr_t, int); 92 93 /* Functions to write low memory and the kernel text. */ 94 void hppa_ktext_stw(vaddr_t, int); 95 void hppa_ktext_stb(vaddr_t, char); 96 97 /* Machine check handling. */ 98 extern u_int os_hpmc[8]; 99 extern u_int os_hpmc_cont; 100 extern u_int os_hpmc_cont_end; 101 extern u_int os_hpmc_checksum[1]; 102 103 int os_toc(void); 104 extern u_int os_toc_end; 105 extern u_int os_toc_checksum[1]; 106 107 void hppa_machine_check(int); 108 109 /* BTLB handling. */ 110 int hppa_btlb_insert(pa_space_t, vaddr_t, paddr_t, vsize_t *, u_int); 111 int hppa_btlb_reload(void); 112 int hppa_btlb_purge(pa_space_t, vaddr_t, vsize_t *); 113 114 /* The LEDs. */ 115 #define HPPA_LED_NETSND (0) 116 #define HPPA_LED_NETRCV (1) 117 #define HPPA_LED_DISK (2) 118 #define HPPA_LED_HEARTBEAT (3) 119 #define _HPPA_LEDS_BLINKABLE (4) 120 #define _HPPA_LEDS_COUNT (8) 121 122 /* This forcefully reboots the machine. */ 123 void cpu_die(void); 124 125 /* These map and unmap page zero. */ 126 int hppa_pagezero_map(void); 127 void hppa_pagezero_unmap(int); 128 129 /* Blinking the LEDs. */ 130 #ifdef USELEDS 131 #define _HPPA_LED_FREQ (16) 132 extern volatile uint8_t *machine_ledaddr; 133 extern int machine_ledword, machine_leds; 134 extern int _hppa_led_on_cycles[]; 135 #define hppa_led_blink(i) \ 136 do { \ 137 if (_hppa_led_on_cycles[i] == -1) \ 138 _hppa_led_on_cycles[i] = 1; \ 139 } while (/* CONSTCOND */ 0) 140 #define hppa_led_on(i, ms) \ 141 do { \ 142 _hppa_led_on_cycles[i] = (((ms) * _HPPA_LED_FREQ) / 1000); \ 143 } while (/* CONSTCOND */ 0) 144 void hppa_led_ctl(int, int, int); 145 #else /* !USELEDS */ 146 #define hppa_led_blink(i) 147 #define hppa_led_on(i, ms) 148 #define hppa_led_ctl(off, on, toggle) 149 #endif /* !USELEDS */ 150 151 #endif /* _KERNEL */ 152