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