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