Home | History | Annotate | Line # | Download | only in include
mon.h revision 1.10
      1 /*
      2  * Copyright (c) 1993 Adam Glass
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  * 3. All advertising materials mentioning features or use of this software
     14  *    must display the following acknowledgement:
     15  *	This product includes software developed by Adam Glass.
     16  * 4. 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  * $Header: /tank/opengrok/rsync2/NetBSD/src/sys/arch/sun3/include/mon.h,v 1.10 1993/08/28 15:36:16 glass Exp $
     32  */
     33 /*
     34  * This file derived from kernel/mach/sun3.md/machMon.h from the
     35  * sprite distribution.
     36  *
     37  * In particular, this file came out of the Walnut Creek cdrom collection
     38  * which contained no warnings about any possible copyright infringement
     39  * It was also indentical to a file in the sprite kernel tar file found on
     40  * allspice.berkeley.edu.
     41  * It also written in the annoying sprite coding style.  I've made
     42  * efforts not to heavily edit their file, just ifdef parts out. -- glass
     43  */
     44 
     45 #ifndef _MACHINE_MON_H
     46 #define _MACHINE_MON_H
     47 /*
     48  * machMon.h --
     49  *
     50  *     Structures, constants and defines for access to the sun monitor.
     51  *     These are translated from the sun monitor header file "sunromvec.h".
     52  *
     53  * NOTE: The file keyboard.h in the monitor directory has all sorts of useful
     54  *       keyboard stuff defined.  I haven't attempted to translate that file
     55  *       because I don't need it.  If anyone wants to use it, be my guest.
     56  *
     57  * Copyright (C) 1985 Regents of the University of California
     58  * All rights reserved.
     59  *
     60  *
     61  * Header: /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v 9.1 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley)
     62  */
     63 
     64 #ifndef _MACHMON
     65 #define _MACHMON
     66 
     67 /*
     68  * The memory addresses for the PROM, and the EEPROM.
     69  * On the sun2 these addresses are actually 0x00EF??00
     70  * but only the bottom 24 bits are looked at so these still
     71  * work ok.
     72  */
     73 
     74 #define PROM_BASE       0x0fef0000
     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 
     88 typedef struct {
     89 	char	devName[2];		/* The name of the device */
     90 	int	(*probe)();		/* probe() --> -1 or found controller
     91 					   number */
     92 	int	(*boot)();		/* boot(bp) --> -1 or start address */
     93 	int	(*open)();		/* open(iobp) --> -1 or 0 */
     94 	int	(*close)();		/* close(iobp) --> -1 or 0 */
     95 	int	(*strategy)();		/* strategy(iobp,rw) --> -1 or 0 */
     96 	char	*desc;			/* Printable string describing dev */
     97 } MachMonBootTable;
     98 
     99 /*
    100  * Structure set up by the boot command to pass arguments to the program that
    101  * is booted.
    102  */
    103 
    104 typedef struct {
    105 	char		*argPtr[8];	/* String arguments */
    106 	char		strings[100];	/* String table for string arguments */
    107 	char		devName[2];	/* Device name */
    108 	int		ctlrNum;	/* Controller number */
    109 	int		unitNum;	/* Unit number */
    110 	int		partNum;	/* Partition/file number */
    111 	char		*fileName;	/* File name, points into strings */
    112 	MachMonBootTable   *bootTable;	/* Points to table entry for device */
    113 } MachMonBootParam;
    114 
    115 /*
    116  * Here is the structure of the vector table which is at the front of the boot
    117  * rom.  The functions defined in here are explained below.
    118  *
    119  * NOTE: This struct has references to the structures keybuf and globram which
    120  *       I have not translated.  If anyone needs to use these they should
    121  *       translate these structs into Sprite format.
    122  */
    123 
    124 typedef struct {
    125 	char		*initSp;		/* Initial system stack ptr
    126 						 * for hardware */
    127 	int		(*startMon)();		/* Initial PC for hardware */
    128 
    129 	int		*diagberr;		/* Bus err handler for diags */
    130 
    131 	/*
    132 	 * Monitor and hardware revision and identification
    133 	 */
    134 
    135 	MachMonBootParam **bootParam;		/* Info for bootstrapped pgm */
    136  	unsigned	*memorySize;		/* Usable memory in bytes */
    137 
    138 	/*
    139 	 * Single-character input and output
    140 	 */
    141 
    142 	unsigned char	(*getChar)();		/* Get char from input source */
    143 	int		(*putChar)();		/* Put char to output sink */
    144 	int		(*mayGet)();		/* Maybe get char, or -1 */
    145 	int		(*mayPut)();		/* Maybe put char, or -1 */
    146 	unsigned char	*echo;			/* Should getchar echo? */
    147 	unsigned char	*inSource;		/* Input source selector */
    148 	unsigned char	*outSink;		/* Output sink selector */
    149 
    150 	/*
    151 	 * Keyboard input (scanned by monitor nmi routine)
    152 	 */
    153 
    154 	int		(*getKey)();		/* Get next key if one exists */
    155 	int		(*initGetKey)();	/* Initialize get key */
    156 	unsigned int	*translation;		/* Kbd translation selector
    157 						   (see keyboard.h in sun
    158 						    monitor code) */
    159 	unsigned char	*keyBid;		/* Keyboard ID byte */
    160 	int		*screen_x;		/* V2: Screen x pos (R/O) */
    161 	int		*screen_y;		/* V2: Screen y pos (R/O) */
    162 	struct keybuf	*keyBuf;		/* Up/down keycode buffer */
    163 
    164 	/*
    165 	 * Monitor revision level.
    166 	 */
    167 
    168 	char		*monId;
    169 
    170 	/*
    171 	 * Frame buffer output and terminal emulation
    172 	 */
    173 
    174 	int		(*fbWriteChar)();	/* Write a character to FB */
    175 	int		*fbAddr;		/* Address of frame buffer */
    176 	char		**font;			/* Font table for FB */
    177 	int		(*fbWriteStr)();	/* Quickly write string to FB */
    178 
    179 	/*
    180 	 * Reboot interface routine -- resets and reboots system.  No return.
    181 	 */
    182 
    183 	int		(*reBoot)();		/* e.g. reBoot("xy()vmunix") */
    184 
    185 	/*
    186 	 * Line input and parsing
    187 	 */
    188 
    189 	unsigned char	*lineBuf;		/* The line input buffer */
    190 	unsigned char	**linePtr;		/* Cur pointer into linebuf */
    191 	int		*lineSize;		/* length of line in linebuf */
    192 	int		(*getLine)();		/* Get line from user */
    193 	unsigned char	(*getNextChar)();	/* Get next char from linebuf */
    194 	unsigned char	(*peekNextChar)();	/* Peek at next char */
    195 	int		*fbThere;		/* =1 if frame buffer there */
    196 	int		(*getNum)();		/* Grab hex num from line */
    197 
    198 	/*
    199 	 * Print formatted output to current output sink
    200 	 */
    201 
    202 	int		(*printf)();		/* Similar to "Kernel printf" */
    203 	int		(*printHex)();		/* Format N digits in hex */
    204 
    205 	/*
    206 	 * Led stuff
    207 	 */
    208 
    209 	unsigned char	*leds;			/* RAM copy of LED register */
    210 	int		(*setLeds)();		/* Sets LED's and RAM copy */
    211 
    212 	/*
    213 	 * Non-maskable interrupt  (nmi) information
    214 	 */
    215 
    216 	int		(*nmiAddr)();		/* Addr for level 7 vector */
    217 	int		(*abortEntry)();	/* Entry for keyboard abort */
    218 	int		*nmiClock;		/* Counts up in msec */
    219 
    220 	/*
    221 	 * Frame buffer type: see <sun/fbio.h>
    222 	 */
    223 
    224 	int		*fbType;
    225 
    226 	/*
    227 	 * Assorted other things
    228 	 */
    229 
    230 	unsigned	romvecVersion;		/* Version # of Romvec */
    231 	struct globram  *globRam;		/* monitor global variables */
    232 	caddr_t		kbdZscc;		/* Addr of keyboard in use */
    233 
    234 	int		*keyrInit;		/* ms before kbd repeat */
    235 	unsigned char	*keyrTick; 		/* ms between repetitions */
    236 	unsigned	*memoryAvail;		/* V1: Main mem usable size */
    237 	long		*resetAddr;		/* where to jump on a reset */
    238 	long		*resetMap;		/* pgmap entry for resetaddr */
    239 						/* Really struct pgmapent *  */
    240 	int		(*exitToMon)();		/* Exit from user program */
    241 	unsigned char	**memorybitmap;		/* V1: &{0 or &bits} */
    242 	void		(*setcxsegmap)();	/* Set seg in any context */
    243 	void		(**vector_cmd)();	/* V2: Handler for 'v' cmd */
    244 	int		dummy1z;
    245 	int		dummy2z;
    246 	int		dummy3z;
    247 	int		dummy4z;
    248 } MachMonRomVector;
    249 
    250 /*
    251  * Functions defined in the vector:
    252  *
    253  *
    254  * getChar -- Return the next character from the input source
    255  *
    256  *     unsigned char getChar()
    257  *
    258  * putChar -- Write the given character to the output source.
    259  *
    260  *     void putChar(ch)
    261  *	   char ch;
    262  *
    263  * mayGet -- Maybe get a character from the current input source.  Return -1
    264  *           if don't return a character.
    265  *
    266  * 	int mayGet()
    267  *
    268  * mayPut -- Maybe put a character to the current output source.   Return -1
    269  *           if no character output.
    270  *
    271  *	int  mayPut(ch)
    272  *	    char ch;
    273  *
    274  * getKey -- Returns a key code (if up/down codes being returned),
    275  * 	     a byte of ASCII (if that's requested),
    276  * 	     NOKEY (if no key has been hit).
    277  *
    278  *	int getKey()
    279  *
    280  * initGetKey --  Initialize things for get key.
    281  *
    282  *	void initGetKey()
    283  *
    284  * fbWriteChar -- Write a character to the frame buffer
    285  *
    286  *	void fwritechar(ch)
    287  *	    unsigned char ch;
    288  *
    289  * fbWriteStr -- Write a string to the frame buffer.
    290  *
    291  *   	void fwritestr(addr,len)
    292  *  	    register unsigned char *addr;	/ * String to be written * /
    293  *  	    register short len;			/ * Length of string * /
    294  *
    295  * getLine -- read the next input line into a global buffer
    296  *
    297  *	getline(echop)
    298  *          int echop;	/ * 1 if should echo input, 0 if not * /
    299  *
    300  * getNextChar -- return the next character from the global line buffer.
    301  *
    302  *	unsigned char getNextChar()
    303  *
    304  * peekNextChar -- look at the next character in the global line buffer.
    305  *
    306  *	unsigned char peekNextChar()
    307  *
    308  * getNum -- Grab hex num from the global line buffer.
    309  *
    310  *	int getNum()
    311  *
    312  * printf -- Scaled down version of C library printf.  Only %d, %x, %s, and %c
    313  * 	     are recognized.
    314  *
    315  * printhex -- prints rightmost <digs> hex digits of <val>
    316  *
    317  *      printhex(val,digs)
    318  *          register int val;
    319  *     	    register int digs;
    320  *
    321  * abortEntry -- Entry for keyboard abort.
    322  *
    323  *     abortEntry()
    324  */
    325 
    326 /*
    327  * Where the rom vector is defined.
    328  */
    329 
    330 #define	romVectorPtr	((MachMonRomVector *) PROM_BASE)
    331 
    332 #if 0
    333 /*
    334  * Functions and defines to access the monitor.
    335  */
    336 
    337 #define Mach_MonPrintf (romVectorPtr->printf)
    338 
    339 extern void Mach_MonPutChar _ARGS_((int ch));
    340 extern int Mach_MonMayPut _ARGS_((int ch));
    341 extern void Mach_MonAbort _ARGS_((void));
    342 extern void Mach_MonReboot _ARGS_((char *rebootString));
    343 extern void Mach_MonStartNmi _ARGS_((void));
    344 extern void Mach_MonStopNmi _ARGS_((void));
    345 
    346 extern  void    Mach_MonTrap _ARGS_((Address address_to_trap_to));
    347 
    348 /*
    349  * These routines no longer work correctly with new virtual memory.
    350  */
    351 
    352 #define Mach_MonGetChar (romVectorPtr->getChar)
    353 #define Mach_MonGetLine (romVectorPtr->getLine)
    354 #define Mach_MonGetNextChar (romVectorPtr->getNextChar)
    355 #define Mach_MonPeekNextChar (romVectorPtr->peekNextChar)
    356 #endif
    357 
    358 #define mon_printf (romVectorPtr->printf)
    359 #define mon_putchar (romVectorPtr->putChar)
    360 #define mon_exit_to_mon (romVectorPtr->exitToMon)
    361 #define mon_reboot (romVectorPtr->exitToMon)
    362 #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();}
    363 
    364 #define mon_setcxsegmap(context, va, sme) \
    365      romVectorPtr->setcxsegmap(context, va, sme)
    366 #define romp (romVectorPtr)
    367 
    368 /*
    369  * MONSTART and MONEND denote the range of the damn monitor.
    370  *
    371  * supposedly you can steal pmegs within this range that do not contain
    372  * valid pages.
    373  */
    374 #define MONSTART     0x0FE00000
    375 #define MONEND       0x0FF00000
    376 
    377 /*
    378  * These describe the monitor's short segment which it basically uses to map
    379  * one stupid page that it uses for storage.  MONSHORTPAGE is the page,
    380  * and MONSHORTSEG is the segment that it is in.  If this sounds dumb to
    381  * you, it is.  I can change the pmeg, but not the virtual address.
    382  * Sun defines these with the high nibble set to 0xF.  I believe this was
    383  * for the monitor source which accesses this piece of memory with addressing
    384  * limitations or some such crud.  I haven't replicated this here, because
    385  * it is confusing, and serves no obvious purpose if you aren't the monitor.
    386  *
    387  */
    388 
    389 #define MONSHORTPAGE 0x0FFFE000
    390 #define MONSHORTSEG  0x0FFE0000
    391 
    392 #endif /* _MACHMON */
    393 #endif /* MACHINE_MON_H */
    394