| @@ -1,1246 +1,1251 @@ | | | @@ -1,1246 +1,1251 @@ |
1 | /* $NetBSD: machdep.c,v 1.191 2014/03/26 16:21:39 isaki Exp $ */ | | 1 | /* $NetBSD: machdep.c,v 1.191.4.1 2015/11/05 20:40:22 riz Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988 University of Utah. | | 4 | * Copyright (c) 1988 University of Utah. |
5 | * Copyright (c) 1982, 1986, 1990, 1993 | | 5 | * Copyright (c) 1982, 1986, 1990, 1993 |
6 | * The Regents of the University of California. All rights reserved. | | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to Berkeley by | | 8 | * This code is derived from software contributed to Berkeley by |
9 | * the Systems Programming Group of the University of Utah Computer | | 9 | * the Systems Programming Group of the University of Utah Computer |
10 | * Science Department. | | 10 | * Science Department. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
15 | * 1. Redistributions of source code must retain the above copyright | | 15 | * 1. Redistributions of source code must retain the above copyright |
16 | * notice, this list of conditions and the following disclaimer. | | 16 | * notice, this list of conditions and the following disclaimer. |
17 | * 2. Redistributions in binary form must reproduce the above copyright | | 17 | * 2. Redistributions in binary form must reproduce the above copyright |
18 | * notice, this list of conditions and the following disclaimer in the | | 18 | * notice, this list of conditions and the following disclaimer in the |
19 | * documentation and/or other materials provided with the distribution. | | 19 | * documentation and/or other materials provided with the distribution. |
20 | * 3. Neither the name of the University nor the names of its contributors | | 20 | * 3. Neither the name of the University nor the names of its contributors |
21 | * may be used to endorse or promote products derived from this software | | 21 | * may be used to endorse or promote products derived from this software |
22 | * without specific prior written permission. | | 22 | * without specific prior written permission. |
23 | * | | 23 | * |
24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 | * SUCH DAMAGE. | | 34 | * SUCH DAMAGE. |
35 | * | | 35 | * |
36 | * from: Utah $Hdr: machdep.c 1.74 92/12/20$ | | 36 | * from: Utah $Hdr: machdep.c 1.74 92/12/20$ |
37 | * | | 37 | * |
38 | * @(#)machdep.c 8.10 (Berkeley) 4/20/94 | | 38 | * @(#)machdep.c 8.10 (Berkeley) 4/20/94 |
39 | */ | | 39 | */ |
40 | | | 40 | |
41 | #include <sys/cdefs.h> | | 41 | #include <sys/cdefs.h> |
42 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.191 2014/03/26 16:21:39 isaki Exp $"); | | 42 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.191.4.1 2015/11/05 20:40:22 riz Exp $"); |
43 | | | 43 | |
44 | #include "opt_ddb.h" | | 44 | #include "opt_ddb.h" |
45 | #include "opt_kgdb.h" | | 45 | #include "opt_kgdb.h" |
46 | #include "opt_compat_netbsd.h" | | 46 | #include "opt_compat_netbsd.h" |
47 | #include "opt_fpu_emulate.h" | | 47 | #include "opt_fpu_emulate.h" |
48 | #include "opt_m060sp.h" | | 48 | #include "opt_m060sp.h" |
49 | #include "opt_modular.h" | | 49 | #include "opt_modular.h" |
50 | #include "opt_panicbutton.h" | | 50 | #include "opt_panicbutton.h" |
51 | #include "opt_extmem.h" | | 51 | #include "opt_extmem.h" |
52 | #include "opt_m68k_arch.h" | | 52 | #include "opt_m68k_arch.h" |
53 | | | 53 | |
54 | #include <sys/param.h> | | 54 | #include <sys/param.h> |
55 | #include <sys/systm.h> | | 55 | #include <sys/systm.h> |
56 | #include <sys/callout.h> | | 56 | #include <sys/callout.h> |
57 | #include <sys/signalvar.h> | | 57 | #include <sys/signalvar.h> |
58 | #include <sys/kauth.h> | | 58 | #include <sys/kauth.h> |
59 | #include <sys/kernel.h> | | 59 | #include <sys/kernel.h> |
60 | #include <sys/proc.h> | | 60 | #include <sys/proc.h> |
61 | #include <sys/buf.h> | | 61 | #include <sys/buf.h> |
62 | #include <sys/reboot.h> | | 62 | #include <sys/reboot.h> |
63 | #include <sys/conf.h> | | 63 | #include <sys/conf.h> |
64 | #include <sys/file.h> | | 64 | #include <sys/file.h> |
65 | #include <sys/malloc.h> | | 65 | #include <sys/malloc.h> |
66 | #include <sys/mbuf.h> | | 66 | #include <sys/mbuf.h> |
67 | #include <sys/msgbuf.h> | | 67 | #include <sys/msgbuf.h> |
68 | #include <sys/ioctl.h> | | 68 | #include <sys/ioctl.h> |
69 | #include <sys/tty.h> | | 69 | #include <sys/tty.h> |
70 | #include <sys/mount.h> | | 70 | #include <sys/mount.h> |
71 | #include <sys/exec.h> | | 71 | #include <sys/exec.h> |
72 | #include <sys/exec_aout.h> /* for MID_* */ | | 72 | #include <sys/exec_aout.h> /* for MID_* */ |
73 | #include <sys/vnode.h> | | 73 | #include <sys/vnode.h> |
74 | #include <sys/syscallargs.h> | | 74 | #include <sys/syscallargs.h> |
75 | #include <sys/core.h> | | 75 | #include <sys/core.h> |
76 | #include <sys/kcore.h> | | 76 | #include <sys/kcore.h> |
77 | #include <sys/ksyms.h> | | 77 | #include <sys/ksyms.h> |
78 | #include <sys/module.h> | | 78 | #include <sys/module.h> |
79 | #include <sys/cpu.h> | | 79 | #include <sys/cpu.h> |
80 | #include <sys/sysctl.h> | | 80 | #include <sys/sysctl.h> |
81 | #include <sys/device.h> | | 81 | #include <sys/device.h> |
82 | | | 82 | |
83 | #include "ksyms.h" | | 83 | #include "ksyms.h" |
84 | | | 84 | |
85 | #if NKSYMS || defined(DDB) || defined(MODULAR) | | 85 | #if NKSYMS || defined(DDB) || defined(MODULAR) |
86 | #include <sys/exec_elf.h> | | 86 | #include <sys/exec_elf.h> |
87 | #endif | | 87 | #endif |
88 | | | 88 | |
89 | #include <machine/db_machdep.h> | | 89 | #include <machine/db_machdep.h> |
90 | #include <ddb/db_sym.h> | | 90 | #include <ddb/db_sym.h> |
91 | #include <ddb/db_extern.h> | | 91 | #include <ddb/db_extern.h> |
92 | | | 92 | |
93 | #include <m68k/cacheops.h> | | 93 | #include <m68k/cacheops.h> |
94 | #include <machine/reg.h> | | 94 | #include <machine/reg.h> |
95 | #include <machine/pcb.h> | | 95 | #include <machine/pcb.h> |
96 | #include <machine/psl.h> | | 96 | #include <machine/psl.h> |
97 | #include <machine/pte.h> | | 97 | #include <machine/pte.h> |
98 | #include <machine/kcore.h> | | 98 | #include <machine/kcore.h> |
99 | | | 99 | |
100 | #include <dev/cons.h> | | 100 | #include <dev/cons.h> |
101 | #include <dev/mm.h> | | 101 | #include <dev/mm.h> |
102 | | | 102 | |
103 | #define MAXMEM 64*1024 /* XXX - from cmap.h */ | | 103 | #define MAXMEM 64*1024 /* XXX - from cmap.h */ |
104 | #include <uvm/uvm.h> | | 104 | #include <uvm/uvm.h> |
105 | | | 105 | |
106 | #include <machine/bus.h> | | 106 | #include <machine/bus.h> |
107 | #include <machine/autoconf.h> | | 107 | #include <machine/autoconf.h> |
108 | #include <arch/x68k/dev/intiovar.h> | | 108 | #include <arch/x68k/dev/intiovar.h> |
| | | 109 | #include <arch/x68k/x68k/iodevice.h> |
109 | | | 110 | |
110 | extern void doboot(void) __attribute__((__noreturn__)); | | 111 | extern void doboot(void) __attribute__((__noreturn__)); |
111 | | | 112 | |
112 | /* the following is used externally (sysctl_hw) */ | | 113 | /* the following is used externally (sysctl_hw) */ |
113 | char machine[] = MACHINE; /* from <machine/param.h> */ | | 114 | char machine[] = MACHINE; /* from <machine/param.h> */ |
114 | | | 115 | |
115 | /* Our exported CPU info; we can have only one. */ | | 116 | /* Our exported CPU info; we can have only one. */ |
116 | struct cpu_info cpu_info_store; | | 117 | struct cpu_info cpu_info_store; |
117 | | | 118 | |
118 | struct vm_map *phys_map = NULL; | | 119 | struct vm_map *phys_map = NULL; |
119 | | | 120 | |
120 | extern paddr_t avail_start, avail_end; | | 121 | extern paddr_t avail_start, avail_end; |
121 | extern u_int lowram; | | 122 | extern u_int lowram; |
122 | extern int end, *esym; | | 123 | extern int end, *esym; |
123 | | | 124 | |
124 | int maxmem; /* max memory per process */ | | 125 | int maxmem; /* max memory per process */ |
125 | | | 126 | |
126 | /* prototypes for local functions */ | | 127 | /* prototypes for local functions */ |
127 | void identifycpu(void); | | 128 | void identifycpu(void); |
128 | static int check_emulator(char *, int); | | 129 | static int check_emulator(char *, int); |
129 | void initcpu(void); | | 130 | void initcpu(void); |
130 | int cpu_dumpsize(void); | | 131 | int cpu_dumpsize(void); |
131 | int cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *); | | 132 | int cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *); |
132 | void cpu_init_kcore_hdr(void); | | 133 | void cpu_init_kcore_hdr(void); |
133 | | | 134 | |
134 | /* functions called from locore.s */ | | 135 | /* functions called from locore.s */ |
135 | void x68k_init(void); | | 136 | void x68k_init(void); |
136 | void dumpsys(void); | | 137 | void dumpsys(void); |
137 | void straytrap(int, u_short); | | 138 | void straytrap(int, u_short); |
138 | void nmihand(struct frame); | | 139 | void nmihand(struct frame); |
139 | void intrhand(int); | | 140 | void intrhand(int); |
140 | | | 141 | |
141 | /* memory probe function called from locore.s */ | | 142 | /* memory probe function called from locore.s */ |
142 | void setmemrange(void); | | 143 | void setmemrange(void); |
143 | #ifdef EXTENDED_MEMORY | | 144 | #ifdef EXTENDED_MEMORY |
144 | static bool mem_exists(paddr_t, paddr_t); | | 145 | static bool mem_exists(paddr_t, paddr_t); |
145 | #endif | | 146 | #endif |
146 | | | 147 | |
147 | typedef struct { | | 148 | typedef struct { |
148 | paddr_t start; | | 149 | paddr_t start; |
149 | paddr_t end; | | 150 | paddr_t end; |
150 | } phys_seg_t; | | 151 | } phys_seg_t; |
151 | | | 152 | |
152 | static int basemem; | | 153 | static int basemem; |
153 | static phys_seg_t phys_basemem_seg; | | 154 | static phys_seg_t phys_basemem_seg; |
154 | #ifdef EXTENDED_MEMORY | | 155 | #ifdef EXTENDED_MEMORY |
155 | #define EXTMEM_SEGS (VM_PHYSSEG_MAX - 1) | | 156 | #define EXTMEM_SEGS (VM_PHYSSEG_MAX - 1) |
156 | static phys_seg_t phys_extmem_seg[EXTMEM_SEGS]; | | 157 | static phys_seg_t phys_extmem_seg[EXTMEM_SEGS]; |
157 | #endif | | 158 | #endif |
158 | | | 159 | |
159 | /* | | 160 | /* |
160 | * On the 68020/68030, the value of delay_divisor is roughly | | 161 | * On the 68020/68030, the value of delay_divisor is roughly |
161 | * 2048 / cpuspeed (where cpuspeed is in MHz). | | 162 | * 2048 / cpuspeed (where cpuspeed is in MHz). |
162 | * | | 163 | * |
163 | * On the 68040, the value of delay_divisor is roughly | | 164 | * On the 68040, the value of delay_divisor is roughly |
164 | * 759 / cpuspeed (where cpuspeed is in MHz). | | 165 | * 759 / cpuspeed (where cpuspeed is in MHz). |
165 | * | | 166 | * |
166 | * On the 68060, the value of delay_divisor is reported to be | | 167 | * On the 68060, the value of delay_divisor is reported to be |
167 | * 128 / cpuspeed (where cpuspeed is in MHz). | | 168 | * 128 / cpuspeed (where cpuspeed is in MHz). |
168 | */ | | 169 | */ |
169 | int delay_divisor = 140; /* assume some reasonable value to start */ | | 170 | int delay_divisor = 140; /* assume some reasonable value to start */ |
170 | static int cpuspeed; /* MPU clock (in MHz) */ | | 171 | static int cpuspeed; /* MPU clock (in MHz) */ |
171 | | | 172 | |
172 | /* | | 173 | /* |
173 | * Machine-dependent crash dump header info. | | 174 | * Machine-dependent crash dump header info. |
174 | */ | | 175 | */ |
175 | cpu_kcore_hdr_t cpu_kcore_hdr; | | 176 | cpu_kcore_hdr_t cpu_kcore_hdr; |
176 | | | 177 | |
177 | static callout_t candbtimer_ch; | | 178 | static callout_t candbtimer_ch; |
178 | | | 179 | |
179 | void | | 180 | void |
180 | x68k_init(void) | | 181 | x68k_init(void) |
181 | { | | 182 | { |
182 | u_int i; | | 183 | u_int i; |
183 | paddr_t msgbuf_pa; | | 184 | paddr_t msgbuf_pa; |
184 | paddr_t s, e; | | 185 | paddr_t s, e; |
185 | | | 186 | |
186 | /* | | 187 | /* |
187 | * Most m68k ports allocate msgbuf at the end of available memory | | 188 | * Most m68k ports allocate msgbuf at the end of available memory |
188 | * (i.e. just after avail_end), but on x68k we allocate msgbuf | | 189 | * (i.e. just after avail_end), but on x68k we allocate msgbuf |
189 | * at the end of main memory for compatibility. | | 190 | * at the end of main memory for compatibility. |
190 | */ | | 191 | */ |
191 | msgbuf_pa = phys_basemem_seg.end - m68k_round_page(MSGBUFSIZE); | | 192 | msgbuf_pa = phys_basemem_seg.end - m68k_round_page(MSGBUFSIZE); |
192 | | | 193 | |
193 | /* | | 194 | /* |
194 | * Tell the VM system about available physical memory. | | 195 | * Tell the VM system about available physical memory. |
195 | */ | | 196 | */ |
196 | /* load the main memory region */ | | 197 | /* load the main memory region */ |
197 | s = avail_start; | | 198 | s = avail_start; |
198 | e = msgbuf_pa; | | 199 | e = msgbuf_pa; |
199 | uvm_page_physload(atop(s), atop(e), atop(s), atop(e), | | 200 | uvm_page_physload(atop(s), atop(e), atop(s), atop(e), |
200 | VM_FREELIST_MAINMEM); | | 201 | VM_FREELIST_MAINMEM); |
201 | | | 202 | |
202 | #ifdef EXTENDED_MEMORY | | 203 | #ifdef EXTENDED_MEMORY |
203 | /* load extended memory regions */ | | 204 | /* load extended memory regions */ |
204 | for (i = 0; i < EXTMEM_SEGS; i++) { | | 205 | for (i = 0; i < EXTMEM_SEGS; i++) { |
205 | if (phys_extmem_seg[i].start == phys_extmem_seg[i].end) | | 206 | if (phys_extmem_seg[i].start == phys_extmem_seg[i].end) |
206 | continue; | | 207 | continue; |
207 | uvm_page_physload(atop(phys_extmem_seg[i].start), | | 208 | uvm_page_physload(atop(phys_extmem_seg[i].start), |
208 | atop(phys_extmem_seg[i].end), | | 209 | atop(phys_extmem_seg[i].end), |
209 | atop(phys_extmem_seg[i].start), | | 210 | atop(phys_extmem_seg[i].start), |
210 | atop(phys_extmem_seg[i].end), | | 211 | atop(phys_extmem_seg[i].end), |
211 | VM_FREELIST_HIGHMEM); | | 212 | VM_FREELIST_HIGHMEM); |
212 | } | | 213 | } |
213 | #endif | | 214 | #endif |
214 | | | 215 | |
215 | /* | | 216 | /* |
216 | * Initialize error message buffer (at end of core). | | 217 | * Initialize error message buffer (at end of core). |
217 | */ | | 218 | */ |
218 | for (i = 0; i < btoc(MSGBUFSIZE); i++) | | 219 | for (i = 0; i < btoc(MSGBUFSIZE); i++) |
219 | pmap_kenter_pa((vaddr_t)msgbufaddr + i * PAGE_SIZE, | | 220 | pmap_kenter_pa((vaddr_t)msgbufaddr + i * PAGE_SIZE, |
220 | msgbuf_pa + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, 0); | | 221 | msgbuf_pa + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, 0); |
221 | pmap_update(pmap_kernel()); | | 222 | pmap_update(pmap_kernel()); |
222 | initmsgbuf(msgbufaddr, m68k_round_page(MSGBUFSIZE)); | | 223 | initmsgbuf(msgbufaddr, m68k_round_page(MSGBUFSIZE)); |
223 | } | | 224 | } |
224 | | | 225 | |
225 | /* | | 226 | /* |
226 | * Console initialization: called early on from main, | | 227 | * Console initialization: called early on from main, |
227 | * before vm init or startup. Do enough configuration | | 228 | * before vm init or startup. Do enough configuration |
228 | * to choose and initialize a console. | | 229 | * to choose and initialize a console. |
229 | */ | | 230 | */ |
230 | void | | 231 | void |
231 | consinit(void) | | 232 | consinit(void) |
232 | { | | 233 | { |
233 | | | 234 | |
234 | /* | | 235 | /* |
235 | * bring graphics layer up. | | 236 | * bring graphics layer up. |
236 | */ | | 237 | */ |
237 | config_console(); | | 238 | config_console(); |
238 | | | 239 | |
239 | /* | | 240 | /* |
240 | * Initialize the console before we print anything out. | | 241 | * Initialize the console before we print anything out. |
241 | */ | | 242 | */ |
242 | cninit(); | | 243 | cninit(); |
243 | | | 244 | |
244 | #ifdef KGDB | | 245 | #ifdef KGDB |
245 | zs_kgdb_init(); /* XXX */ | | 246 | zs_kgdb_init(); /* XXX */ |
246 | #endif | | 247 | #endif |
247 | #if NKSYMS || defined(DDB) || defined(MODULAR) | | 248 | #if NKSYMS || defined(DDB) || defined(MODULAR) |
248 | ksyms_addsyms_elf((int)esym - (int)&end - sizeof(Elf32_Ehdr), | | 249 | ksyms_addsyms_elf((int)esym - (int)&end - sizeof(Elf32_Ehdr), |
249 | (void *)&end, esym); | | 250 | (void *)&end, esym); |
250 | #endif | | 251 | #endif |
251 | #ifdef DDB | | 252 | #ifdef DDB |
252 | if (boothowto & RB_KDB) | | 253 | if (boothowto & RB_KDB) |
253 | Debugger(); | | 254 | Debugger(); |
254 | #endif | | 255 | #endif |
255 | } | | 256 | } |
256 | | | 257 | |
257 | /* | | 258 | /* |
258 | * cpu_startup: allocate memory for variable-sized tables, | | 259 | * cpu_startup: allocate memory for variable-sized tables, |
259 | * initialize cpu, and do autoconfiguration. | | 260 | * initialize cpu, and do autoconfiguration. |
260 | */ | | 261 | */ |
261 | void | | 262 | void |
262 | cpu_startup(void) | | 263 | cpu_startup(void) |
263 | { | | 264 | { |
264 | vaddr_t minaddr, maxaddr; | | 265 | vaddr_t minaddr, maxaddr; |
265 | char pbuf[9]; | | 266 | char pbuf[9]; |
266 | #ifdef DEBUG | | 267 | #ifdef DEBUG |
267 | extern int pmapdebug; | | 268 | extern int pmapdebug; |
268 | int opmapdebug = pmapdebug; | | 269 | int opmapdebug = pmapdebug; |
269 | | | 270 | |
270 | pmapdebug = 0; | | 271 | pmapdebug = 0; |
271 | #endif | | 272 | #endif |
272 | | | 273 | |
273 | if (fputype != FPU_NONE) | | 274 | if (fputype != FPU_NONE) |
274 | m68k_make_fpu_idle_frame(); | | 275 | m68k_make_fpu_idle_frame(); |
275 | | | 276 | |
276 | /* | | 277 | /* |
277 | * Initialize the kernel crash dump header. | | 278 | * Initialize the kernel crash dump header. |
278 | */ | | 279 | */ |
279 | cpu_init_kcore_hdr(); | | 280 | cpu_init_kcore_hdr(); |
280 | | | 281 | |
281 | /* | | 282 | /* |
282 | * Good {morning,afternoon,evening,night}. | | 283 | * Good {morning,afternoon,evening,night}. |
283 | */ | | 284 | */ |
284 | printf("%s%s", copyright, version); | | 285 | printf("%s%s", copyright, version); |
285 | identifycpu(); | | 286 | identifycpu(); |
286 | format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); | | 287 | format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); |
287 | printf("total memory = %s\n", pbuf); | | 288 | printf("total memory = %s\n", pbuf); |
288 | | | 289 | |
289 | minaddr = 0; | | 290 | minaddr = 0; |
290 | | | 291 | |
291 | /* | | 292 | /* |
292 | * Allocate a submap for physio | | 293 | * Allocate a submap for physio |
293 | */ | | 294 | */ |
294 | phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, | | 295 | phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, |
295 | VM_PHYS_SIZE, 0, false, NULL); | | 296 | VM_PHYS_SIZE, 0, false, NULL); |
296 | | | 297 | |
297 | #ifdef DEBUG | | 298 | #ifdef DEBUG |
298 | pmapdebug = opmapdebug; | | 299 | pmapdebug = opmapdebug; |
299 | #endif | | 300 | #endif |
300 | format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); | | 301 | format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); |
301 | printf("avail memory = %s\n", pbuf); | | 302 | printf("avail memory = %s\n", pbuf); |
302 | | | 303 | |
303 | /* | | 304 | /* |
304 | * Set up CPU-specific registers, cache, etc. | | 305 | * Set up CPU-specific registers, cache, etc. |
305 | */ | | 306 | */ |
306 | initcpu(); | | 307 | initcpu(); |
307 | | | 308 | |
308 | callout_init(&candbtimer_ch, 0); | | 309 | callout_init(&candbtimer_ch, 0); |
309 | } | | 310 | } |
310 | | | 311 | |
311 | static const char *fpu_descr[] = { | | 312 | static const char *fpu_descr[] = { |
312 | #ifdef FPU_EMULATE | | 313 | #ifdef FPU_EMULATE |
313 | ", emulator FPU", /* 0 */ | | 314 | ", emulator FPU", /* 0 */ |
314 | #else | | 315 | #else |
315 | ", no math support", /* 0 */ | | 316 | ", no math support", /* 0 */ |
316 | #endif | | 317 | #endif |
317 | ", m68881 FPU", /* 1 */ | | 318 | ", m68881 FPU", /* 1 */ |
318 | ", m68882 FPU", /* 2 */ | | 319 | ", m68882 FPU", /* 2 */ |
319 | "/FPU", /* 3 */ | | 320 | "/FPU", /* 3 */ |
320 | "/FPU", /* 4 */ | | 321 | "/FPU", /* 4 */ |
321 | }; | | 322 | }; |
322 | | | 323 | |
323 | void | | 324 | void |
324 | identifycpu(void) | | 325 | identifycpu(void) |
325 | { | | 326 | { |
326 | /* there's alot of XXX in here... */ | | 327 | /* there's alot of XXX in here... */ |
327 | const char *cpu_type, *mach, *mmu, *fpu; | | 328 | const char *cpu_type, *mach, *mmu, *fpu; |
328 | char clock[16]; | | 329 | char clock[16]; |
329 | char emubuf[20]; | | 330 | char emubuf[20]; |
330 | | | 331 | |
331 | /* | | 332 | /* |
332 | * check machine type constant | | 333 | * check machine type constant |
333 | */ | | 334 | */ |
334 | switch (intio_get_sysport_mpustat()) { | | 335 | switch (intio_get_sysport_mpustat()) { |
335 | case 0xdc: | | 336 | case 0xdc: |
336 | /* | | 337 | /* |
337 | * CPU Type == 68030, Clock == 25MHz | | 338 | * CPU Type == 68030, Clock == 25MHz |
338 | */ | | 339 | */ |
339 | mach = "030"; | | 340 | mach = "030"; |
340 | break; | | 341 | break; |
341 | case 0xfe: | | 342 | case 0xfe: |
342 | /* | | 343 | /* |
343 | * CPU Type == 68000, Clock == 16MHz | | 344 | * CPU Type == 68000, Clock == 16MHz |
344 | */ | | 345 | */ |
345 | mach = "000XVI"; | | 346 | mach = "000XVI"; |
346 | break; | | 347 | break; |
347 | case 0xff: | | 348 | case 0xff: |
348 | /* | | 349 | /* |
349 | * CPU Type == 68000, Clock == 10MHz | | 350 | * CPU Type == 68000, Clock == 10MHz |
350 | */ | | 351 | */ |
351 | mach = "000/ACE/PRO/EXPERT/SUPER"; | | 352 | mach = "000/ACE/PRO/EXPERT/SUPER"; |
352 | break; | | 353 | break; |
353 | default: | | 354 | default: |
354 | /* | | 355 | /* |
355 | * unknown type | | 356 | * unknown type |
356 | */ | | 357 | */ |
357 | mach = "000?(unknown model)"; | | 358 | mach = "000?(unknown model)"; |
358 | break; | | 359 | break; |
359 | } | | 360 | } |
360 | | | 361 | |
361 | emubuf[0] = '\0'; | | 362 | emubuf[0] = '\0'; |
362 | check_emulator(emubuf, sizeof(emubuf)); | | 363 | check_emulator(emubuf, sizeof(emubuf)); |
363 | | | 364 | |
364 | cpuspeed = 2048 / delay_divisor; | | 365 | cpuspeed = 2048 / delay_divisor; |
365 | snprintf(clock, sizeof(clock), "%dMHz", cpuspeed); | | 366 | snprintf(clock, sizeof(clock), "%dMHz", cpuspeed); |
366 | switch (cputype) { | | 367 | switch (cputype) { |
367 | case CPU_68060: | | 368 | case CPU_68060: |
368 | cpu_type = "m68060"; | | 369 | cpu_type = "m68060"; |
369 | mmu = "/MMU"; | | 370 | mmu = "/MMU"; |
370 | cpuspeed = 128 / delay_divisor; | | 371 | cpuspeed = 128 / delay_divisor; |
371 | snprintf(clock, sizeof(clock), "%d/%dMHz", cpuspeed*2, cpuspeed); | | 372 | snprintf(clock, sizeof(clock), "%d/%dMHz", cpuspeed*2, cpuspeed); |
372 | break; | | 373 | break; |
373 | case CPU_68040: | | 374 | case CPU_68040: |
374 | cpu_type = "m68040"; | | 375 | cpu_type = "m68040"; |
375 | mmu = "/MMU"; | | 376 | mmu = "/MMU"; |
376 | cpuspeed = 759 / delay_divisor; | | 377 | cpuspeed = 759 / delay_divisor; |
377 | snprintf(clock, sizeof(clock), "%d/%dMHz", cpuspeed*2, cpuspeed); | | 378 | snprintf(clock, sizeof(clock), "%d/%dMHz", cpuspeed*2, cpuspeed); |
378 | break; | | 379 | break; |
379 | case CPU_68030: | | 380 | case CPU_68030: |
380 | cpu_type = "m68030"; | | 381 | cpu_type = "m68030"; |
381 | mmu = "/MMU"; | | 382 | mmu = "/MMU"; |
382 | break; | | 383 | break; |
383 | case CPU_68020: | | 384 | case CPU_68020: |
384 | cpu_type = "m68020"; | | 385 | cpu_type = "m68020"; |
385 | mmu = ", m68851 MMU"; | | 386 | mmu = ", m68851 MMU"; |
386 | break; | | 387 | break; |
387 | default: | | 388 | default: |
388 | cpu_type = "unknown"; | | 389 | cpu_type = "unknown"; |
389 | mmu = ", unknown MMU"; | | 390 | mmu = ", unknown MMU"; |
390 | break; | | 391 | break; |
391 | } | | 392 | } |
392 | if (fputype >= 0 && fputype < sizeof(fpu_descr)/sizeof(fpu_descr[0])) | | 393 | if (fputype >= 0 && fputype < sizeof(fpu_descr)/sizeof(fpu_descr[0])) |
393 | fpu = fpu_descr[fputype]; | | 394 | fpu = fpu_descr[fputype]; |
394 | else | | 395 | else |
395 | fpu = ", unknown FPU"; | | 396 | fpu = ", unknown FPU"; |
396 | cpu_setmodel("X68%s (%s CPU%s%s, %s clock)%s%s", | | 397 | cpu_setmodel("X68%s (%s CPU%s%s, %s clock)%s%s", |
397 | mach, cpu_type, mmu, fpu, clock, | | 398 | mach, cpu_type, mmu, fpu, clock, |
398 | emubuf[0] ? " on " : "", emubuf); | | 399 | emubuf[0] ? " on " : "", emubuf); |
399 | printf("%s\n", cpu_getmodel()); | | 400 | printf("%s\n", cpu_getmodel()); |
400 | } | | 401 | } |
401 | | | 402 | |
402 | /* | | 403 | /* |
403 | * If it is an emulator, store the name in buf and return 1. | | 404 | * If it is an emulator, store the name in buf and return 1. |
404 | * Otherwise return 0. | | 405 | * Otherwise return 0. |
405 | */ | | 406 | */ |
406 | static int | | 407 | static int |
407 | check_emulator(char *buf, int bufsize) | | 408 | check_emulator(char *buf, int bufsize) |
408 | { | | 409 | { |
409 | int xm6major; | | 410 | int xm6major; |
410 | int xm6minor; | | 411 | int xm6minor; |
411 | int xm6imark; | | 412 | int xm6imark; |
412 | int xm6imajor; | | 413 | int xm6imajor; |
413 | int xm6iminor; | | 414 | int xm6iminor; |
414 | | | 415 | |
415 | /* XM6 and its family */ | | 416 | /* XM6 and its family */ |
416 | intio_set_sysport_sramwp('X'); | | 417 | intio_set_sysport_sramwp('X'); |
417 | if (intio_get_sysport_sramwp() == '6') { | | 418 | if (intio_get_sysport_sramwp() == '6') { |
418 | xm6major = intio_get_sysport_sramwp(); | | 419 | xm6major = intio_get_sysport_sramwp(); |
419 | xm6minor = intio_get_sysport_sramwp(); | | 420 | xm6minor = intio_get_sysport_sramwp(); |
420 | xm6imark = intio_get_sysport_sramwp(); | | 421 | xm6imark = intio_get_sysport_sramwp(); |
421 | switch (xm6imark) { | | 422 | switch (xm6imark) { |
422 | case 0xff: /* Original XM6 or unknown compatibles */ | | 423 | case 0xff: /* Original XM6 or unknown compatibles */ |
423 | snprintf(buf, bufsize, "XM6 v%d.%02d", | | 424 | snprintf(buf, bufsize, "XM6 v%d.%02d", |
424 | xm6major, xm6minor); | | 425 | xm6major, xm6minor); |
425 | break; | | 426 | break; |
426 | | | 427 | |
427 | case 'i': /* XM6i */ | | 428 | case 'i': /* XM6i */ |
428 | xm6imajor = intio_get_sysport_sramwp(); | | 429 | xm6imajor = intio_get_sysport_sramwp(); |
429 | xm6iminor = intio_get_sysport_sramwp(); | | 430 | xm6iminor = intio_get_sysport_sramwp(); |
430 | snprintf(buf, bufsize, "XM6i v%d.%02d", | | 431 | snprintf(buf, bufsize, "XM6i v%d.%02d", |
431 | xm6imajor, xm6iminor); | | 432 | xm6imajor, xm6iminor); |
432 | break; | | 433 | break; |
433 | | | 434 | |
434 | case 'g': /* XM6 TypeG */ | | 435 | case 'g': /* XM6 TypeG */ |
435 | snprintf(buf, bufsize, "XM6 TypeG v%d.%02d", | | 436 | snprintf(buf, bufsize, "XM6 TypeG v%d.%02d", |
436 | xm6major, xm6minor); | | 437 | xm6major, xm6minor); |
437 | break; | | 438 | break; |
438 | | | 439 | |
439 | default: /* Other XM6 compatibles? */ | | 440 | default: /* Other XM6 compatibles? */ |
440 | /* XXX what should I do? */ | | 441 | /* XXX what should I do? */ |
441 | return 0; | | 442 | return 0; |
442 | } | | 443 | } |
443 | return 1; | | 444 | return 1; |
444 | } | | 445 | } |
445 | | | 446 | |
446 | return 0; | | 447 | return 0; |
447 | } | | 448 | } |
448 | | | 449 | |
449 | /* | | 450 | /* |
450 | * machine dependent system variables. | | 451 | * machine dependent system variables. |
451 | */ | | 452 | */ |
452 | SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup") | | 453 | SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup") |
453 | { | | 454 | { |
454 | | | 455 | |
455 | sysctl_createv(clog, 0, NULL, NULL, | | 456 | sysctl_createv(clog, 0, NULL, NULL, |
456 | CTLFLAG_PERMANENT, | | 457 | CTLFLAG_PERMANENT, |
457 | CTLTYPE_NODE, "machdep", NULL, | | 458 | CTLTYPE_NODE, "machdep", NULL, |
458 | NULL, 0, NULL, 0, | | 459 | NULL, 0, NULL, 0, |
459 | CTL_MACHDEP, CTL_EOL); | | 460 | CTL_MACHDEP, CTL_EOL); |
460 | | | 461 | |
461 | sysctl_createv(clog, 0, NULL, NULL, | | 462 | sysctl_createv(clog, 0, NULL, NULL, |
462 | CTLFLAG_PERMANENT, | | 463 | CTLFLAG_PERMANENT, |
463 | CTLTYPE_STRUCT, "console_device", NULL, | | 464 | CTLTYPE_STRUCT, "console_device", NULL, |
464 | sysctl_consdev, 0, NULL, sizeof(dev_t), | | 465 | sysctl_consdev, 0, NULL, sizeof(dev_t), |
465 | CTL_MACHDEP, CPU_CONSDEV, CTL_EOL); | | 466 | CTL_MACHDEP, CPU_CONSDEV, CTL_EOL); |
466 | } | | 467 | } |
467 | | | 468 | |
468 | int waittime = -1; | | 469 | int waittime = -1; |
469 | int power_switch_is_off = 0; | | 470 | int power_switch_is_off = 0; |
470 | | | 471 | |
471 | void | | 472 | void |
472 | cpu_reboot(int howto, char *bootstr) | | 473 | cpu_reboot(int howto, char *bootstr) |
473 | { | | 474 | { |
474 | struct pcb *pcb = lwp_getpcb(curlwp); | | 475 | struct pcb *pcb = lwp_getpcb(curlwp); |
475 | | | 476 | |
476 | /* take a snap shot before clobbering any registers */ | | 477 | /* take a snap shot before clobbering any registers */ |
477 | if (pcb != NULL) | | 478 | if (pcb != NULL) |
478 | savectx(pcb); | | 479 | savectx(pcb); |
479 | | | 480 | |
480 | boothowto = howto; | | 481 | boothowto = howto; |
481 | if ((howto & RB_NOSYNC) == 0 && waittime < 0) { | | 482 | if ((howto & RB_NOSYNC) == 0 && waittime < 0) { |
482 | waittime = 0; | | 483 | waittime = 0; |
483 | vfs_shutdown(); | | 484 | vfs_shutdown(); |
484 | /* | | 485 | /* |
485 | * If we've been adjusting the clock, the todr | | 486 | * If we've been adjusting the clock, the todr |
486 | * will be out of synch; adjust it now. | | 487 | * will be out of synch; adjust it now. |
487 | */ | | 488 | */ |
488 | /*resettodr();*/ | | 489 | /*resettodr();*/ |
489 | } | | 490 | } |
490 | | | 491 | |
491 | /* Disable interrputs. */ | | 492 | /* Disable interrputs. */ |
492 | splhigh(); | | 493 | splhigh(); |
493 | | | 494 | |
494 | if (howto & RB_DUMP) | | 495 | if (howto & RB_DUMP) |
495 | dumpsys(); | | 496 | dumpsys(); |
496 | | | 497 | |
497 | /* Run any shutdown hooks. */ | | 498 | /* Run any shutdown hooks. */ |
498 | doshutdownhooks(); | | 499 | doshutdownhooks(); |
499 | | | 500 | |
500 | pmf_system_shutdown(boothowto); | | 501 | pmf_system_shutdown(boothowto); |
501 | | | 502 | |
502 | #if defined(PANICWAIT) && !defined(DDB) | | 503 | #if defined(PANICWAIT) && !defined(DDB) |
503 | if ((howto & RB_HALT) == 0 && panicstr) { | | 504 | if ((howto & RB_HALT) == 0 && panicstr) { |
504 | printf("hit any key to reboot...\n"); | | 505 | printf("hit any key to reboot...\n"); |
505 | (void)cngetc(); | | 506 | (void)cngetc(); |
506 | printf("\n"); | | 507 | printf("\n"); |
507 | } | | 508 | } |
508 | #endif | | 509 | #endif |
509 | | | 510 | |
510 | /* Finally, halt/reboot the system. */ | | 511 | /* Finally, halt/reboot the system. */ |
511 | /* a) RB_POWERDOWN | | 512 | /* a) RB_POWERDOWN |
512 | * a1: the power switch is still on | | 513 | * a1: the power switch is still on |
513 | * Power cannot be removed; simply halt the system (b) | | 514 | * Power cannot be removed; simply halt the system (b) |
514 | * Power switch state is checked in shutdown hook | | 515 | * Power switch state is checked in shutdown hook |
515 | * a2: the power switch is off | | 516 | * a2: the power switch is off |
516 | * Remove the power | | 517 | * Remove the power |
517 | * b) RB_HALT | | 518 | * b) RB_HALT |
518 | * call cngetc | | 519 | * call cngetc |
519 | * c) otherwise | | 520 | * c) otherwise |
520 | * Reboot | | 521 | * Reboot |
521 | */ | | 522 | */ |
522 | if (((howto & RB_POWERDOWN) == RB_POWERDOWN) && power_switch_is_off) { | | 523 | if (((howto & RB_POWERDOWN) == RB_POWERDOWN) && power_switch_is_off) { |
523 | printf("powering off...\n"); | | 524 | printf("powering off...\n"); |
524 | delay(1000000); | | 525 | delay(1000000); |
| | | 526 | |
| | | 527 | /* Turn off the alarm signal of RTC */ |
| | | 528 | IODEVbase->io_rtc.bank0.reset = 0x0c; |
| | | 529 | |
525 | intio_set_sysport_powoff(0x00); | | 530 | intio_set_sysport_powoff(0x00); |
526 | intio_set_sysport_powoff(0x0f); | | 531 | intio_set_sysport_powoff(0x0f); |
527 | intio_set_sysport_powoff(0x0f); | | 532 | intio_set_sysport_powoff(0x0f); |
528 | delay(1000000); | | 533 | delay(1000000); |
529 | printf("WARNING: powerdown failed\n"); | | 534 | printf("WARNING: powerdown failed\n"); |
530 | delay(1000000); | | 535 | delay(1000000); |
531 | /* PASSTHROUGH even if came back */ | | 536 | /* PASSTHROUGH even if came back */ |
532 | } else if ((howto & RB_HALT) == RB_HALT) { | | 537 | } else if ((howto & RB_HALT) == RB_HALT) { |
533 | printf("System halted. Hit any key to reboot.\n\n"); | | 538 | printf("System halted. Hit any key to reboot.\n\n"); |
534 | (void)cngetc(); | | 539 | (void)cngetc(); |
535 | } | | 540 | } |
536 | | | 541 | |
537 | printf("rebooting...\n"); | | 542 | printf("rebooting...\n"); |
538 | DELAY(1000000); | | 543 | DELAY(1000000); |
539 | doboot(); | | 544 | doboot(); |
540 | /* NOTREACHED */ | | 545 | /* NOTREACHED */ |
541 | } | | 546 | } |
542 | | | 547 | |
543 | /* | | 548 | /* |
544 | * Initialize the kernel crash dump header. | | 549 | * Initialize the kernel crash dump header. |
545 | */ | | 550 | */ |
546 | void | | 551 | void |
547 | cpu_init_kcore_hdr(void) | | 552 | cpu_init_kcore_hdr(void) |
548 | { | | 553 | { |
549 | cpu_kcore_hdr_t *h = &cpu_kcore_hdr; | | 554 | cpu_kcore_hdr_t *h = &cpu_kcore_hdr; |
550 | struct m68k_kcore_hdr *m = &h->un._m68k; | | 555 | struct m68k_kcore_hdr *m = &h->un._m68k; |
551 | int i; | | 556 | int i; |
552 | | | 557 | |
553 | memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr)); | | 558 | memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr)); |
554 | | | 559 | |
555 | /* | | 560 | /* |
556 | * Initialize the `dispatcher' portion of the header. | | 561 | * Initialize the `dispatcher' portion of the header. |
557 | */ | | 562 | */ |
558 | strcpy(h->name, machine); | | 563 | strcpy(h->name, machine); |
559 | h->page_size = PAGE_SIZE; | | 564 | h->page_size = PAGE_SIZE; |
560 | h->kernbase = KERNBASE; | | 565 | h->kernbase = KERNBASE; |
561 | | | 566 | |
562 | /* | | 567 | /* |
563 | * Fill in information about our MMU configuration. | | 568 | * Fill in information about our MMU configuration. |
564 | */ | | 569 | */ |
565 | m->mmutype = mmutype; | | 570 | m->mmutype = mmutype; |
566 | m->sg_v = SG_V; | | 571 | m->sg_v = SG_V; |
567 | m->sg_frame = SG_FRAME; | | 572 | m->sg_frame = SG_FRAME; |
568 | m->sg_ishift = SG_ISHIFT; | | 573 | m->sg_ishift = SG_ISHIFT; |
569 | m->sg_pmask = SG_PMASK; | | 574 | m->sg_pmask = SG_PMASK; |
570 | m->sg40_shift1 = SG4_SHIFT1; | | 575 | m->sg40_shift1 = SG4_SHIFT1; |
571 | m->sg40_mask2 = SG4_MASK2; | | 576 | m->sg40_mask2 = SG4_MASK2; |
572 | m->sg40_shift2 = SG4_SHIFT2; | | 577 | m->sg40_shift2 = SG4_SHIFT2; |
573 | m->sg40_mask3 = SG4_MASK3; | | 578 | m->sg40_mask3 = SG4_MASK3; |
574 | m->sg40_shift3 = SG4_SHIFT3; | | 579 | m->sg40_shift3 = SG4_SHIFT3; |
575 | m->sg40_addr1 = SG4_ADDR1; | | 580 | m->sg40_addr1 = SG4_ADDR1; |
576 | m->sg40_addr2 = SG4_ADDR2; | | 581 | m->sg40_addr2 = SG4_ADDR2; |
577 | m->pg_v = PG_V; | | 582 | m->pg_v = PG_V; |
578 | m->pg_frame = PG_FRAME; | | 583 | m->pg_frame = PG_FRAME; |
579 | | | 584 | |
580 | /* | | 585 | /* |
581 | * Initialize pointer to kernel segment table. | | 586 | * Initialize pointer to kernel segment table. |
582 | */ | | 587 | */ |
583 | m->sysseg_pa = (uint32_t)(pmap_kernel()->pm_stpa); | | 588 | m->sysseg_pa = (uint32_t)(pmap_kernel()->pm_stpa); |
584 | | | 589 | |
585 | /* | | 590 | /* |
586 | * Initialize relocation value such that: | | 591 | * Initialize relocation value such that: |
587 | * | | 592 | * |
588 | * pa = (va - KERNBASE) + reloc | | 593 | * pa = (va - KERNBASE) + reloc |
589 | */ | | 594 | */ |
590 | m->reloc = lowram; | | 595 | m->reloc = lowram; |
591 | | | 596 | |
592 | /* | | 597 | /* |
593 | * Define the end of the relocatable range. | | 598 | * Define the end of the relocatable range. |
594 | */ | | 599 | */ |
595 | m->relocend = (uint32_t)&end; | | 600 | m->relocend = (uint32_t)&end; |
596 | | | 601 | |
597 | /* | | 602 | /* |
598 | * X68k has multiple RAM segments on some models. | | 603 | * X68k has multiple RAM segments on some models. |
599 | */ | | 604 | */ |
600 | m->ram_segs[0].start = lowram; | | 605 | m->ram_segs[0].start = lowram; |
601 | m->ram_segs[0].size = mem_size - lowram; | | 606 | m->ram_segs[0].size = mem_size - lowram; |
602 | for (i = 1; i < vm_nphysseg; i++) { | | 607 | for (i = 1; i < vm_nphysseg; i++) { |
603 | m->ram_segs[i].start = | | 608 | m->ram_segs[i].start = |
604 | ctob(VM_PHYSMEM_PTR(i)->start); | | 609 | ctob(VM_PHYSMEM_PTR(i)->start); |
605 | m->ram_segs[i].size = | | 610 | m->ram_segs[i].size = |
606 | ctob(VM_PHYSMEM_PTR(i)->end - VM_PHYSMEM_PTR(i)->start); | | 611 | ctob(VM_PHYSMEM_PTR(i)->end - VM_PHYSMEM_PTR(i)->start); |
607 | } | | 612 | } |
608 | } | | 613 | } |
609 | | | 614 | |
610 | /* | | 615 | /* |
611 | * Compute the size of the machine-dependent crash dump header. | | 616 | * Compute the size of the machine-dependent crash dump header. |
612 | * Returns size in disk blocks. | | 617 | * Returns size in disk blocks. |
613 | */ | | 618 | */ |
614 | | | 619 | |
615 | #define CHDRSIZE (ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t))) | | 620 | #define CHDRSIZE (ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t))) |
616 | #define MDHDRSIZE roundup(CHDRSIZE, dbtob(1)) | | 621 | #define MDHDRSIZE roundup(CHDRSIZE, dbtob(1)) |
617 | | | 622 | |
618 | int | | 623 | int |
619 | cpu_dumpsize(void) | | 624 | cpu_dumpsize(void) |
620 | { | | 625 | { |
621 | | | 626 | |
622 | return btodb(MDHDRSIZE); | | 627 | return btodb(MDHDRSIZE); |
623 | } | | 628 | } |
624 | | | 629 | |
625 | /* | | 630 | /* |
626 | * Called by dumpsys() to dump the machine-dependent header. | | 631 | * Called by dumpsys() to dump the machine-dependent header. |
627 | */ | | 632 | */ |
628 | int | | 633 | int |
629 | cpu_dump(int (*dump)(dev_t, daddr_t, void *, size_t), daddr_t *blknop) | | 634 | cpu_dump(int (*dump)(dev_t, daddr_t, void *, size_t), daddr_t *blknop) |
630 | { | | 635 | { |
631 | int buf[MDHDRSIZE / sizeof(int)]; | | 636 | int buf[MDHDRSIZE / sizeof(int)]; |
632 | cpu_kcore_hdr_t *chdr; | | 637 | cpu_kcore_hdr_t *chdr; |
633 | kcore_seg_t *kseg; | | 638 | kcore_seg_t *kseg; |
634 | int error; | | 639 | int error; |
635 | | | 640 | |
636 | kseg = (kcore_seg_t *)buf; | | 641 | kseg = (kcore_seg_t *)buf; |
637 | chdr = (cpu_kcore_hdr_t *)&buf[ALIGN(sizeof(kcore_seg_t)) / | | 642 | chdr = (cpu_kcore_hdr_t *)&buf[ALIGN(sizeof(kcore_seg_t)) / |
638 | sizeof(int)]; | | 643 | sizeof(int)]; |
639 | | | 644 | |
640 | /* Create the segment header. */ | | 645 | /* Create the segment header. */ |
641 | CORE_SETMAGIC(*kseg, KCORE_MAGIC, MID_MACHINE, CORE_CPU); | | 646 | CORE_SETMAGIC(*kseg, KCORE_MAGIC, MID_MACHINE, CORE_CPU); |
642 | kseg->c_size = MDHDRSIZE - ALIGN(sizeof(kcore_seg_t)); | | 647 | kseg->c_size = MDHDRSIZE - ALIGN(sizeof(kcore_seg_t)); |
643 | | | 648 | |
644 | memcpy(chdr, &cpu_kcore_hdr, sizeof(cpu_kcore_hdr_t)); | | 649 | memcpy(chdr, &cpu_kcore_hdr, sizeof(cpu_kcore_hdr_t)); |
645 | error = (*dump)(dumpdev, *blknop, (void *)buf, sizeof(buf)); | | 650 | error = (*dump)(dumpdev, *blknop, (void *)buf, sizeof(buf)); |
646 | *blknop += btodb(sizeof(buf)); | | 651 | *blknop += btodb(sizeof(buf)); |
647 | return (error); | | 652 | return (error); |
648 | } | | 653 | } |
649 | | | 654 | |
650 | /* | | 655 | /* |
651 | * These variables are needed by /sbin/savecore | | 656 | * These variables are needed by /sbin/savecore |
652 | */ | | 657 | */ |
653 | uint32_t dumpmag = 0x8fca0101; /* magic number */ | | 658 | uint32_t dumpmag = 0x8fca0101; /* magic number */ |
654 | int dumpsize = 0; /* pages */ | | 659 | int dumpsize = 0; /* pages */ |
655 | long dumplo = 0; /* blocks */ | | 660 | long dumplo = 0; /* blocks */ |
656 | | | 661 | |
657 | /* | | 662 | /* |
658 | * This is called by main to set dumplo and dumpsize. | | 663 | * This is called by main to set dumplo and dumpsize. |
659 | * Dumps always skip the first PAGE_SIZE of disk space in | | 664 | * Dumps always skip the first PAGE_SIZE of disk space in |
660 | * case there might be a disk label stored there. If there | | 665 | * case there might be a disk label stored there. If there |
661 | * is extra space, put dump at the end to reduce the chance | | 666 | * is extra space, put dump at the end to reduce the chance |
662 | * that swapping trashes it. | | 667 | * that swapping trashes it. |
663 | */ | | 668 | */ |
664 | void | | 669 | void |
665 | cpu_dumpconf(void) | | 670 | cpu_dumpconf(void) |
666 | { | | 671 | { |
667 | cpu_kcore_hdr_t *h = &cpu_kcore_hdr; | | 672 | cpu_kcore_hdr_t *h = &cpu_kcore_hdr; |
668 | struct m68k_kcore_hdr *m = &h->un._m68k; | | 673 | struct m68k_kcore_hdr *m = &h->un._m68k; |
669 | int chdrsize; /* size of dump header */ | | 674 | int chdrsize; /* size of dump header */ |
670 | int nblks; /* size of dump area */ | | 675 | int nblks; /* size of dump area */ |
671 | int i; | | 676 | int i; |
672 | | | 677 | |
673 | if (dumpdev == NODEV) | | 678 | if (dumpdev == NODEV) |
674 | return; | | 679 | return; |
675 | nblks = bdev_size(dumpdev); | | 680 | nblks = bdev_size(dumpdev); |
676 | chdrsize = cpu_dumpsize(); | | 681 | chdrsize = cpu_dumpsize(); |
677 | | | 682 | |
678 | dumpsize = 0; | | 683 | dumpsize = 0; |
679 | for (i = 0; m->ram_segs[i].size && i < M68K_NPHYS_RAM_SEGS; i++) | | 684 | for (i = 0; m->ram_segs[i].size && i < M68K_NPHYS_RAM_SEGS; i++) |
680 | dumpsize += btoc(m->ram_segs[i].size); | | 685 | dumpsize += btoc(m->ram_segs[i].size); |
681 | /* | | 686 | /* |
682 | * Check to see if we will fit. Note we always skip the | | 687 | * Check to see if we will fit. Note we always skip the |
683 | * first PAGE_SIZE in case there is a disk label there. | | 688 | * first PAGE_SIZE in case there is a disk label there. |
684 | */ | | 689 | */ |
685 | if (nblks < (ctod(dumpsize) + chdrsize + ctod(1))) { | | 690 | if (nblks < (ctod(dumpsize) + chdrsize + ctod(1))) { |
686 | dumpsize = 0; | | 691 | dumpsize = 0; |
687 | dumplo = -1; | | 692 | dumplo = -1; |
688 | return; | | 693 | return; |
689 | } | | 694 | } |
690 | | | 695 | |
691 | /* | | 696 | /* |
692 | * Put dump at the end of the partition. | | 697 | * Put dump at the end of the partition. |
693 | */ | | 698 | */ |
694 | dumplo = (nblks - 1) - ctod(dumpsize) - chdrsize; | | 699 | dumplo = (nblks - 1) - ctod(dumpsize) - chdrsize; |
695 | } | | 700 | } |
696 | | | 701 | |
697 | void | | 702 | void |
698 | dumpsys(void) | | 703 | dumpsys(void) |
699 | { | | 704 | { |
700 | cpu_kcore_hdr_t *h = &cpu_kcore_hdr; | | 705 | cpu_kcore_hdr_t *h = &cpu_kcore_hdr; |
701 | struct m68k_kcore_hdr *m = &h->un._m68k; | | 706 | struct m68k_kcore_hdr *m = &h->un._m68k; |
702 | const struct bdevsw *bdev; | | 707 | const struct bdevsw *bdev; |
703 | daddr_t blkno; /* current block to write */ | | 708 | daddr_t blkno; /* current block to write */ |
704 | /* dump routine */ | | 709 | /* dump routine */ |
705 | int (*dump)(dev_t, daddr_t, void *, size_t); | | 710 | int (*dump)(dev_t, daddr_t, void *, size_t); |
706 | int pg; /* page being dumped */ | | 711 | int pg; /* page being dumped */ |
707 | paddr_t maddr; /* PA being dumped */ | | 712 | paddr_t maddr; /* PA being dumped */ |
708 | int seg; /* RAM segment being dumped */ | | 713 | int seg; /* RAM segment being dumped */ |
709 | int error; /* error code from (*dump)() */ | | 714 | int error; /* error code from (*dump)() */ |
710 | | | 715 | |
711 | /* XXX initialized here because of gcc lossage */ | | 716 | /* XXX initialized here because of gcc lossage */ |
712 | seg = 0; | | 717 | seg = 0; |
713 | maddr = m->ram_segs[seg].start; | | 718 | maddr = m->ram_segs[seg].start; |
714 | pg = 0; | | 719 | pg = 0; |
715 | | | 720 | |
716 | /* Make sure dump device is valid. */ | | 721 | /* Make sure dump device is valid. */ |
717 | if (dumpdev == NODEV) | | 722 | if (dumpdev == NODEV) |
718 | return; | | 723 | return; |
719 | bdev = bdevsw_lookup(dumpdev); | | 724 | bdev = bdevsw_lookup(dumpdev); |
720 | if (bdev == NULL) | | 725 | if (bdev == NULL) |
721 | return; | | 726 | return; |
722 | if (dumpsize == 0) { | | 727 | if (dumpsize == 0) { |
723 | cpu_dumpconf(); | | 728 | cpu_dumpconf(); |
724 | if (dumpsize == 0) | | 729 | if (dumpsize == 0) |
725 | return; | | 730 | return; |
726 | } | | 731 | } |
727 | if (dumplo <= 0) { | | 732 | if (dumplo <= 0) { |
728 | printf("\ndump to dev %u,%u not possible\n", | | 733 | printf("\ndump to dev %u,%u not possible\n", |
729 | major(dumpdev), minor(dumpdev)); | | 734 | major(dumpdev), minor(dumpdev)); |
730 | return; | | 735 | return; |
731 | } | | 736 | } |
732 | dump = bdev->d_dump; | | 737 | dump = bdev->d_dump; |
733 | blkno = dumplo; | | 738 | blkno = dumplo; |
734 | | | 739 | |
735 | printf("\ndumping to dev %u,%u offset %ld\n", | | 740 | printf("\ndumping to dev %u,%u offset %ld\n", |
736 | major(dumpdev), minor(dumpdev), dumplo); | | 741 | major(dumpdev), minor(dumpdev), dumplo); |
737 | | | 742 | |
738 | printf("dump "); | | 743 | printf("dump "); |
739 | | | 744 | |
740 | /* Write the dump header. */ | | 745 | /* Write the dump header. */ |
741 | error = cpu_dump(dump, &blkno); | | 746 | error = cpu_dump(dump, &blkno); |
742 | if (error) | | 747 | if (error) |
743 | goto bad; | | 748 | goto bad; |
744 | | | 749 | |
745 | for (pg = 0; pg < dumpsize; pg++) { | | 750 | for (pg = 0; pg < dumpsize; pg++) { |
746 | #define NPGMB (1024*1024/PAGE_SIZE) | | 751 | #define NPGMB (1024*1024/PAGE_SIZE) |
747 | /* print out how many MBs we have dumped */ | | 752 | /* print out how many MBs we have dumped */ |
748 | if (pg && (pg % NPGMB) == 0) | | 753 | if (pg && (pg % NPGMB) == 0) |
749 | printf_nolog("%d ", pg / NPGMB); | | 754 | printf_nolog("%d ", pg / NPGMB); |
750 | #undef NPGMB | | 755 | #undef NPGMB |
751 | if (maddr == 0) { | | 756 | if (maddr == 0) { |
752 | /* Skip first page */ | | 757 | /* Skip first page */ |
753 | maddr += PAGE_SIZE; | | 758 | maddr += PAGE_SIZE; |
754 | blkno += btodb(PAGE_SIZE); | | 759 | blkno += btodb(PAGE_SIZE); |
755 | continue; | | 760 | continue; |
756 | } | | 761 | } |
757 | while (maddr >= | | 762 | while (maddr >= |
758 | (m->ram_segs[seg].start + m->ram_segs[seg].size)) { | | 763 | (m->ram_segs[seg].start + m->ram_segs[seg].size)) { |
759 | if (++seg >= M68K_NPHYS_RAM_SEGS || | | 764 | if (++seg >= M68K_NPHYS_RAM_SEGS || |
760 | m->ram_segs[seg].size == 0) { | | 765 | m->ram_segs[seg].size == 0) { |
761 | error = EINVAL; /* XXX ?? */ | | 766 | error = EINVAL; /* XXX ?? */ |
762 | goto bad; | | 767 | goto bad; |
763 | } | | 768 | } |
764 | maddr = m->ram_segs[seg].start; | | 769 | maddr = m->ram_segs[seg].start; |
765 | } | | 770 | } |
766 | pmap_enter(pmap_kernel(), (vaddr_t)vmmap, maddr, | | 771 | pmap_enter(pmap_kernel(), (vaddr_t)vmmap, maddr, |
767 | VM_PROT_READ, VM_PROT_READ|PMAP_WIRED); | | 772 | VM_PROT_READ, VM_PROT_READ|PMAP_WIRED); |
768 | pmap_update(pmap_kernel()); | | 773 | pmap_update(pmap_kernel()); |
769 | | | 774 | |
770 | error = (*dump)(dumpdev, blkno, vmmap, PAGE_SIZE); | | 775 | error = (*dump)(dumpdev, blkno, vmmap, PAGE_SIZE); |
771 | bad: | | 776 | bad: |
772 | switch (error) { | | 777 | switch (error) { |
773 | case 0: | | 778 | case 0: |
774 | maddr += PAGE_SIZE; | | 779 | maddr += PAGE_SIZE; |
775 | blkno += btodb(PAGE_SIZE); | | 780 | blkno += btodb(PAGE_SIZE); |
776 | break; | | 781 | break; |
777 | | | 782 | |
778 | case ENXIO: | | 783 | case ENXIO: |
779 | printf("device bad\n"); | | 784 | printf("device bad\n"); |
780 | return; | | 785 | return; |
781 | | | 786 | |
782 | case EFAULT: | | 787 | case EFAULT: |
783 | printf("device not ready\n"); | | 788 | printf("device not ready\n"); |
784 | return; | | 789 | return; |
785 | | | 790 | |
786 | case EINVAL: | | 791 | case EINVAL: |
787 | printf("area improper\n"); | | 792 | printf("area improper\n"); |
788 | return; | | 793 | return; |
789 | | | 794 | |
790 | case EIO: | | 795 | case EIO: |
791 | printf("i/o error\n"); | | 796 | printf("i/o error\n"); |
792 | return; | | 797 | return; |
793 | | | 798 | |
794 | case EINTR: | | 799 | case EINTR: |
795 | printf("aborted from console\n"); | | 800 | printf("aborted from console\n"); |
796 | return; | | 801 | return; |
797 | | | 802 | |
798 | default: | | 803 | default: |
799 | printf("error %d\n", error); | | 804 | printf("error %d\n", error); |
800 | return; | | 805 | return; |
801 | } | | 806 | } |
802 | } | | 807 | } |
803 | printf("succeeded\n"); | | 808 | printf("succeeded\n"); |
804 | } | | 809 | } |
805 | | | 810 | |
806 | void | | 811 | void |
807 | initcpu(void) | | 812 | initcpu(void) |
808 | { | | 813 | { |
809 | /* XXX should init '40 vecs here, too */ | | 814 | /* XXX should init '40 vecs here, too */ |
810 | #if defined(M68060) | | 815 | #if defined(M68060) |
811 | extern void *vectab[256]; | | 816 | extern void *vectab[256]; |
812 | #if defined(M060SP) | | 817 | #if defined(M060SP) |
813 | extern uint8_t I_CALL_TOP[]; | | 818 | extern uint8_t I_CALL_TOP[]; |
814 | extern uint8_t FP_CALL_TOP[]; | | 819 | extern uint8_t FP_CALL_TOP[]; |
815 | #else | | 820 | #else |
816 | extern uint8_t illinst; | | 821 | extern uint8_t illinst; |
817 | #endif | | 822 | #endif |
818 | extern uint8_t fpfault; | | 823 | extern uint8_t fpfault; |
819 | #endif | | 824 | #endif |
820 | | | 825 | |
821 | #ifdef MAPPEDCOPY | | 826 | #ifdef MAPPEDCOPY |
822 | | | 827 | |
823 | /* | | 828 | /* |
824 | * Initialize lower bound for doing copyin/copyout using | | 829 | * Initialize lower bound for doing copyin/copyout using |
825 | * page mapping (if not already set). We don't do this on | | 830 | * page mapping (if not already set). We don't do this on |
826 | * VAC machines as it loses big time. | | 831 | * VAC machines as it loses big time. |
827 | */ | | 832 | */ |
828 | if ((int)mappedcopysize == -1) { | | 833 | if ((int)mappedcopysize == -1) { |
829 | mappedcopysize = PAGE_SIZE; | | 834 | mappedcopysize = PAGE_SIZE; |
830 | } | | 835 | } |
831 | #endif | | 836 | #endif |
832 | | | 837 | |
833 | #if defined(M68060) | | 838 | #if defined(M68060) |
834 | if (cputype == CPU_68060) { | | 839 | if (cputype == CPU_68060) { |
835 | #if defined(M060SP) | | 840 | #if defined(M060SP) |
836 | /* integer support */ | | 841 | /* integer support */ |
837 | vectab[61] = &I_CALL_TOP[128 + 0x00]; | | 842 | vectab[61] = &I_CALL_TOP[128 + 0x00]; |
838 | | | 843 | |
839 | /* floating point support */ | | 844 | /* floating point support */ |
840 | vectab[11] = &FP_CALL_TOP[128 + 0x30]; | | 845 | vectab[11] = &FP_CALL_TOP[128 + 0x30]; |
841 | vectab[55] = &FP_CALL_TOP[128 + 0x38]; | | 846 | vectab[55] = &FP_CALL_TOP[128 + 0x38]; |
842 | vectab[60] = &FP_CALL_TOP[128 + 0x40]; | | 847 | vectab[60] = &FP_CALL_TOP[128 + 0x40]; |
843 | | | 848 | |
844 | vectab[54] = &FP_CALL_TOP[128 + 0x00]; | | 849 | vectab[54] = &FP_CALL_TOP[128 + 0x00]; |
845 | vectab[52] = &FP_CALL_TOP[128 + 0x08]; | | 850 | vectab[52] = &FP_CALL_TOP[128 + 0x08]; |
846 | vectab[53] = &FP_CALL_TOP[128 + 0x10]; | | 851 | vectab[53] = &FP_CALL_TOP[128 + 0x10]; |
847 | vectab[51] = &FP_CALL_TOP[128 + 0x18]; | | 852 | vectab[51] = &FP_CALL_TOP[128 + 0x18]; |
848 | vectab[50] = &FP_CALL_TOP[128 + 0x20]; | | 853 | vectab[50] = &FP_CALL_TOP[128 + 0x20]; |
849 | vectab[49] = &FP_CALL_TOP[128 + 0x28]; | | 854 | vectab[49] = &FP_CALL_TOP[128 + 0x28]; |
850 | #else | | 855 | #else |
851 | vectab[61] = &illinst; | | 856 | vectab[61] = &illinst; |
852 | #endif | | 857 | #endif |
853 | vectab[48] = &fpfault; | | 858 | vectab[48] = &fpfault; |
854 | } | | 859 | } |
855 | DCIS(); | | 860 | DCIS(); |
856 | #endif | | 861 | #endif |
857 | } | | 862 | } |
858 | | | 863 | |
859 | void | | 864 | void |
860 | straytrap(int pc, u_short evec) | | 865 | straytrap(int pc, u_short evec) |
861 | { | | 866 | { |
862 | | | 867 | |
863 | printf("unexpected trap (vector offset %x) from %x\n", | | 868 | printf("unexpected trap (vector offset %x) from %x\n", |
864 | evec & 0xFFF, pc); | | 869 | evec & 0xFFF, pc); |
865 | #if defined(DDB) | | 870 | #if defined(DDB) |
866 | Debugger(); | | 871 | Debugger(); |
867 | #endif | | 872 | #endif |
868 | } | | 873 | } |
869 | | | 874 | |
870 | int *nofault; | | 875 | int *nofault; |
871 | | | 876 | |
872 | int | | 877 | int |
873 | badaddr(volatile void* addr) | | 878 | badaddr(volatile void* addr) |
874 | { | | 879 | { |
875 | int i; | | 880 | int i; |
876 | label_t faultbuf; | | 881 | label_t faultbuf; |
877 | | | 882 | |
878 | nofault = (int *)&faultbuf; | | 883 | nofault = (int *)&faultbuf; |
879 | if (setjmp((label_t *)nofault)) { | | 884 | if (setjmp((label_t *)nofault)) { |
880 | nofault = NULL; | | 885 | nofault = NULL; |
881 | return 1; | | 886 | return 1; |
882 | } | | 887 | } |
883 | i = *(volatile short *)addr; | | 888 | i = *(volatile short *)addr; |
884 | __USE(i); | | 889 | __USE(i); |
885 | nofault = NULL; | | 890 | nofault = NULL; |
886 | return 0; | | 891 | return 0; |
887 | } | | 892 | } |
888 | | | 893 | |
889 | int | | 894 | int |
890 | badbaddr(volatile void *addr) | | 895 | badbaddr(volatile void *addr) |
891 | { | | 896 | { |
892 | int i; | | 897 | int i; |
893 | label_t faultbuf; | | 898 | label_t faultbuf; |
894 | | | 899 | |
895 | nofault = (int *)&faultbuf; | | 900 | nofault = (int *)&faultbuf; |
896 | if (setjmp((label_t *)nofault)) { | | 901 | if (setjmp((label_t *)nofault)) { |
897 | nofault = NULL; | | 902 | nofault = NULL; |
898 | return 1; | | 903 | return 1; |
899 | } | | 904 | } |
900 | i = *(volatile char *)addr; | | 905 | i = *(volatile char *)addr; |
901 | __USE(i); | | 906 | __USE(i); |
902 | nofault = NULL; | | 907 | nofault = NULL; |
903 | return 0; | | 908 | return 0; |
904 | } | | 909 | } |
905 | | | 910 | |
906 | void | | 911 | void |
907 | intrhand(int sr) | | 912 | intrhand(int sr) |
908 | { | | 913 | { |
909 | | | 914 | |
910 | printf("intrhand: unexpected sr 0x%x\n", sr); | | 915 | printf("intrhand: unexpected sr 0x%x\n", sr); |
911 | } | | 916 | } |
912 | | | 917 | |
913 | const uint16_t ipl2psl_table[NIPL] = { | | 918 | const uint16_t ipl2psl_table[NIPL] = { |
914 | [IPL_NONE] = PSL_S | PSL_IPL0, | | 919 | [IPL_NONE] = PSL_S | PSL_IPL0, |
915 | [IPL_SOFTCLOCK] = PSL_S | PSL_IPL1, | | 920 | [IPL_SOFTCLOCK] = PSL_S | PSL_IPL1, |
916 | [IPL_SOFTBIO] = PSL_S | PSL_IPL1, | | 921 | [IPL_SOFTBIO] = PSL_S | PSL_IPL1, |
917 | [IPL_SOFTNET] = PSL_S | PSL_IPL1, | | 922 | [IPL_SOFTNET] = PSL_S | PSL_IPL1, |
918 | [IPL_SOFTSERIAL] = PSL_S | PSL_IPL1, | | 923 | [IPL_SOFTSERIAL] = PSL_S | PSL_IPL1, |
919 | [IPL_VM] = PSL_S | PSL_IPL5, | | 924 | [IPL_VM] = PSL_S | PSL_IPL5, |
920 | [IPL_SCHED] = PSL_S | PSL_IPL7, | | 925 | [IPL_SCHED] = PSL_S | PSL_IPL7, |
921 | [IPL_HIGH] = PSL_S | PSL_IPL7, | | 926 | [IPL_HIGH] = PSL_S | PSL_IPL7, |
922 | }; | | 927 | }; |
923 | | | 928 | |
924 | #if (defined(DDB) || defined(DEBUG)) && !defined(PANICBUTTON) | | 929 | #if (defined(DDB) || defined(DEBUG)) && !defined(PANICBUTTON) |
925 | #define PANICBUTTON | | 930 | #define PANICBUTTON |
926 | #endif | | 931 | #endif |
927 | | | 932 | |
928 | #ifdef PANICBUTTON | | 933 | #ifdef PANICBUTTON |
929 | int panicbutton = 1; /* non-zero if panic buttons are enabled */ | | 934 | int panicbutton = 1; /* non-zero if panic buttons are enabled */ |
930 | int crashandburn = 0; | | 935 | int crashandburn = 0; |
931 | int candbdelay = 50; /* give em half a second */ | | 936 | int candbdelay = 50; /* give em half a second */ |
932 | void candbtimer(void *); | | 937 | void candbtimer(void *); |
933 | | | 938 | |
934 | void | | 939 | void |
935 | candbtimer(void *arg) | | 940 | candbtimer(void *arg) |
936 | { | | 941 | { |
937 | | | 942 | |
938 | crashandburn = 0; | | 943 | crashandburn = 0; |
939 | } | | 944 | } |
940 | #endif | | 945 | #endif |
941 | | | 946 | |
942 | /* | | 947 | /* |
943 | * Level 7 interrupts can be caused by the keyboard or parity errors. | | 948 | * Level 7 interrupts can be caused by the keyboard or parity errors. |
944 | */ | | 949 | */ |
945 | void | | 950 | void |
946 | nmihand(struct frame frame) | | 951 | nmihand(struct frame frame) |
947 | { | | 952 | { |
948 | | | 953 | |
949 | intio_set_sysport_keyctrl(intio_get_sysport_keyctrl() | 0x04); | | 954 | intio_set_sysport_keyctrl(intio_get_sysport_keyctrl() | 0x04); |
950 | | | 955 | |
951 | if (1) { | | 956 | if (1) { |
952 | #ifdef PANICBUTTON | | 957 | #ifdef PANICBUTTON |
953 | static int innmihand = 0; | | 958 | static int innmihand = 0; |
954 | | | 959 | |
955 | /* | | 960 | /* |
956 | * Attempt to reduce the window of vulnerability for recursive | | 961 | * Attempt to reduce the window of vulnerability for recursive |
957 | * NMIs (e.g. someone holding down the keyboard reset button). | | 962 | * NMIs (e.g. someone holding down the keyboard reset button). |
958 | */ | | 963 | */ |
959 | if (innmihand == 0) { | | 964 | if (innmihand == 0) { |
960 | innmihand = 1; | | 965 | innmihand = 1; |
961 | printf("Got a keyboard NMI\n"); | | 966 | printf("Got a keyboard NMI\n"); |
962 | innmihand = 0; | | 967 | innmihand = 0; |
963 | } | | 968 | } |
964 | #ifdef DDB | | 969 | #ifdef DDB |
965 | Debugger(); | | 970 | Debugger(); |
966 | #else | | 971 | #else |
967 | if (panicbutton) { | | 972 | if (panicbutton) { |
968 | if (crashandburn) { | | 973 | if (crashandburn) { |
969 | crashandburn = 0; | | 974 | crashandburn = 0; |
970 | panic(panicstr ? | | 975 | panic(panicstr ? |
971 | "forced crash, nosync" : "forced crash"); | | 976 | "forced crash, nosync" : "forced crash"); |
972 | } | | 977 | } |
973 | crashandburn++; | | 978 | crashandburn++; |
974 | callout_reset(&candbtimer_ch, candbdelay, | | 979 | callout_reset(&candbtimer_ch, candbdelay, |
975 | candbtimer, NULL); | | 980 | candbtimer, NULL); |
976 | } | | 981 | } |
977 | #endif /* DDB */ | | 982 | #endif /* DDB */ |
978 | #endif /* PANICBUTTON */ | | 983 | #endif /* PANICBUTTON */ |
979 | return; | | 984 | return; |
980 | } | | 985 | } |
981 | /* panic?? */ | | 986 | /* panic?? */ |
982 | printf("unexpected level 7 interrupt ignored\n"); | | 987 | printf("unexpected level 7 interrupt ignored\n"); |
983 | } | | 988 | } |
984 | | | 989 | |
985 | /* | | 990 | /* |
986 | * cpu_exec_aout_makecmds(): | | 991 | * cpu_exec_aout_makecmds(): |
987 | * cpu-dependent a.out format hook for execve(). | | 992 | * cpu-dependent a.out format hook for execve(). |
988 | * | | 993 | * |
989 | * Determine of the given exec package refers to something which we | | 994 | * Determine of the given exec package refers to something which we |
990 | * understand and, if so, set up the vmcmds for it. | | 995 | * understand and, if so, set up the vmcmds for it. |
991 | * | | 996 | * |
992 | * XXX what are the special cases for the hp300? | | 997 | * XXX what are the special cases for the hp300? |
993 | * XXX why is this COMPAT_NOMID? was something generating | | 998 | * XXX why is this COMPAT_NOMID? was something generating |
994 | * hp300 binaries with an a_mid of 0? i thought that was only | | 999 | * hp300 binaries with an a_mid of 0? i thought that was only |
995 | * done on little-endian machines... -- cgd | | 1000 | * done on little-endian machines... -- cgd |
996 | */ | | 1001 | */ |
997 | int | | 1002 | int |
998 | cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp) | | 1003 | cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp) |
999 | { | | 1004 | { |
1000 | #if defined(COMPAT_NOMID) || defined(COMPAT_44) | | 1005 | #if defined(COMPAT_NOMID) || defined(COMPAT_44) |
1001 | u_long midmag, magic; | | 1006 | u_long midmag, magic; |
1002 | u_short mid; | | 1007 | u_short mid; |
1003 | int error; | | 1008 | int error; |
1004 | struct exec *execp = epp->ep_hdr; | | 1009 | struct exec *execp = epp->ep_hdr; |
1005 | | | 1010 | |
1006 | midmag = ntohl(execp->a_midmag); | | 1011 | midmag = ntohl(execp->a_midmag); |
1007 | mid = (midmag >> 16) & 0xffff; | | 1012 | mid = (midmag >> 16) & 0xffff; |
1008 | magic = midmag & 0xffff; | | 1013 | magic = midmag & 0xffff; |
1009 | | | 1014 | |
1010 | midmag = mid << 16 | magic; | | 1015 | midmag = mid << 16 | magic; |
1011 | | | 1016 | |
1012 | switch (midmag) { | | 1017 | switch (midmag) { |
1013 | #ifdef COMPAT_NOMID | | 1018 | #ifdef COMPAT_NOMID |
1014 | case (MID_ZERO << 16) | ZMAGIC: | | 1019 | case (MID_ZERO << 16) | ZMAGIC: |
1015 | error = exec_aout_prep_oldzmagic(l->l_proc, epp); | | 1020 | error = exec_aout_prep_oldzmagic(l->l_proc, epp); |
1016 | break; | | 1021 | break; |
1017 | #endif | | 1022 | #endif |
1018 | #ifdef COMPAT_44 | | 1023 | #ifdef COMPAT_44 |
1019 | case (MID_HP300 << 16) | ZMAGIC: | | 1024 | case (MID_HP300 << 16) | ZMAGIC: |
1020 | error = exec_aout_prep_oldzmagic(l->l_proc, epp); | | 1025 | error = exec_aout_prep_oldzmagic(l->l_proc, epp); |
1021 | break; | | 1026 | break; |
1022 | #endif | | 1027 | #endif |
1023 | default: | | 1028 | default: |
1024 | error = ENOEXEC; | | 1029 | error = ENOEXEC; |
1025 | } | | 1030 | } |
1026 | | | 1031 | |
1027 | return error; | | 1032 | return error; |
1028 | #else /* !(defined(COMPAT_NOMID) || defined(COMPAT_44)) */ | | 1033 | #else /* !(defined(COMPAT_NOMID) || defined(COMPAT_44)) */ |
1029 | return ENOEXEC; | | 1034 | return ENOEXEC; |
1030 | #endif | | 1035 | #endif |
1031 | } | | 1036 | } |
1032 | | | 1037 | |
1033 | #ifdef MODULAR | | 1038 | #ifdef MODULAR |
1034 | /* | | 1039 | /* |
1035 | * Push any modules loaded by the bootloader etc. | | 1040 | * Push any modules loaded by the bootloader etc. |
1036 | */ | | 1041 | */ |
1037 | void | | 1042 | void |
1038 | module_init_md(void) | | 1043 | module_init_md(void) |
1039 | { | | 1044 | { |
1040 | } | | 1045 | } |
1041 | #endif | | 1046 | #endif |
1042 | | | 1047 | |
1043 | #ifdef EXTENDED_MEMORY | | 1048 | #ifdef EXTENDED_MEMORY |
1044 | | | 1049 | |
1045 | static const struct memlist { | | 1050 | static const struct memlist { |
1046 | paddr_t exstart; | | 1051 | paddr_t exstart; |
1047 | psize_t minsize; | | 1052 | psize_t minsize; |
1048 | psize_t maxsize; | | 1053 | psize_t maxsize; |
1049 | } memlist[] = { | | 1054 | } memlist[] = { |
1050 | /* We define two extended memory regions for all possible settings. */ | | 1055 | /* We define two extended memory regions for all possible settings. */ |
1051 | | | 1056 | |
1052 | /* | | 1057 | /* |
1053 | * The first region is at 0x01000000: | | 1058 | * The first region is at 0x01000000: |
1054 | * | | 1059 | * |
1055 | * TS-6BE16: 16MB at 0x01000000 (to 0x01FFFFFF) | | 1060 | * TS-6BE16: 16MB at 0x01000000 (to 0x01FFFFFF) |
1056 | * XM6i: 4MB - 240MB at 0x01000000 (upto 0x0FFFFFFF) | | 1061 | * XM6i: 4MB - 240MB at 0x01000000 (upto 0x0FFFFFFF) |
1057 | */ | | 1062 | */ |
1058 | { 0x01000000, 0x00400000, 0x0f000000 }, | | 1063 | { 0x01000000, 0x00400000, 0x0f000000 }, |
1059 | | | 1064 | |
1060 | /* | | 1065 | /* |
1061 | * The second region is at 0x10000000: | | 1066 | * The second region is at 0x10000000: |
1062 | * | | 1067 | * |
1063 | * 060turbo: 4MB - 128MB at 0x10000000 (upto 0x17FFFFFF) | | 1068 | * 060turbo: 4MB - 128MB at 0x10000000 (upto 0x17FFFFFF) |
1064 | * XM6i: 4MB - 768MB at 0x10000000 (upto 0x3FFFFFFF) | | 1069 | * XM6i: 4MB - 768MB at 0x10000000 (upto 0x3FFFFFFF) |
1065 | */ | | 1070 | */ |
1066 | { 0x10000000, 0x00400000, 0x30000000 }, | | 1071 | { 0x10000000, 0x00400000, 0x30000000 }, |
1067 | }; | | 1072 | }; |
1068 | | | 1073 | |
1069 | /* check each 4MB region */ | | 1074 | /* check each 4MB region */ |
1070 | #define EXTMEM_RANGE (4 * 1024 * 1024) | | 1075 | #define EXTMEM_RANGE (4 * 1024 * 1024) |
1071 | | | 1076 | |
1072 | /* | | 1077 | /* |
1073 | * check memory existency | | 1078 | * check memory existency |
1074 | */ | | 1079 | */ |
1075 | static bool | | 1080 | static bool |
1076 | mem_exists(paddr_t mem, paddr_t basemax) | | 1081 | mem_exists(paddr_t mem, paddr_t basemax) |
1077 | { | | 1082 | { |
1078 | /* most variables must be register! */ | | 1083 | /* most variables must be register! */ |
1079 | volatile unsigned char *m, *b; | | 1084 | volatile unsigned char *m, *b; |
1080 | unsigned char save_m, save_b=0; /* XXX: shutup gcc */ | | 1085 | unsigned char save_m, save_b=0; /* XXX: shutup gcc */ |
1081 | bool baseismem; | | 1086 | bool baseismem; |
1082 | bool exists = false; | | 1087 | bool exists = false; |
1083 | void *base; | | 1088 | void *base; |
1084 | void *begin_check, *end_check; | | 1089 | void *begin_check, *end_check; |
1085 | label_t faultbuf; | | 1090 | label_t faultbuf; |
1086 | | | 1091 | |
1087 | /* | | 1092 | /* |
1088 | * In this function we assume: | | 1093 | * In this function we assume: |
1089 | * - MMU is not enabled yet but PA == VA | | 1094 | * - MMU is not enabled yet but PA == VA |
1090 | * (i.e. no RELOC() macro to convert PA to VA) | | 1095 | * (i.e. no RELOC() macro to convert PA to VA) |
1091 | * - bus error can be caught by setjmp() | | 1096 | * - bus error can be caught by setjmp() |
1092 | * (i.e. %vbr register is initialized properly) | | 1097 | * (i.e. %vbr register is initialized properly) |
1093 | * - all memory cache is not enabled | | 1098 | * - all memory cache is not enabled |
1094 | */ | | 1099 | */ |
1095 | | | 1100 | |
1096 | /* only 24bits are significant on normal X680x0 systems */ | | 1101 | /* only 24bits are significant on normal X680x0 systems */ |
1097 | base = (void *)(mem & 0x00FFFFFF); | | 1102 | base = (void *)(mem & 0x00FFFFFF); |
1098 | | | 1103 | |
1099 | m = (void *)mem; | | 1104 | m = (void *)mem; |
1100 | b = (void *)base; | | 1105 | b = (void *)base; |
1101 | | | 1106 | |
1102 | /* This is somewhat paranoid -- avoid overwriting myself */ | | 1107 | /* This is somewhat paranoid -- avoid overwriting myself */ |
1103 | __asm("lea %%pc@(begin_check_mem),%0" : "=a"(begin_check)); | | 1108 | __asm("lea %%pc@(begin_check_mem),%0" : "=a"(begin_check)); |
1104 | __asm("lea %%pc@(end_check_mem),%0" : "=a"(end_check)); | | 1109 | __asm("lea %%pc@(end_check_mem),%0" : "=a"(end_check)); |
1105 | if (base >= begin_check && base < end_check) { | | 1110 | if (base >= begin_check && base < end_check) { |
1106 | size_t off = (char *)end_check - (char *)begin_check; | | 1111 | size_t off = (char *)end_check - (char *)begin_check; |
1107 | | | 1112 | |
1108 | m -= off; | | 1113 | m -= off; |
1109 | b -= off; | | 1114 | b -= off; |
1110 | } | | 1115 | } |
1111 | | | 1116 | |
1112 | nofault = (int *)&faultbuf; | | 1117 | nofault = (int *)&faultbuf; |
1113 | if (setjmp((label_t *)nofault)) { | | 1118 | if (setjmp((label_t *)nofault)) { |
1114 | nofault = (int *)0; | | 1119 | nofault = (int *)0; |
1115 | return false; | | 1120 | return false; |
1116 | } | | 1121 | } |
1117 | | | 1122 | |
1118 | (void)*m; | | 1123 | (void)*m; |
1119 | /* | | 1124 | /* |
1120 | * Can't check by writing if the corresponding | | 1125 | * Can't check by writing if the corresponding |
1121 | * base address isn't memory. | | 1126 | * base address isn't memory. |
1122 | * | | 1127 | * |
1123 | * I hope this would be no harm.... | | 1128 | * I hope this would be no harm.... |
1124 | */ | | 1129 | */ |
1125 | baseismem = base < (void *)basemax; | | 1130 | baseismem = base < (void *)basemax; |
1126 | | | 1131 | |
1127 | __asm("begin_check_mem:"); | | 1132 | __asm("begin_check_mem:"); |
1128 | /* save original value (base must be saved first) */ | | 1133 | /* save original value (base must be saved first) */ |
1129 | if (baseismem) | | 1134 | if (baseismem) |
1130 | save_b = *b; | | 1135 | save_b = *b; |
1131 | save_m = *m; | | 1136 | save_m = *m; |
1132 | | | 1137 | |
1133 | /* | | 1138 | /* |
1134 | * stack and other data segment variables are unusable | | 1139 | * stack and other data segment variables are unusable |
1135 | * til end_check_mem, because they may be clobbered. | | 1140 | * til end_check_mem, because they may be clobbered. |
1136 | */ | | 1141 | */ |
1137 | | | 1142 | |
1138 | /* | | 1143 | /* |
1139 | * check memory by writing/reading | | 1144 | * check memory by writing/reading |
1140 | */ | | 1145 | */ |
1141 | if (baseismem) | | 1146 | if (baseismem) |
1142 | *b = 0x55; | | 1147 | *b = 0x55; |
1143 | *m = 0xAA; | | 1148 | *m = 0xAA; |
1144 | if ((baseismem && *b != 0x55) || *m != 0xAA) | | 1149 | if ((baseismem && *b != 0x55) || *m != 0xAA) |
1145 | goto out; | | 1150 | goto out; |
1146 | | | 1151 | |
1147 | *m = 0x55; | | 1152 | *m = 0x55; |
1148 | if (baseismem) | | 1153 | if (baseismem) |
1149 | *b = 0xAA; | | 1154 | *b = 0xAA; |
1150 | if (*m != 0x55 || (baseismem && *b != 0xAA)) | | 1155 | if (*m != 0x55 || (baseismem && *b != 0xAA)) |
1151 | goto out; | | 1156 | goto out; |
1152 | | | 1157 | |
1153 | exists = true; | | 1158 | exists = true; |
1154 | out: | | 1159 | out: |
1155 | *m = save_m; | | 1160 | *m = save_m; |
1156 | if (baseismem) | | 1161 | if (baseismem) |
1157 | *b = save_b; | | 1162 | *b = save_b; |
1158 | | | 1163 | |
1159 | __asm("end_check_mem:"); | | 1164 | __asm("end_check_mem:"); |
1160 | | | 1165 | |
1161 | nofault = (int *)0; | | 1166 | nofault = (int *)0; |
1162 | | | 1167 | |
1163 | return exists; | | 1168 | return exists; |
1164 | } | | 1169 | } |
1165 | #endif | | 1170 | #endif |
1166 | | | 1171 | |
1167 | void | | 1172 | void |
1168 | setmemrange(void) | | 1173 | setmemrange(void) |
1169 | { | | 1174 | { |
1170 | #ifdef EXTENDED_MEMORY | | 1175 | #ifdef EXTENDED_MEMORY |
1171 | int i; | | 1176 | int i; |
1172 | paddr_t exstart, exend; | | 1177 | paddr_t exstart, exend; |
1173 | psize_t size, minsize, maxsize; | | 1178 | psize_t size, minsize, maxsize; |
1174 | const struct memlist *mlist = memlist; | | 1179 | const struct memlist *mlist = memlist; |
1175 | paddr_t basemax = m68k_ptob(physmem); | | 1180 | paddr_t basemax = m68k_ptob(physmem); |
1176 | #endif | | 1181 | #endif |
1177 | | | 1182 | |
1178 | /* | | 1183 | /* |
1179 | * VM system is not started yet, and even MMU is not enabled here. | | 1184 | * VM system is not started yet, and even MMU is not enabled here. |
1180 | * We assume VA == PA and don't bother to use RELOC() macro | | 1185 | * We assume VA == PA and don't bother to use RELOC() macro |
1181 | * as pmap_bootstrap() does. | | 1186 | * as pmap_bootstrap() does. |
1182 | */ | | 1187 | */ |
1183 | | | 1188 | |
1184 | /* save the original base memory range */ | | 1189 | /* save the original base memory range */ |
1185 | basemem = physmem; | | 1190 | basemem = physmem; |
1186 | | | 1191 | |
1187 | /* | | 1192 | /* |
1188 | * XXX | | 1193 | * XXX |
1189 | * Probably we should also probe the main memory region | | 1194 | * Probably we should also probe the main memory region |
1190 | * for machines which might have a wrong value in a dead SRAM. | | 1195 | * for machines which might have a wrong value in a dead SRAM. |
1191 | */ | | 1196 | */ |
1192 | phys_basemem_seg.start = lowram; | | 1197 | phys_basemem_seg.start = lowram; |
1193 | phys_basemem_seg.end = m68k_ptob(basemem) + lowram; | | 1198 | phys_basemem_seg.end = m68k_ptob(basemem) + lowram; |
1194 | | | 1199 | |
1195 | #ifdef EXTENDED_MEMORY | | 1200 | #ifdef EXTENDED_MEMORY |
1196 | /* discover extended memory */ | | 1201 | /* discover extended memory */ |
1197 | for (i = 0; i < __arraycount(memlist); i++) { | | 1202 | for (i = 0; i < __arraycount(memlist); i++) { |
1198 | exstart = mlist[i].exstart; | | 1203 | exstart = mlist[i].exstart; |
1199 | minsize = mlist[i].minsize; | | 1204 | minsize = mlist[i].minsize; |
1200 | maxsize = mlist[i].maxsize; | | 1205 | maxsize = mlist[i].maxsize; |
1201 | /* | | 1206 | /* |
1202 | * Normally, x68k hardware is NOT 32bit-clean. | | 1207 | * Normally, x68k hardware is NOT 32bit-clean. |
1203 | * But some type of extended memory is in 32bit address space. | | 1208 | * But some type of extended memory is in 32bit address space. |
1204 | * Check whether. | | 1209 | * Check whether. |
1205 | */ | | 1210 | */ |
1206 | if (!mem_exists(exstart, basemax)) | | 1211 | if (!mem_exists(exstart, basemax)) |
1207 | continue; | | 1212 | continue; |
1208 | exend = 0; | | 1213 | exend = 0; |
1209 | /* range check */ | | 1214 | /* range check */ |
1210 | for (size = minsize; size <= maxsize; size += EXTMEM_RANGE) { | | 1215 | for (size = minsize; size <= maxsize; size += EXTMEM_RANGE) { |
1211 | if (!mem_exists(exstart + size - 4, basemax)) | | 1216 | if (!mem_exists(exstart + size - 4, basemax)) |
1212 | break; | | 1217 | break; |
1213 | exend = exstart + size; | | 1218 | exend = exstart + size; |
1214 | } | | 1219 | } |
1215 | if (exstart < exend) { | | 1220 | if (exstart < exend) { |
1216 | phys_extmem_seg[i].start = exstart; | | 1221 | phys_extmem_seg[i].start = exstart; |
1217 | phys_extmem_seg[i].end = exend; | | 1222 | phys_extmem_seg[i].end = exend; |
1218 | physmem += m68k_btop(exend - exstart); | | 1223 | physmem += m68k_btop(exend - exstart); |
1219 | if (maxmem < m68k_btop(exend)) | | 1224 | if (maxmem < m68k_btop(exend)) |
1220 | maxmem = m68k_btop(exend); | | 1225 | maxmem = m68k_btop(exend); |
1221 | } | | 1226 | } |
1222 | } | | 1227 | } |
1223 | #endif | | 1228 | #endif |
1224 | } | | 1229 | } |
1225 | | | 1230 | |
1226 | int idepth; | | 1231 | int idepth; |
1227 | | | 1232 | |
1228 | bool | | 1233 | bool |
1229 | cpu_intr_p(void) | | 1234 | cpu_intr_p(void) |
1230 | { | | 1235 | { |
1231 | | | 1236 | |
1232 | return idepth != 0; | | 1237 | return idepth != 0; |
1233 | } | | 1238 | } |
1234 | | | 1239 | |
1235 | int | | 1240 | int |
1236 | mm_md_physacc(paddr_t pa, vm_prot_t prot) | | 1241 | mm_md_physacc(paddr_t pa, vm_prot_t prot) |
1237 | { | | 1242 | { |
1238 | int i; | | 1243 | int i; |
1239 | | | 1244 | |
1240 | for (i = 0; i < vm_nphysseg; i++) { | | 1245 | for (i = 0; i < vm_nphysseg; i++) { |
1241 | if (ctob(vm_physmem[i].start) <= pa && | | 1246 | if (ctob(vm_physmem[i].start) <= pa && |
1242 | pa < ctob(vm_physmem[i].end)) | | 1247 | pa < ctob(vm_physmem[i].end)) |
1243 | return 0; | | 1248 | return 0; |
1244 | } | | 1249 | } |
1245 | return EFAULT; | | 1250 | return EFAULT; |
1246 | } | | 1251 | } |