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 (expand / 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,14 +1,14 @@ @@ -1,14 +1,14 @@
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.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
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>
@@ -141,27 +141,27 @@ extern void syscnattach(int); @@ -141,27 +141,27 @@ extern void syscnattach(int);
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),
@@ -172,27 +172,27 @@ luna68k_init() @@ -172,27 +172,27 @@ luna68k_init()
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".
@@ -204,26 +204,27 @@ luna68k_init() @@ -204,26 +204,27 @@ luna68k_init()
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);
@@ -258,56 +259,60 @@ cpu_startup(void) @@ -258,56 +259,60 @@ cpu_startup(void)
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")
@@ -319,28 +324,27 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc @@ -319,28 +324,27 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc
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 }
@@ -361,44 +365,46 @@ cpu_reboot(volatile int howto, char *boo @@ -361,44 +365,46 @@ cpu_reboot(volatile int howto, char *boo
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));
@@ -421,42 +427,42 @@ cpu_init_kcore_hdr(void) @@ -421,42 +427,42 @@ cpu_init_kcore_hdr(void)
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
@@ -464,53 +470,51 @@ cpu_init_kcore_hdr(void) @@ -464,53 +470,51 @@ cpu_init_kcore_hdr(void)
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{
@@ -634,123 +638,126 @@ dumpsys(void) @@ -634,123 +638,126 @@ dumpsys(void)
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{