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