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