Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / next68k / stand / boot / machdep.c
blob30d06e076b833f9090965fb0e57b4ba6a0723928
1 /* $NetBSD: machdep.c,v 1.6 2005/12/11 12:18:29 christos Exp $ */
2 /*
3 * Copyright (c) 1998 Darrin Jewell
4 * Copyright (c) 1994 Rolf Grossmann
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Rolf Grossmann.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/types.h>
35 #include <stand.h>
36 #include <next68k/next68k/nextrom.h>
38 char *mg;
40 #define MON(type, off) (*(type *)((u_int) (mg) + off))
42 extern int entry_point;
44 #ifdef DEBUG
45 int debug = 1;
46 #else
47 int debug = 0;
48 #endif
50 #ifdef DEBUG
51 #define DPRINTF(x) printf x
52 #else
53 #define DPRINTF(x)
54 #endif
56 void
57 machdep_start(char *entry, int howto, char *loadaddr, char *ssym, char *esym)
59 DPRINTF(("machdep_start(entry=%p,howto=0x%x,loadaddr=%p,ssym=%p,esym=%p\n",
60 entry, howto, loadaddr, ssym, esym));
61 MON(int,MG_boot_how) = howto;
62 entry_point = (int)entry + (int)loadaddr;
63 DPRINTF(("start=0x%lx\n", (u_long)entry_point));
65 /* @@@ hack to pass esym to kernel */
66 *((u_int *)loadaddr) = (u_int)esym;
68 /* return to exec, so that main can return entry point */
71 typedef int (*getcptr)(void);
72 typedef int (*putcptr)(int);
74 int
75 getchar(void)
77 return(MON(getcptr,MG_getc)());
80 void
81 putchar(int c)
83 MON(putcptr,MG_putc)(c);
86 __dead void
87 _rtt(void)
89 extern __dead void _halt(void);
91 printf("Press any key to halt.\n");
92 getchar();
93 _halt();
94 /* NOTREACHED */
97 struct trapframe {
98 int dregs[8];
99 int aregs[8];
100 short sr;
101 int pc;
102 u_short fmt:4,
103 vec:12;
104 char info[0];
105 } __attribute__ ((packed));
107 int trap(struct trapframe *);
110 trap(struct trapframe *fp)
112 static int intrap = 0;
114 if (intrap)
115 return 0;
116 intrap = 1;
117 printf("Got unexpected trap: format=%x vector=%x sr=%x pc=%x\n",
118 fp->fmt, fp->vec, fp->sr, fp->pc);
119 printf("dregs: %x %x %x %x %x %x %x %x\n",
120 fp->dregs[0], fp->dregs[1], fp->dregs[2], fp->dregs[3],
121 fp->dregs[4], fp->dregs[5], fp->dregs[6], fp->dregs[7]);
122 printf("aregs: %x %x %x %x %x %x %x %x\n",
123 fp->aregs[0], fp->aregs[1], fp->aregs[2], fp->aregs[3],
124 fp->aregs[4], fp->aregs[5], fp->aregs[6], fp->aregs[7]);
125 intrap = 0;
126 #ifdef DEBUG
127 if (debug)
129 int i;
130 int *p;
131 p = (int *)(fp->pc);
132 for (i = 0; i < 64; i++) {
133 if ((i % 8) == 0)
134 printf ("\npc %x: ", (int)&p[i-16]);
135 printf ("%x ", p[i]);
137 p = (int *)(fp->info);
138 for (i = 0; i < 64; i++) {
139 if ((i % 8) == 0)
140 printf ("\nstk %x: ", (int)&p[i-16]);
141 printf ("%x ", p[i]);
143 printf ("\n");
145 #endif
146 printf("Halting.\n");
147 return 0;