oldmon.h revision 1.5 1 /* $NetBSD: oldmon.h,v 1.5 1995/09/03 21:36:06 pk 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 enum maptypes { /* Page map entry types. */
52 MAP_MAINMEM,
53 MAP_OBIO,
54 MAP_MBMEM,
55 MAP_MBIO,
56 MAP_VME16A16D,
57 MAP_VME16A32D,
58 MAP_VME24A16D,
59 MAP_VME24A32D,
60 MAP_VME32A16D,
61 MAP_VME32A32D
62 };
63 /*
64 * This table gives information about the resources needed by a device.
65 */
66 struct devinfo {
67 unsigned int d_devbytes; /* Bytes occupied by device in IO space.*/
68 unsigned int d_dmabytes; /* Bytes needed by device in DMA memory.*/
69 unsigned int d_localbytes;/* Bytes needed by device for local info.*/
70 unsigned int d_stdcount; /* How many standard addresses. */
71 unsigned long *d_stdaddrs; /* The vector of standard addresses. */
72 enum maptypes d_devtype; /* What map space device is in. */
73 unsigned int d_maxiobytes;/* Size to break big I/O's into. */
74 };
75
76 /*
77 * The table entry that describes a device. It exists in the PROM; a
78 * pointer to it is passed in MachMonBootParam. It can be used to locate
79 * PROM subroutines for opening, reading, and writing the device.
80 *
81 * When using this interface, only one device can be open at once.
82 *
83 * NOTE: I am not sure what arguments boot, open, close, and strategy take.
84 * What is here is just translated verbatim from the sun monitor code. We
85 * should figure this out eventually if we need it.
86 */
87 struct om_boottable {
88 char b_devname[2]; /* The name of the device */
89 int (*b_probe)(); /* probe() --> -1 or found controller
90 number */
91 int (*b_boot)(); /* boot(bp) --> -1 or start address */
92 int (*b_open)(); /* open(iobp) --> -1 or 0 */
93 int (*b_close)(); /* close(iobp) --> -1 or 0 */
94 int (*b_strategy)(); /* strategy(iobp,rw) --> -1 or 0 */
95 char *b_desc; /* Printable string describing dev */
96 struct devinfo *b_devinfo; /* info to configure device. */
97 };
98
99 /*
100 * Structure set up by the boot command to pass arguments to the program that
101 * is booted.
102 */
103 struct om_bootparam {
104 char *argPtr[8]; /* String arguments */
105 char strings[100]; /* String table for string arguments */
106 char devName[2]; /* Device name */
107 int ctlrNum; /* Controller number */
108 int unitNum; /* Unit number */
109 int partNum; /* Partition/file number */
110 char *fileName; /* File name, points into strings */
111 struct om_boottable *bootTable; /* Points to table entry for device */
112 };
113
114 /*
115 * Here is the structure of the vector table which is at the front of the boot
116 * rom. The functions defined in here are explained below.
117 *
118 * NOTE: This struct has references to the structures keybuf and globram which
119 * I have not translated. If anyone needs to use these they should
120 * translate these structs into Sprite format.
121 */
122 struct om_vector {
123 char *initSp; /* Initial system stack ptr for hardware */
124 int (*startMon)(); /* Initial PC for hardware */
125 int *diagberr; /* Bus err handler for diags */
126
127 /* Monitor and hardware revision and identification */
128 struct om_bootparam **bootParam; /* Info for bootstrapped pgm */
129 u_long *memorySize; /* Usable memory in bytes */
130
131 /* Single-character input and output */
132 int (*getChar)(void); /* Get char from input source */
133 void (*putChar)(int); /* Put char to output sink */
134 int (*mayGet)(void); /* Maybe get char, or -1 */
135 int (*mayPut)(int); /* Maybe put char, or -1 */
136 u_char *echo; /* Should getchar echo? */
137 u_char *inSource; /* Input source selector */
138 u_char *outSink; /* Output sink selector */
139 #define PROMDEV_KBD 0 /* input from keyboard */
140 #define PROMDEV_SCREEN 0 /* output to screen */
141 #define PROMDEV_TTYA 1 /* in/out to ttya */
142 #define PROMDEV_TTYB 2 /* in/out to ttyb */
143
144 /* Keyboard input (scanned by monitor nmi routine) */
145 int (*getKey)(); /* Get next key if one exists */
146 int (*initGetKey)(); /* Initialize get key */
147 u_int *translation; /* Kbd translation selector */
148 u_char *keyBid; /* Keyboard ID byte */
149 int *screen_x; /* V2: Screen x pos (R/O) */
150 int *screen_y; /* V2: Screen y pos (R/O) */
151 struct keybuf *keyBuf; /* Up/down keycode buffer */
152
153 /* Monitor revision level. */
154 char *monId;
155
156 /* Frame buffer output and terminal emulation */
157 int (*fbWriteChar)(); /* Write a character to FB */
158 int *fbAddr; /* Address of frame buffer */
159 char **font; /* Font table for FB */
160 void (*fbWriteStr)(char *, int); /* Quickly write string to FB */
161
162 /* Reboot interface routine -- resets and reboots system. */
163 void (*reBoot)(char *); /* e.g. reBoot("xy()vmunix") */
164
165 /* Line input and parsing */
166 u_char *lineBuf; /* The line input buffer */
167 u_char **linePtr; /* Cur pointer into linebuf */
168 int *lineSize; /* length of line in linebuf */
169 int (*getLine)(); /* Get line from user */
170 u_char (*getNextChar)(); /* Get next char from linebuf */
171 u_char (*peekNextChar)(); /* Peek at next char */
172 int *fbThere; /* =1 if frame buffer there */
173 int (*getNum)(); /* Grab hex num from line */
174
175 /* Print formatted output to current output sink */
176 int (*printf)(); /* Similar to "Kernel printf" */
177 int (*printHex)(); /* Format N digits in hex */
178
179 /* Led stuff */
180 u_char *leds; /* RAM copy of LED register */
181 int (*setLeds)(); /* Sets LED's and RAM copy */
182
183 /* Non-maskable interrupt (nmi) information */
184 int (*nmiAddr)(); /* Addr for level 7 vector */
185 void (*abortEntry)(void); /* Entry for keyboard abort */
186 int *nmiClock; /* Counts up in msec */
187
188 /* Frame buffer type: see <machine/fbio.h> */
189 int *fbType;
190
191 /* Assorted other things */
192 u_long romvecVersion; /* Version # of Romvec */
193 struct globram *globRam; /* monitor global variables */
194 caddr_t kbdZscc; /* Addr of keyboard in use */
195
196 int *keyrInit; /* ms before kbd repeat */
197 u_char *keyrTick; /* ms between repetitions */
198 u_long *memoryAvail; /* V1: Main mem usable size */
199 long *resetAddr; /* where to jump on a reset */
200 long *resetMap; /* pgmap entry for resetaddr */
201 /* Really struct pgmapent * */
202
203 __dead void (*exitToMon)(void); /* Exit from user program */
204 u_char **memorybitmap; /* V1: &{0 or &bits} */
205 void (*setcxsegmap)(); /* Set seg in any context */
206 void (**vector_cmd)(); /* V2: Handler for 'v' cmd */
207 u_long *ExpectedTrapSig;
208 u_long *TrapVectorTable;
209 int dummy1z;
210 int dummy2z;
211 int dummy3z;
212 int dummy4z;
213 };
214
215 #define romVectorPtr ((struct om_vector *)PROM_BASE)
216
217 #define mon_printf (romVectorPtr->printf)
218 #define mon_putchar (romVectorPtr->putChar)
219 #define mon_may_getchar (romVectorPtr->mayGet)
220 #define mon_exit_to_mon (romVectorPtr->exitToMon)
221 #define mon_reboot (romVectorPtr->exitToMon)
222 #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();}
223
224 #define mon_setcxsegmap(context, va, sme) \
225 romVectorPtr->setcxsegmap(context, va, sme)
226 #define romp (romVectorPtr)
227
228 /*
229 * OLDMON_STARTVADDR and OLDMON_ENDVADDR denote the range of the damn monitor.
230 *
231 * supposedly you can steal pmegs within this range that do not contain
232 * valid pages.
233 */
234 #define OLDMON_STARTVADDR 0xFFD00000
235 #define OLDMON_ENDVADDR 0xFFF00000
236
237 /*
238 * These describe the monitor's short segment which it basically uses to map
239 * one stupid page that it uses for storage. MONSHORTPAGE is the page,
240 * and MONSHORTSEG is the segment that it is in. If this sounds dumb to
241 * you, it is. I can change the pmeg, but not the virtual address.
242 * Sun defines these with the high nibble set to 0xF. I believe this was
243 * for the monitor source which accesses this piece of memory with addressing
244 * limitations or some such crud. I haven't replicated this here, because
245 * it is confusing, and serves no obvious purpose if you aren't the monitor.
246 *
247 */
248 #define MONSHORTPAGE 0x0FFFE000
249 #define MONSHORTSEG 0x0FFE0000
250
251 /*
252 * A "stand alone I/O request".
253 * This is passed as the main argument to the PROM I/O routines
254 * in the `om_boottable' structure.
255 */
256 struct saioreq {
257 char si_flgs;
258 struct om_boottable *si_boottab;/* Points to boottab entry if any */
259 char *si_devdata; /* Device-specific data pointer */
260 int si_ctlr; /* Controller number or address */
261 int si_unit; /* Unit number within controller */
262 long si_boff; /* Partition number within unit */
263 long si_cyloff;
264 long si_offset;
265 long si_bn; /* Block number to R/W */
266 char *si_ma; /* Memory address to R/W */
267 int si_cc; /* Character count to R/W */
268 struct saif *si_sif; /* net if. pointer (set by b_open) */
269 char *si_devaddr; /* Points to mapped in device */
270 char *si_dmaaddr; /* Points to allocated DMA space */
271 };
272 #define SAIO_F_READ 0x01
273 #define SAIO_F_WRITE 0x02
274 #define SAIO_F_ALLOC 0x04
275 #define SAIO_F_FILE 0x08
276 #define SAIO_F_EOF 0x10 /* EOF on device */
277 #define SAIO_F_AJAR 0x20 /* Descriptor "ajar" (stopped but not closed) */
278
279
280 /*
281 * Ethernet interface descriptor
282 * First, set: saiop->si_devaddr, saiop->si_dmaaddr, etc.
283 * Then: saiop->si_boottab->b_open() will set:
284 * saiop->si_sif;
285 * saiop->si_devdata;
286 * The latter is the first arg to the following functions.
287 * Note that the buffer must be in DVMA space...
288 */
289 struct saif {
290 /* transmit packet, returns zero on success. */
291 int (*sif_xmit)(void *devdata, char *buf, int len);
292 /* wait for packet, zero if none arrived */
293 int (*sif_poll)(void *devdata, char *buf);
294 /* reset interface, set addresses, etc. */
295 int (*sif_reset)(void *devdata, struct saioreq *sip);
296 /* Later (sun4 only) proms have more stuff here. */
297 };
298 #endif /* MACHINE_OLDMON_H */
299