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