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