Thu Jul 28 09:56:34 2011 UTC ()
KNF, use ANSI decls, remove an obsolete hack, misc cosmetics etc.


(tsutsui)
diff -r1.80 -r1.81 src/sys/arch/luna68k/luna68k/machdep.c

cvs diff -r1.80 -r1.81 src/sys/arch/luna68k/luna68k/machdep.c (switch to unified diff)

--- src/sys/arch/luna68k/luna68k/machdep.c 2011/06/12 03:35:43 1.80
+++ src/sys/arch/luna68k/luna68k/machdep.c 2011/07/28 09:56:34 1.81
@@ -1,849 +1,856 @@ @@ -1,849 +1,856 @@
1/* $NetBSD: machdep.c,v 1.80 2011/06/12 03:35:43 rmind Exp $ */ 1/* $NetBSD: machdep.c,v 1.81 2011/07/28 09:56:34 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tohru Nishimura. 8 * by Tohru Nishimura.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 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 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 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 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 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 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 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 32#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
33 33
34__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.80 2011/06/12 03:35:43 rmind Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.81 2011/07/28 09:56:34 tsutsui Exp $");
35 35
36#include "opt_ddb.h" 36#include "opt_ddb.h"
37#include "opt_kgdb.h" 37#include "opt_kgdb.h"
38#include "opt_compat_sunos.h" 38#include "opt_compat_sunos.h"
39#include "opt_modular.h" 39#include "opt_modular.h"
40#include "opt_panicbutton.h" 40#include "opt_panicbutton.h"
41#include "opt_m68k_arch.h" 41#include "opt_m68k_arch.h"
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/kernel.h> 45#include <sys/kernel.h>
46#include <sys/proc.h> 46#include <sys/proc.h>
47#include <sys/buf.h> 47#include <sys/buf.h>
48#include <sys/reboot.h> 48#include <sys/reboot.h>
49#include <sys/conf.h> 49#include <sys/conf.h>
50#include <sys/file.h> 50#include <sys/file.h>
51#include <sys/device.h> 51#include <sys/device.h>
52#include <sys/malloc.h> 52#include <sys/malloc.h>
53#include <sys/mbuf.h> 53#include <sys/mbuf.h>
54#include <sys/msgbuf.h> 54#include <sys/msgbuf.h>
55#include <sys/ioctl.h> 55#include <sys/ioctl.h>
56#include <sys/tty.h> 56#include <sys/tty.h>
57#include <sys/mount.h> 57#include <sys/mount.h>
58#include <sys/exec.h> 58#include <sys/exec.h>
59#include <sys/exec_aout.h> /* for MID_* */ 59#include <sys/exec_aout.h> /* for MID_* */
60#include <sys/core.h> 60#include <sys/core.h>
61#include <sys/kauth.h> 61#include <sys/kauth.h>
62#include <sys/kcore.h> 62#include <sys/kcore.h>
63#include <sys/vnode.h> 63#include <sys/vnode.h>
64#include <sys/syscallargs.h> 64#include <sys/syscallargs.h>
65#include <sys/ksyms.h> 65#include <sys/ksyms.h>
66#include <sys/module.h> 66#include <sys/module.h>
67#ifdef KGDB 67#ifdef KGDB
68#include <sys/kgdb.h> 68#include <sys/kgdb.h>
69#endif 69#endif
70#include <sys/boot_flag.h> 70#include <sys/boot_flag.h>
71 71
72#include <uvm/uvm_extern.h> 72#include <uvm/uvm_extern.h>
73 73
74#include <sys/sysctl.h> 74#include <sys/sysctl.h>
75 75
76#include <machine/cpu.h> 76#include <machine/cpu.h>
77#include <machine/reg.h> 77#include <machine/reg.h>
78#include <machine/pcb.h> 78#include <machine/pcb.h>
79#include <machine/psl.h> 79#include <machine/psl.h>
80#include <machine/pte.h> 80#include <machine/pte.h>
81#include <machine/kcore.h> /* XXX should be pulled in by sys/kcore.h */ 81#include <machine/kcore.h> /* XXX should be pulled in by sys/kcore.h */
82 82
83#include <dev/cons.h> 83#include <dev/cons.h>
84#include <dev/mm.h> 84#include <dev/mm.h>
85 85
86#if defined(DDB) 86#if defined(DDB)
87#include <machine/db_machdep.h> 87#include <machine/db_machdep.h>
88#include <ddb/db_sym.h> 88#include <ddb/db_sym.h>
89#include <ddb/db_extern.h> 89#include <ddb/db_extern.h>
90#endif 90#endif
91 91
92#include "ksyms.h" 92#include "ksyms.h"
93 93
94/* 94/*
95 * Info for CTL_HW 95 * Info for CTL_HW
96 */ 96 */
97char machine[] = MACHINE; 97char machine[] = MACHINE;
98char cpu_model[60]; 98char cpu_model[60];
99 99
100/* Our exported CPU info; we can have only one. */  100/* Our exported CPU info; we can have only one. */
101struct cpu_info cpu_info_store; 101struct cpu_info cpu_info_store;
102 102
103struct vm_map *phys_map = NULL; 103struct vm_map *phys_map = NULL;
104 104
105int maxmem; /* max memory per process */ 105int maxmem; /* max memory per process */
106int physmem; /* set by locore */ 106int physmem; /* set by locore */
107/* 107/*
108 * safepri is a safe priority for sleep to set for a spin-wait 108 * safepri is a safe priority for sleep to set for a spin-wait
109 * during autoconfiguration or after a panic. 109 * during autoconfiguration or after a panic.
110 */ 110 */
111int safepri = PSL_LOWIPL; 111int safepri = PSL_LOWIPL;
112 112
113extern u_int lowram; 113extern u_int lowram;
114 114
115void luna68k_init(void); 115void luna68k_init(void);
116void identifycpu(void); 116void identifycpu(void);
117void dumpsys(void); 117void dumpsys(void);
118 118
119void straytrap(int, u_short); 119void straytrap(int, u_short);
120void nmihand(struct frame); 120void nmihand(struct frame);
121 121
122int cpu_dumpsize(void); 122int cpu_dumpsize(void);
123int cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *); 123int cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *);
124void cpu_init_kcore_hdr(void); 124void cpu_init_kcore_hdr(void);
125 125
126/* 126/*
127 * Machine-independent crash dump header info. 127 * Machine-independent crash dump header info.
128 */ 128 */
129cpu_kcore_hdr_t cpu_kcore_hdr; 129cpu_kcore_hdr_t cpu_kcore_hdr;
130 130
131int machtype; /* model: 1 for LUNA-1, 2 for LUNA-2 */ 131int machtype; /* model: 1 for LUNA-1, 2 for LUNA-2 */
132int sysconsole; /* console: 0 for ttya, 1 for video */ 132int sysconsole; /* console: 0 for ttya, 1 for video */
133 133
134extern struct consdev syscons; 134extern struct consdev syscons;
135extern void omfb_cnattach(void); 135extern void omfb_cnattach(void);
136extern void ws_cnattach(void); 136extern void ws_cnattach(void);
137extern void syscnattach(int); 137extern void syscnattach(int);
138 138
139/* 139/*
140 * On the 68020/68030, the value of delay_divisor is roughly 140 * On the 68020/68030, the value of delay_divisor is roughly
141 * 2048 / cpuspeed (where cpuspeed is in MHz). 141 * 2048 / cpuspeed (where cpuspeed is in MHz).
142 * 142 *
143 * On the 68040/68060(?), the value of delay_divisor is roughly 143 * On the 68040/68060(?), the value of delay_divisor is roughly
144 * 759 / cpuspeed (where cpuspeed is in MHz). 144 * 759 / cpuspeed (where cpuspeed is in MHz).
145 * XXX -- is the above formula correct? 145 * XXX -- is the above formula correct?
146 */ 146 */
147int cpuspeed = 25; /* only used for printing later */ 147int cpuspeed = 25; /* only used for printing later */
148int delay_divisor = 300; /* for delay() loop count */ 148int delay_divisor = 300; /* for delay() loop count */
149 149
150/* 150/*
151 * Early initialization, before main() is called. 151 * Early initialization, before main() is called.
152 */ 152 */
153void 153void
154luna68k_init() 154luna68k_init(void)
155{ 155{
156 volatile unsigned char *pio0 = (void *)0x49000000; 156 volatile unsigned char *pio0 = (void *)0x49000000;
157 int sw1, i; 157 int sw1, i;
158 char *cp; 158 char *cp;
159 extern char bootarg[64]; 159 extern char bootarg[64];
160 160
161 extern paddr_t avail_start, avail_end; 161 extern paddr_t avail_start, avail_end;
162 162
163 /* 163 /*
164 * Tell the VM system about available physical memory. The 164 * Tell the VM system about available physical memory. The
165 * luna68k only has one segment. 165 * luna68k only has one segment.
166 */ 166 */
167 uvm_page_physload(atop(avail_start), atop(avail_end), 167 uvm_page_physload(atop(avail_start), atop(avail_end),
168 atop(avail_start), atop(avail_end), VM_FREELIST_DEFAULT); 168 atop(avail_start), atop(avail_end), VM_FREELIST_DEFAULT);
169 169
170 /* 170 /*
171 * Initialize error message buffer (at end of core). 171 * Initialize error message buffer (at end of core).
172 * avail_end was pre-decremented in pmap_bootstrap to compensate. 172 * avail_end was pre-decremented in pmap_bootstrap to compensate.
173 */ 173 */
174 for (i = 0; i < btoc(MSGBUFSIZE); i++) 174 for (i = 0; i < btoc(MSGBUFSIZE); i++)
175 pmap_enter(pmap_kernel(), (vaddr_t)msgbufaddr + i * PAGE_SIZE, 175 pmap_enter(pmap_kernel(), (vaddr_t)msgbufaddr + i * PAGE_SIZE,
176 avail_end + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, 176 avail_end + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE,
177 VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED); 177 VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED);
178 pmap_update(pmap_kernel()); 178 pmap_update(pmap_kernel());
179 initmsgbuf(msgbufaddr, m68k_round_page(MSGBUFSIZE)); 179 initmsgbuf(msgbufaddr, m68k_round_page(MSGBUFSIZE));
180 180
181 181
182 pio0[3] = 0xb6; 182 pio0[3] = 0xb6;
183 pio0[2] = 1 << 6; /* enable parity check */ 183 pio0[2] = 1 << 6; /* enable parity check */
184 pio0[3] = 0xb6; 184 pio0[3] = 0xb6;
185 sw1 = pio0[0]; /* dipssw1 value */ 185 sw1 = pio0[0]; /* dip sw1 value */
186 sw1 ^= 0xff; 186 sw1 ^= 0xff;
187 sysconsole = !(sw1 & 0x2); /* console selection */ 187 sysconsole = !(sw1 & 0x2); /* console selection */
188 188
189 boothowto = 0; 189 boothowto = 0;
190 i = 0; 190 i = 0;
191 /* 191 /*
192 * 'bootarg' has; 192 * 'bootarg' has;
193 * "<args of x command> ENADDR=<addr> HOST=<host> SERVER=<name>" 193 * "<args of x command> ENADDR=<addr> HOST=<host> SERVER=<name>"
194 * where <addr> is MAC address of which network loader used (not 194 * where <addr> is MAC address of which network loader used (not
195 * necessarily same as one at 0x4101.FFE0), <host> and <name> 195 * necessarily same as one at 0x4101.FFE0), <host> and <name>
196 * are the values of HOST and SERVER environment variables, 196 * are the values of HOST and SERVER environment variables,
197 * 197 *
198 * NetBSD/luna68k cares only the first argment; any of "sda". 198 * NetBSD/luna68k cares only the first argment; any of "sda".
199 */ 199 */
200 for (cp = bootarg; *cp != ' '; cp++) { 200 for (cp = bootarg; *cp != ' '; cp++) {
201 BOOT_FLAG(*cp, boothowto); 201 BOOT_FLAG(*cp, boothowto);
202 if (i++ >= sizeof(bootarg)) 202 if (i++ >= sizeof(bootarg))
203 break; 203 break;
204 } 204 }
205#if 0 /* overload 1:sw1, which now means 'go ROM monitor' after poweron */ 205#if 0 /* overload 1:sw1, which now means 'go ROM monitor' after poweron */
206 if (boothowto == 0) 206 if (boothowto == 0)
207 boothowto = (sw1 & 0x1) ? RB_SINGLE : 0; 207 boothowto = (sw1 & 0x1) ? RB_SINGLE : 0;
208#endif 208#endif
209} 209}
210 210
211/* 211/*
212 * Console initialization: called early on from main, 212 * Console initialization: called early on from main,
213 */ 213 */
214void 214void
215consinit(void) 215consinit(void)
216{ 216{
 217
217 if (sysconsole == 0) 218 if (sysconsole == 0)
218 syscnattach(0); 219 syscnattach(0);
219 else { 220 else {
220 omfb_cnattach(); 221 omfb_cnattach();
221 ws_cnattach(); 222 ws_cnattach();
222 } 223 }
223 224
224#if NKSYMS || defined(DDB) || defined(MODULAR) 225#if NKSYMS || defined(DDB) || defined(MODULAR)
225 { 226 {
226 extern char end[]; 227 extern char end[];
227 extern int *esym; 228 extern int *esym;
228 229
229 ksyms_addsyms_elf(*(int *)&end, ((int *)&end) + 1, esym); 230 ksyms_addsyms_elf(*(int *)&end, ((int *)&end) + 1, esym);
230 } 231 }
231#endif 232#endif
232#ifdef DDB 233#ifdef DDB
233 if (boothowto & RB_KDB) 234 if (boothowto & RB_KDB)
234 cpu_Debugger(); 235 cpu_Debugger();
235#endif 236#endif
236} 237}
237 238
238/* 239/*
239 * cpu_startup: allocate memory for variable-sized tables. 240 * cpu_startup: allocate memory for variable-sized tables.
240 */ 241 */
241void 242void
242cpu_startup(void) 243cpu_startup(void)
243{ 244{
244 vaddr_t minaddr, maxaddr; 245 vaddr_t minaddr, maxaddr;
245 char pbuf[9]; 246 char pbuf[9];
246 extern void greeting(void); 247 extern void greeting(void);
247 248
248 if (fputype != FPU_NONE) 249 if (fputype != FPU_NONE)
249 m68k_make_fpu_idle_frame(); 250 m68k_make_fpu_idle_frame();
250 251
251 /* 252 /*
252 * Initialize the kernel crash dump header. 253 * Initialize the kernel crash dump header.
253 */ 254 */
254 cpu_init_kcore_hdr(); 255 cpu_init_kcore_hdr();
255 256
256 /* 257 /*
257 * Good {morning,afternoon,evening,night}. 258 * Good {morning,afternoon,evening,night}.
258 */ 259 */
259 printf("%s%s", copyright, version); 260 printf("%s%s", copyright, version);
260 identifycpu(); 261 identifycpu();
261 262
262 format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); 263 format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
263 printf("total memory = %s\n", pbuf); 264 printf("total memory = %s\n", pbuf);
264 265
265 minaddr = 0; 266 minaddr = 0;
266 267
267 /* 268 /*
268 * Allocate a submap for physio 269 * Allocate a submap for physio
269 */ 270 */
270 phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, 271 phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
271 VM_PHYS_SIZE, 0, false, NULL); 272 VM_PHYS_SIZE, 0, false, NULL);
272 273
273 format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); 274 format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
274 printf("avail memory = %s\n", pbuf); 275 printf("avail memory = %s\n", pbuf);
275 276
276 /* 277 /*
277 * Say "Hi" to the world 278 * Say "Hi" to the world
278 */ 279 */
279 greeting(); 280 greeting();
280} 281}
281 282
282void 283void
283identifycpu(void) 284identifycpu(void)
284{ 285{
285 extern int cputype; 286 extern int cputype;
286 const char *cpu; 287 const char *cpu;
287 288
288 memset(cpu_model, 0, sizeof(cpu_model)); 289 memset(cpu_model, 0, sizeof(cpu_model));
289 switch (cputype) { 290 switch (cputype) {
290 case CPU_68030: 291 case CPU_68030:
291 cpu = "MC68030 CPU+MMU, MC68882 FPU"; 292 cpu = "MC68030 CPU+MMU, MC68882 FPU";
292 machtype = LUNA_I; 293 machtype = LUNA_I;
293 cpuspeed = 20; delay_divisor = 102; /* 20MHz 68030 */ 294 /* 20MHz 68030 */
 295 cpuspeed = 20;
 296 delay_divisor = 102;
294 hz = 60; 297 hz = 60;
295 break; 298 break;
296#if defined(M68040) 299#if defined(M68040)
297 case CPU_68040: 300 case CPU_68040:
298 cpu = "MC68040 CPU+MMU+FPU, 4k on-chip physical I/D caches"; 301 cpu = "MC68040 CPU+MMU+FPU, 4k on-chip physical I/D caches";
299 machtype = LUNA_II; 302 machtype = LUNA_II;
300 cpuspeed = 25; delay_divisor = 300; /* 25MHz 68040 */ 303 /* 25MHz 68040 */
 304 cpuspeed = 25;
 305 delay_divisor = 300;
301 break; 306 break;
302#endif 307#endif
303 default: 308 default:
304 panic("unknown CPU type"); 309 panic("unknown CPU type");
305 } 310 }
306 strcpy(cpu_model, cpu); 311 strcpy(cpu_model, cpu);
307 printf("%s\n", cpu_model); 312 printf("%s\n", cpu_model);
308} 313}
309 314
310/* 315/*
311 * machine dependent system variables. 316 * machine dependent system variables.
312 */ 317 */
313SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup") 318SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
314{ 319{
315 320
316 sysctl_createv(clog, 0, NULL, NULL, 321 sysctl_createv(clog, 0, NULL, NULL,
317 CTLFLAG_PERMANENT, 322 CTLFLAG_PERMANENT,
318 CTLTYPE_NODE, "machdep", NULL, 323 CTLTYPE_NODE, "machdep", NULL,
319 NULL, 0, NULL, 0, 324 NULL, 0, NULL, 0,
320 CTL_MACHDEP, CTL_EOL); 325 CTL_MACHDEP, CTL_EOL);
321 326
322 sysctl_createv(clog, 0, NULL, NULL, 327 sysctl_createv(clog, 0, NULL, NULL,
323 CTLFLAG_PERMANENT, 328 CTLFLAG_PERMANENT,
324 CTLTYPE_STRUCT, "console_device", NULL, 329 CTLTYPE_STRUCT, "console_device", NULL,
325 sysctl_consdev, 0, NULL, sizeof(dev_t), 330 sysctl_consdev, 0, NULL, sizeof(dev_t),
326 CTL_MACHDEP, CPU_CONSDEV, CTL_EOL); 331 CTL_MACHDEP, CPU_CONSDEV, CTL_EOL);
327} 332}
328 333
329int waittime = -1; 334int waittime = -1;
330 335
331void 336void
332cpu_reboot(volatile int howto, char *bootstr) 337cpu_reboot(int howto, char *bootstr)
333 /* howto: XXX to shutup GCC XXX */ 
334{ 338{
335 struct pcb *pcb = lwp_getpcb(curlwp); 339 struct pcb *pcb = lwp_getpcb(curlwp);
336 extern void doboot(void); 340 extern void doboot(void);
337 341
338 /* take a snap shot before clobbering any registers */ 342 /* take a snap shot before clobbering any registers */
339 if (pcb != NULL) 343 if (pcb != NULL)
340 savectx(pcb); 344 savectx(pcb);
341 345
342 /* If system is hold, just halt. */ 346 /* If system is hold, just halt. */
343 if (cold) { 347 if (cold) {
344 howto |= RB_HALT; 348 howto |= RB_HALT;
345 goto haltsys; 349 goto haltsys;
346 } 350 }
347 351
348 boothowto = howto; 352 boothowto = howto;
349 if ((howto & RB_NOSYNC) == 0 && waittime < 0) { 353 if ((howto & RB_NOSYNC) == 0 && waittime < 0) {
350 waittime = 0; 354 waittime = 0;
351 vfs_shutdown(); 355 vfs_shutdown();
352 /* 356 /*
353 * If we've been adjusting the clock, the todr 357 * If we've been adjusting the clock, the todr
354 * will be out of synch; adjust it now. 358 * will be out of synch; adjust it now.
355 */ 359 */
356 resettodr(); 360 resettodr();
357 } 361 }
358 362
359 /* Disable interrupts. */ 363 /* Disable interrupts. */
360 splhigh(); 364 splhigh();
361 365
362 /* If rebooting and a dump is requested, do it. */ 366 /* If rebooting and a dump is requested, do it. */
363 if (howto & RB_DUMP) 367 if (howto & RB_DUMP)
364 dumpsys(); 368 dumpsys();
365 369
366haltsys: 370haltsys:
367 /* Run any shutdown hooks. */ 371 /* Run any shutdown hooks. */
368 doshutdownhooks(); 372 doshutdownhooks();
369 373
370 pmf_system_shutdown(boothowto); 374 pmf_system_shutdown(boothowto);
371 375
372 /* Finally, halt/reboot the system. */ 376 /* Finally, halt/reboot the system. */
373 if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { 377 if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
374 u_int8_t *pio = (void *)0x4d000000; 378 uint8_t *pio = (void *)0x4d000000;
375 379
376 printf("power is going down.\n"); 380 printf("power is going down.\n");
377 DELAY(100000); 381 DELAY(100000);
378 pio[3] = 0x94; 382 pio[3] = 0x94;
379 pio[2] = 0 << 4; 383 pio[2] = 0 << 4;
380 for (;;) /* NOP */; 384 for (;;)
 385 /* NOP */;
381 } 386 }
382 if (howto & RB_HALT) { 387 if (howto & RB_HALT) {
383 printf("System halted. Hit any key to reboot.\n\n"); 388 printf("System halted. Hit any key to reboot.\n\n");
384 (void)cngetc(); 389 (void)cngetc();
385 } 390 }
386 391
387 printf("rebooting...\n"); 392 printf("rebooting...\n");
388 DELAY(100000); 393 DELAY(100000);
389 doboot(); 394 doboot();
390 /*NOTREACHED*/ 395 /*NOTREACHED*/
391 while (1) ; 396 for (;;)
 397 ;
392} 398}
393 399
394/* 400/*
395 * Initialize the kernel crash dump header. 401 * Initialize the kernel crash dump header.
396 */ 402 */
397void 403void
398cpu_init_kcore_hdr(void) 404cpu_init_kcore_hdr(void)
399{ 405{
400 cpu_kcore_hdr_t *h = &cpu_kcore_hdr; 406 cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
401 struct m68k_kcore_hdr *m = &h->un._m68k; 407 struct m68k_kcore_hdr *m = &h->un._m68k;
402 extern char end[]; 408 extern char end[];
403 409
404 memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr));  410 memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr));
405 411
406 /* 412 /*
407 * Initialize the `dispatcher' portion of the header. 413 * Initialize the `dispatcher' portion of the header.
408 */ 414 */
409 strcpy(h->name, machine); 415 strcpy(h->name, machine);
410 h->page_size = PAGE_SIZE; 416 h->page_size = PAGE_SIZE;
411 h->kernbase = KERNBASE; 417 h->kernbase = KERNBASE;
412 418
413 /* 419 /*
414 * Fill in information about our MMU configuration. 420 * Fill in information about our MMU configuration.
415 */ 421 */
416 m->mmutype = mmutype; 422 m->mmutype = mmutype;
417 m->sg_v = SG_V; 423 m->sg_v = SG_V;
418 m->sg_frame = SG_FRAME; 424 m->sg_frame = SG_FRAME;
419 m->sg_ishift = SG_ISHIFT; 425 m->sg_ishift = SG_ISHIFT;
420 m->sg_pmask = SG_PMASK; 426 m->sg_pmask = SG_PMASK;
421 m->sg40_shift1 = SG4_SHIFT1; 427 m->sg40_shift1 = SG4_SHIFT1;
422 m->sg40_mask2 = SG4_MASK2; 428 m->sg40_mask2 = SG4_MASK2;
423 m->sg40_shift2 = SG4_SHIFT2; 429 m->sg40_shift2 = SG4_SHIFT2;
424 m->sg40_mask3 = SG4_MASK3; 430 m->sg40_mask3 = SG4_MASK3;
425 m->sg40_shift3 = SG4_SHIFT3; 431 m->sg40_shift3 = SG4_SHIFT3;
426 m->sg40_addr1 = SG4_ADDR1; 432 m->sg40_addr1 = SG4_ADDR1;
427 m->sg40_addr2 = SG4_ADDR2; 433 m->sg40_addr2 = SG4_ADDR2;
428 m->pg_v = PG_V; 434 m->pg_v = PG_V;
429 m->pg_frame = PG_FRAME; 435 m->pg_frame = PG_FRAME;
430 436
431 /* 437 /*
432 * Initialize pointer to kernel segment table. 438 * Initialize pointer to kernel segment table.
433 */ 439 */
434 m->sysseg_pa = (u_int32_t)(pmap_kernel()->pm_stpa); 440 m->sysseg_pa = (uint32_t)(pmap_kernel()->pm_stpa);
435 441
436 /* 442 /*
437 * Initialize relocation value such that: 443 * Initialize relocation value such that:
438 * 444 *
439 * pa = (va - KERNBASE) + reloc 445 * pa = (va - KERNBASE) + reloc
440 * 446 *
441 * Since we're linked and loaded at the same place, 447 * Since we're linked and loaded at the same place,
442 * and the kernel is mapped va == pa, this is 0. 448 * and the kernel is mapped va == pa, this is 0.
443 */ 449 */
444 m->reloc = 0; 450 m->reloc = 0;
445 451
446 /* 452 /*
447 * Define the end of the relocatable range. 453 * Define the end of the relocatable range.
448 */ 454 */
449 m->relocend = (u_int32_t)end; 455 m->relocend = (uint32_t)end;
450 456
451 /* 457 /*
452 * The luna68k has one contiguous memory segment. 458 * The luna68k has one contiguous memory segment.
453 */ 459 */
454 m->ram_segs[0].start = 0 /* lowram */; 460 m->ram_segs[0].start = 0 /* lowram */;
455 m->ram_segs[0].size = ctob(physmem); 461 m->ram_segs[0].size = ctob(physmem);
456} 462}
457 463
458/* 464/*
459 * Compute the size of the machine-dependent crash dump header. 465 * Compute the size of the machine-dependent crash dump header.
460 * Returns size in disk blocks. 466 * Returns size in disk blocks.
461 */ 467 */
462 468
463#define CHDRSIZE (ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t))) 469#define CHDRSIZE (ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t)))
464#define MDHDRSIZE roundup(CHDRSIZE, dbtob(1)) 470#define MDHDRSIZE roundup(CHDRSIZE, dbtob(1))
465 471
466int 472int
467cpu_dumpsize(void) 473cpu_dumpsize(void)
468{ 474{
469 475
470 return btodb(MDHDRSIZE); 476 return btodb(MDHDRSIZE);
471} 477}
472 478
473/* 479/*
474 * Called by dumpsys() to dump the machine-dependent header. 480 * Called by dumpsys() to dump the machine-dependent header.
475 */ 481 */
476int 482int
477cpu_dump(dump, blknop) 483cpu_dump(int (*dump)(dev_t, daddr_t, void *, size_t), daddr_t *blknop)
478 int (*dump)(dev_t, daddr_t, void *, size_t);  
479 daddr_t *blknop; 
480{ 484{
481 int buf[MDHDRSIZE / sizeof(int)];  485 int buf[MDHDRSIZE / sizeof(int)];
482 cpu_kcore_hdr_t *chdr; 486 cpu_kcore_hdr_t *chdr;
483 kcore_seg_t *kseg; 487 kcore_seg_t *kseg;
484 int error; 488 int error;
485 489
486 kseg = (kcore_seg_t *)buf; 490 kseg = (kcore_seg_t *)buf;
487 chdr = (cpu_kcore_hdr_t *)&buf[ALIGN(sizeof(kcore_seg_t)) / 491 chdr = (cpu_kcore_hdr_t *)&buf[ALIGN(sizeof(kcore_seg_t)) /
488 sizeof(int)]; 492 sizeof(int)];
489 493
490 /* Create the segment header. */ 494 /* Create the segment header. */
491 CORE_SETMAGIC(*kseg, KCORE_MAGIC, MID_MACHINE, CORE_CPU); 495 CORE_SETMAGIC(*kseg, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
492 kseg->c_size = MDHDRSIZE - ALIGN(sizeof(kcore_seg_t)); 496 kseg->c_size = MDHDRSIZE - ALIGN(sizeof(kcore_seg_t));
493 497
494 memcpy(chdr, &cpu_kcore_hdr, sizeof(cpu_kcore_hdr_t)); 498 memcpy(chdr, &cpu_kcore_hdr, sizeof(cpu_kcore_hdr_t));
495 error = (*dump)(dumpdev, *blknop, (void *)buf, sizeof(buf)); 499 error = (*dump)(dumpdev, *blknop, (void *)buf, sizeof(buf));
496 *blknop += btodb(sizeof(buf)); 500 *blknop += btodb(sizeof(buf));
497 return (error); 501 return error;
498} 502}
499 503
500/* 504/*
501 * These variables are needed by /sbin/savecore 505 * These variables are needed by /sbin/savecore
502 */ 506 */
503u_int32_t dumpmag = 0x8fca0101; /* magic number */ 507uint32_t dumpmag = 0x8fca0101; /* magic number */
504int dumpsize = 0; /* pages */ 508int dumpsize = 0; /* pages */
505long dumplo = 0; /* blocks */ 509long dumplo = 0; /* blocks */
506 510
507/* 511/*
508 * This is called by main to set dumplo and dumpsize. 512 * This is called by main to set dumplo and dumpsize.
509 * Dumps always skip the first PAGE_SIZE of disk space 513 * Dumps always skip the first PAGE_SIZE of disk space
510 * in case there might be a disk label stored there. 514 * in case there might be a disk label stored there.
511 * If there is extra space, put dump at the end to 515 * If there is extra space, put dump at the end to
512 * reduce the chance that swapping trashes it. 516 * reduce the chance that swapping trashes it.
513 */ 517 */
514void 518void
515cpu_dumpconf(void) 519cpu_dumpconf(void)
516{ 520{
517 const struct bdevsw *bdev; 521 const struct bdevsw *bdev;
518 int chdrsize; /* size of dump header */ 522 int chdrsize; /* size of dump header */
519 int nblks; /* size of dump area */ 523 int nblks; /* size of dump area */
520 524
521 if (dumpdev == NODEV) 525 if (dumpdev == NODEV)
522 return; 526 return;
523 bdev = bdevsw_lookup(dumpdev); 527 bdev = bdevsw_lookup(dumpdev);
524 if (bdev == NULL) { 528 if (bdev == NULL) {
525 dumpdev = NODEV; 529 dumpdev = NODEV;
526 return; 530 return;
527 } 531 }
528 if (bdev->d_psize == NULL) 532 if (bdev->d_psize == NULL)
529 return; 533 return;
530 nblks = (*bdev->d_psize)(dumpdev); 534 nblks = (*bdev->d_psize)(dumpdev);
531 chdrsize = cpu_dumpsize(); 535 chdrsize = cpu_dumpsize();
532 536
533 dumpsize = btoc(cpu_kcore_hdr.un._m68k.ram_segs[0].size); 537 dumpsize = btoc(cpu_kcore_hdr.un._m68k.ram_segs[0].size);
534 538
535 /* 539 /*
536 * Check do see if we will fit. Note we always skip the 540 * Check do see if we will fit. Note we always skip the
537 * first PAGE_SIZE in case there is a disk label there. 541 * first PAGE_SIZE in case there is a disk label there.
538 */ 542 */
539 if (nblks < (ctod(dumpsize) + chdrsize + ctod(1))) { 543 if (nblks < (ctod(dumpsize) + chdrsize + ctod(1))) {
540 dumpsize = 0; 544 dumpsize = 0;
541 dumplo = -1; 545 dumplo = -1;
542 return; 546 return;
543 } 547 }
544 548
545 /* 549 /*
546 * Put dump at the end of the partition. 550 * Put dump at the end of the partition.
547 */ 551 */
548 dumplo = (nblks - 1) - ctod(dumpsize) - chdrsize; 552 dumplo = (nblks - 1) - ctod(dumpsize) - chdrsize;
549} 553}
550 554
551/* 555/*
552 * Dump physical memory onto the dump device. Called by cpu_reboot(). 556 * Dump physical memory onto the dump device. Called by cpu_reboot().
553 */ 557 */
554void 558void
555dumpsys(void) 559dumpsys(void)
556{ 560{
557 const struct bdevsw *bdev; 561 const struct bdevsw *bdev;
558 daddr_t blkno; /* current block to write */ 562 daddr_t blkno; /* current block to write */
559 /* dump routine */ 563 /* dump routine */
560 int (*dump)(dev_t, daddr_t, void *, size_t); 564 int (*dump)(dev_t, daddr_t, void *, size_t);
561 int pg; /* page being dumped */ 565 int pg; /* page being dumped */
562 paddr_t maddr; /* PA being dumped */ 566 paddr_t maddr; /* PA being dumped */
563 int error; /* error code from (*dump)() */ 567 int error; /* error code from (*dump)() */
564 568
565 /* XXX initialized here because of gcc lossage */ 569 /* XXX initialized here because of gcc lossage */
566 maddr = 0 /* lowram */; 570 maddr = 0 /* lowram */;
567 pg = 0; 571 pg = 0;
568 572
569 /* Make sure dump device is valid. */ 573 /* Make sure dump device is valid. */
570 if (dumpdev == NODEV) 574 if (dumpdev == NODEV)
571 return; 575 return;
572 bdev = bdevsw_lookup(dumpdev); 576 bdev = bdevsw_lookup(dumpdev);
573 if (bdev == NULL) 577 if (bdev == NULL)
574 return; 578 return;
575 if (dumpsize == 0) { 579 if (dumpsize == 0) {
576 cpu_dumpconf(); 580 cpu_dumpconf();
577 if (dumpsize == 0) 581 if (dumpsize == 0)
578 return; 582 return;
579 } 583 }
580 if (dumplo <= 0) { 584 if (dumplo <= 0) {
581 printf("\ndump to dev %u,%u not possible\n", 585 printf("\ndump to dev %u,%u not possible\n",
582 major(dumpdev), minor(dumpdev)); 586 major(dumpdev), minor(dumpdev));
583 return; 587 return;
584 } 588 }
585 dump = bdev->d_dump; 589 dump = bdev->d_dump;
586 blkno = dumplo; 590 blkno = dumplo;
587 591
588 printf("\ndumping to dev %u,%u offset %ld\n", 592 printf("\ndumping to dev %u,%u offset %ld\n",
589 major(dumpdev), minor(dumpdev), dumplo); 593 major(dumpdev), minor(dumpdev), dumplo);
590 594
591 printf("dump "); 595 printf("dump ");
592 596
593 /* Write the dump header. */ 597 /* Write the dump header. */
594 error = cpu_dump(dump, &blkno); 598 error = cpu_dump(dump, &blkno);
595 if (error) 599 if (error)
596 goto bad; 600 goto bad;
597 601
598 for (pg = 0; pg < dumpsize; pg++) { 602 for (pg = 0; pg < dumpsize; pg++) {
599#define NPGMB (1024*1024/PAGE_SIZE) 603#define NPGMB (1024*1024/PAGE_SIZE)
600 /* print out how many MBs we have dumped */ 604 /* print out how many MBs we have dumped */
601 if (pg && (pg % NPGMB) == 0) 605 if (pg && (pg % NPGMB) == 0)
602 printf("%d ", pg / NPGMB); 606 printf("%d ", pg / NPGMB);
603#undef NPGMB 607#undef NPGMB
604 pmap_enter(pmap_kernel(), (vaddr_t)vmmap, maddr, 608 pmap_enter(pmap_kernel(), (vaddr_t)vmmap, maddr,
605 VM_PROT_READ, VM_PROT_READ|PMAP_WIRED); 609 VM_PROT_READ, VM_PROT_READ|PMAP_WIRED);
606 610
607 pmap_update(pmap_kernel()); 611 pmap_update(pmap_kernel());
608 error = (*dump)(dumpdev, blkno, vmmap, PAGE_SIZE); 612 error = (*dump)(dumpdev, blkno, vmmap, PAGE_SIZE);
609 bad: 613 bad:
610 switch (error) { 614 switch (error) {
611 case 0: 615 case 0:
612 maddr += PAGE_SIZE; 616 maddr += PAGE_SIZE;
613 blkno += btodb(PAGE_SIZE); 617 blkno += btodb(PAGE_SIZE);
614 break; 618 break;
615 619
616 case ENXIO: 620 case ENXIO:
617 printf("device bad\n"); 621 printf("device bad\n");
618 return; 622 return;
619 623
620 case EFAULT: 624 case EFAULT:
621 printf("device not ready\n"); 625 printf("device not ready\n");
622 return; 626 return;
623 627
624 case EINVAL: 628 case EINVAL:
625 printf("area improper\n"); 629 printf("area improper\n");
626 return; 630 return;
627 631
628 case EIO: 632 case EIO:
629 printf("i/o error\n"); 633 printf("i/o error\n");
630 return; 634 return;
631 635
632 case EINTR: 636 case EINTR:
633 printf("aborted from console\n"); 637 printf("aborted from console\n");
634 return; 638 return;
635 639
636 default: 640 default:
637 printf("error %d\n", error); 641 printf("error %d\n", error);
638 return; 642 return;
639 } 643 }
640 } 644 }
641 printf("succeeded\n"); 645 printf("succeeded\n");
642} 646}
643 647
644void 648void
645straytrap(int pc, u_short evec) 649straytrap(int pc, u_short evec)
646{ 650{
 651
647 printf("unexpected trap (vector offset %x) from %x\n", 652 printf("unexpected trap (vector offset %x) from %x\n",
648 evec & 0xFFF, pc); 653 evec & 0xFFF, pc);
649} 654}
650 655
651int *nofault; 656int *nofault;
652 657
653int 658int
654badaddr(register void *addr, int nbytes) 659badaddr(register void *addr, int nbytes)
655{ 660{
656 register int i; 661 register int i;
657 label_t faultbuf; 662 label_t faultbuf;
658 663
659#ifdef lint 664#ifdef lint
660 i = *addr; if (i) return (0); 665 i = *addr; if (i) return (0);
661#endif 666#endif
662 667
663 nofault = (int *) &faultbuf; 668 nofault = (int *)&faultbuf;
664 if (setjmp((label_t *)nofault)) { 669 if (setjmp((label_t *)nofault)) {
665 nofault = (int *) 0; 670 nofault = (int *)0;
666 return(1); 671 return 1;
667 } 672 }
668 673
669 switch (nbytes) { 674 switch (nbytes) {
670 case 1: 675 case 1:
671 i = *(volatile char *)addr; 676 i = *(volatile int8_t *)addr;
672 break; 677 break;
673 678
674 case 2: 679 case 2:
675 i = *(volatile short *)addr; 680 i = *(volatile int16_t *)addr;
676 break; 681 break;
677 682
678 case 4: 683 case 4:
679 i = *(volatile int *)addr; 684 i = *(volatile int32_t *)addr;
680 break; 685 break;
681 686
682 default: 687 default:
683 panic("badaddr: bad request"); 688 panic("badaddr: bad request");
684 } 689 }
685 nofault = (int *) 0; 690 nofault = (int *)0;
686 return (0); 691 return 0;
687} 692}
688 693
689void luna68k_abort(const char *); 694void luna68k_abort(const char *);
690 695
691static int innmihand; /* simple mutex */ 696static int innmihand; /* simple mutex */
692 697
693/* 698/*
694 * Level 7 interrupts are caused by e.g. the ABORT switch. 699 * Level 7 interrupts are caused by e.g. the ABORT switch.
695 * 700 *
696 * If we have DDB, then break into DDB on ABORT. In a production 701 * If we have DDB, then break into DDB on ABORT. In a production
697 * environment, bumping the ABORT switch would be bad, so we enable 702 * environment, bumping the ABORT switch would be bad, so we enable
698 * panic'ing on ABORT with the kernel option "PANICBUTTON". 703 * panic'ing on ABORT with the kernel option "PANICBUTTON".
699 */ 704 */
700void 705void
701nmihand(struct frame frame) 706nmihand(struct frame frame)
702{ 707{
 708
703 /* Prevent unwanted recursion */ 709 /* Prevent unwanted recursion */
704 if (innmihand) 710 if (innmihand)
705 return; 711 return;
706 innmihand = 1; 712 innmihand = 1;
707 713
708 luna68k_abort("ABORT SWITCH"); 714 luna68k_abort("ABORT SWITCH");
709} 715}
710 716
711/* 717/*
712 * Common code for handling ABORT signals from buttons, switches, 718 * Common code for handling ABORT signals from buttons, switches,
713 * serial lines, etc. 719 * serial lines, etc.
714 */ 720 */
715void 721void
716luna68k_abort(const char *cp) 722luna68k_abort(const char *cp)
717{ 723{
 724
718#ifdef DDB 725#ifdef DDB
719 printf("%s\n", cp); 726 printf("%s\n", cp);
720 cpu_Debugger(); 727 cpu_Debugger();
721#else 728#else
722#ifdef PANICBUTTON 729#ifdef PANICBUTTON
723 panic(cp); 730 panic(cp);
724#else 731#else
725 printf("%s ignored\n", cp); 732 printf("%s ignored\n", cp);
726#endif /* PANICBUTTON */ 733#endif /* PANICBUTTON */
727#endif /* DDB */ 734#endif /* DDB */
728} 735}
729 736
730/* 737/*
731 * cpu_exec_aout_makecmds(): 738 * cpu_exec_aout_makecmds():
732 * CPU-dependent a.out format hook for execve(). 739 * CPU-dependent a.out format hook for execve().
733 *  740 *
734 * Determine of the given exec package refers to something which we 741 * Determine of the given exec package refers to something which we
735 * understand and, if so, set up the vmcmds for it. 742 * understand and, if so, set up the vmcmds for it.
736 */ 743 */
737int 744int
738cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp) 745cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp)
739{ 746{
740 int error = ENOEXEC; 747 int error = ENOEXEC;
741#ifdef COMPAT_SUNOS 748#ifdef COMPAT_SUNOS
742 extern sunos_exec_aout_makecmds 749 extern sunos_exec_aout_makecmds(struct proc *, struct exec_package *);
743(struct proc *, struct exec_package *); 750
744 if ((error = sunos_exec_aout_makecmds(l->l_proc, epp)) == 0) 751 if ((error = sunos_exec_aout_makecmds(l->l_proc, epp)) == 0)
745 return 0; 752 return 0;
746#endif 753#endif
747 return error; 754 return error;
748} 755}
749 756
750#ifdef MODULAR 757#ifdef MODULAR
751/* 758/*
752 * Push any modules loaded by the bootloader etc. 759 * Push any modules loaded by the bootloader etc.
753 */ 760 */
754void 761void
755module_init_md(void) 762module_init_md(void)
756{ 763{
757} 764}
758#endif 765#endif
759 766
760#if 1 767#if 1
761 768
762struct consdev *cn_tab = &syscons; 769struct consdev *cn_tab = &syscons;
763 770
764#else 771#else
765 772
766/* 773/*
767 * romcons is useful until m68k TC register is initialized. 774 * romcons is useful until m68k TC register is initialized.
768 */ 775 */
769int romcngetc(dev_t); 776int romcngetc(dev_t);
770void romcnputc(dev_t, int); 777void romcnputc(dev_t, int);
771 778
772struct consdev romcons = { 779struct consdev romcons = {
773 NULL, 780 NULL,
774 NULL, 781 NULL,
775 romcngetc, 782 romcngetc,
776 romcnputc, 783 romcnputc,
777 nullcnpollc, 784 nullcnpollc,
778 makedev(7, 0), /* XXX */ 785 makedev(7, 0), /* XXX */
779 CN_DEAD, 786 CN_DEAD,
780}; 787};
781struct consdev *cn_tab = &romcons; 788struct consdev *cn_tab = &romcons;
782 789
783#define __ ((int **)0x41000000) 790#define __ ((int **)0x41000000)
784#define GETC() (*(int (*)())__[6])() 791#define GETC() (*(int (*)())__[6])()
785#define PUTC(x) (*(void (*)())__[7])(x) 792#define PUTC(x) (*(void (*)())__[7])(x)
786 793
787#define ROMPUTC(x) \ 794#define ROMPUTC(x) \
788({ \ 795({ \
789 register _r; \ 796 register _r; \
790 __asm volatile (" \ 797 __asm volatile (" \
791 movc %%vbr,%0 ; \ 798 movc %%vbr,%0 ; \
792 movel %0,%%sp@- ; \ 799 movel %0,%%sp@- ; \
793 clrl %0 ; \ 800 clrl %0 ; \
794 movc %0,%%vbr" \ 801 movc %0,%%vbr" \
795 : "=r" (_r)); \ 802 : "=r" (_r)); \
796 PUTC(x); \ 803 PUTC(x); \
797 __asm volatile (" \ 804 __asm volatile (" \
798 movel %%sp@+,%0 ; \ 805 movel %%sp@+,%0 ; \
799 movc %0,%%vbr" \ 806 movc %0,%%vbr" \
800 : "=r" (_r)); \ 807 : "=r" (_r)); \
801}) 808})
802 809
803#define ROMGETC() \ 810#define ROMGETC() \
804({ \ 811({ \
805 register _r, _c; \ 812 register _r, _c; \
806 __asm volatile (" \ 813 __asm volatile (" \
807 movc %%vbr,%0 ; \ 814 movc %%vbr,%0 ; \
808 movel %0,%%sp@- ; \ 815 movel %0,%%sp@- ; \
809 clrl %0 ; \ 816 clrl %0 ; \
810 movc %0,%%vbr" \ 817 movc %0,%%vbr" \
811 : "=r" (_r)); \ 818 : "=r" (_r)); \
812 _c = GETC(); \ 819 _c = GETC(); \
813 __asm volatile (" \ 820 __asm volatile (" \
814 movel %%sp@+,%0 ; \ 821 movel %%sp@+,%0 ; \
815 movc %0,%%vbr" \ 822 movc %0,%%vbr" \
816 : "=r" (_r)); \ 823 : "=r" (_r)); \
817 _c; \ 824 _c; \
818}) 825})
819 826
820void 827void
821romcnputc(dev_t dev, int c) 828romcnputc(dev_t dev, int c)
822{ 829{
823 int s; 830 int s;
824 831
825 s = splhigh(); 832 s = splhigh();
826 ROMPUTC(c); 833 ROMPUTC(c);
827 splx(s); 834 splx(s);
828} 835}
829 836
830int 837int
831romcngetc(dev_t dev) 838romcngetc(dev_t dev)
832{ 839{
833 int s, c; 840 int s, c;
834 841
835 do { 842 do {
836 s = splhigh(); 843 s = splhigh();
837 c = ROMGETC(); 844 c = ROMGETC();
838 splx(s); 845 splx(s);
839 } while (c == -1); 846 } while (c == -1);
840 return c; 847 return c;
841} 848}
842#endif 849#endif
843 850
844int 851int
845mm_md_physacc(paddr_t pa, vm_prot_t prot) 852mm_md_physacc(paddr_t pa, vm_prot_t prot)
846{ 853{
847 854
848 return (pa < lowram || pa >= 0xfffffffc) ? EFAULT : 0; 855 return (pa < lowram || pa >= 0xfffffffc) ? EFAULT : 0;
849} 856}