1 /*
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1982, 1986, 1990, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.
9 *
10 * %sccs.include.redist.c%
11 *
12 * from: Utah $Hdr: machdep.c 1.10 92/06/18
13 *
14 * @(#)machdep.c 8.1 (Berkeley) 06/10/93
15 */
16
17 #include <sys/param.h>
18
19 /*
20 * Copy bytes within kernel
21 */
bcopy(from,to,count)22 bcopy(from, to, count)
23 register caddr_t from, to;
24 register unsigned count;
25 {
26 while (count--)
27 *to++ = *from++;
28 }
29
bzero(to,count)30 bzero(to, count)
31 register caddr_t to;
32 register unsigned count;
33 {
34 while (count--)
35 *to++ = 0;
36 }
37
bcmp(s1,s2,len)38 bcmp(s1, s2, len)
39 register char *s1, *s2;
40 register int len;
41 {
42 while (len--)
43 if (*s1++ != *s2++)
44 return (1);
45 return (0);
46 }
47
48 #ifdef ROMPRF
49 int userom;
50 #endif
51
52 struct trapframe {
53 int dregs[8];
54 int aregs[8];
55 int whoknows;
56 short sr;
57 int pc;
58 short frame;
59 };
60
61 trap(fp)
62 struct trapframe *fp;
63 {
64 static int intrap = 0;
65
66 if (intrap)
67 return(0);
68 intrap = 1;
69 #ifdef ROMPRF
70 userom = 1;
71 #endif
72 printf("Got unexpected trap: format=%x vector=%x ps=%x pc=%x\n",
73 (fp->frame>>12)&0xF, fp->frame&0xFFF, fp->sr, fp->pc);
74 printf("dregs: %x %x %x %x %x %x %x %x\n",
75 fp->dregs[0], fp->dregs[1], fp->dregs[2], fp->dregs[3],
76 fp->dregs[4], fp->dregs[5], fp->dregs[6], fp->dregs[7]);
77 printf("aregs: %x %x %x %x %x %x %x %x\n",
78 fp->aregs[0], fp->aregs[1], fp->aregs[2], fp->aregs[3],
79 fp->aregs[4], fp->aregs[5], fp->aregs[6], fp->aregs[7]);
80 #ifdef ROMPRF
81 userom = 0;
82 #endif
83 intrap = 0;
84 return(0);
85 }
86
87 #ifdef ROMPRF
88 #define ROWS 46
89 #define COLS 128
90
romputchar(c)91 romputchar(c)
92 register int c;
93 {
94 static char buf[COLS];
95 static int col = 0, row = 0;
96 register int i;
97
98 switch (c) {
99 case '\0':
100 break;
101 case '\r':
102 break; /* ignore */
103 case '\n':
104 for (i = col; i < COLS-1; i++)
105 buf[i] = ' ';
106 buf[i] = '\0';
107 romout(row, buf);
108 col = 0;
109 if (++row == ROWS)
110 row = 0;
111 break;
112
113 case '\t':
114 do {
115 romputchar(' ');
116 } while (col & 7);
117 break;
118
119 default:
120 buf[col] = c;
121 if (++col == COLS-1)
122 romputchar('\n');
123 break;
124 }
125 }
126 #endif
127