xref: /netbsd-src/sys/arch/sun3/include/mon.h (revision ae9172d6cd9432a6a1a56760d86b32c57a66c39c)
1 /*	$NetBSD: mon.h,v 1.15 1994/11/21 21:33:51 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  * The table entry that describes a device.  It exists in the PROM; a
79  * pointer to it is passed in MachMonBootParam.  It can be used to locate
80  * PROM subroutines for opening, reading, and writing the device.
81  *
82  * When using this interface, only one device can be open at once.
83  *
84  * NOTE: I am not sure what arguments boot, open, close, and strategy take.
85  * What is here is just translated verbatim from the sun monitor code.  We
86  * should figure this out eventually if we need it.
87  */
88 
89 typedef struct {
90 	char	devName[2];		/* The name of the device */
91 	int	(*probe)();		/* probe() --> -1 or found controller
92 					   number */
93 	int	(*boot)();		/* boot(bp) --> -1 or start address */
94 	int	(*open)();		/* open(iobp) --> -1 or 0 */
95 	int	(*close)();		/* close(iobp) --> -1 or 0 */
96 	int	(*strategy)();		/* strategy(iobp,rw) --> -1 or 0 */
97 	char	*desc;			/* Printable string describing dev */
98 } MachMonBootTable;
99 
100 /*
101  * Structure set up by the boot command to pass arguments to the program that
102  * is booted.
103  */
104 
105 typedef struct {
106 	char		*argPtr[8];	/* String arguments */
107 	char		strings[100];	/* String table for string arguments */
108 	char		devName[2];	/* Device name */
109 	int		ctlrNum;	/* Controller number */
110 	int		unitNum;	/* Unit number */
111 	int		partNum;	/* Partition/file number */
112 	char		*fileName;	/* File name, points into strings */
113 	MachMonBootTable   *bootTable;	/* Points to table entry for device */
114 } MachMonBootParam;
115 
116 /*
117  * Here is the structure of the vector table which is at the front of the boot
118  * rom.  The functions defined in here are explained below.
119  *
120  * NOTE: This struct has references to the structures keybuf and globram which
121  *       I have not translated.  If anyone needs to use these they should
122  *       translate these structs into Sprite format.
123  */
124 
125 typedef struct {
126 	char		*initSp;		/* Initial system stack ptr
127 						 * for hardware */
128 	int		(*startMon)();		/* Initial PC for hardware */
129 
130 	int		*diagberr;		/* Bus err handler for diags */
131 
132 	/*
133 	 * Monitor and hardware revision and identification
134 	 */
135 
136 	MachMonBootParam **bootParam;		/* Info for bootstrapped pgm */
137  	unsigned	*memorySize;		/* Usable memory in bytes */
138 
139 	/*
140 	 * Single-character input and output
141 	 */
142 
143 	unsigned char	(*getChar)();		/* Get char from input source */
144 	int		(*putChar)();		/* Put char to output sink */
145 	int		(*mayGet)();		/* Maybe get char, or -1 */
146 	int		(*mayPut)();		/* Maybe put char, or -1 */
147 	unsigned char	*echo;			/* Should getchar echo? */
148 	unsigned char	*inSource;		/* Input source selector */
149 	unsigned char	*outSink;		/* Output sink selector */
150 
151 	/*
152 	 * Keyboard input (scanned by monitor nmi routine)
153 	 */
154 
155 	int		(*getKey)();		/* Get next key if one exists */
156 	int		(*initGetKey)();	/* Initialize get key */
157 	unsigned int	*translation;		/* Kbd translation selector
158 						   (see keyboard.h in sun
159 						    monitor code) */
160 	unsigned char	*keyBid;		/* Keyboard ID byte */
161 	int		*screen_x;		/* V2: Screen x pos (R/O) */
162 	int		*screen_y;		/* V2: Screen y pos (R/O) */
163 	struct keybuf	*keyBuf;		/* Up/down keycode buffer */
164 
165 	/*
166 	 * Monitor revision level.
167 	 */
168 
169 	char		*monId;
170 
171 	/*
172 	 * Frame buffer output and terminal emulation
173 	 */
174 
175 	int		(*fbWriteChar)();	/* Write a character to FB */
176 	int		*fbAddr;		/* Address of frame buffer */
177 	char		**font;			/* Font table for FB */
178 	int		(*fbWriteStr)();	/* Quickly write string to FB */
179 
180 	/*
181 	 * Reboot interface routine -- resets and reboots system.  No return.
182 	 */
183 
184 	int		(*reBoot)();		/* e.g. reBoot("xy()vmunix") */
185 
186 	/*
187 	 * Line input and parsing
188 	 */
189 
190 	unsigned char	*lineBuf;		/* The line input buffer */
191 	unsigned char	**linePtr;		/* Cur pointer into linebuf */
192 	int		*lineSize;		/* length of line in linebuf */
193 	int		(*getLine)();		/* Get line from user */
194 	unsigned char	(*getNextChar)();	/* Get next char from linebuf */
195 	unsigned char	(*peekNextChar)();	/* Peek at next char */
196 	int		*fbThere;		/* =1 if frame buffer there */
197 	int		(*getNum)();		/* Grab hex num from line */
198 
199 	/*
200 	 * Print formatted output to current output sink
201 	 */
202 
203 	int		(*printf)();		/* Similar to "Kernel printf" */
204 	int		(*printHex)();		/* Format N digits in hex */
205 
206 	/*
207 	 * Led stuff
208 	 */
209 
210 	unsigned char	*leds;			/* RAM copy of LED register */
211 	int		(*setLeds)();		/* Sets LED's and RAM copy */
212 
213 	/*
214 	 * Non-maskable interrupt  (nmi) information
215 	 */
216 
217 	int		(*nmiAddr)();		/* Addr for level 7 vector */
218 	int		(*abortEntry)();	/* Entry for keyboard abort */
219 	int		*nmiClock;		/* Counts up in msec */
220 
221 	/*
222 	 * Frame buffer type: see <sun/fbio.h>
223 	 */
224 
225 	int		*fbType;
226 
227 	/*
228 	 * Assorted other things
229 	 */
230 
231 	unsigned	romvecVersion;		/* Version # of Romvec */
232 	struct globram  *globRam;		/* monitor global variables */
233 	caddr_t		kbdZscc;		/* Addr of keyboard in use */
234 
235 	int		*keyrInit;		/* ms before kbd repeat */
236 	unsigned char	*keyrTick; 		/* ms between repetitions */
237 	unsigned	*memoryAvail;		/* V1: Main mem usable size */
238 	long		*resetAddr;		/* where to jump on a reset */
239 	long		*resetMap;		/* pgmap entry for resetaddr */
240 						/* Really struct pgmapent *  */
241 	int		(*exitToMon)();		/* Exit from user program */
242 	unsigned char	**memorybitmap;		/* V1: &{0 or &bits} */
243 	void		(*setcxsegmap)();	/* Set seg in any context */
244 	void		(**vector_cmd)();	/* V2: Handler for 'v' cmd */
245 	int		dummy1z;
246 	int		dummy2z;
247 	int		dummy3z;
248 	int		dummy4z;
249 } MachMonRomVector;
250 
251 /*
252  * Functions defined in the vector:
253  *
254  *
255  * getChar -- Return the next character from the input source
256  *
257  *     unsigned char getChar()
258  *
259  * putChar -- Write the given character to the output source.
260  *
261  *     void putChar(ch)
262  *	   char ch;
263  *
264  * mayGet -- Maybe get a character from the current input source.  Return -1
265  *           if don't return a character.
266  *
267  * 	int mayGet()
268  *
269  * mayPut -- Maybe put a character to the current output source.   Return -1
270  *           if no character output.
271  *
272  *	int  mayPut(ch)
273  *	    char ch;
274  *
275  * getKey -- Returns a key code (if up/down codes being returned),
276  * 	     a byte of ASCII (if that's requested),
277  * 	     NOKEY (if no key has been hit).
278  *
279  *	int getKey()
280  *
281  * initGetKey --  Initialize things for get key.
282  *
283  *	void initGetKey()
284  *
285  * fbWriteChar -- Write a character to the frame buffer
286  *
287  *	void fwritechar(ch)
288  *	    unsigned char ch;
289  *
290  * fbWriteStr -- Write a string to the frame buffer.
291  *
292  *   	void fwritestr(addr,len)
293  *  	    register unsigned char *addr;	/ * String to be written * /
294  *  	    register short len;			/ * Length of string * /
295  *
296  * getLine -- read the next input line into a global buffer
297  *
298  *	getline(echop)
299  *          int echop;	/ * 1 if should echo input, 0 if not * /
300  *
301  * getNextChar -- return the next character from the global line buffer.
302  *
303  *	unsigned char getNextChar()
304  *
305  * peekNextChar -- look at the next character in the global line buffer.
306  *
307  *	unsigned char peekNextChar()
308  *
309  * getNum -- Grab hex num from the global line buffer.
310  *
311  *	int getNum()
312  *
313  * printf -- Scaled down version of C library printf.  Only %d, %x, %s, and %c
314  * 	     are recognized.
315  *
316  * printhex -- prints rightmost <digs> hex digits of <val>
317  *
318  *      printhex(val,digs)
319  *          register int val;
320  *     	    register int digs;
321  *
322  * abortEntry -- Entry for keyboard abort.
323  *
324  *     abortEntry()
325  */
326 
327 /*
328  * Where the rom vector is defined.
329  */
330 
331 #define	romVectorPtr	((MachMonRomVector *) PROM_BASE)
332 
333 /*
334  * Functions and defines to access the monitor.
335  */
336 
337 #define mon_printf (romVectorPtr->printf)
338 #define mon_putchar (romVectorPtr->putChar)
339 #define mon_may_getchar (romVectorPtr->mayGet)
340 #define mon_exit_to_mon (romVectorPtr->exitToMon)
341 #define mon_reboot (romVectorPtr->reBoot)
342 #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();}
343 
344 #define mon_setcxsegmap(context, va, sme) \
345      romVectorPtr->setcxsegmap(context, va, sme)
346 #define romp (romVectorPtr)
347 
348 /*
349  * MONSTART and MONEND denote the range of the damn monitor.
350  *
351  * supposedly you can steal pmegs within this range that do not contain
352  * valid pages.
353  */
354 #define MONSTART     0x0FE00000
355 #define MONEND       0x0FF00000
356 
357 /*
358  * These describe the monitor's short segment which it basically uses to map
359  * one stupid page that it uses for storage.  MONSHORTPAGE is the page,
360  * and MONSHORTSEG is the segment that it is in.  If this sounds dumb to
361  * you, it is.  I can change the pmeg, but not the virtual address.
362  * Sun defines these with the high nibble set to 0xF.  I believe this was
363  * for the monitor source which accesses this piece of memory with addressing
364  * limitations or some such crud.  I haven't replicated this here, because
365  * it is confusing, and serves no obvious purpose if you aren't the monitor.
366  *
367  */
368 
369 #define MONSHORTPAGE 0x0FFFE000
370 #define MONSHORTSEG  0x0FFE0000
371 
372 #endif /* _MACHMON */
373 #endif /* MACHINE_MON_H */
374