oldmon.h revision 1.1.1.1.32.1 1 1.1.1.1.32.1 nathanw /* $NetBSD: oldmon.h,v 1.1.1.1.32.1 2002/01/08 00:27:59 nathanw Exp $ */
2 1.1 eeh
3 1.1 eeh /*
4 1.1 eeh * Copyright (C) 1985 Regents of the University of California
5 1.1 eeh * Copyright (c) 1993 Adam Glass
6 1.1 eeh * All rights reserved.
7 1.1 eeh *
8 1.1 eeh * Redistribution and use in source and binary forms, with or without
9 1.1 eeh * modification, are permitted provided that the following conditions
10 1.1 eeh * are met:
11 1.1 eeh * 1. Redistributions of source code must retain the above copyright
12 1.1 eeh * notice, this list of conditions and the following disclaimer.
13 1.1 eeh * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 eeh * notice, this list of conditions and the following disclaimer in the
15 1.1 eeh * documentation and/or other materials provided with the distribution.
16 1.1 eeh * 3. All advertising materials mentioning features or use of this software
17 1.1 eeh * must display the following acknowledgement:
18 1.1 eeh * This product includes software developed by Adam Glass.
19 1.1 eeh * 4. The name of the Author may not be used to endorse or promote products
20 1.1 eeh * derived from this software without specific prior written permission.
21 1.1 eeh *
22 1.1 eeh * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND
23 1.1 eeh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1 eeh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1 eeh * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 1.1 eeh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 eeh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 eeh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 eeh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 eeh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 eeh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 eeh * SUCH DAMAGE.
33 1.1 eeh *
34 1.1 eeh * from: Sprite /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v
35 1.1 eeh * 9.1 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley)
36 1.1 eeh */
37 1.1 eeh #ifndef _MACHINE_OLDMON_H
38 1.1 eeh #define _MACHINE_OLDMON_H
39 1.1.1.1.32.1 nathanw
40 1.1.1.1.32.1 nathanw #if defined(_KERNEL_OPT)
41 1.1.1.1.32.1 nathanw #include "opt_sparc_arch.h"
42 1.1.1.1.32.1 nathanw #endif
43 1.1 eeh
44 1.1 eeh /*
45 1.1 eeh * Structures, constants and defines for access to the sun monitor.
46 1.1 eeh * These are translated from the sun monitor header file "sunromvec.h".
47 1.1 eeh *
48 1.1 eeh * The memory addresses for the PROM, and the EEPROM.
49 1.1 eeh * On the sun2 these addresses are actually 0x00EF??00
50 1.1 eeh * but only the bottom 24 bits are looked at so these still
51 1.1 eeh * work ok.
52 1.1 eeh */
53 1.1 eeh #define PROM_BASE 0xffe81000
54 1.1 eeh
55 1.1 eeh enum maptypes { /* Page map entry types. */
56 1.1 eeh MAP_MAINMEM,
57 1.1 eeh MAP_OBIO,
58 1.1 eeh MAP_MBMEM,
59 1.1 eeh MAP_MBIO,
60 1.1 eeh MAP_VME16A16D,
61 1.1 eeh MAP_VME16A32D,
62 1.1 eeh MAP_VME24A16D,
63 1.1 eeh MAP_VME24A32D,
64 1.1 eeh MAP_VME32A16D,
65 1.1 eeh MAP_VME32A32D
66 1.1 eeh };
67 1.1 eeh /*
68 1.1 eeh * This table gives information about the resources needed by a device.
69 1.1 eeh */
70 1.1 eeh struct devinfo {
71 1.1 eeh unsigned int d_devbytes; /* Bytes occupied by device in IO space.*/
72 1.1 eeh unsigned int d_dmabytes; /* Bytes needed by device in DMA memory.*/
73 1.1 eeh unsigned int d_localbytes;/* Bytes needed by device for local info.*/
74 1.1 eeh unsigned int d_stdcount; /* How many standard addresses. */
75 1.1 eeh unsigned long *d_stdaddrs; /* The vector of standard addresses. */
76 1.1 eeh enum maptypes d_devtype; /* What map space device is in. */
77 1.1 eeh unsigned int d_maxiobytes;/* Size to break big I/O's into. */
78 1.1 eeh };
79 1.1 eeh
80 1.1 eeh /*
81 1.1 eeh * A "stand alone I/O request".
82 1.1 eeh * This is passed as the main argument to the PROM I/O routines
83 1.1 eeh * in the `om_boottable' structure.
84 1.1 eeh */
85 1.1 eeh struct saioreq {
86 1.1 eeh char si_flgs;
87 1.1 eeh struct om_boottable *si_boottab;/* Points to boottab entry if any */
88 1.1 eeh char *si_devdata; /* Device-specific data pointer */
89 1.1 eeh int si_ctlr; /* Controller number or address */
90 1.1 eeh int si_unit; /* Unit number within controller */
91 1.1 eeh long si_boff; /* Partition number within unit */
92 1.1 eeh long si_cyloff;
93 1.1 eeh long si_offset;
94 1.1 eeh long si_bn; /* Block number to R/W */
95 1.1 eeh char *si_ma; /* Memory address to R/W */
96 1.1 eeh int si_cc; /* Character count to R/W */
97 1.1 eeh struct saif *si_sif; /* net if. pointer (set by b_open) */
98 1.1 eeh char *si_devaddr; /* Points to mapped in device */
99 1.1 eeh char *si_dmaaddr; /* Points to allocated DMA space */
100 1.1 eeh };
101 1.1 eeh #define SAIO_F_READ 0x01
102 1.1 eeh #define SAIO_F_WRITE 0x02
103 1.1 eeh #define SAIO_F_ALLOC 0x04
104 1.1 eeh #define SAIO_F_FILE 0x08
105 1.1 eeh #define SAIO_F_EOF 0x10 /* EOF on device */
106 1.1 eeh #define SAIO_F_AJAR 0x20 /* Descriptor "ajar" (stopped but not closed) */
107 1.1 eeh
108 1.1 eeh
109 1.1 eeh /*
110 1.1 eeh * The table entry that describes a device. It exists in the PROM; a
111 1.1 eeh * pointer to it is passed in MachMonBootParam. It can be used to locate
112 1.1 eeh * PROM subroutines for opening, reading, and writing the device.
113 1.1 eeh *
114 1.1 eeh * When using this interface, only one device can be open at once.
115 1.1 eeh *
116 1.1 eeh * NOTE: I am not sure what arguments boot, open, close, and strategy take.
117 1.1 eeh * What is here is just translated verbatim from the sun monitor code. We
118 1.1 eeh * should figure this out eventually if we need it.
119 1.1 eeh */
120 1.1 eeh struct om_boottable {
121 1.1 eeh char b_devname[2]; /* The name of the device */
122 1.1 eeh int (*b_probe) __P((void)); /* probe() --> -1 or found controller
123 1.1 eeh number */
124 1.1 eeh int (*b_boot) __P((void)); /* boot(bp) --> -1 or start address */
125 1.1 eeh int (*b_open)
126 1.1 eeh __P((struct saioreq *));/* open(iobp) --> -1 or 0 */
127 1.1 eeh int (*b_close)
128 1.1 eeh __P((struct saioreq *));/* close(iobp) --> -1 or 0 */
129 1.1 eeh int (*b_strategy)
130 1.1 eeh __P((struct saioreq *, int));/* strategy(iobp,rw) --> -1 or 0 */
131 1.1 eeh char *b_desc; /* Printable string describing dev */
132 1.1 eeh struct devinfo *b_devinfo; /* info to configure device. */
133 1.1 eeh };
134 1.1 eeh
135 1.1 eeh /*
136 1.1 eeh * Structure set up by the boot command to pass arguments to the program that
137 1.1 eeh * is booted.
138 1.1 eeh */
139 1.1 eeh struct om_bootparam {
140 1.1 eeh char *argPtr[8]; /* String arguments */
141 1.1 eeh char strings[100]; /* String table for string arguments */
142 1.1 eeh char devName[2]; /* Device name */
143 1.1 eeh int ctlrNum; /* Controller number */
144 1.1 eeh int unitNum; /* Unit number */
145 1.1 eeh int partNum; /* Partition/file number */
146 1.1 eeh char *fileName; /* File name, points into strings */
147 1.1 eeh struct om_boottable *bootTable; /* Points to table entry for device */
148 1.1 eeh };
149 1.1 eeh
150 1.1 eeh /*
151 1.1 eeh * Here is the structure of the vector table which is at the front of the boot
152 1.1 eeh * rom. The functions defined in here are explained below.
153 1.1 eeh *
154 1.1 eeh * NOTE: This struct has references to the structures keybuf and globram which
155 1.1 eeh * I have not translated. If anyone needs to use these they should
156 1.1 eeh * translate these structs into Sprite format.
157 1.1 eeh */
158 1.1 eeh struct om_vector {
159 1.1 eeh char *initSp; /* Initial system stack ptr for hardware */
160 1.1 eeh int (*startMon) __P((void));/* Initial PC for hardware */
161 1.1 eeh int *diagberr; /* Bus err handler for diags */
162 1.1 eeh
163 1.1 eeh /* Monitor and hardware revision and identification */
164 1.1 eeh struct om_bootparam **bootParam; /* Info for bootstrapped pgm */
165 1.1 eeh u_long *memorySize; /* Usable memory in bytes */
166 1.1 eeh
167 1.1 eeh /* Single-character input and output */
168 1.1 eeh int (*getChar) __P((void)); /* Get char from input source */
169 1.1 eeh void (*putChar) __P((int)); /* Put char to output sink */
170 1.1 eeh int (*mayGet) __P((void)); /* Maybe get char, or -1 */
171 1.1 eeh int (*mayPut) __P((int)); /* Maybe put char, or -1 */
172 1.1 eeh u_char *echo; /* Should getchar echo? */
173 1.1 eeh u_char *inSource; /* Input source selector */
174 1.1 eeh u_char *outSink; /* Output sink selector */
175 1.1 eeh #define PROMDEV_KBD 0 /* input from keyboard */
176 1.1 eeh #define PROMDEV_SCREEN 0 /* output to screen */
177 1.1 eeh #define PROMDEV_TTYA 1 /* in/out to ttya */
178 1.1 eeh #define PROMDEV_TTYB 2 /* in/out to ttyb */
179 1.1 eeh
180 1.1 eeh /* Keyboard input (scanned by monitor nmi routine) */
181 1.1 eeh int (*getKey) __P((void)); /* Get next key if one exists */
182 1.1 eeh int (*initGetKey) __P((void));/* Initialize get key */
183 1.1 eeh u_int *translation; /* Kbd translation selector */
184 1.1 eeh u_char *keyBid; /* Keyboard ID byte */
185 1.1 eeh int *screen_x; /* V2: Screen x pos (R/O) */
186 1.1 eeh int *screen_y; /* V2: Screen y pos (R/O) */
187 1.1 eeh struct keybuf *keyBuf; /* Up/down keycode buffer */
188 1.1 eeh
189 1.1 eeh /* Monitor revision level. */
190 1.1 eeh char *monId;
191 1.1 eeh
192 1.1 eeh /* Frame buffer output and terminal emulation */
193 1.1 eeh int (*fbWriteChar) __P((void));/* Write a character to FB */
194 1.1 eeh int *fbAddr; /* Address of frame buffer */
195 1.1 eeh char **font; /* Font table for FB */
196 1.1 eeh void (*fbWriteStr) __P((char *, int));
197 1.1 eeh /* Quickly write string to FB */
198 1.1 eeh
199 1.1 eeh /* Reboot interface routine -- resets and reboots system. */
200 1.1 eeh void (*reBoot) __P((char *)); /* e.g. reBoot("xy()vmunix") */
201 1.1 eeh
202 1.1 eeh /* Line input and parsing */
203 1.1 eeh u_char *lineBuf; /* The line input buffer */
204 1.1 eeh u_char **linePtr; /* Cur pointer into linebuf */
205 1.1 eeh int *lineSize; /* length of line in linebuf */
206 1.1 eeh int (*getLine) __P((void)); /* Get line from user */
207 1.1 eeh u_char (*getNextChar) __P((void));/* Get next char from linebuf */
208 1.1 eeh u_char (*peekNextChar) __P((void));/* Peek at next char */
209 1.1 eeh int *fbThere; /* =1 if frame buffer there */
210 1.1 eeh int (*getNum) __P((void)); /* Grab hex num from line */
211 1.1 eeh
212 1.1 eeh /* Print formatted output to current output sink */
213 1.1 eeh int (*printf) __P((void)); /* Similar to "Kernel printf" */
214 1.1 eeh int (*printHex) __P((void));/* Format N digits in hex */
215 1.1 eeh
216 1.1 eeh /* Led stuff */
217 1.1 eeh u_char *leds; /* RAM copy of LED register */
218 1.1 eeh int (*setLeds) __P((void)); /* Sets LED's and RAM copy */
219 1.1 eeh
220 1.1 eeh /* Non-maskable interrupt (nmi) information */
221 1.1 eeh int (*nmiAddr) __P((void)); /* Addr for level 7 vector */
222 1.1 eeh void (*abortEntry) __P((void));/* Entry for keyboard abort */
223 1.1 eeh int *nmiClock; /* Counts up in msec */
224 1.1 eeh
225 1.1 eeh /* Frame buffer type: see <machine/fbio.h> */
226 1.1 eeh int *fbType;
227 1.1 eeh
228 1.1 eeh /* Assorted other things */
229 1.1 eeh u_long romvecVersion; /* Version # of Romvec */
230 1.1 eeh struct globram *globRam; /* monitor global variables */
231 1.1 eeh caddr_t kbdZscc; /* Addr of keyboard in use */
232 1.1 eeh
233 1.1 eeh int *keyrInit; /* ms before kbd repeat */
234 1.1 eeh u_char *keyrTick; /* ms between repetitions */
235 1.1 eeh u_long *memoryAvail; /* V1: Main mem usable size */
236 1.1 eeh long *resetAddr; /* where to jump on a reset */
237 1.1 eeh long *resetMap; /* pgmap entry for resetaddr */
238 1.1 eeh /* Really struct pgmapent * */
239 1.1 eeh
240 1.1 eeh __dead void (*exitToMon)
241 1.1 eeh __P((void)) __attribute__((noreturn));/* Exit from user program */
242 1.1 eeh u_char **memorybitmap; /* V1: &{0 or &bits} */
243 1.1 eeh void (*setcxsegmap) /* Set seg in any context */
244 1.1 eeh __P((int, caddr_t, int));
245 1.1 eeh void (**vector_cmd) __P((u_long, char *));/* V2: Handler for 'v' cmd */
246 1.1 eeh u_long *ExpectedTrapSig;
247 1.1 eeh u_long *TrapVectorTable;
248 1.1 eeh int dummy1z;
249 1.1 eeh int dummy2z;
250 1.1 eeh int dummy3z;
251 1.1 eeh int dummy4z;
252 1.1 eeh };
253 1.1 eeh
254 1.1 eeh #define romVectorPtr ((struct om_vector *)PROM_BASE)
255 1.1 eeh
256 1.1 eeh #define mon_printf (romVectorPtr->printf)
257 1.1 eeh #define mon_putchar (romVectorPtr->putChar)
258 1.1 eeh #define mon_may_getchar (romVectorPtr->mayGet)
259 1.1 eeh #define mon_exit_to_mon (romVectorPtr->exitToMon)
260 1.1 eeh #define mon_reboot (romVectorPtr->exitToMon)
261 1.1 eeh #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();}
262 1.1 eeh
263 1.1 eeh #define mon_setcxsegmap(context, va, sme) \
264 1.1 eeh romVectorPtr->setcxsegmap(context, va, sme)
265 1.1 eeh #define romp (romVectorPtr)
266 1.1 eeh
267 1.1 eeh /*
268 1.1 eeh * OLDMON_STARTVADDR and OLDMON_ENDVADDR denote the range of the damn monitor.
269 1.1 eeh *
270 1.1 eeh * supposedly you can steal pmegs within this range that do not contain
271 1.1 eeh * valid pages.
272 1.1 eeh */
273 1.1 eeh #define OLDMON_STARTVADDR 0xFFD00000
274 1.1 eeh #define OLDMON_ENDVADDR 0xFFF00000
275 1.1 eeh
276 1.1 eeh /*
277 1.1 eeh * These describe the monitor's short segment which it basically uses to map
278 1.1 eeh * one stupid page that it uses for storage. MONSHORTPAGE is the page,
279 1.1 eeh * and MONSHORTSEG is the segment that it is in. If this sounds dumb to
280 1.1 eeh * you, it is. I can change the pmeg, but not the virtual address.
281 1.1 eeh * Sun defines these with the high nibble set to 0xF. I believe this was
282 1.1 eeh * for the monitor source which accesses this piece of memory with addressing
283 1.1 eeh * limitations or some such crud. I haven't replicated this here, because
284 1.1 eeh * it is confusing, and serves no obvious purpose if you aren't the monitor.
285 1.1 eeh *
286 1.1 eeh */
287 1.1 eeh #define MONSHORTPAGE 0x0FFFE000
288 1.1 eeh #define MONSHORTSEG 0x0FFE0000
289 1.1 eeh
290 1.1 eeh
291 1.1 eeh
292 1.1 eeh /*
293 1.1 eeh * Ethernet interface descriptor
294 1.1 eeh * First, set: saiop->si_devaddr, saiop->si_dmaaddr, etc.
295 1.1 eeh * Then: saiop->si_boottab->b_open() will set:
296 1.1 eeh * saiop->si_sif;
297 1.1 eeh * saiop->si_devdata;
298 1.1 eeh * The latter is the first arg to the following functions.
299 1.1 eeh * Note that the buffer must be in DVMA space...
300 1.1 eeh */
301 1.1 eeh struct saif {
302 1.1 eeh /* transmit packet, returns zero on success. */
303 1.1 eeh int (*sif_xmit)(void *devdata, char *buf, int len);
304 1.1 eeh /* wait for packet, zero if none arrived */
305 1.1 eeh int (*sif_poll)(void *devdata, char *buf);
306 1.1 eeh /* reset interface, set addresses, etc. */
307 1.1 eeh int (*sif_reset)(void *devdata, struct saioreq *sip);
308 1.1 eeh /* Later (sun4 only) proms have more stuff here. */
309 1.1 eeh };
310 1.1 eeh
311 1.1 eeh
312 1.1 eeh #if defined(SUN4)
313 1.1 eeh void oldmon_w_trace __P((u_long));
314 1.1 eeh void oldmon_w_cmd __P((u_long, char *));
315 1.1 eeh #endif
316 1.1 eeh
317 1.1 eeh #endif /* _MACHINE_OLDMON_H */
318