machdep.c revision 1.3 1 /* $NetBSD: machdep.c,v 1.3 1997/05/12 07:53:02 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1982, 1986, 1990, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * from: Utah $Hdr: machdep.c 1.10 92/06/18
41 *
42 * @(#)machdep.c 8.1 (Berkeley) 6/10/93
43 */
44
45 #include <sys/param.h>
46 #include <hp300/stand/common/samachdep.h>
47
48 char *
49 getmachineid()
50 {
51 extern int machineid;
52 char *cp;
53
54 switch (machineid) {
55 case HP_320:
56 cp = "320"; break;
57 case HP_330:
58 cp = "318/319/330"; break;
59 case HP_340:
60 cp = "340"; break;
61 case HP_345:
62 cp = "345"; break;
63 case HP_350:
64 cp = "350"; break;
65 case HP_360:
66 cp = "360"; break;
67 case HP_370:
68 cp = "370"; break;
69 case HP_375:
70 cp = "375"; break;
71 case HP_380:
72 cp = "380"; break;
73 case HP_400:
74 cp = "400"; break;
75 case HP_425:
76 cp = "425"; break;
77 case HP_433:
78 cp = "433"; break;
79 default:
80 cp = "???"; break;
81 }
82 return(cp);
83 }
84
85 int userom;
86
87 struct trapframe {
88 int dregs[8];
89 int aregs[8];
90 int whoknows;
91 short sr;
92 int pc;
93 short frame;
94 };
95
96 trap(fp)
97 struct trapframe *fp;
98 {
99 static int intrap = 0;
100
101 if (intrap)
102 return(0);
103 intrap = 1;
104
105 #if 0
106 userom = 1;
107 #endif
108
109 printf("Got unexpected trap: format=%x vector=%x ps=%x pc=%x\n",
110 (fp->frame>>12)&0xF, fp->frame&0xFFF, fp->sr, fp->pc);
111 printf("dregs: %x %x %x %x %x %x %x %x\n",
112 fp->dregs[0], fp->dregs[1], fp->dregs[2], fp->dregs[3],
113 fp->dregs[4], fp->dregs[5], fp->dregs[6], fp->dregs[7]);
114 printf("aregs: %x %x %x %x %x %x %x %x\n",
115 fp->aregs[0], fp->aregs[1], fp->aregs[2], fp->aregs[3],
116 fp->aregs[4], fp->aregs[5], fp->aregs[6], fp->aregs[7]);
117
118 #if 0
119 userom = 0;
120 #endif
121
122 intrap = 0;
123 return(0);
124 }
125
126 #define ROWS 24
127 #define COLS 80
128
129 void
130 romputchar(c)
131 int c;
132 {
133 static char buf[COLS];
134 static int col = 0, row = 0;
135 int i;
136
137 switch (c) {
138 case '\0':
139 break;
140 case '\r':
141 break; /* ignore */
142 case '\n':
143 for (i = col; i < COLS-1; i++)
144 buf[i] = ' ';
145 buf[i] = '\0';
146 romout(row, buf);
147 col = 0;
148 if (++row == ROWS)
149 row = 0;
150 break;
151
152 case '\t':
153 do {
154 romputchar(' ');
155 } while (col & 7);
156 break;
157
158 default:
159 buf[col] = c;
160 if (++col == COLS-1)
161 romputchar('\n');
162 break;
163 }
164 }
165
166 void
167 machdep_start(entry, howto, loadaddr, ssym, esym)
168 char *entry;
169 int howto;
170 char *loadaddr;
171 char *ssym, *esym;
172 {
173
174 asm("movl %0,d7" : : "m" (howto));
175 asm("movl %0,d6" : : "m" (opendev));
176 asm("movl %0,d5" : : "m" (cons_scode));
177 asm("movl %0,a5" : : "a" (loadaddr));
178 asm("movl %0,a4" : : "a" (esym));
179 (*((int (*)())entry))();
180 }
181