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