machdep.c revision 1.72 1 /* $NetBSD: machdep.c,v 1.72 2009/11/23 00:11:44 rmind 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.72 2009/11/23 00:11:44 rmind 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/exec.h>
58 #include <sys/exec_aout.h> /* for MID_* */
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(void)
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(void)
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 struct pcb *pcb = lwp_getpcb(l);
291 extern int fputype;
292
293 frame->f_sr = PSL_USERSET;
294 frame->f_pc = pack->ep_entry & ~1;
295 frame->f_regs[D0] = 0;
296 frame->f_regs[D1] = 0;
297 frame->f_regs[D2] = 0;
298 frame->f_regs[D3] = 0;
299 frame->f_regs[D4] = 0;
300 frame->f_regs[D5] = 0;
301 frame->f_regs[D6] = 0;
302 frame->f_regs[D7] = 0;
303 frame->f_regs[A0] = 0;
304 frame->f_regs[A1] = 0;
305 frame->f_regs[A2] = (int)l->l_proc->p_psstr;
306 frame->f_regs[A3] = 0;
307 frame->f_regs[A4] = 0;
308 frame->f_regs[A5] = 0;
309 frame->f_regs[A6] = 0;
310 frame->f_regs[SP] = stack;
311
312 /* restore a null state frame */
313 pcb->pcb_fpregs.fpf_null = 0;
314 if (fputype)
315 m68881_restore(&pcb->pcb_fpregs);
316 }
317
318 void
319 identifycpu(void)
320 {
321 extern int cputype;
322 const char *cpu;
323
324 memset(cpu_model, 0, sizeof(cpu_model));
325 switch (cputype) {
326 case CPU_68030:
327 cpu = "MC68030 CPU+MMU, MC68882 FPU";
328 machtype = LUNA_I;
329 cpuspeed = 20; delay_divisor = 102; /* 20MHz 68030 */
330 hz = 60;
331 break;
332 #if defined(M68040)
333 case CPU_68040:
334 cpu = "MC68040 CPU+MMU+FPU, 4k on-chip physical I/D caches";
335 machtype = LUNA_II;
336 cpuspeed = 25; delay_divisor = 300; /* 25MHz 68040 */
337 break;
338 #endif
339 default:
340 panic("unknown CPU type");
341 }
342 strcpy(cpu_model, cpu);
343 printf("%s\n", cpu_model);
344 }
345
346 /*
347 * machine dependent system variables.
348 */
349 SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
350 {
351
352 sysctl_createv(clog, 0, NULL, NULL,
353 CTLFLAG_PERMANENT,
354 CTLTYPE_NODE, "machdep", NULL,
355 NULL, 0, NULL, 0,
356 CTL_MACHDEP, CTL_EOL);
357
358 sysctl_createv(clog, 0, NULL, NULL,
359 CTLFLAG_PERMANENT,
360 CTLTYPE_STRUCT, "console_device", NULL,
361 sysctl_consdev, 0, NULL, sizeof(dev_t),
362 CTL_MACHDEP, CPU_CONSDEV, CTL_EOL);
363 }
364
365 int waittime = -1;
366
367 void
368 cpu_reboot(volatile int howto, char *bootstr)
369 /* howto: XXX to shutup GCC XXX */
370 {
371 struct pcb *pcb = lwp_getpcb(curlwp);
372 extern void doboot(void);
373
374 /* take a snap shot before clobbering any registers */
375 if (pcb != NULL)
376 savectx(pcb);
377
378 /* If system is hold, just halt. */
379 if (cold) {
380 howto |= RB_HALT;
381 goto haltsys;
382 }
383
384 boothowto = howto;
385 if ((howto & RB_NOSYNC) == 0 && waittime < 0) {
386 waittime = 0;
387 vfs_shutdown();
388 /*
389 * If we've been adjusting the clock, the todr
390 * will be out of synch; adjust it now.
391 */
392 resettodr();
393 }
394
395 /* Disable interrupts. */
396 splhigh();
397
398 /* If rebooting and a dump is requested, do it. */
399 if (howto & RB_DUMP)
400 dumpsys();
401
402 haltsys:
403 /* Run any shutdown hooks. */
404 doshutdownhooks();
405
406 pmf_system_shutdown(boothowto);
407
408 /* Finally, halt/reboot the system. */
409 if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
410 u_int8_t *pio = (void *)0x4d000000;
411
412 printf("power is going down.\n");
413 DELAY(100000);
414 pio[3] = 0x94;
415 pio[2] = 0 << 4;
416 for (;;) /* NOP */;
417 }
418 if (howto & RB_HALT) {
419 printf("System halted. Hit any key to reboot.\n\n");
420 (void)cngetc();
421 }
422
423 printf("rebooting...\n");
424 DELAY(100000);
425 doboot();
426 /*NOTREACHED*/
427 while (1) ;
428 }
429
430 /*
431 * Initialize the kernel crash dump header.
432 */
433 void
434 cpu_init_kcore_hdr(void)
435 {
436 cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
437 struct m68k_kcore_hdr *m = &h->un._m68k;
438 extern char end[];
439
440 memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr));
441
442 /*
443 * Initialize the `dispatcher' portion of the header.
444 */
445 strcpy(h->name, machine);
446 h->page_size = PAGE_SIZE;
447 h->kernbase = KERNBASE;
448
449 /*
450 * Fill in information about our MMU configuration.
451 */
452 m->mmutype = mmutype;
453 m->sg_v = SG_V;
454 m->sg_frame = SG_FRAME;
455 m->sg_ishift = SG_ISHIFT;
456 m->sg_pmask = SG_PMASK;
457 m->sg40_shift1 = SG4_SHIFT1;
458 m->sg40_mask2 = SG4_MASK2;
459 m->sg40_shift2 = SG4_SHIFT2;
460 m->sg40_mask3 = SG4_MASK3;
461 m->sg40_shift3 = SG4_SHIFT3;
462 m->sg40_addr1 = SG4_ADDR1;
463 m->sg40_addr2 = SG4_ADDR2;
464 m->pg_v = PG_V;
465 m->pg_frame = PG_FRAME;
466
467 /*
468 * Initialize pointer to kernel segment table.
469 */
470 m->sysseg_pa = (u_int32_t)(pmap_kernel()->pm_stpa);
471
472 /*
473 * Initialize relocation value such that:
474 *
475 * pa = (va - KERNBASE) + reloc
476 *
477 * Since we're linked and loaded at the same place,
478 * and the kernel is mapped va == pa, this is 0.
479 */
480 m->reloc = 0;
481
482 /*
483 * Define the end of the relocatable range.
484 */
485 m->relocend = (u_int32_t)end;
486
487 /*
488 * The luna68k has one contiguous memory segment.
489 */
490 m->ram_segs[0].start = 0 /* lowram */;
491 m->ram_segs[0].size = ctob(physmem);
492 }
493
494 /*
495 * Compute the size of the machine-dependent crash dump header.
496 * Returns size in disk blocks.
497 */
498
499 #define CHDRSIZE (ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t)))
500 #define MDHDRSIZE roundup(CHDRSIZE, dbtob(1))
501
502 int
503 cpu_dumpsize(void)
504 {
505
506 return btodb(MDHDRSIZE);
507 }
508
509 /*
510 * Called by dumpsys() to dump the machine-dependent header.
511 */
512 int
513 cpu_dump(dump, blknop)
514 int (*dump)(dev_t, daddr_t, void *, size_t);
515 daddr_t *blknop;
516 {
517 int buf[MDHDRSIZE / sizeof(int)];
518 cpu_kcore_hdr_t *chdr;
519 kcore_seg_t *kseg;
520 int error;
521
522 kseg = (kcore_seg_t *)buf;
523 chdr = (cpu_kcore_hdr_t *)&buf[ALIGN(sizeof(kcore_seg_t)) /
524 sizeof(int)];
525
526 /* Create the segment header. */
527 CORE_SETMAGIC(*kseg, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
528 kseg->c_size = MDHDRSIZE - ALIGN(sizeof(kcore_seg_t));
529
530 memcpy(chdr, &cpu_kcore_hdr, sizeof(cpu_kcore_hdr_t));
531 error = (*dump)(dumpdev, *blknop, (void *)buf, sizeof(buf));
532 *blknop += btodb(sizeof(buf));
533 return (error);
534 }
535
536 /*
537 * These variables are needed by /sbin/savecore
538 */
539 u_int32_t dumpmag = 0x8fca0101; /* magic number */
540 int dumpsize = 0; /* pages */
541 long dumplo = 0; /* blocks */
542
543 /*
544 * This is called by main to set dumplo and dumpsize.
545 * Dumps always skip the first PAGE_SIZE of disk space
546 * in case there might be a disk label stored there.
547 * If there is extra space, put dump at the end to
548 * reduce the chance that swapping trashes it.
549 */
550 void
551 cpu_dumpconf(void)
552 {
553 const struct bdevsw *bdev;
554 int chdrsize; /* size of dump header */
555 int nblks; /* size of dump area */
556
557 if (dumpdev == NODEV)
558 return;
559 bdev = bdevsw_lookup(dumpdev);
560 if (bdev == NULL) {
561 dumpdev = NODEV;
562 return;
563 }
564 if (bdev->d_psize == NULL)
565 return;
566 nblks = (*bdev->d_psize)(dumpdev);
567 chdrsize = cpu_dumpsize();
568
569 dumpsize = btoc(cpu_kcore_hdr.un._m68k.ram_segs[0].size);
570
571 /*
572 * Check do see if we will fit. Note we always skip the
573 * first PAGE_SIZE in case there is a disk label there.
574 */
575 if (nblks < (ctod(dumpsize) + chdrsize + ctod(1))) {
576 dumpsize = 0;
577 dumplo = -1;
578 return;
579 }
580
581 /*
582 * Put dump at the end of the partition.
583 */
584 dumplo = (nblks - 1) - ctod(dumpsize) - chdrsize;
585 }
586
587 /*
588 * Dump physical memory onto the dump device. Called by cpu_reboot().
589 */
590 void
591 dumpsys(void)
592 {
593 const struct bdevsw *bdev;
594 daddr_t blkno; /* current block to write */
595 /* dump routine */
596 int (*dump)(dev_t, daddr_t, void *, size_t);
597 int pg; /* page being dumped */
598 paddr_t maddr; /* PA being dumped */
599 int error; /* error code from (*dump)() */
600
601 /* XXX initialized here because of gcc lossage */
602 maddr = 0 /* lowram */;
603 pg = 0;
604
605 /* Make sure dump device is valid. */
606 if (dumpdev == NODEV)
607 return;
608 bdev = bdevsw_lookup(dumpdev);
609 if (bdev == NULL)
610 return;
611 if (dumpsize == 0) {
612 cpu_dumpconf();
613 if (dumpsize == 0)
614 return;
615 }
616 if (dumplo <= 0) {
617 printf("\ndump to dev %u,%u not possible\n",
618 major(dumpdev), minor(dumpdev));
619 return;
620 }
621 dump = bdev->d_dump;
622 blkno = dumplo;
623
624 printf("\ndumping to dev %u,%u offset %ld\n",
625 major(dumpdev), minor(dumpdev), dumplo);
626
627 printf("dump ");
628
629 /* Write the dump header. */
630 error = cpu_dump(dump, &blkno);
631 if (error)
632 goto bad;
633
634 for (pg = 0; pg < dumpsize; pg++) {
635 #define NPGMB (1024*1024/PAGE_SIZE)
636 /* print out how many MBs we have dumped */
637 if (pg && (pg % NPGMB) == 0)
638 printf("%d ", pg / NPGMB);
639 #undef NPGMB
640 pmap_enter(pmap_kernel(), (vaddr_t)vmmap, maddr,
641 VM_PROT_READ, VM_PROT_READ|PMAP_WIRED);
642
643 pmap_update(pmap_kernel());
644 error = (*dump)(dumpdev, blkno, vmmap, PAGE_SIZE);
645 bad:
646 switch (error) {
647 case 0:
648 maddr += PAGE_SIZE;
649 blkno += btodb(PAGE_SIZE);
650 break;
651
652 case ENXIO:
653 printf("device bad\n");
654 return;
655
656 case EFAULT:
657 printf("device not ready\n");
658 return;
659
660 case EINVAL:
661 printf("area improper\n");
662 return;
663
664 case EIO:
665 printf("i/o error\n");
666 return;
667
668 case EINTR:
669 printf("aborted from console\n");
670 return;
671
672 default:
673 printf("error %d\n", error);
674 return;
675 }
676 }
677 printf("succeeded\n");
678 }
679
680 void
681 straytrap(int pc, u_short evec)
682 {
683 printf("unexpected trap (vector offset %x) from %x\n",
684 evec & 0xFFF, pc);
685 }
686
687 int *nofault;
688
689 int
690 badaddr(register void *addr, int nbytes)
691 {
692 register int i;
693 label_t faultbuf;
694
695 #ifdef lint
696 i = *addr; if (i) return (0);
697 #endif
698
699 nofault = (int *) &faultbuf;
700 if (setjmp((label_t *)nofault)) {
701 nofault = (int *) 0;
702 return(1);
703 }
704
705 switch (nbytes) {
706 case 1:
707 i = *(volatile char *)addr;
708 break;
709
710 case 2:
711 i = *(volatile short *)addr;
712 break;
713
714 case 4:
715 i = *(volatile int *)addr;
716 break;
717
718 default:
719 panic("badaddr: bad request");
720 }
721 nofault = (int *) 0;
722 return (0);
723 }
724
725 void luna68k_abort(const char *);
726
727 static int innmihand; /* simple mutex */
728
729 /*
730 * Level 7 interrupts are caused by e.g. the ABORT switch.
731 *
732 * If we have DDB, then break into DDB on ABORT. In a production
733 * environment, bumping the ABORT switch would be bad, so we enable
734 * panic'ing on ABORT with the kernel option "PANICBUTTON".
735 */
736 void
737 nmihand(struct frame frame)
738 {
739 /* Prevent unwanted recursion */
740 if (innmihand)
741 return;
742 innmihand = 1;
743
744 luna68k_abort("ABORT SWITCH");
745 }
746
747 /*
748 * Common code for handling ABORT signals from buttons, switches,
749 * serial lines, etc.
750 */
751 void
752 luna68k_abort(const char *cp)
753 {
754 #ifdef DDB
755 printf("%s\n", cp);
756 cpu_Debugger();
757 #else
758 #ifdef PANICBUTTON
759 panic(cp);
760 #else
761 printf("%s ignored\n", cp);
762 #endif /* PANICBUTTON */
763 #endif /* DDB */
764 }
765
766 /*
767 * cpu_exec_aout_makecmds():
768 * CPU-dependent a.out format hook for execve().
769 *
770 * Determine of the given exec package refers to something which we
771 * understand and, if so, set up the vmcmds for it.
772 */
773 int
774 cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp)
775 {
776 int error = ENOEXEC;
777 #ifdef COMPAT_SUNOS
778 extern sunos_exec_aout_makecmds
779 (struct proc *, struct exec_package *);
780 if ((error = sunos_exec_aout_makecmds(l->l_proc, epp)) == 0)
781 return 0;
782 #endif
783 return error;
784 }
785
786 #if 1
787
788 struct consdev *cn_tab = &syscons;
789
790 #else
791
792 /*
793 * romcons is useful until m68k TC register is initialized.
794 */
795 int romcngetc(dev_t);
796 void romcnputc(dev_t, int);
797
798 struct consdev romcons = {
799 NULL,
800 NULL,
801 romcngetc,
802 romcnputc,
803 nullcnpollc,
804 makedev(7, 0), /* XXX */
805 CN_DEAD,
806 };
807 struct consdev *cn_tab = &romcons;
808
809 #define __ ((int **)0x41000000)
810 #define GETC() (*(int (*)())__[6])()
811 #define PUTC(x) (*(void (*)())__[7])(x)
812
813 #define ROMPUTC(x) \
814 ({ \
815 register _r; \
816 __asm volatile (" \
817 movc %%vbr,%0 ; \
818 movel %0,%%sp@- ; \
819 clrl %0 ; \
820 movc %0,%%vbr" \
821 : "=r" (_r)); \
822 PUTC(x); \
823 __asm volatile (" \
824 movel %%sp@+,%0 ; \
825 movc %0,%%vbr" \
826 : "=r" (_r)); \
827 })
828
829 #define ROMGETC() \
830 ({ \
831 register _r, _c; \
832 __asm volatile (" \
833 movc %%vbr,%0 ; \
834 movel %0,%%sp@- ; \
835 clrl %0 ; \
836 movc %0,%%vbr" \
837 : "=r" (_r)); \
838 _c = GETC(); \
839 __asm volatile (" \
840 movel %%sp@+,%0 ; \
841 movc %0,%%vbr" \
842 : "=r" (_r)); \
843 _c; \
844 })
845
846 void
847 romcnputc(dev_t dev, int c)
848 {
849 int s;
850
851 s = splhigh();
852 ROMPUTC(c);
853 splx(s);
854 }
855
856 int
857 romcngetc(dev_t dev)
858 {
859 int s, c;
860
861 do {
862 s = splhigh();
863 c = ROMGETC();
864 splx(s);
865 } while (c == -1);
866 return c;
867 }
868 #endif
869