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