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