1 /* $NetBSD: mon.h,v 1.1 2001/06/14 12:57:11 fredette 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 /* 55 * machMon.h -- 56 * 57 * Structures, constants and defines for access to the sun monitor. 58 * These are translated from the sun monitor header file "sunromvec.h". 59 * 60 * NOTE: The file keyboard.h in the monitor directory has all sorts of useful 61 * keyboard stuff defined. I haven't attempted to translate that file 62 * because I don't need it. If anyone wants to use it, be my guest. 63 * 64 * Copyright (C) 1985 Regents of the University of California 65 * All rights reserved. 66 * 67 * 68 * Header: /sprite/src/kernel/mach/sun3.md/RCS/machMon.h,v 9.1 69 * 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley) 70 */ 71 72 /* 73 * Structure set up by the boot command to pass arguments to the program that 74 * is booted. 75 */ 76 struct 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 boottab *bootDevice; /* Defined in saio.h */ 85 } __attribute__((packed)); 86 87 /* 88 * This structure defines a segment of physical memory. To support 89 * sparse physical memory, the PROM constructs a linked list of 90 * these at power-on-self-test time. 91 */ 92 struct physmemory { 93 u_int address; 94 u_int size; 95 struct physmemory *next; 96 }; 97 98 /* 99 * Here is the structure of the vector table found at the front of the boot 100 * rom. The functions defined in here are explained below. 101 * 102 * NOTE: This struct has references to the structures keybuf and globram which 103 * I have not translated. If anyone needs to use these they should 104 * translate these structs into Sprite format. 105 */ 106 struct sunromvec { 107 char *init_SP; /* Initial SP for hardware */ 108 char *init_PC; /* Initial PC for hardware */ 109 int *diagberr; /* Bus err handler for diags */ 110 111 /* 112 * Monitor and hardware revision and identification 113 */ 114 115 struct bootparam **bootParam; /* Info for bootstrapped pgm */ 116 u_int *memorySize; /* Usable memory in bytes */ 117 118 /* 119 * Single-character input and output 120 */ 121 122 u_char (*getChar)__P((void)); /* Get char from input source */ 123 int (*putChar)__P((int)); /* Put char to output sink */ 124 int (*mayGet)__P((void)); /* Maybe get char, or -1 */ 125 int (*mayPut)__P((int)); /* Maybe put char, or -1 */ 126 u_char *echo; /* Should getchar echo? */ 127 u_char *inSource; /* Input source selector */ 128 u_char *outSink; /* Output sink selector */ 129 #define PROMDEV_KBD 0 /* input from keyboard */ 130 #define PROMDEV_SCREEN 0 /* output to screen */ 131 #define PROMDEV_TTYA 1 /* in/out to ttya */ 132 #define PROMDEV_TTYB 2 /* in/out to ttyb */ 133 134 /* 135 * Keyboard input (scanned by monitor nmi routine) 136 */ 137 138 int (*getKey)__P((void)); /* Get next key if one exists */ 139 int (*initGetKey)__P((void*)); /* Initialize get key */ 140 u_int *translation; /* Kbd translation selector 141 (see keyboard.h in sun 142 monitor code) */ 143 u_char *keyBid; /* Keyboard ID byte */ 144 int *screen_x; /* V2: Screen x pos (R/O) */ 145 int *screen_y; /* V2: Screen y pos (R/O) */ 146 struct keybuf *keyBuf; /* Up/down keycode buffer */ 147 148 /* 149 * Monitor revision level. 150 */ 151 152 char *monId; 153 154 /* 155 * Frame buffer output and terminal emulation 156 */ 157 158 int (*fbWriteChar)__P((int)); /* Write a character to FB */ 159 int *fbAddr; /* Address of frame buffer */ 160 char **font; /* Font table for FB */ 161 /* Quickly write string to FB */ 162 int (*fbWriteStr)__P((char *buf, int len)); 163 164 /* 165 * Reboot interface routine -- resets and reboots system. No return. 166 */ 167 168 int (*reBoot)__P((char *)); /* e.g. reBoot("xy()vmunix") */ 169 170 /* 171 * Line input and parsing 172 */ 173 174 u_char *lineBuf; /* The line input buffer */ 175 u_char **linePtr; /* Cur pointer into linebuf */ 176 int *lineSize; /* length of line in linebuf */ 177 int (*getLine)__P((int)); /* Get line from user */ 178 u_char (*getNextChar)__P((void)); /* Get next char from linebuf */ 179 u_char (*peekNextChar)__P((void)); /* Peek at next char */ 180 int *fbThere; /* =1 if frame buffer there */ 181 int (*getNum)__P((void)); /* Grab hex num from line */ 182 183 /* 184 * Print formatted output to current output sink 185 */ 186 187 int (*printf)__P((char *, ...)); /* Like kernel printf */ 188 int (*printHex)__P((int,int)); /* Format N digits in hex */ 189 190 /* 191 * Led stuff 192 */ 193 194 u_char *leds; /* RAM copy of LED register */ 195 int (*setLeds)__P((int)); /* Sets LED's and RAM copy */ 196 197 /* 198 * Non-maskable interrupt (nmi) information 199 */ 200 201 int (*nmiAddr)__P((void*)); /* Addr for level 7 vector */ 202 int (*abortEntry)__P((void*)); /* Entry for keyboard abort */ 203 int *nmiClock; /* Counts up in msec */ 204 205 /* 206 * Frame buffer type: see <sun/fbio.h> 207 */ 208 209 int *fbType; 210 211 /* 212 * Assorted other things 213 */ 214 215 u_int romvecVersion; /* Version # of Romvec */ 216 struct globram *globRam; /* monitor global variables */ 217 void *kbdZscc; /* Addr of keyboard in use */ 218 219 int *keyrInit; /* ms before kbd repeat */ 220 u_char *keyrTick; /* ms between repetitions */ 221 u_int *memoryAvail; /* V1: Main mem usable size */ 222 long *resetAddr; /* where to jump on a reset */ 223 long *resetMap; /* pgmap entry for resetaddr */ 224 /* Really struct pgmapent * */ 225 int (*exitToMon)__P((void)); /* Exit from user program */ 226 u_char **memorybitmap; /* V1: &{0 or &bits} */ 227 228 /**************************************************************** 229 * Note: from here on, things vary per-architecture! 230 ****************************************************************/ 231 union { 232 void *un_pad[8]; /* this determines the size */ 233 struct { 234 /* Set seg in all contexts (ctx, va, sme) */ 235 void (*un3_setcxsegmap)__P((int,int,int)); 236 /* V2: Handler for 'v' cmd */ 237 void (**un3_vector_cmd)__P((int, char*)); 238 } un3; 239 struct { 240 /* V2: Handler for 'v' cmd */ 241 void (**un3x_vector_cmd)__P((int, char*)); 242 /* Address of low memory PTEs (maps at least 4MB) */ 243 int **un3x_lomemptaddr; 244 /* 245 * Address of debug/mon PTEs which map the 2MB space 246 * starting at MON_KDB_BASE, ending at MONEND. 247 */ 248 int **un3x_monptaddr; 249 /* 250 * Address of dvma PTEs. This is a VA that maps the I/O MMU 251 * page table, but only the last part, which corresponds to 252 * the CPU virtual space at MON_DVMA_BASE (see below). 253 */ 254 int **un3x_dvmaptaddr; 255 /* 256 * Physical Address of the debug/mon PTEs found at the 257 * virtual address given by *romVectorPtr->monptaddr; 258 */ 259 int **un3x_monptphysaddr; 260 /* 261 * Address of shadow copy of DVMA PTEs. This is a VA that 262 * maps the PTEs used by the CPU to map the same physical 263 * pages as the I/O MMU into the CPU virtual space starting 264 * at MON_DVMA_BASE, length MON_DVMA_SIZE (see below). 265 */ 266 int **un3x_shadowpteaddr; 267 /* Ptr to memory list for 3/80 */ 268 struct physmemory *un3x_physmemory; 269 } un3x; 270 } mon_un; 271 } __attribute__((packed)); 272 273 /* 274 * Functions defined in the vector: 275 * 276 * 277 * getChar -- Return the next character from the input source 278 * 279 * u_char getChar() 280 * 281 * putChar -- Write the given character to the output source. 282 * 283 * void putChar(ch) 284 * char ch; 285 * 286 * mayGet -- Maybe get a character from the current input source. Return -1 287 * if don't return a character. 288 * 289 * int mayGet() 290 * 291 * mayPut -- Maybe put a character to the current output source. Return -1 292 * if no character output. 293 * 294 * int mayPut(ch) 295 * char ch; 296 * 297 * getKey -- Returns a key code (if up/down codes being returned), 298 * a byte of ASCII (if that's requested), 299 * NOKEY (if no key has been hit). 300 * 301 * int getKey() 302 * 303 * initGetKey -- Initialize things for get key. 304 * 305 * void initGetKey() 306 * 307 * fbWriteChar -- Write a character to the frame buffer 308 * 309 * void fwritechar(ch) 310 * u_char ch; 311 * 312 * fbWriteStr -- Write a string to the frame buffer. 313 * 314 * void fwritestr(addr,len) 315 * register u_char *addr; / * String to be written * / 316 * register short len; / * Length of string * / 317 * 318 * getLine -- read the next input line into a global buffer 319 * 320 * getline(echop) 321 * int echop; / * 1 if should echo input, 0 if not * / 322 * 323 * getNextChar -- return the next character from the global line buffer. 324 * 325 * u_char getNextChar() 326 * 327 * peekNextChar -- look at the next character in the global line buffer. 328 * 329 * u_char peekNextChar() 330 * 331 * getNum -- Grab hex num from the global line buffer. 332 * 333 * int getNum() 334 * 335 * printf -- Scaled down version of C library printf. Only %d, %x, %s, and %c 336 * are recognized. 337 * 338 * printhex -- prints rightmost <digs> hex digits of <val> 339 * 340 * printhex(val,digs) 341 * register int val; 342 * register int digs; 343 * 344 * abortEntry -- Entry for keyboard abort. 345 * 346 * abortEntry() 347 */ 348 349 /* 350 * Functions and defines to access the monitor. 351 */ 352 353 #define mon_printf (romVectorPtr->printf) 354 #define mon_putchar (romVectorPtr->putChar) 355 #define mon_may_getchar (romVectorPtr->mayGet) 356 #define mon_exit_to_mon (romVectorPtr->exitToMon) 357 #define mon_reboot (romVectorPtr->reBoot) 358 359 /* 360 * Sun2 specific stuff... 361 */ 362 363 /* 364 * MONSTART and MONEND denote the range used by the monitor. 365 * PROM_BASE is the virtual address of the PROM. 366 */ 367 #define SUN2_MONSTART 0x00E00000 368 #define SUN2_PROM_BASE 0x00EF0000 369 #define SUN2_MONEND 0x00F00000 370 371 /* 372 * Sun3 specific stuff... 373 */ 374 375 #ifdef _SUN3_ 376 #define setcxsegmap mon_un.un3.un3_setcxsegmap 377 #define vector_cmd mon_un.un3.un3_vector_cmd 378 #define romVectorPtr ((struct sunromvec *) SUN3_PROM_BASE) 379 #endif /* SUN3 */ 380 381 /* 382 * MONSTART and MONEND denote the range used by the monitor. 383 * PROM_BASE is the virtual address of the PROM. 384 */ 385 #define SUN3_MONSTART 0x0FE00000 386 #define SUN3_PROM_BASE 0x0FEF0000 387 #define SUN3_MONEND 0x0FF00000 388 389 /* 390 * These describe the monitor's short segment (one it can reach using 391 * short PC-relative addressing) which it uses to map its data page. 392 * MONSHORTPAGE is the page; MONSHORTSEG is the containing segment. 393 * Its mapping must not be removed or the PROM monitor will fail. 394 * MONSHORTPAGE is also where the "ie" puts its SCP. 395 */ 396 #define SUN3_MONSHORTPAGE 0x0FFFE000 397 #define SUN3_MONSHORTSEG 0x0FFE0000 398 399 /* 400 * Sun3X specific stuff... 401 */ 402 403 #ifdef _SUN3X_ 404 #define vector_cmd mon_un.un3x.un3x_vector_cmd 405 #define lomemptaddr mon_un.un3x.un3x_lomemptaddr 406 #define monptaddr mon_un.un3x.un3x_monptaddr 407 #define dvmaptaddr mon_un.un3x.un3x_dvmaptaddr 408 #define monptphysaddr mon_un.un3x.un3x_monptphysaddr 409 #define shadowpteaddr mon_un.un3x.un3x_shadowpteaddr 410 #define v_physmemory mon_un.un3x.un3x_physmemory 411 #define romVectorPtr ((struct sunromvec *) SUN3X_PROM_BASE) 412 #endif /* SUN3X */ 413 414 /* 415 * We don't have a separate kernel debugger like sun kadb, 416 * but this range is setup by the monitor for such a thing. 417 * We might as well preserve the mappings anyway. 418 */ 419 #define SUN3X_MON_KDB_BASE 0xFEE00000 420 #define SUN3X_MON_KDB_SIZE 0x100000 421 422 /* 423 * MONSTART and MONEND define the range used by the monitor. 424 * MONDATA is its data page (do not touch!) 425 * PROM_BASE is where the boot PROM lives. 426 */ 427 #define SUN3X_MONSTART 0xFEF00000 428 #define SUN3X_MONDATA 0xFEF72000 429 #define SUN3X_PROM_BASE 0xFEFE0000 430 #define SUN3X_MONEND 0xFF000000 431 432 /* 433 * These define the CPU virtual address range mapped by the 434 * PROM for use as DVMA space. The physical pages mapped in 435 * this range are also mapped by the I/O MMU. Note that the 436 * last page is reserved for the PROM (really for the "ie"). 437 */ 438 #define SUN3X_MON_DVMA_BASE 0xFFF00000 439 #define SUN3X_MON_DVMA_SIZE 0x100000 /* 1MB */ 440 441 #ifdef _STANDALONE 442 /* The libsa code uses a pointer... */ 443 extern struct sunromvec *_romvec; 444 #undef romVectorPtr 445 #define romVectorPtr _romvec 446 #endif /* _STANDALONE */ 447 448 #endif /* _MACHINE_MON_H */ 449