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