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