1 /* $NetBSD: mon.h,v 1.24 2001/02/22 07:11:09 chs 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 130 /* 131 * Keyboard input (scanned by monitor nmi routine) 132 */ 133 134 int (*getKey)__P((void)); /* Get next key if one exists */ 135 int (*initGetKey)__P((void*)); /* Initialize get key */ 136 u_int *translation; /* Kbd translation selector 137 (see keyboard.h in sun 138 monitor code) */ 139 u_char *keyBid; /* Keyboard ID byte */ 140 int *screen_x; /* V2: Screen x pos (R/O) */ 141 int *screen_y; /* V2: Screen y pos (R/O) */ 142 struct keybuf *keyBuf; /* Up/down keycode buffer */ 143 144 /* 145 * Monitor revision level. 146 */ 147 148 char *monId; 149 150 /* 151 * Frame buffer output and terminal emulation 152 */ 153 154 int (*fbWriteChar)__P((int)); /* Write a character to FB */ 155 int *fbAddr; /* Address of frame buffer */ 156 char **font; /* Font table for FB */ 157 /* Quickly write string to FB */ 158 int (*fbWriteStr)__P((char *buf, int len)); 159 160 /* 161 * Reboot interface routine -- resets and reboots system. No return. 162 */ 163 164 int (*reBoot)__P((char *)); /* e.g. reBoot("xy()vmunix") */ 165 166 /* 167 * Line input and parsing 168 */ 169 170 u_char *lineBuf; /* The line input buffer */ 171 u_char **linePtr; /* Cur pointer into linebuf */ 172 int *lineSize; /* length of line in linebuf */ 173 int (*getLine)__P((int)); /* Get line from user */ 174 u_char (*getNextChar)__P((void)); /* Get next char from linebuf */ 175 u_char (*peekNextChar)__P((void)); /* Peek at next char */ 176 int *fbThere; /* =1 if frame buffer there */ 177 int (*getNum)__P((void)); /* Grab hex num from line */ 178 179 /* 180 * Print formatted output to current output sink 181 */ 182 183 int (*printf)__P((char *, ...)); /* Like kernel printf */ 184 int (*printHex)__P((int,int)); /* Format N digits in hex */ 185 186 /* 187 * Led stuff 188 */ 189 190 u_char *leds; /* RAM copy of LED register */ 191 int (*setLeds)__P((int)); /* Sets LED's and RAM copy */ 192 193 /* 194 * Non-maskable interrupt (nmi) information 195 */ 196 197 int (*nmiAddr)__P((void*)); /* Addr for level 7 vector */ 198 int (*abortEntry)__P((void*)); /* Entry for keyboard abort */ 199 int *nmiClock; /* Counts up in msec */ 200 201 /* 202 * Frame buffer type: see <sun/fbio.h> 203 */ 204 205 int *fbType; 206 207 /* 208 * Assorted other things 209 */ 210 211 u_int romvecVersion; /* Version # of Romvec */ 212 struct globram *globRam; /* monitor global variables */ 213 void *kbdZscc; /* Addr of keyboard in use */ 214 215 int *keyrInit; /* ms before kbd repeat */ 216 u_char *keyrTick; /* ms between repetitions */ 217 u_int *memoryAvail; /* V1: Main mem usable size */ 218 long *resetAddr; /* where to jump on a reset */ 219 long *resetMap; /* pgmap entry for resetaddr */ 220 /* Really struct pgmapent * */ 221 int (*exitToMon)__P((void)); /* Exit from user program */ 222 u_char **memorybitmap; /* V1: &{0 or &bits} */ 223 224 /**************************************************************** 225 * Note: from here on, things vary per-architecture! 226 ****************************************************************/ 227 union { 228 void *un_pad[8]; /* this determines the size */ 229 struct { 230 /* Set seg in all contexts (ctx, va, sme) */ 231 void (*un3_setcxsegmap)__P((int,int,int)); 232 /* V2: Handler for 'v' cmd */ 233 void (**un3_vector_cmd)__P((int, char*)); 234 } un3; 235 struct { 236 /* V2: Handler for 'v' cmd */ 237 void (**un3x_vector_cmd)__P((int, char*)); 238 /* Address of low memory PTEs (maps at least 4MB) */ 239 int **un3x_lomemptaddr; 240 /* 241 * Address of debug/mon PTEs which map the 2MB space 242 * starting at MON_KDB_BASE, ending at MONEND. 243 */ 244 int **un3x_monptaddr; 245 /* 246 * Address of dvma PTEs. This is a VA that maps the I/O MMU 247 * page table, but only the last part, which corresponds to 248 * the CPU virtual space at MON_DVMA_BASE (see below). 249 */ 250 int **un3x_dvmaptaddr; 251 /* 252 * Physical Address of the debug/mon PTEs found at the 253 * virtual address given by *romVectorPtr->monptaddr; 254 */ 255 int **un3x_monptphysaddr; 256 /* 257 * Address of shadow copy of DVMA PTEs. This is a VA that 258 * maps the PTEs used by the CPU to map the same physical 259 * pages as the I/O MMU into the CPU virtual space starting 260 * at MON_DVMA_BASE, length MON_DVMA_SIZE (see below). 261 */ 262 int **un3x_shadowpteaddr; 263 /* Ptr to memory list for 3/80 */ 264 struct physmemory *un3x_physmemory; 265 } un3x; 266 } mon_un; 267 } __attribute__((packed)); 268 269 /* 270 * Functions defined in the vector: 271 * 272 * 273 * getChar -- Return the next character from the input source 274 * 275 * u_char getChar() 276 * 277 * putChar -- Write the given character to the output source. 278 * 279 * void putChar(ch) 280 * char ch; 281 * 282 * mayGet -- Maybe get a character from the current input source. Return -1 283 * if don't return a character. 284 * 285 * int mayGet() 286 * 287 * mayPut -- Maybe put a character to the current output source. Return -1 288 * if no character output. 289 * 290 * int mayPut(ch) 291 * char ch; 292 * 293 * getKey -- Returns a key code (if up/down codes being returned), 294 * a byte of ASCII (if that's requested), 295 * NOKEY (if no key has been hit). 296 * 297 * int getKey() 298 * 299 * initGetKey -- Initialize things for get key. 300 * 301 * void initGetKey() 302 * 303 * fbWriteChar -- Write a character to the frame buffer 304 * 305 * void fwritechar(ch) 306 * u_char ch; 307 * 308 * fbWriteStr -- Write a string to the frame buffer. 309 * 310 * void fwritestr(addr,len) 311 * register u_char *addr; / * String to be written * / 312 * register short len; / * Length of string * / 313 * 314 * getLine -- read the next input line into a global buffer 315 * 316 * getline(echop) 317 * int echop; / * 1 if should echo input, 0 if not * / 318 * 319 * getNextChar -- return the next character from the global line buffer. 320 * 321 * u_char getNextChar() 322 * 323 * peekNextChar -- look at the next character in the global line buffer. 324 * 325 * u_char peekNextChar() 326 * 327 * getNum -- Grab hex num from the global line buffer. 328 * 329 * int getNum() 330 * 331 * printf -- Scaled down version of C library printf. Only %d, %x, %s, and %c 332 * are recognized. 333 * 334 * printhex -- prints rightmost <digs> hex digits of <val> 335 * 336 * printhex(val,digs) 337 * register int val; 338 * register int digs; 339 * 340 * abortEntry -- Entry for keyboard abort. 341 * 342 * abortEntry() 343 */ 344 345 /* 346 * Functions and defines to access the monitor. 347 */ 348 349 #define mon_printf (romVectorPtr->printf) 350 #define mon_putchar (romVectorPtr->putChar) 351 #define mon_may_getchar (romVectorPtr->mayGet) 352 #define mon_exit_to_mon (romVectorPtr->exitToMon) 353 #define mon_reboot (romVectorPtr->reBoot) 354 355 356 /* 357 * Sun3 specific stuff... 358 */ 359 360 #ifdef _SUN3_ 361 #define setcxsegmap mon_un.un3.un3_setcxsegmap 362 #define vector_cmd mon_un.un3.un3_vector_cmd 363 #define romVectorPtr ((struct sunromvec *) SUN3_PROM_BASE) 364 #endif /* SUN3 */ 365 366 /* 367 * MONSTART and MONEND denote the range used by the monitor. 368 * PROM_BASE is the virtual address of the PROM. 369 */ 370 #define SUN3_MONSTART 0x0FE00000 371 #define SUN3_PROM_BASE 0x0FEF0000 372 #define SUN3_MONEND 0x0FF00000 373 374 /* 375 * These describe the monitor's short segment (one it can reach using 376 * short PC-relative addressing) which it uses to map its data page. 377 * MONSHORTPAGE is the page; MONSHORTSEG is the containing segment. 378 * Its mapping must not be removed or the PROM monitor will fail. 379 * MONSHORTPAGE is also where the "ie" puts its SCP. 380 */ 381 #define SUN3_MONSHORTPAGE 0x0FFFE000 382 #define SUN3_MONSHORTSEG 0x0FFE0000 383 384 /* 385 * Sun3X specific stuff... 386 */ 387 388 #ifdef _SUN3X_ 389 #define vector_cmd mon_un.un3x.un3x_vector_cmd 390 #define lomemptaddr mon_un.un3x.un3x_lomemptaddr 391 #define monptaddr mon_un.un3x.un3x_monptaddr 392 #define dvmaptaddr mon_un.un3x.un3x_dvmaptaddr 393 #define monptphysaddr mon_un.un3x.un3x_monptphysaddr 394 #define shadowpteaddr mon_un.un3x.un3x_shadowpteaddr 395 #define v_physmemory mon_un.un3x.un3x_physmemory 396 #define romVectorPtr ((struct sunromvec *) SUN3X_PROM_BASE) 397 #endif /* SUN3X */ 398 399 /* 400 * We don't have a separate kernel debugger like sun kadb, 401 * but this range is setup by the monitor for such a thing. 402 * We might as well preserve the mappings anyway. 403 */ 404 #define SUN3X_MON_KDB_BASE 0xFEE00000 405 #define SUN3X_MON_KDB_SIZE 0x100000 406 407 /* 408 * MONSTART and MONEND define the range used by the monitor. 409 * MONDATA is its data page (do not touch!) 410 * PROM_BASE is where the boot PROM lives. 411 */ 412 #define SUN3X_MONSTART 0xFEF00000 413 #define SUN3X_MONDATA 0xFEF72000 414 #define SUN3X_PROM_BASE 0xFEFE0000 415 #define SUN3X_MONEND 0xFF000000 416 417 /* 418 * These define the CPU virtual address range mapped by the 419 * PROM for use as DVMA space. The physical pages mapped in 420 * this range are also mapped by the I/O MMU. Note that the 421 * last page is reserved for the PROM (really for the "ie"). 422 */ 423 #define SUN3X_MON_DVMA_BASE 0xFFF00000 424 #define SUN3X_MON_DVMA_SIZE 0x100000 /* 1MB */ 425 426 #ifdef _STANDALONE 427 /* The libsa code uses a pointer... */ 428 extern struct sunromvec *_romvec; 429 #undef romVectorPtr 430 #define romVectorPtr _romvec 431 #endif /* _STANDALONE */ 432 433 #endif /* _MACHINE_MON_H */ 434