1 /* 2 * This file derived from kernel/mach/sun3.md/machMon.h from the 3 * sprite distribution. 4 * 5 * In particular, this file came out of the Walnut Creek cdrom collection 6 * which contained no warnings about any possible copyright infringement 7 * It was also indentical to a file in the sprite kernel tar file found on 8 * allspice.berkeley.edu. 9 * It also written in the annoying sprite coding style. I've made 10 * efforts not to heavily edit their file, just ifdef parts out. -- glass 11 */ 12 13 #ifndef _SUN3_MON_H 14 #define _SUN3_MON_H 15 /* 16 * machMon.h -- 17 * 18 * Structures, constants and defines for access to the sun monitor. 19 * These are translated from the sun monitor header file "sunromvec.h". 20 * 21 * NOTE: The file keyboard.h in the monitor directory has all sorts of useful 22 * keyboard stuff defined. I haven't attempted to translate that file 23 * because I don't need it. If anyone wants to use it, be my guest. 24 * 25 * Copyright (C) 1985 Regents of the University of California 26 * All rights reserved. 27 * 28 * 29 * Header: /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v 9.1 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley) 30 */ 31 32 #ifndef _MACHMON 33 #define _MACHMON 34 35 /* 36 * The memory addresses for the PROM, and the EEPROM. 37 * On the sun2 these addresses are actually 0x00EF??00 38 * but only the bottom 24 bits are looked at so these still 39 * work ok. 40 */ 41 42 #define PROM_BASE 0x0fef0000 43 44 /* 45 * The table entry that describes a device. It exists in the PROM; a 46 * pointer to it is passed in MachMonBootParam. It can be used to locate 47 * PROM subroutines for opening, reading, and writing the device. 48 * 49 * When using this interface, only one device can be open at once. 50 * 51 * NOTE: I am not sure what arguments boot, open, close, and strategy take. 52 * What is here is just translated verbatim from the sun monitor code. We 53 * should figure this out eventually if we need it. 54 */ 55 56 typedef struct { 57 char devName[2]; /* The name of the device */ 58 int (*probe)(); /* probe() --> -1 or found controller 59 number */ 60 int (*boot)(); /* boot(bp) --> -1 or start address */ 61 int (*open)(); /* open(iobp) --> -1 or 0 */ 62 int (*close)(); /* close(iobp) --> -1 or 0 */ 63 int (*strategy)(); /* strategy(iobp,rw) --> -1 or 0 */ 64 char *desc; /* Printable string describing dev */ 65 } MachMonBootTable; 66 67 /* 68 * Structure set up by the boot command to pass arguments to the program that 69 * is booted. 70 */ 71 72 typedef struct { 73 char *argPtr[8]; /* String arguments */ 74 char strings[100]; /* String table for string arguments */ 75 char devName[2]; /* Device name */ 76 int ctlrNum; /* Controller number */ 77 int unitNum; /* Unit number */ 78 int partNum; /* Partition/file number */ 79 char *fileName; /* File name, points into strings */ 80 MachMonBootTable *bootTable; /* Points to table entry for device */ 81 } MachMonBootParam; 82 83 /* 84 * Here is the structure of the vector table which is at the front of the boot 85 * rom. The functions defined in here are explained below. 86 * 87 * NOTE: This struct has references to the structures keybuf and globram which 88 * I have not translated. If anyone needs to use these they should 89 * translate these structs into Sprite format. 90 */ 91 92 typedef struct { 93 char *initSp; /* Initial system stack ptr 94 * for hardware */ 95 int (*startMon)(); /* Initial PC for hardware */ 96 97 int *diagberr; /* Bus err handler for diags */ 98 99 /* 100 * Monitor and hardware revision and identification 101 */ 102 103 MachMonBootParam **bootParam; /* Info for bootstrapped pgm */ 104 unsigned *memorySize; /* Usable memory in bytes */ 105 106 /* 107 * Single-character input and output 108 */ 109 110 unsigned char (*getChar)(); /* Get char from input source */ 111 int (*putChar)(); /* Put char to output sink */ 112 int (*mayGet)(); /* Maybe get char, or -1 */ 113 int (*mayPut)(); /* Maybe put char, or -1 */ 114 unsigned char *echo; /* Should getchar echo? */ 115 unsigned char *inSource; /* Input source selector */ 116 unsigned char *outSink; /* Output sink selector */ 117 118 /* 119 * Keyboard input (scanned by monitor nmi routine) 120 */ 121 122 int (*getKey)(); /* Get next key if one exists */ 123 int (*initGetKey)(); /* Initialize get key */ 124 unsigned int *translation; /* Kbd translation selector 125 (see keyboard.h in sun 126 monitor code) */ 127 unsigned char *keyBid; /* Keyboard ID byte */ 128 int *screen_x; /* V2: Screen x pos (R/O) */ 129 int *screen_y; /* V2: Screen y pos (R/O) */ 130 struct keybuf *keyBuf; /* Up/down keycode buffer */ 131 132 /* 133 * Monitor revision level. 134 */ 135 136 char *monId; 137 138 /* 139 * Frame buffer output and terminal emulation 140 */ 141 142 int (*fbWriteChar)(); /* Write a character to FB */ 143 int *fbAddr; /* Address of frame buffer */ 144 char **font; /* Font table for FB */ 145 int (*fbWriteStr)(); /* Quickly write string to FB */ 146 147 /* 148 * Reboot interface routine -- resets and reboots system. No return. 149 */ 150 151 int (*reBoot)(); /* e.g. reBoot("xy()vmunix") */ 152 153 /* 154 * Line input and parsing 155 */ 156 157 unsigned char *lineBuf; /* The line input buffer */ 158 unsigned char **linePtr; /* Cur pointer into linebuf */ 159 int *lineSize; /* length of line in linebuf */ 160 int (*getLine)(); /* Get line from user */ 161 unsigned char (*getNextChar)(); /* Get next char from linebuf */ 162 unsigned char (*peekNextChar)(); /* Peek at next char */ 163 int *fbThere; /* =1 if frame buffer there */ 164 int (*getNum)(); /* Grab hex num from line */ 165 166 /* 167 * Print formatted output to current output sink 168 */ 169 170 int (*printf)(); /* Similar to "Kernel printf" */ 171 int (*printHex)(); /* Format N digits in hex */ 172 173 /* 174 * Led stuff 175 */ 176 177 unsigned char *leds; /* RAM copy of LED register */ 178 int (*setLeds)(); /* Sets LED's and RAM copy */ 179 180 /* 181 * Non-maskable interrupt (nmi) information 182 */ 183 184 int (*nmiAddr)(); /* Addr for level 7 vector */ 185 int (*abortEntry)(); /* Entry for keyboard abort */ 186 int *nmiClock; /* Counts up in msec */ 187 188 /* 189 * Frame buffer type: see <sun/fbio.h> 190 */ 191 192 int *fbType; 193 194 /* 195 * Assorted other things 196 */ 197 198 unsigned romvecVersion; /* Version # of Romvec */ 199 struct globram *globRam; /* monitor global variables */ 200 caddr_t kbdZscc; /* Addr of keyboard in use */ 201 202 int *keyrInit; /* ms before kbd repeat */ 203 unsigned char *keyrTick; /* ms between repetitions */ 204 unsigned *memoryAvail; /* V1: Main mem usable size */ 205 long *resetAddr; /* where to jump on a reset */ 206 long *resetMap; /* pgmap entry for resetaddr */ 207 /* Really struct pgmapent * */ 208 int (*exitToMon)(); /* Exit from user program */ 209 unsigned char **memorybitmap; /* V1: &{0 or &bits} */ 210 void (*setcxsegmap)(); /* Set seg in any context */ 211 void (**vector_cmd)(); /* V2: Handler for 'v' cmd */ 212 int dummy1z; 213 int dummy2z; 214 int dummy3z; 215 int dummy4z; 216 } MachMonRomVector; 217 218 /* 219 * Functions defined in the vector: 220 * 221 * 222 * getChar -- Return the next character from the input source 223 * 224 * unsigned char getChar() 225 * 226 * putChar -- Write the given character to the output source. 227 * 228 * void putChar(ch) 229 * char ch; 230 * 231 * mayGet -- Maybe get a character from the current input source. Return -1 232 * if don't return a character. 233 * 234 * int mayGet() 235 * 236 * mayPut -- Maybe put a character to the current output source. Return -1 237 * if no character output. 238 * 239 * int mayPut(ch) 240 * char ch; 241 * 242 * getKey -- Returns a key code (if up/down codes being returned), 243 * a byte of ASCII (if that's requested), 244 * NOKEY (if no key has been hit). 245 * 246 * int getKey() 247 * 248 * initGetKey -- Initialize things for get key. 249 * 250 * void initGetKey() 251 * 252 * fbWriteChar -- Write a character to the frame buffer 253 * 254 * void fwritechar(ch) 255 * unsigned char ch; 256 * 257 * fbWriteStr -- Write a string to the frame buffer. 258 * 259 * void fwritestr(addr,len) 260 * register unsigned char *addr; / * String to be written * / 261 * register short len; / * Length of string * / 262 * 263 * getLine -- read the next input line into a global buffer 264 * 265 * getline(echop) 266 * int echop; / * 1 if should echo input, 0 if not * / 267 * 268 * getNextChar -- return the next character from the global line buffer. 269 * 270 * unsigned char getNextChar() 271 * 272 * peekNextChar -- look at the next character in the global line buffer. 273 * 274 * unsigned char peekNextChar() 275 * 276 * getNum -- Grab hex num from the global line buffer. 277 * 278 * int getNum() 279 * 280 * printf -- Scaled down version of C library printf. Only %d, %x, %s, and %c 281 * are recognized. 282 * 283 * printhex -- prints rightmost <digs> hex digits of <val> 284 * 285 * printhex(val,digs) 286 * register int val; 287 * register int digs; 288 * 289 * abortEntry -- Entry for keyboard abort. 290 * 291 * abortEntry() 292 */ 293 294 /* 295 * Where the rom vector is defined. 296 */ 297 298 #define romVectorPtr ((MachMonRomVector *) PROM_BASE) 299 300 #if 0 301 /* 302 * Functions and defines to access the monitor. 303 */ 304 305 #define Mach_MonPrintf (romVectorPtr->printf) 306 307 extern void Mach_MonPutChar _ARGS_((int ch)); 308 extern int Mach_MonMayPut _ARGS_((int ch)); 309 extern void Mach_MonAbort _ARGS_((void)); 310 extern void Mach_MonReboot _ARGS_((char *rebootString)); 311 extern void Mach_MonStartNmi _ARGS_((void)); 312 extern void Mach_MonStopNmi _ARGS_((void)); 313 314 extern void Mach_MonTrap _ARGS_((Address address_to_trap_to)); 315 316 /* 317 * These routines no longer work correctly with new virtual memory. 318 */ 319 320 #define Mach_MonGetChar (romVectorPtr->getChar) 321 #define Mach_MonGetLine (romVectorPtr->getLine) 322 #define Mach_MonGetNextChar (romVectorPtr->getNextChar) 323 #define Mach_MonPeekNextChar (romVectorPtr->peekNextChar) 324 #endif 325 326 #define mon_printf (romVectorPtr->printf) 327 #define mon_putchar (romVectorPtr->printf) 328 #define mon_exit_to_mon (romVectorPtr->exitToMon) 329 #define mon_reboot (romVectorPtr->exitToMon) 330 #define romp (romVectorPtr) 331 332 #define MONSTART 0x0FE00000 333 #define MONEND 0x0FF00000 334 335 #endif /* _MACHMON */ 336 #endif /* SUN3_MON_H */ 337