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