Home | History | Annotate | Line # | Download | only in include
oldmon.h revision 1.7
      1 /*	$NetBSD: oldmon.h,v 1.7 1996/02/13 17:04:59 christos 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  * The table entry that describes a device.  It exists in the PROM; a
     78  * pointer to it is passed in MachMonBootParam.  It can be used to locate
     79  * PROM subroutines for opening, reading, and writing the device.
     80  *
     81  * When using this interface, only one device can be open at once.
     82  *
     83  * NOTE: I am not sure what arguments boot, open, close, and strategy take.
     84  * What is here is just translated verbatim from the sun monitor code.  We
     85  * should figure this out eventually if we need it.
     86  */
     87 struct om_boottable {
     88 	char	b_devname[2];		/* The name of the device */
     89 	int	(*b_probe) __P((void));	/* probe() --> -1 or found controller
     90 					   number */
     91 	int	(*b_boot) __P((void));	/* boot(bp) --> -1 or start address */
     92 	int	(*b_open) __P((void));	/* open(iobp) --> -1 or 0 */
     93 	int	(*b_close) __P((void));	/* close(iobp) --> -1 or 0 */
     94 	int	(*b_strategy) __P((void));/* strategy(iobp,rw) --> -1 or 0 */
     95 	char	*b_desc;		/* Printable string describing dev */
     96 	struct devinfo *b_devinfo;      /* info to configure device. */
     97 };
     98 
     99 /*
    100  * Structure set up by the boot command to pass arguments to the program that
    101  * is booted.
    102  */
    103 struct om_bootparam {
    104 	char	*argPtr[8];		/* String arguments */
    105 	char	strings[100];		/* String table for string arguments */
    106 	char	devName[2];		/* Device name */
    107 	int	ctlrNum;		/* Controller number */
    108 	int	unitNum;		/* Unit number */
    109 	int	partNum;		/* Partition/file number */
    110 	char	*fileName;		/* File name, points into strings */
    111 	struct om_boottable *bootTable;	/* Points to table entry for device */
    112 };
    113 
    114 /*
    115  * Here is the structure of the vector table which is at the front of the boot
    116  * rom.  The functions defined in here are explained below.
    117  *
    118  * NOTE: This struct has references to the structures keybuf and globram which
    119  *       I have not translated.  If anyone needs to use these they should
    120  *       translate these structs into Sprite format.
    121  */
    122 struct om_vector {
    123 	char	*initSp;		/* Initial system stack ptr for hardware */
    124 	int	(*startMon) __P((void));/* Initial PC for hardware */
    125 	int	*diagberr;		/* Bus err handler for diags */
    126 
    127 	/* Monitor and hardware revision and identification */
    128 	struct om_bootparam **bootParam;	/* Info for bootstrapped pgm */
    129  	u_long	*memorySize;		/* Usable memory in bytes */
    130 
    131 	/* Single-character input and output */
    132 	int	(*getChar) __P((void));	/* Get char from input source */
    133 	void	(*putChar) __P((int));	/* Put char to output sink */
    134 	int	(*mayGet) __P((void));	/* Maybe get char, or -1 */
    135 	int	(*mayPut) __P((int));	/* Maybe put char, or -1 */
    136 	u_char	*echo;			/* Should getchar echo? */
    137 	u_char	*inSource;		/* Input source selector */
    138 	u_char	*outSink;		/* Output sink selector */
    139 #define	PROMDEV_KBD	0		/* input from keyboard */
    140 #define	PROMDEV_SCREEN	0		/* output to screen */
    141 #define	PROMDEV_TTYA	1		/* in/out to ttya */
    142 #define	PROMDEV_TTYB	2		/* in/out to ttyb */
    143 
    144 	/* Keyboard input (scanned by monitor nmi routine) */
    145 	int	(*getKey) __P((void));	/* Get next key if one exists */
    146 	int	(*initGetKey) __P((void));/* Initialize get key */
    147 	u_int	*translation;		/* Kbd translation selector */
    148 	u_char	*keyBid;		/* Keyboard ID byte */
    149 	int	*screen_x;		/* V2: Screen x pos (R/O) */
    150 	int	*screen_y;		/* V2: Screen y pos (R/O) */
    151 	struct keybuf	*keyBuf;	/* Up/down keycode buffer */
    152 
    153 	/* Monitor revision level. */
    154 	char	*monId;
    155 
    156 	/* Frame buffer output and terminal emulation */
    157 	int	(*fbWriteChar) __P((void));/* Write a character to FB */
    158 	int	*fbAddr;		/* Address of frame buffer */
    159 	char	**font;			/* Font table for FB */
    160 	void	(*fbWriteStr) __P((char *, int));
    161 					/* Quickly write string to FB */
    162 
    163 	/* Reboot interface routine -- resets and reboots system. */
    164 	void	(*reBoot) __P((char *));	/* e.g. reBoot("xy()vmunix") */
    165 
    166 	/* Line input and parsing */
    167 	u_char	*lineBuf;		/* The line input buffer */
    168 	u_char	**linePtr;		/* Cur pointer into linebuf */
    169 	int	*lineSize;		/* length of line in linebuf */
    170 	int	(*getLine) __P((void));	/* Get line from user */
    171 	u_char	(*getNextChar) __P((void));/* Get next char from linebuf */
    172 	u_char	(*peekNextChar) __P((void));/* Peek at next char */
    173 	int	*fbThere;		/* =1 if frame buffer there */
    174 	int	(*getNum) __P((void));	/* Grab hex num from line */
    175 
    176 	/* Print formatted output to current output sink */
    177 	int	(*printf) __P((void));	/* Similar to "Kernel printf" */
    178 	int	(*printHex) __P((void));/* Format N digits in hex */
    179 
    180 	/* Led stuff */
    181 	u_char	*leds;			/* RAM copy of LED register */
    182 	int	(*setLeds) __P((void));	/* Sets LED's and RAM copy */
    183 
    184 	/* Non-maskable interrupt  (nmi) information */
    185 	int	(*nmiAddr) __P((void));	/* Addr for level 7 vector */
    186 	void	(*abortEntry) __P((void));/* Entry for keyboard abort */
    187 	int	*nmiClock;		/* Counts up in msec */
    188 
    189 	/* Frame buffer type: see <machine/fbio.h> */
    190 	int	*fbType;
    191 
    192 	/* Assorted other things */
    193 	u_long	romvecVersion;		/* Version # of Romvec */
    194 	struct globram *globRam;	/* monitor global variables */
    195 	caddr_t	kbdZscc;		/* Addr of keyboard in use */
    196 
    197 	int	*keyrInit;		/* ms before kbd repeat */
    198 	u_char	*keyrTick; 		/* ms between repetitions */
    199 	u_long	*memoryAvail;		/* V1: Main mem usable size */
    200 	long	*resetAddr;		/* where to jump on a reset */
    201 	long	*resetMap;		/* pgmap entry for resetaddr */
    202 					/* Really struct pgmapent *  */
    203 
    204 	__dead void (*exitToMon) __P((void));/* Exit from user program */
    205 	u_char	**memorybitmap;		/* V1: &{0 or &bits} */
    206 	void	(*setcxsegmap)		/* Set seg in any context */
    207 		    __P((int, caddt_t, int));
    208 	void	(**vector_cmd) __P((void));/* V2: Handler for 'v' cmd */
    209   	u_long	*ExpectedTrapSig;
    210   	u_long	*TrapVectorTable;
    211 	int	dummy1z;
    212 	int	dummy2z;
    213 	int	dummy3z;
    214 	int	dummy4z;
    215 };
    216 
    217 #define	romVectorPtr	((struct om_vector *)PROM_BASE)
    218 
    219 #define mon_printf (romVectorPtr->printf)
    220 #define mon_putchar (romVectorPtr->putChar)
    221 #define mon_may_getchar (romVectorPtr->mayGet)
    222 #define mon_exit_to_mon (romVectorPtr->exitToMon)
    223 #define mon_reboot (romVectorPtr->exitToMon)
    224 #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();}
    225 
    226 #define mon_setcxsegmap(context, va, sme) \
    227     romVectorPtr->setcxsegmap(context, va, sme)
    228 #define romp (romVectorPtr)
    229 
    230 /*
    231  * OLDMON_STARTVADDR and OLDMON_ENDVADDR denote the range of the damn monitor.
    232  *
    233  * supposedly you can steal pmegs within this range that do not contain
    234  * valid pages.
    235  */
    236 #define OLDMON_STARTVADDR	0xFFD00000
    237 #define OLDMON_ENDVADDR		0xFFF00000
    238 
    239 /*
    240  * These describe the monitor's short segment which it basically uses to map
    241  * one stupid page that it uses for storage.  MONSHORTPAGE is the page,
    242  * and MONSHORTSEG is the segment that it is in.  If this sounds dumb to
    243  * you, it is.  I can change the pmeg, but not the virtual address.
    244  * Sun defines these with the high nibble set to 0xF.  I believe this was
    245  * for the monitor source which accesses this piece of memory with addressing
    246  * limitations or some such crud.  I haven't replicated this here, because
    247  * it is confusing, and serves no obvious purpose if you aren't the monitor.
    248  *
    249  */
    250 #define MONSHORTPAGE	0x0FFFE000
    251 #define MONSHORTSEG	0x0FFE0000
    252 
    253 /*
    254  * A "stand alone I/O request".
    255  * This is passed as the main argument to the PROM I/O routines
    256  * in the `om_boottable' structure.
    257  */
    258 struct saioreq {
    259 	char	si_flgs;
    260 	struct om_boottable *si_boottab;/* Points to boottab entry if any */
    261 	char	*si_devdata;		/* Device-specific data pointer */
    262 	int	si_ctlr;		/* Controller number or address */
    263 	int	si_unit;		/* Unit number within controller */
    264 	long	si_boff;		/* Partition number within unit */
    265 	long	si_cyloff;
    266 	long	si_offset;
    267 	long	si_bn;			/* Block number to R/W */
    268 	char	*si_ma;			/* Memory address to R/W */
    269 	int	si_cc;			/* Character count to R/W */
    270 	struct	saif *si_sif;		/* net if. pointer (set by b_open) */
    271 	char 	*si_devaddr;		/* Points to mapped in device */
    272 	char	*si_dmaaddr;		/* Points to allocated DMA space */
    273 };
    274 #define SAIO_F_READ	0x01
    275 #define SAIO_F_WRITE	0x02
    276 #define SAIO_F_ALLOC	0x04
    277 #define SAIO_F_FILE	0x08
    278 #define	SAIO_F_EOF	0x10	/* EOF on device */
    279 #define SAIO_F_AJAR	0x20	/* Descriptor "ajar" (stopped but not closed) */
    280 
    281 
    282 /*
    283  * Ethernet interface descriptor
    284  * First, set: saiop->si_devaddr, saiop->si_dmaaddr, etc.
    285  * Then:  saiop->si_boottab->b_open()  will set:
    286  *   saiop->si_sif;
    287  *   saiop->si_devdata;
    288  * The latter is the first arg to the following functions.
    289  * Note that the buffer must be in DVMA space...
    290  */
    291 struct saif {
    292 	/* transmit packet, returns zero on success. */
    293 	int	(*sif_xmit)(void *devdata, char *buf, int len);
    294 	/* wait for packet, zero if none arrived */
    295 	int	(*sif_poll)(void *devdata, char *buf);
    296 	/* reset interface, set addresses, etc. */
    297 	int	(*sif_reset)(void *devdata, struct saioreq *sip);
    298 	/* Later (sun4 only) proms have more stuff here. */
    299 };
    300 #endif /* _MACHINE_OLDMON_H */
    301