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