1*53524e44Schristos /* $NetBSD: oldmon.h,v 1.17 2007/03/04 06:00:44 christos Exp $ */ 2274a9076Sderaadt 3c6a626e1Sderaadt /* 4c6a626e1Sderaadt * Copyright (C) 1985 Regents of the University of California 5c6a626e1Sderaadt * Copyright (c) 1993 Adam Glass 6c6a626e1Sderaadt * All rights reserved. 7c6a626e1Sderaadt * 8c6a626e1Sderaadt * Redistribution and use in source and binary forms, with or without 9c6a626e1Sderaadt * modification, are permitted provided that the following conditions 10c6a626e1Sderaadt * are met: 11c6a626e1Sderaadt * 1. Redistributions of source code must retain the above copyright 12c6a626e1Sderaadt * notice, this list of conditions and the following disclaimer. 13c6a626e1Sderaadt * 2. Redistributions in binary form must reproduce the above copyright 14c6a626e1Sderaadt * notice, this list of conditions and the following disclaimer in the 15c6a626e1Sderaadt * documentation and/or other materials provided with the distribution. 16c6a626e1Sderaadt * 3. All advertising materials mentioning features or use of this software 17c6a626e1Sderaadt * must display the following acknowledgement: 18c6a626e1Sderaadt * This product includes software developed by Adam Glass. 19c6a626e1Sderaadt * 4. The name of the Author may not be used to endorse or promote products 20c6a626e1Sderaadt * derived from this software without specific prior written permission. 21c6a626e1Sderaadt * 22c6a626e1Sderaadt * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND 23c6a626e1Sderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24c6a626e1Sderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25c6a626e1Sderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26c6a626e1Sderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27c6a626e1Sderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28c6a626e1Sderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29c6a626e1Sderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30c6a626e1Sderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31c6a626e1Sderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32c6a626e1Sderaadt * SUCH DAMAGE. 33c6a626e1Sderaadt * 34c6a626e1Sderaadt * from: Sprite /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v 35c6a626e1Sderaadt * 9.1 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley) 36c6a626e1Sderaadt */ 37c6a626e1Sderaadt #ifndef _MACHINE_OLDMON_H 38c6a626e1Sderaadt #define _MACHINE_OLDMON_H 39c6a626e1Sderaadt 40860b0688Sdarrenr #if defined(_KERNEL_OPT) 41860b0688Sdarrenr #include "opt_sparc_arch.h" 42860b0688Sdarrenr #endif 43860b0688Sdarrenr 44c6a626e1Sderaadt /* 45c6a626e1Sderaadt * Structures, constants and defines for access to the sun monitor. 46c6a626e1Sderaadt * These are translated from the sun monitor header file "sunromvec.h". 47c6a626e1Sderaadt * 48c6a626e1Sderaadt * The memory addresses for the PROM, and the EEPROM. 49c6a626e1Sderaadt * On the sun2 these addresses are actually 0x00EF??00 50c6a626e1Sderaadt * but only the bottom 24 bits are looked at so these still 51c6a626e1Sderaadt * work ok. 52c6a626e1Sderaadt */ 53c6a626e1Sderaadt #define PROM_BASE 0xffe81000 54c6a626e1Sderaadt 55af6e3d03Spk enum maptypes { /* Page map entry types. */ 56af6e3d03Spk MAP_MAINMEM, 57af6e3d03Spk MAP_OBIO, 58af6e3d03Spk MAP_MBMEM, 59af6e3d03Spk MAP_MBIO, 60af6e3d03Spk MAP_VME16A16D, 61af6e3d03Spk MAP_VME16A32D, 62af6e3d03Spk MAP_VME24A16D, 63af6e3d03Spk MAP_VME24A32D, 64af6e3d03Spk MAP_VME32A16D, 65af6e3d03Spk MAP_VME32A32D 66af6e3d03Spk }; 67af6e3d03Spk /* 68af6e3d03Spk * This table gives information about the resources needed by a device. 69af6e3d03Spk */ 70af6e3d03Spk struct devinfo { 71af6e3d03Spk unsigned int d_devbytes; /* Bytes occupied by device in IO space.*/ 72af6e3d03Spk unsigned int d_dmabytes; /* Bytes needed by device in DMA memory.*/ 73af6e3d03Spk unsigned int d_localbytes;/* Bytes needed by device for local info.*/ 74af6e3d03Spk unsigned int d_stdcount; /* How many standard addresses. */ 75af6e3d03Spk unsigned long *d_stdaddrs; /* The vector of standard addresses. */ 76af6e3d03Spk enum maptypes d_devtype; /* What map space device is in. */ 77af6e3d03Spk unsigned int d_maxiobytes;/* Size to break big I/O's into. */ 78af6e3d03Spk }; 79af6e3d03Spk 80c6a626e1Sderaadt /* 81e259a024Spk * A "stand alone I/O request". 82e259a024Spk * This is passed as the main argument to the PROM I/O routines 83e259a024Spk * in the `om_boottable' structure. 84e259a024Spk */ 85e259a024Spk struct saioreq { 86e259a024Spk char si_flgs; 87e259a024Spk struct om_boottable *si_boottab;/* Points to boottab entry if any */ 88e259a024Spk char *si_devdata; /* Device-specific data pointer */ 89e259a024Spk int si_ctlr; /* Controller number or address */ 90e259a024Spk int si_unit; /* Unit number within controller */ 91e259a024Spk long si_boff; /* Partition number within unit */ 92e259a024Spk long si_cyloff; 93e259a024Spk long si_offset; 94e259a024Spk long si_bn; /* Block number to R/W */ 95e259a024Spk char *si_ma; /* Memory address to R/W */ 96e259a024Spk int si_cc; /* Character count to R/W */ 97e259a024Spk struct saif *si_sif; /* net if. pointer (set by b_open) */ 98e259a024Spk char *si_devaddr; /* Points to mapped in device */ 99e259a024Spk char *si_dmaaddr; /* Points to allocated DMA space */ 100e259a024Spk }; 101e259a024Spk #define SAIO_F_READ 0x01 102e259a024Spk #define SAIO_F_WRITE 0x02 103e259a024Spk #define SAIO_F_ALLOC 0x04 104e259a024Spk #define SAIO_F_FILE 0x08 105e259a024Spk #define SAIO_F_EOF 0x10 /* EOF on device */ 106e259a024Spk #define SAIO_F_AJAR 0x20 /* Descriptor "ajar" (stopped but not closed) */ 107e259a024Spk 108e259a024Spk 109e259a024Spk /* 110c6a626e1Sderaadt * The table entry that describes a device. It exists in the PROM; a 111c6a626e1Sderaadt * pointer to it is passed in MachMonBootParam. It can be used to locate 112c6a626e1Sderaadt * PROM subroutines for opening, reading, and writing the device. 113c6a626e1Sderaadt * 114c6a626e1Sderaadt * When using this interface, only one device can be open at once. 115c6a626e1Sderaadt * 116c6a626e1Sderaadt * NOTE: I am not sure what arguments boot, open, close, and strategy take. 117c6a626e1Sderaadt * What is here is just translated verbatim from the sun monitor code. We 118c6a626e1Sderaadt * should figure this out eventually if we need it. 119c6a626e1Sderaadt */ 120c6a626e1Sderaadt struct om_boottable { 121af6e3d03Spk char b_devname[2]; /* The name of the device */ 1228ea3cb44Suwe int (*b_probe)(void); /* probe() --> -1 or found controller 123c6a626e1Sderaadt number */ 1248ea3cb44Suwe int (*b_boot)(void); /* boot(bp) --> -1 or start address */ 1258ea3cb44Suwe int (*b_open)(struct saioreq *); 1268ea3cb44Suwe /* open(iobp) --> -1 or 0 */ 1278ea3cb44Suwe int (*b_close)(struct saioreq *); 1288ea3cb44Suwe /* close(iobp) --> -1 or 0 */ 1298ea3cb44Suwe int (*b_strategy)(struct saioreq *, int); 1308ea3cb44Suwe /* strategy(iobp,rw) --> -1 or 0 */ 131af6e3d03Spk char *b_desc; /* Printable string describing dev */ 132af6e3d03Spk struct devinfo *b_devinfo; /* info to configure device. */ 133c6a626e1Sderaadt }; 134c6a626e1Sderaadt 135c6a626e1Sderaadt /* 136c6a626e1Sderaadt * Structure set up by the boot command to pass arguments to the program that 137c6a626e1Sderaadt * is booted. 138c6a626e1Sderaadt */ 139c6a626e1Sderaadt struct om_bootparam { 140c6a626e1Sderaadt char *argPtr[8]; /* String arguments */ 141c6a626e1Sderaadt char strings[100]; /* String table for string arguments */ 142c6a626e1Sderaadt char devName[2]; /* Device name */ 143c6a626e1Sderaadt int ctlrNum; /* Controller number */ 144c6a626e1Sderaadt int unitNum; /* Unit number */ 145c6a626e1Sderaadt int partNum; /* Partition/file number */ 146c6a626e1Sderaadt char *fileName; /* File name, points into strings */ 147c6a626e1Sderaadt struct om_boottable *bootTable; /* Points to table entry for device */ 148c6a626e1Sderaadt }; 149c6a626e1Sderaadt 150c6a626e1Sderaadt /* 151c6a626e1Sderaadt * Here is the structure of the vector table which is at the front of the boot 152c6a626e1Sderaadt * rom. The functions defined in here are explained below. 153c6a626e1Sderaadt * 154c6a626e1Sderaadt * NOTE: This struct has references to the structures keybuf and globram which 155c6a626e1Sderaadt * I have not translated. If anyone needs to use these they should 156c6a626e1Sderaadt * translate these structs into Sprite format. 157c6a626e1Sderaadt */ 158c6a626e1Sderaadt struct om_vector { 159c6a626e1Sderaadt char *initSp; /* Initial system stack ptr for hardware */ 1608ea3cb44Suwe int (*startMon)(void); /* Initial PC for hardware */ 161c6a626e1Sderaadt int *diagberr; /* Bus err handler for diags */ 162c6a626e1Sderaadt 163c6a626e1Sderaadt /* Monitor and hardware revision and identification */ 164c6a626e1Sderaadt struct om_bootparam **bootParam; /* Info for bootstrapped pgm */ 165c6a626e1Sderaadt u_long *memorySize; /* Usable memory in bytes */ 166c6a626e1Sderaadt 167c6a626e1Sderaadt /* Single-character input and output */ 1688ea3cb44Suwe int (*getChar)(void); /* Get char from input source */ 1698ea3cb44Suwe void (*putChar)(int); /* Put char to output sink */ 1708ea3cb44Suwe int (*mayGet)(void); /* Maybe get char, or -1 */ 1718ea3cb44Suwe int (*mayPut)(int); /* Maybe put char, or -1 */ 172c6a626e1Sderaadt u_char *echo; /* Should getchar echo? */ 173c6a626e1Sderaadt u_char *inSource; /* Input source selector */ 174c6a626e1Sderaadt u_char *outSink; /* Output sink selector */ 175c6a626e1Sderaadt #define PROMDEV_KBD 0 /* input from keyboard */ 176c6a626e1Sderaadt #define PROMDEV_SCREEN 0 /* output to screen */ 177c6a626e1Sderaadt #define PROMDEV_TTYA 1 /* in/out to ttya */ 178c6a626e1Sderaadt #define PROMDEV_TTYB 2 /* in/out to ttyb */ 179c6a626e1Sderaadt 180c6a626e1Sderaadt /* Keyboard input (scanned by monitor nmi routine) */ 1818ea3cb44Suwe int (*getKey)(void); /* Get next key if one exists */ 1828ea3cb44Suwe int (*initGetKey)(void); /* Initialize get key */ 183c6a626e1Sderaadt u_int *translation; /* Kbd translation selector */ 184c6a626e1Sderaadt u_char *keyBid; /* Keyboard ID byte */ 185c6a626e1Sderaadt int *screen_x; /* V2: Screen x pos (R/O) */ 186c6a626e1Sderaadt int *screen_y; /* V2: Screen y pos (R/O) */ 187c6a626e1Sderaadt struct keybuf *keyBuf; /* Up/down keycode buffer */ 188c6a626e1Sderaadt 189c6a626e1Sderaadt /* Monitor revision level. */ 190c6a626e1Sderaadt char *monId; 191c6a626e1Sderaadt 192c6a626e1Sderaadt /* Frame buffer output and terminal emulation */ 1938ea3cb44Suwe int (*fbWriteChar)(void); /* Write a character to FB */ 194c6a626e1Sderaadt int *fbAddr; /* Address of frame buffer */ 195c6a626e1Sderaadt char **font; /* Font table for FB */ 1968ea3cb44Suwe void (*fbWriteStr)(const char *, int); 197c6edd77bSchristos /* Quickly write string to FB */ 198c6a626e1Sderaadt 199c6a626e1Sderaadt /* Reboot interface routine -- resets and reboots system. */ 2008ea3cb44Suwe void (*reBoot)(const char *) /* e.g. reBoot("xy()vmunix") */ 2011e5bf777Spk __attribute__((__noreturn__)); 202c6a626e1Sderaadt 203c6a626e1Sderaadt /* Line input and parsing */ 204c6a626e1Sderaadt u_char *lineBuf; /* The line input buffer */ 205c6a626e1Sderaadt u_char **linePtr; /* Cur pointer into linebuf */ 206c6a626e1Sderaadt int *lineSize; /* length of line in linebuf */ 2078ea3cb44Suwe int (*getLine)(void); /* Get line from user */ 2088ea3cb44Suwe u_char (*getNextChar)(void); /* Get next char from linebuf */ 2098ea3cb44Suwe u_char (*peekNextChar)(void); /* Peek at next char */ 210c6a626e1Sderaadt int *fbThere; /* =1 if frame buffer there */ 2118ea3cb44Suwe int (*getNum)(void); /* Grab hex num from line */ 212c6a626e1Sderaadt 213c6a626e1Sderaadt /* Print formatted output to current output sink */ 2148ea3cb44Suwe int (*printf)(void); /* Similar to "Kernel printf" */ 2158ea3cb44Suwe int (*printHex)(void); /* Format N digits in hex */ 216c6a626e1Sderaadt 217c6a626e1Sderaadt /* Led stuff */ 218c6a626e1Sderaadt u_char *leds; /* RAM copy of LED register */ 2198ea3cb44Suwe int (*setLeds)(void); /* Sets LED's and RAM copy */ 220c6a626e1Sderaadt 221c6a626e1Sderaadt /* Non-maskable interrupt (nmi) information */ 2228ea3cb44Suwe int (*nmiAddr)(void); /* Addr for level 7 vector */ 2238ea3cb44Suwe void (*abortEntry)(void); /* Entry for keyboard abort */ 224c6a626e1Sderaadt int *nmiClock; /* Counts up in msec */ 225c6a626e1Sderaadt 226c6a626e1Sderaadt /* Frame buffer type: see <machine/fbio.h> */ 227c6a626e1Sderaadt int *fbType; 228c6a626e1Sderaadt 229c6a626e1Sderaadt /* Assorted other things */ 230c6a626e1Sderaadt u_long romvecVersion; /* Version # of Romvec */ 231c6a626e1Sderaadt struct globram *globRam; /* monitor global variables */ 232*53524e44Schristos void * kbdZscc; /* Addr of keyboard in use */ 233c6a626e1Sderaadt 234c6a626e1Sderaadt int *keyrInit; /* ms before kbd repeat */ 235c6a626e1Sderaadt u_char *keyrTick; /* ms between repetitions */ 236c6a626e1Sderaadt u_long *memoryAvail; /* V1: Main mem usable size */ 237c6a626e1Sderaadt long *resetAddr; /* where to jump on a reset */ 238c6a626e1Sderaadt long *resetMap; /* pgmap entry for resetaddr */ 239c6a626e1Sderaadt /* Really struct pgmapent * */ 240c6a626e1Sderaadt 2418ea3cb44Suwe __dead void (*exitToMon)(void) /* Exit from user program */ 2421e5bf777Spk __attribute__((noreturn)); 243c6a626e1Sderaadt u_char **memorybitmap; /* V1: &{0 or &bits} */ 244cbb1d18eSchristos void (*setcxsegmap) /* Set seg in any context */ 245*53524e44Schristos (int, void *, int); 2468ea3cb44Suwe void (**vector_cmd)(u_long, char *); 2478ea3cb44Suwe /* V2: Handler for 'v' cmd */ 248c6a626e1Sderaadt u_long *ExpectedTrapSig; 249c6a626e1Sderaadt u_long *TrapVectorTable; 250c6a626e1Sderaadt int dummy1z; 251c6a626e1Sderaadt int dummy2z; 252c6a626e1Sderaadt int dummy3z; 253c6a626e1Sderaadt int dummy4z; 254c6a626e1Sderaadt }; 255c6a626e1Sderaadt 256c6a626e1Sderaadt #define romVectorPtr ((struct om_vector *)PROM_BASE) 257c6a626e1Sderaadt 258c6a626e1Sderaadt #define mon_printf (romVectorPtr->printf) 259c6a626e1Sderaadt #define mon_putchar (romVectorPtr->putChar) 260c6a626e1Sderaadt #define mon_may_getchar (romVectorPtr->mayGet) 261c6a626e1Sderaadt #define mon_exit_to_mon (romVectorPtr->exitToMon) 262c6a626e1Sderaadt #define mon_reboot (romVectorPtr->exitToMon) 263c6a626e1Sderaadt #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();} 264c6a626e1Sderaadt 265c6a626e1Sderaadt #define mon_setcxsegmap(context, va, sme) \ 266c6a626e1Sderaadt romVectorPtr->setcxsegmap(context, va, sme) 267c6a626e1Sderaadt 268c6a626e1Sderaadt /* 269c28af547Sderaadt * OLDMON_STARTVADDR and OLDMON_ENDVADDR denote the range of the damn monitor. 270c6a626e1Sderaadt * 271c6a626e1Sderaadt * supposedly you can steal pmegs within this range that do not contain 272c6a626e1Sderaadt * valid pages. 273c6a626e1Sderaadt */ 274c28af547Sderaadt #define OLDMON_STARTVADDR 0xFFD00000 275c28af547Sderaadt #define OLDMON_ENDVADDR 0xFFF00000 276c6a626e1Sderaadt 277c6a626e1Sderaadt /* 278c6a626e1Sderaadt * These describe the monitor's short segment which it basically uses to map 279c6a626e1Sderaadt * one stupid page that it uses for storage. MONSHORTPAGE is the page, 280c6a626e1Sderaadt * and MONSHORTSEG is the segment that it is in. If this sounds dumb to 281c6a626e1Sderaadt * you, it is. I can change the pmeg, but not the virtual address. 282c6a626e1Sderaadt * Sun defines these with the high nibble set to 0xF. I believe this was 283c6a626e1Sderaadt * for the monitor source which accesses this piece of memory with addressing 284c6a626e1Sderaadt * limitations or some such crud. I haven't replicated this here, because 285c6a626e1Sderaadt * it is confusing, and serves no obvious purpose if you aren't the monitor. 286c6a626e1Sderaadt * 287c6a626e1Sderaadt */ 288c6a626e1Sderaadt #define MONSHORTPAGE 0x0FFFE000 289c6a626e1Sderaadt #define MONSHORTSEG 0x0FFE0000 290c6a626e1Sderaadt 291af6e3d03Spk 292af6e3d03Spk 293af6e3d03Spk /* 294af6e3d03Spk * Ethernet interface descriptor 295af6e3d03Spk * First, set: saiop->si_devaddr, saiop->si_dmaaddr, etc. 296af6e3d03Spk * Then: saiop->si_boottab->b_open() will set: 297af6e3d03Spk * saiop->si_sif; 298af6e3d03Spk * saiop->si_devdata; 299af6e3d03Spk * The latter is the first arg to the following functions. 300af6e3d03Spk * Note that the buffer must be in DVMA space... 301af6e3d03Spk */ 302af6e3d03Spk struct saif { 303af6e3d03Spk /* transmit packet, returns zero on success. */ 304af6e3d03Spk int (*sif_xmit)(void *devdata, char *buf, int len); 305af6e3d03Spk /* wait for packet, zero if none arrived */ 306af6e3d03Spk int (*sif_poll)(void *devdata, char *buf); 307af6e3d03Spk /* reset interface, set addresses, etc. */ 308af6e3d03Spk int (*sif_reset)(void *devdata, struct saioreq *sip); 309af6e3d03Spk /* Later (sun4 only) proms have more stuff here. */ 310af6e3d03Spk }; 3119a07d9deSchristos 3129a07d9deSchristos 3139a07d9deSchristos #if defined(SUN4) 3148ea3cb44Suwe void oldmon_w_trace(u_long); 3158ea3cb44Suwe void oldmon_w_cmd(u_long, char *); 3169a07d9deSchristos #endif 3179a07d9deSchristos 318c6edd77bSchristos #endif /* _MACHINE_OLDMON_H */ 319