oldmon.h revision 1.4 1 /* $NetBSD: oldmon.h,v 1.4 1994/11/20 20:53:16 deraadt Exp $ */
2
3 /*
4 * Copyright (C) 1985 Regents of the University of California
5 * Copyright (c) 1993 Adam Glass
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Adam Glass.
19 * 4. The name of the Author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * from: Sprite /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v
35 * 9.1 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley)
36 */
37 #ifndef _MACHINE_OLDMON_H
38 #define _MACHINE_OLDMON_H
39
40 /*
41 * Structures, constants and defines for access to the sun monitor.
42 * These are translated from the sun monitor header file "sunromvec.h".
43 *
44 * The memory addresses for the PROM, and the EEPROM.
45 * On the sun2 these addresses are actually 0x00EF??00
46 * but only the bottom 24 bits are looked at so these still
47 * work ok.
48 */
49 #define PROM_BASE 0xffe81000
50
51 /*
52 * The table entry that describes a device. It exists in the PROM; a
53 * pointer to it is passed in MachMonBootParam. It can be used to locate
54 * PROM subroutines for opening, reading, and writing the device.
55 *
56 * When using this interface, only one device can be open at once.
57 *
58 * NOTE: I am not sure what arguments boot, open, close, and strategy take.
59 * What is here is just translated verbatim from the sun monitor code. We
60 * should figure this out eventually if we need it.
61 */
62 struct om_boottable {
63 char devName[2]; /* The name of the device */
64 int (*probe)(); /* probe() --> -1 or found controller
65 number */
66 int (*boot)(); /* boot(bp) --> -1 or start address */
67 int (*open)(); /* open(iobp) --> -1 or 0 */
68 int (*close)(); /* close(iobp) --> -1 or 0 */
69 int (*strategy)(); /* strategy(iobp,rw) --> -1 or 0 */
70 char *desc; /* Printable string describing dev */
71 };
72
73 /*
74 * Structure set up by the boot command to pass arguments to the program that
75 * is booted.
76 */
77 struct om_bootparam {
78 char *argPtr[8]; /* String arguments */
79 char strings[100]; /* String table for string arguments */
80 char devName[2]; /* Device name */
81 int ctlrNum; /* Controller number */
82 int unitNum; /* Unit number */
83 int partNum; /* Partition/file number */
84 char *fileName; /* File name, points into strings */
85 struct om_boottable *bootTable; /* Points to table entry for device */
86 };
87
88 /*
89 * Here is the structure of the vector table which is at the front of the boot
90 * rom. The functions defined in here are explained below.
91 *
92 * NOTE: This struct has references to the structures keybuf and globram which
93 * I have not translated. If anyone needs to use these they should
94 * translate these structs into Sprite format.
95 */
96 struct om_vector {
97 char *initSp; /* Initial system stack ptr for hardware */
98 int (*startMon)(); /* Initial PC for hardware */
99 int *diagberr; /* Bus err handler for diags */
100
101 /* Monitor and hardware revision and identification */
102 struct om_bootparam **bootParam; /* Info for bootstrapped pgm */
103 u_long *memorySize; /* Usable memory in bytes */
104
105 /* Single-character input and output */
106 int (*getChar)(void); /* Get char from input source */
107 void (*putChar)(int); /* Put char to output sink */
108 int (*mayGet)(void); /* Maybe get char, or -1 */
109 int (*mayPut)(int); /* Maybe put char, or -1 */
110 u_char *echo; /* Should getchar echo? */
111 u_char *inSource; /* Input source selector */
112 u_char *outSink; /* Output sink selector */
113 #define PROMDEV_KBD 0 /* input from keyboard */
114 #define PROMDEV_SCREEN 0 /* output to screen */
115 #define PROMDEV_TTYA 1 /* in/out to ttya */
116 #define PROMDEV_TTYB 2 /* in/out to ttyb */
117
118 /* Keyboard input (scanned by monitor nmi routine) */
119 int (*getKey)(); /* Get next key if one exists */
120 int (*initGetKey)(); /* Initialize get key */
121 u_int *translation; /* Kbd translation selector */
122 u_char *keyBid; /* Keyboard ID byte */
123 int *screen_x; /* V2: Screen x pos (R/O) */
124 int *screen_y; /* V2: Screen y pos (R/O) */
125 struct keybuf *keyBuf; /* Up/down keycode buffer */
126
127 /* Monitor revision level. */
128 char *monId;
129
130 /* Frame buffer output and terminal emulation */
131 int (*fbWriteChar)(); /* Write a character to FB */
132 int *fbAddr; /* Address of frame buffer */
133 char **font; /* Font table for FB */
134 void (*fbWriteStr)(char *, int); /* Quickly write string to FB */
135
136 /* Reboot interface routine -- resets and reboots system. */
137 void (*reBoot)(char *); /* e.g. reBoot("xy()vmunix") */
138
139 /* Line input and parsing */
140 u_char *lineBuf; /* The line input buffer */
141 u_char **linePtr; /* Cur pointer into linebuf */
142 int *lineSize; /* length of line in linebuf */
143 int (*getLine)(); /* Get line from user */
144 u_char (*getNextChar)(); /* Get next char from linebuf */
145 u_char (*peekNextChar)(); /* Peek at next char */
146 int *fbThere; /* =1 if frame buffer there */
147 int (*getNum)(); /* Grab hex num from line */
148
149 /* Print formatted output to current output sink */
150 int (*printf)(); /* Similar to "Kernel printf" */
151 int (*printHex)(); /* Format N digits in hex */
152
153 /* Led stuff */
154 u_char *leds; /* RAM copy of LED register */
155 int (*setLeds)(); /* Sets LED's and RAM copy */
156
157 /* Non-maskable interrupt (nmi) information */
158 int (*nmiAddr)(); /* Addr for level 7 vector */
159 void (*abortEntry)(void); /* Entry for keyboard abort */
160 int *nmiClock; /* Counts up in msec */
161
162 /* Frame buffer type: see <machine/fbio.h> */
163 int *fbType;
164
165 /* Assorted other things */
166 u_long romvecVersion; /* Version # of Romvec */
167 struct globram *globRam; /* monitor global variables */
168 caddr_t kbdZscc; /* Addr of keyboard in use */
169
170 int *keyrInit; /* ms before kbd repeat */
171 u_char *keyrTick; /* ms between repetitions */
172 u_long *memoryAvail; /* V1: Main mem usable size */
173 long *resetAddr; /* where to jump on a reset */
174 long *resetMap; /* pgmap entry for resetaddr */
175 /* Really struct pgmapent * */
176
177 __dead void (*exitToMon)(void); /* Exit from user program */
178 u_char **memorybitmap; /* V1: &{0 or &bits} */
179 void (*setcxsegmap)(); /* Set seg in any context */
180 void (**vector_cmd)(); /* V2: Handler for 'v' cmd */
181 u_long *ExpectedTrapSig;
182 u_long *TrapVectorTable;
183 int dummy1z;
184 int dummy2z;
185 int dummy3z;
186 int dummy4z;
187 };
188
189 #define romVectorPtr ((struct om_vector *)PROM_BASE)
190
191 #define mon_printf (romVectorPtr->printf)
192 #define mon_putchar (romVectorPtr->putChar)
193 #define mon_may_getchar (romVectorPtr->mayGet)
194 #define mon_exit_to_mon (romVectorPtr->exitToMon)
195 #define mon_reboot (romVectorPtr->exitToMon)
196 #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();}
197
198 #define mon_setcxsegmap(context, va, sme) \
199 romVectorPtr->setcxsegmap(context, va, sme)
200 #define romp (romVectorPtr)
201
202 /*
203 * OLDMON_STARTVADDR and OLDMON_ENDVADDR denote the range of the damn monitor.
204 *
205 * supposedly you can steal pmegs within this range that do not contain
206 * valid pages.
207 */
208 #define OLDMON_STARTVADDR 0xFFD00000
209 #define OLDMON_ENDVADDR 0xFFF00000
210
211 /*
212 * These describe the monitor's short segment which it basically uses to map
213 * one stupid page that it uses for storage. MONSHORTPAGE is the page,
214 * and MONSHORTSEG is the segment that it is in. If this sounds dumb to
215 * you, it is. I can change the pmeg, but not the virtual address.
216 * Sun defines these with the high nibble set to 0xF. I believe this was
217 * for the monitor source which accesses this piece of memory with addressing
218 * limitations or some such crud. I haven't replicated this here, because
219 * it is confusing, and serves no obvious purpose if you aren't the monitor.
220 *
221 */
222 #define MONSHORTPAGE 0x0FFFE000
223 #define MONSHORTSEG 0x0FFE0000
224
225 #endif /* MACHINE_OLDMON_H */
226