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