1 /* $NetBSD: mon.h,v 1.22 1997/02/05 14:51:23 gwr Exp $ */ 2 3 /*- 4 * Copyright (c) 1996 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Adam Glass. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 /* 40 * This file derived from kernel/mach/sun3.md/machMon.h from the 41 * sprite distribution. 42 * 43 * In particular, this file came out of the Walnut Creek cdrom collection 44 * which contained no warnings about any possible copyright infringement. 45 * It was also indentical to a file in the sprite kernel tar file found on 46 * allspice.berkeley.edu. 47 * It also written in the annoying sprite coding style. I've made 48 * efforts not to heavily edit their file, just ifdef parts out. -- glass 49 */ 50 51 #ifndef _MACHINE_MON_H 52 #define _MACHINE_MON_H 53 /* 54 * machMon.h -- 55 * 56 * Structures, constants and defines for access to the sun monitor. 57 * These are translated from the sun monitor header file "sunromvec.h". 58 * 59 * NOTE: The file keyboard.h in the monitor directory has all sorts of useful 60 * keyboard stuff defined. I haven't attempted to translate that file 61 * because I don't need it. If anyone wants to use it, be my guest. 62 * 63 * Copyright (C) 1985 Regents of the University of California 64 * All rights reserved. 65 * 66 * 67 * Header: /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v 9.1 68 * 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley) 69 */ 70 71 #ifndef _MACHMON 72 #define _MACHMON 73 74 /* 75 * Structure set up by the boot command to pass arguments to the program that 76 * is booted. 77 */ 78 typedef struct bootparam { 79 char *argPtr[8]; /* String arguments */ 80 char strings[100]; /* String table for string arguments */ 81 char devName[2]; /* Device name */ 82 int ctlrNum; /* Controller number */ 83 int unitNum; /* Unit number */ 84 int partNum; /* Partition/file number */ 85 char *fileName; /* File name, points into strings */ 86 struct boottab *bootDevice; /* Defined in saio.h */ 87 } MachMonBootParam; 88 89 #ifdef sun3x 90 /* 91 * This structure defines a segment of physical memory. To support 92 * sparse physical memory, the PROM constructs a linked list of 93 * these at power-on-self-test time. 94 */ 95 struct physmemory { 96 unsigned int address; 97 unsigned int size; 98 struct physmemory *next; 99 }; 100 #endif /* sun3x */ 101 102 /* 103 * Here is the structure of the vector table found at the front of the boot 104 * rom. The functions defined in here are explained below. 105 * 106 * NOTE: This struct has references to the structures keybuf and globram which 107 * I have not translated. If anyone needs to use these they should 108 * translate these structs into Sprite format. 109 */ 110 typedef struct { 111 char *initSp; /* Initial system stack ptr 112 * for hardware */ 113 int (*startMon)__P((void)); /* Initial PC for hardware */ 114 115 int *diagberr; /* Bus err handler for diags */ 116 117 /* 118 * Monitor and hardware revision and identification 119 */ 120 121 struct bootparam **bootParam; /* Info for bootstrapped pgm */ 122 u_int *memorySize; /* Usable memory in bytes */ 123 124 /* 125 * Single-character input and output 126 */ 127 128 u_char (*getChar)__P((void)); /* Get char from input source */ 129 int (*putChar)__P((int)); /* Put char to output sink */ 130 int (*mayGet)__P((void)); /* Maybe get char, or -1 */ 131 int (*mayPut)__P((int)); /* Maybe put char, or -1 */ 132 u_char *echo; /* Should getchar echo? */ 133 u_char *inSource; /* Input source selector */ 134 u_char *outSink; /* Output sink selector */ 135 136 /* 137 * Keyboard input (scanned by monitor nmi routine) 138 */ 139 140 int (*getKey)__P((void)); /* Get next key if one exists */ 141 int (*initGetKey)__P((void*)); /* Initialize get key */ 142 u_int *translation; /* Kbd translation selector 143 (see keyboard.h in sun 144 monitor code) */ 145 u_char *keyBid; /* Keyboard ID byte */ 146 int *screen_x; /* V2: Screen x pos (R/O) */ 147 int *screen_y; /* V2: Screen y pos (R/O) */ 148 struct keybuf *keyBuf; /* Up/down keycode buffer */ 149 150 /* 151 * Monitor revision level. 152 */ 153 154 char *monId; 155 156 /* 157 * Frame buffer output and terminal emulation 158 */ 159 160 int (*fbWriteChar)__P((int)); /* Write a character to FB */ 161 int *fbAddr; /* Address of frame buffer */ 162 char **font; /* Font table for FB */ 163 /* Quickly write string to FB */ 164 int (*fbWriteStr)__P((char *buf, int len)); 165 166 /* 167 * Reboot interface routine -- resets and reboots system. No return. 168 */ 169 170 int (*reBoot)__P((char *)); /* e.g. reBoot("xy()vmunix") */ 171 172 /* 173 * Line input and parsing 174 */ 175 176 u_char *lineBuf; /* The line input buffer */ 177 u_char **linePtr; /* Cur pointer into linebuf */ 178 int *lineSize; /* length of line in linebuf */ 179 int (*getLine)__P((int)); /* Get line from user */ 180 u_char (*getNextChar)__P((void)); /* Get next char from linebuf */ 181 u_char (*peekNextChar)__P((void)); /* Peek at next char */ 182 int *fbThere; /* =1 if frame buffer there */ 183 int (*getNum)__P((void)); /* Grab hex num from line */ 184 185 /* 186 * Print formatted output to current output sink 187 */ 188 189 int (*printf)__P((char *, ...)); /* Like kernel printf */ 190 int (*printHex)__P((int,int)); /* Format N digits in hex */ 191 192 /* 193 * Led stuff 194 */ 195 196 u_char *leds; /* RAM copy of LED register */ 197 int (*setLeds)__P((int)); /* Sets LED's and RAM copy */ 198 199 /* 200 * Non-maskable interrupt (nmi) information 201 */ 202 203 int (*nmiAddr)__P((void*)); /* Addr for level 7 vector */ 204 int (*abortEntry)__P((void*)); /* Entry for keyboard abort */ 205 int *nmiClock; /* Counts up in msec */ 206 207 /* 208 * Frame buffer type: see <sun/fbio.h> 209 */ 210 211 int *fbType; 212 213 /* 214 * Assorted other things 215 */ 216 217 u_int romvecVersion; /* Version # of Romvec */ 218 struct globram *globRam; /* monitor global variables */ 219 caddr_t kbdZscc; /* Addr of keyboard in use */ 220 221 int *keyrInit; /* ms before kbd repeat */ 222 u_char *keyrTick; /* ms between repetitions */ 223 u_int *memoryAvail; /* V1: Main mem usable size */ 224 long *resetAddr; /* where to jump on a reset */ 225 long *resetMap; /* pgmap entry for resetaddr */ 226 /* Really struct pgmapent * */ 227 int (*exitToMon)__P((void)); /* Exit from user program */ 228 u_char **memorybitmap; /* V1: &{0 or &bits} */ 229 230 /**************************************************************** 231 * Note: from here on, things vary per-architecture! 232 ****************************************************************/ 233 234 #ifdef sun3 235 /* Set seg in all contexts */ 236 void (*setcxsegmap)__P((int,int,int)); 237 238 /* V2: Handler for 'v' cmd */ 239 void (**vector_cmd)__P((int, char*)); 240 241 int pad[6]; 242 #endif /* sun3 */ 243 #ifdef sun3x 244 245 /* V2: Handler for 'v' cmd */ 246 void (**vector_cmd)__P((int, char*)); 247 248 /* Address of low memory PTEs (maps at least 4MB) */ 249 int **lomemptaddr; 250 251 /* 252 * Address of debug/mon PTEs which map the 2MB space 253 * starting at MON_KDB_START, ending at MONEND. 254 */ 255 int **monptaddr; 256 257 /* 258 * Address of dvma PTEs. This is a VA that maps the I/O MMU 259 * page table, but only the last part, which corresponds to 260 * the CPU virtual space at MON_DVMA_BASE (see below). 261 */ 262 int **dvmaptaddr; 263 264 /* 265 * Physical Address of the debug/mon PTEs found at the 266 * virtual address given by *romVectorPtr->monptaddr; 267 */ 268 int **monptphysaddr; 269 270 /* 271 * Address of shadow copy of DVMA PTEs. This is a VA that 272 * maps the PTEs used by the CPU to map the same physical 273 * pages as the I/O MMU into the CPU virtual space starting 274 * at MON_DVMA_BASE, length MON_DVMA_SIZE (see below). 275 */ 276 int **shadowpteaddr; 277 278 struct physmemory *v_physmemory; /* Ptr to memory list for 3/80 */ 279 280 int pad[1]; 281 282 #endif /* sun3x */ 283 } MachMonRomVector; 284 285 /* 286 * Functions defined in the vector: 287 * 288 * 289 * getChar -- Return the next character from the input source 290 * 291 * u_char getChar() 292 * 293 * putChar -- Write the given character to the output source. 294 * 295 * void putChar(ch) 296 * char ch; 297 * 298 * mayGet -- Maybe get a character from the current input source. Return -1 299 * if don't return a character. 300 * 301 * int mayGet() 302 * 303 * mayPut -- Maybe put a character to the current output source. Return -1 304 * if no character output. 305 * 306 * int mayPut(ch) 307 * char ch; 308 * 309 * getKey -- Returns a key code (if up/down codes being returned), 310 * a byte of ASCII (if that's requested), 311 * NOKEY (if no key has been hit). 312 * 313 * int getKey() 314 * 315 * initGetKey -- Initialize things for get key. 316 * 317 * void initGetKey() 318 * 319 * fbWriteChar -- Write a character to the frame buffer 320 * 321 * void fwritechar(ch) 322 * u_char ch; 323 * 324 * fbWriteStr -- Write a string to the frame buffer. 325 * 326 * void fwritestr(addr,len) 327 * register u_char *addr; / * String to be written * / 328 * register short len; / * Length of string * / 329 * 330 * getLine -- read the next input line into a global buffer 331 * 332 * getline(echop) 333 * int echop; / * 1 if should echo input, 0 if not * / 334 * 335 * getNextChar -- return the next character from the global line buffer. 336 * 337 * u_char getNextChar() 338 * 339 * peekNextChar -- look at the next character in the global line buffer. 340 * 341 * u_char peekNextChar() 342 * 343 * getNum -- Grab hex num from the global line buffer. 344 * 345 * int getNum() 346 * 347 * printf -- Scaled down version of C library printf. Only %d, %x, %s, and %c 348 * are recognized. 349 * 350 * printhex -- prints rightmost <digs> hex digits of <val> 351 * 352 * printhex(val,digs) 353 * register int val; 354 * register int digs; 355 * 356 * abortEntry -- Entry for keyboard abort. 357 * 358 * abortEntry() 359 */ 360 361 /* 362 * Where the rom vector is defined. 363 */ 364 365 #define romVectorPtr ((MachMonRomVector *) PROM_BASE) 366 /* #define romp romVectorPtr XXX - Too prone to conflicts. */ 367 368 /* 369 * Functions and defines to access the monitor. 370 */ 371 372 #define mon_printf (romVectorPtr->printf) 373 #define mon_putchar (romVectorPtr->putChar) 374 #define mon_may_getchar (romVectorPtr->mayGet) 375 #define mon_exit_to_mon (romVectorPtr->exitToMon) 376 #define mon_reboot (romVectorPtr->reBoot) 377 #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();} 378 379 #ifdef sun3 380 381 #define mon_setcxsegmap(context, va, sme) \ 382 romVectorPtr->setcxsegmap(context, va, sme) 383 384 /* 385 * The memory addresses for the PROM, and the EEPROM. 386 * On the sun2 these addresses are actually 0x00EF??00 387 * but only the bottom 24 bits are looked at so these still 388 * work ok. 389 */ 390 391 #define PROM_BASE 0x0fef0000 392 393 /* 394 * MONSTART and MONEND denote the range used by the monitor. 395 */ 396 #define MONSTART 0x0FE00000 397 #define MONEND 0x0FF00000 398 399 /* 400 * These describe the monitor's short segment which it basically uses to map 401 * one stupid page that it uses for storage. MONSHORTPAGE is the page, 402 * and MONSHORTSEG is the segment that it is in. Its mapping must not 403 * be removed (or the PROM monitor will be unhappy). 404 */ 405 406 #define MONSHORTPAGE 0x0FFFE000 407 #define MONSHORTSEG 0x0FFE0000 408 409 #endif /* sun3 */ 410 #ifdef sun3x 411 412 /* 413 * We don't have a separate kernel debugger like sun kadb, 414 * but this range is setup by the monitor for such a thing. 415 * We might as well preserve the mappings anyway. 416 */ 417 #define MON_KDB_START 0xFEE00000 418 #define MON_KDB_SIZE 0x100000 419 420 /* 421 * MONSTART and MONEND define the range used by the monitor. 422 * MONDATA is its data page (do not touch!) 423 * PROM_BASE is where the boot PROM lives. 424 */ 425 #define MONSTART 0xFEF00000 426 #define MONDATA 0xFEF72000 427 #define PROM_BASE 0xFEFE0000 428 #define MONEND 0xFF000000 429 430 /* 431 * These define the CPU virtual address range mapped by the 432 * PROM for use as DVMA space. The physical pages mapped in 433 * this range are also mapped by the I/O MMU. 434 */ 435 #define MON_DVMA_BASE 0xFFF00000 436 #define MON_DVMA_SIZE 0x100000 /* 1MB */ 437 438 #endif /* sun3x */ 439 #endif /* _MACHMON */ 440 #endif /* MACHINE_MON_H */ 441