machdep.c revision 1.1 1 /* $NetBSD: machdep.c,v 1.1 1997/02/04 03:52:39 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 "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_350:
62 cp = "350"; break;
63 case HP_360:
64 cp = "360"; break;
65 case HP_370:
66 cp = "370"; break;
67 case HP_375:
68 cp = "345/375/400"; break;
69 case HP_380:
70 cp = "380/425"; break;
71 case HP_433:
72 cp = "433"; break;
73 default:
74 cp = "???"; break;
75 }
76 return(cp);
77 }
78
79 #ifdef ROMPRF
80 int userom;
81 #endif
82
83 struct trapframe {
84 int dregs[8];
85 int aregs[8];
86 int whoknows;
87 short sr;
88 int pc;
89 short frame;
90 };
91
92 trap(fp)
93 struct trapframe *fp;
94 {
95 static int intrap = 0;
96
97 if (intrap)
98 return(0);
99 intrap = 1;
100 #ifdef ROMPRF
101 userom = 1;
102 #endif
103 printf("Got unexpected trap: format=%x vector=%x ps=%x pc=%x\n",
104 (fp->frame>>12)&0xF, fp->frame&0xFFF, fp->sr, fp->pc);
105 printf("dregs: %x %x %x %x %x %x %x %x\n",
106 fp->dregs[0], fp->dregs[1], fp->dregs[2], fp->dregs[3],
107 fp->dregs[4], fp->dregs[5], fp->dregs[6], fp->dregs[7]);
108 printf("aregs: %x %x %x %x %x %x %x %x\n",
109 fp->aregs[0], fp->aregs[1], fp->aregs[2], fp->aregs[3],
110 fp->aregs[4], fp->aregs[5], fp->aregs[6], fp->aregs[7]);
111 #ifdef ROMPRF
112 userom = 0;
113 #endif
114 intrap = 0;
115 return(0);
116 }
117
118 #ifdef ROMPRF
119 #define ROWS 46
120 #define COLS 128
121
122 romputchar(c)
123 register int c;
124 {
125 static char buf[COLS];
126 static int col = 0, row = 0;
127 register int i;
128
129 switch (c) {
130 case '\0':
131 break;
132 case '\r':
133 break; /* ignore */
134 case '\n':
135 for (i = col; i < COLS-1; i++)
136 buf[i] = ' ';
137 buf[i] = '\0';
138 romout(row, buf);
139 col = 0;
140 if (++row == ROWS)
141 row = 0;
142 break;
143
144 case '\t':
145 do {
146 romputchar(' ');
147 } while (col & 7);
148 break;
149
150 default:
151 buf[col] = c;
152 if (++col == COLS-1)
153 romputchar('\n');
154 break;
155 }
156 }
157 #endif
158
159 void
160 machdep_start(entry, howto, loadaddr, ssym, esym)
161 char *entry;
162 int howto;
163 char *loadaddr;
164 char *ssym, *esym;
165 {
166
167 asm("movl %0,d7" : : "m" (howto));
168 asm("movl %0,d6" : : "m" (opendev));
169 asm("movl %0,d5" : : "m" (cons_scode));
170 asm("movl %0,a5" : : "a" (loadaddr));
171 asm("movl %0,a4" : : "a" (esym));
172 (*((int (*)())entry))();
173 }
174