mon.h revision 1.16 1 /* $NetBSD: mon.h,v 1.16 1995/02/07 05:01:05 gwr Exp $ */
2
3 /*
4 * Copyright (c) 1993 Adam Glass
5 * All rights reserved.
6 *
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 Adam Glass.
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.
20 *
21 * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 /*
35 * This file derived from kernel/mach/sun3.md/machMon.h from the
36 * sprite distribution.
37 *
38 * In particular, this file came out of the Walnut Creek cdrom collection
39 * which contained no warnings about any possible copyright infringement.
40 * It was also indentical to a file in the sprite kernel tar file found on
41 * allspice.berkeley.edu.
42 * It also written in the annoying sprite coding style. I've made
43 * efforts not to heavily edit their file, just ifdef parts out. -- glass
44 */
45
46 #ifndef _MACHINE_MON_H
47 #define _MACHINE_MON_H
48 /*
49 * machMon.h --
50 *
51 * Structures, constants and defines for access to the sun monitor.
52 * These are translated from the sun monitor header file "sunromvec.h".
53 *
54 * NOTE: The file keyboard.h in the monitor directory has all sorts of useful
55 * keyboard stuff defined. I haven't attempted to translate that file
56 * because I don't need it. If anyone wants to use it, be my guest.
57 *
58 * Copyright (C) 1985 Regents of the University of California
59 * All rights reserved.
60 *
61 *
62 * Header: /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v 9.1 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley)
63 */
64
65 #ifndef _MACHMON
66 #define _MACHMON
67
68 /*
69 * The memory addresses for the PROM, and the EEPROM.
70 * On the sun2 these addresses are actually 0x00EF??00
71 * but only the bottom 24 bits are looked at so these still
72 * work ok.
73 */
74
75 #define PROM_BASE 0x0fef0000
76
77 /*
78 * Structure set up by the boot command to pass arguments to the program that
79 * is booted.
80 */
81 typedef struct bootparam {
82 char *argPtr[8]; /* String arguments */
83 char strings[100]; /* String table for string arguments */
84 char devName[2]; /* Device name */
85 int ctlrNum; /* Controller number */
86 int unitNum; /* Unit number */
87 int partNum; /* Partition/file number */
88 char *fileName; /* File name, points into strings */
89 struct boottab *bootDevice; /* Defined in saio.h */
90 } MachMonBootParam;
91
92 /*
93 * Here is the structure of the vector table which is at the front of the boot
94 * rom. The functions defined in here are explained below.
95 *
96 * NOTE: This struct has references to the structures keybuf and globram which
97 * I have not translated. If anyone needs to use these they should
98 * translate these structs into Sprite format.
99 */
100 typedef struct {
101 char *initSp; /* Initial system stack ptr
102 * for hardware */
103 int (*startMon)(); /* Initial PC for hardware */
104
105 int *diagberr; /* Bus err handler for diags */
106
107 /*
108 * Monitor and hardware revision and identification
109 */
110
111 struct bootparam **bootParam; /* Info for bootstrapped pgm */
112 unsigned *memorySize; /* Usable memory in bytes */
113
114 /*
115 * Single-character input and output
116 */
117
118 unsigned char (*getChar)(); /* Get char from input source */
119 int (*putChar)(); /* Put char to output sink */
120 int (*mayGet)(); /* Maybe get char, or -1 */
121 int (*mayPut)(); /* Maybe put char, or -1 */
122 unsigned char *echo; /* Should getchar echo? */
123 unsigned char *inSource; /* Input source selector */
124 unsigned char *outSink; /* Output sink selector */
125
126 /*
127 * Keyboard input (scanned by monitor nmi routine)
128 */
129
130 int (*getKey)(); /* Get next key if one exists */
131 int (*initGetKey)(); /* Initialize get key */
132 unsigned int *translation; /* Kbd translation selector
133 (see keyboard.h in sun
134 monitor code) */
135 unsigned char *keyBid; /* Keyboard ID byte */
136 int *screen_x; /* V2: Screen x pos (R/O) */
137 int *screen_y; /* V2: Screen y pos (R/O) */
138 struct keybuf *keyBuf; /* Up/down keycode buffer */
139
140 /*
141 * Monitor revision level.
142 */
143
144 char *monId;
145
146 /*
147 * Frame buffer output and terminal emulation
148 */
149
150 int (*fbWriteChar)(); /* Write a character to FB */
151 int *fbAddr; /* Address of frame buffer */
152 char **font; /* Font table for FB */
153 int (*fbWriteStr)(); /* Quickly write string to FB */
154
155 /*
156 * Reboot interface routine -- resets and reboots system. No return.
157 */
158
159 int (*reBoot)(); /* e.g. reBoot("xy()vmunix") */
160
161 /*
162 * Line input and parsing
163 */
164
165 unsigned char *lineBuf; /* The line input buffer */
166 unsigned char **linePtr; /* Cur pointer into linebuf */
167 int *lineSize; /* length of line in linebuf */
168 int (*getLine)(); /* Get line from user */
169 unsigned char (*getNextChar)(); /* Get next char from linebuf */
170 unsigned char (*peekNextChar)(); /* Peek at next char */
171 int *fbThere; /* =1 if frame buffer there */
172 int (*getNum)(); /* Grab hex num from line */
173
174 /*
175 * Print formatted output to current output sink
176 */
177
178 int (*printf)(); /* Similar to "Kernel printf" */
179 int (*printHex)(); /* Format N digits in hex */
180
181 /*
182 * Led stuff
183 */
184
185 unsigned char *leds; /* RAM copy of LED register */
186 int (*setLeds)(); /* Sets LED's and RAM copy */
187
188 /*
189 * Non-maskable interrupt (nmi) information
190 */
191
192 int (*nmiAddr)(); /* Addr for level 7 vector */
193 int (*abortEntry)(); /* Entry for keyboard abort */
194 int *nmiClock; /* Counts up in msec */
195
196 /*
197 * Frame buffer type: see <sun/fbio.h>
198 */
199
200 int *fbType;
201
202 /*
203 * Assorted other things
204 */
205
206 unsigned romvecVersion; /* Version # of Romvec */
207 struct globram *globRam; /* monitor global variables */
208 caddr_t kbdZscc; /* Addr of keyboard in use */
209
210 int *keyrInit; /* ms before kbd repeat */
211 unsigned char *keyrTick; /* ms between repetitions */
212 unsigned *memoryAvail; /* V1: Main mem usable size */
213 long *resetAddr; /* where to jump on a reset */
214 long *resetMap; /* pgmap entry for resetaddr */
215 /* Really struct pgmapent * */
216 int (*exitToMon)(); /* Exit from user program */
217 unsigned char **memorybitmap; /* V1: &{0 or &bits} */
218 void (*setcxsegmap)(); /* Set seg in any context */
219 void (**vector_cmd)(); /* V2: Handler for 'v' cmd */
220 int dummy1z;
221 int dummy2z;
222 int dummy3z;
223 int dummy4z;
224 } MachMonRomVector;
225
226 /*
227 * Functions defined in the vector:
228 *
229 *
230 * getChar -- Return the next character from the input source
231 *
232 * unsigned char getChar()
233 *
234 * putChar -- Write the given character to the output source.
235 *
236 * void putChar(ch)
237 * char ch;
238 *
239 * mayGet -- Maybe get a character from the current input source. Return -1
240 * if don't return a character.
241 *
242 * int mayGet()
243 *
244 * mayPut -- Maybe put a character to the current output source. Return -1
245 * if no character output.
246 *
247 * int mayPut(ch)
248 * char ch;
249 *
250 * getKey -- Returns a key code (if up/down codes being returned),
251 * a byte of ASCII (if that's requested),
252 * NOKEY (if no key has been hit).
253 *
254 * int getKey()
255 *
256 * initGetKey -- Initialize things for get key.
257 *
258 * void initGetKey()
259 *
260 * fbWriteChar -- Write a character to the frame buffer
261 *
262 * void fwritechar(ch)
263 * unsigned char ch;
264 *
265 * fbWriteStr -- Write a string to the frame buffer.
266 *
267 * void fwritestr(addr,len)
268 * register unsigned char *addr; / * String to be written * /
269 * register short len; / * Length of string * /
270 *
271 * getLine -- read the next input line into a global buffer
272 *
273 * getline(echop)
274 * int echop; / * 1 if should echo input, 0 if not * /
275 *
276 * getNextChar -- return the next character from the global line buffer.
277 *
278 * unsigned char getNextChar()
279 *
280 * peekNextChar -- look at the next character in the global line buffer.
281 *
282 * unsigned char peekNextChar()
283 *
284 * getNum -- Grab hex num from the global line buffer.
285 *
286 * int getNum()
287 *
288 * printf -- Scaled down version of C library printf. Only %d, %x, %s, and %c
289 * are recognized.
290 *
291 * printhex -- prints rightmost <digs> hex digits of <val>
292 *
293 * printhex(val,digs)
294 * register int val;
295 * register int digs;
296 *
297 * abortEntry -- Entry for keyboard abort.
298 *
299 * abortEntry()
300 */
301
302 /*
303 * Where the rom vector is defined.
304 */
305
306 #define romVectorPtr ((MachMonRomVector *) PROM_BASE)
307
308 /*
309 * Functions and defines to access the monitor.
310 */
311
312 #define mon_printf (romVectorPtr->printf)
313 #define mon_putchar (romVectorPtr->putChar)
314 #define mon_may_getchar (romVectorPtr->mayGet)
315 #define mon_exit_to_mon (romVectorPtr->exitToMon)
316 #define mon_reboot (romVectorPtr->reBoot)
317 #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();}
318
319 #define mon_setcxsegmap(context, va, sme) \
320 romVectorPtr->setcxsegmap(context, va, sme)
321 #define romp (romVectorPtr)
322
323 /*
324 * MONSTART and MONEND denote the range of the damn monitor.
325 *
326 * supposedly you can steal pmegs within this range that do not contain
327 * valid pages.
328 */
329 #define MONSTART 0x0FE00000
330 #define MONEND 0x0FF00000
331
332 /*
333 * These describe the monitor's short segment which it basically uses to map
334 * one stupid page that it uses for storage. MONSHORTPAGE is the page,
335 * and MONSHORTSEG is the segment that it is in. If this sounds dumb to
336 * you, it is. I can change the pmeg, but not the virtual address.
337 * Sun defines these with the high nibble set to 0xF. I believe this was
338 * for the monitor source which accesses this piece of memory with addressing
339 * limitations or some such crud. I haven't replicated this here, because
340 * it is confusing, and serves no obvious purpose if you aren't the monitor.
341 *
342 */
343
344 #define MONSHORTPAGE 0x0FFFE000
345 #define MONSHORTSEG 0x0FFE0000
346
347 #endif /* _MACHMON */
348 #endif /* MACHINE_MON_H */
349