No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / sun3 / include / mon.h
blobe3aac7e62a7723a9fa06727efafc9dff95e7158f
1 /* $NetBSD: mon.h,v 1.28 2006/10/01 03:53:27 tsutsui Exp $ */
3 /*-
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Adam Glass.
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * This file derived from kernel/mach/sun3.md/machMon.h from the
34 * sprite distribution.
36 * In particular, this file came out of the Walnut Creek cdrom collection
37 * which contained no warnings about any possible copyright infringement.
38 * It was also indentical to a file in the sprite kernel tar file found on
39 * allspice.berkeley.edu.
40 * It also written in the annoying sprite coding style. I've made
41 * efforts not to heavily edit their file, just ifdef parts out. -- glass
44 #ifndef _MACHINE_MON_H
45 #define _MACHINE_MON_H
48 * machMon.h --
50 * Structures, constants and defines for access to the sun monitor.
51 * These are translated from the sun monitor header file "sunromvec.h".
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.
57 * Copyright (C) 1985 Regents of the University of California
58 * All rights reserved.
61 * Header: /sprite/src/kernel/mach/sun3.md/RCS/machMon.h,v 9.1
62 * 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley)
66 * Structure set up by the boot command to pass arguments to the program that
67 * is booted.
69 struct bootparam {
70 char *argPtr[8]; /* String arguments */
71 char strings[100]; /* String table for string arguments */
72 char devName[2]; /* Device name */
73 int ctlrNum; /* Controller number */
74 int unitNum; /* Unit number */
75 int partNum; /* Partition/file number */
76 char *fileName; /* File name, points into strings */
77 struct boottab *bootDevice; /* Defined in saio.h */
78 } __attribute__((packed));
81 * This structure defines a segment of physical memory. To support
82 * sparse physical memory, the PROM constructs a linked list of
83 * these at power-on-self-test time.
85 struct physmemory {
86 u_int address;
87 u_int size;
88 struct physmemory *next;
92 * Here is the structure of the vector table found at the front of the boot
93 * rom. The functions defined in here are explained below.
95 * NOTE: This struct has references to the structures keybuf and globram which
96 * I have not translated. If anyone needs to use these they should
97 * translate these structs into Sprite format.
99 struct sunromvec {
100 char *init_SP; /* Initial SP for hardware */
101 char *init_PC; /* Initial PC for hardware */
102 int *diagberr; /* Bus err handler for diags */
105 * Monitor and hardware revision and identification
108 struct bootparam **bootParam; /* Info for bootstrapped pgm */
109 u_int *memorySize; /* Usable memory in bytes */
112 * Single-character input and output
115 u_char (*getChar)(void); /* Get char from input source */
116 int (*putChar)(int); /* Put char to output sink */
117 int (*mayGet)(void); /* Maybe get char, or -1 */
118 int (*mayPut)(int); /* Maybe put char, or -1 */
119 u_char *echo; /* Should getchar echo? */
120 u_char *inSource; /* Input source selector */
121 u_char *outSink; /* Output sink selector */
124 * Keyboard input (scanned by monitor nmi routine)
127 int (*getKey)(void); /* Get next key if one exists */
128 int (*initGetKey)(void *); /* Initialize get key */
129 u_int *translation; /* Kbd translation selector
130 (see keyboard.h in sun
131 monitor code) */
132 u_char *keyBid; /* Keyboard ID byte */
133 int *screen_x; /* V2: Screen x pos (R/O) */
134 int *screen_y; /* V2: Screen y pos (R/O) */
135 struct keybuf *keyBuf; /* Up/down keycode buffer */
138 * Monitor revision level.
141 char *monId;
144 * Frame buffer output and terminal emulation
147 int (*fbWriteChar)(int); /* Write a character to FB */
148 int *fbAddr; /* Address of frame buffer */
149 char **font; /* Font table for FB */
150 /* Quickly write string to FB */
151 int (*fbWriteStr)(char *buf, int len);
154 * Reboot interface routine -- resets and reboots system. No return.
157 int (*reBoot)(const char *); /* e.g. reBoot("xy()vmunix") */
160 * Line input and parsing
163 u_char *lineBuf; /* The line input buffer */
164 u_char **linePtr; /* Cur pointer into linebuf */
165 int *lineSize; /* length of line in linebuf */
166 int (*getLine)(int); /* Get line from user */
167 u_char (*getNextChar)(void); /* Get next char from linebuf */
168 u_char (*peekNextChar)(void); /* Peek at next char */
169 int *fbThere; /* =1 if frame buffer there */
170 int (*getNum)(void); /* Grab hex num from line */
173 * Print formatted output to current output sink
176 int (*printf)(const char *, ...); /* Like kernel printf */
177 int (*printHex)(int, int); /* Format N digits in hex */
180 * Led stuff
183 u_char *leds; /* RAM copy of LED register */
184 int (*setLeds)(int); /* Sets LED's and RAM copy */
187 * Non-maskable interrupt (nmi) information
190 int (*nmiAddr)(void *); /* Addr for level 7 vector */
191 int (*abortEntry)(void *); /* Entry for keyboard abort */
192 int *nmiClock; /* Counts up in msec */
195 * Frame buffer type: see <sun/fbio.h>
198 int *fbType;
201 * Assorted other things
204 u_int romvecVersion; /* Version # of Romvec */
205 struct globram *globRam; /* monitor global variables */
206 void *kbdZscc; /* Addr of keyboard in use */
208 int *keyrInit; /* ms before kbd repeat */
209 u_char *keyrTick; /* ms between repetitions */
210 u_int *memoryAvail; /* V1: Main mem usable size */
211 long *resetAddr; /* where to jump on a reset */
212 long *resetMap; /* pgmap entry for resetaddr */
213 /* Really struct pgmapent * */
214 int (*exitToMon)(void); /* Exit from user program */
215 u_char **memorybitmap; /* V1: &{0 or &bits} */
217 /****************************************************************
218 * Note: from here on, things vary per-architecture!
219 ****************************************************************/
220 union {
221 void *un_pad[8]; /* this determines the size */
222 struct {
223 /* Set seg in all contexts (ctx, va, sme) */
224 void (*un3_setcxsegmap)(int, int, int);
225 /* V2: Handler for 'v' cmd */
226 void (**un3_vector_cmd)(int, char *);
227 } un3;
228 struct {
229 /* V2: Handler for 'v' cmd */
230 void (**un3x_vector_cmd)(int, char *);
231 /* Address of low memory PTEs (maps at least 4MB) */
232 int **un3x_lomemptaddr;
234 * Address of debug/mon PTEs which map the 2MB space
235 * starting at MON_KDB_BASE, ending at MONEND.
237 int **un3x_monptaddr;
239 * Address of dvma PTEs. This is a VA that maps the I/O MMU
240 * page table, but only the last part, which corresponds to
241 * the CPU virtual space at MON_DVMA_BASE (see below).
243 int **un3x_dvmaptaddr;
245 * Physical Address of the debug/mon PTEs found at the
246 * virtual address given by *romVectorPtr->monptaddr;
248 int **un3x_monptphysaddr;
250 * Address of shadow copy of DVMA PTEs. This is a VA that
251 * maps the PTEs used by the CPU to map the same physical
252 * pages as the I/O MMU into the CPU virtual space starting
253 * at MON_DVMA_BASE, length MON_DVMA_SIZE (see below).
255 int **un3x_shadowpteaddr;
256 /* Ptr to memory list for 3/80 */
257 struct physmemory *un3x_physmemory;
258 } un3x;
259 } mon_un;
260 } __attribute__((packed));
263 * Functions defined in the vector:
266 * getChar -- Return the next character from the input source
268 * u_char getChar()
270 * putChar -- Write the given character to the output source.
272 * void putChar(ch)
273 * char ch;
275 * mayGet -- Maybe get a character from the current input source. Return -1
276 * if don't return a character.
278 * int mayGet()
280 * mayPut -- Maybe put a character to the current output source. Return -1
281 * if no character output.
283 * int mayPut(ch)
284 * char ch;
286 * getKey -- Returns a key code (if up/down codes being returned),
287 * a byte of ASCII (if that's requested),
288 * NOKEY (if no key has been hit).
290 * int getKey()
292 * initGetKey -- Initialize things for get key.
294 * void initGetKey()
296 * fbWriteChar -- Write a character to the frame buffer
298 * void fwritechar(ch)
299 * u_char ch;
301 * fbWriteStr -- Write a string to the frame buffer.
303 * void fwritestr(addr,len)
304 * u_char *addr; / * String to be written * /
305 * short len; / * Length of string * /
307 * getLine -- read the next input line into a global buffer
309 * getline(echop)
310 * int echop; / * 1 if should echo input, 0 if not * /
312 * getNextChar -- return the next character from the global line buffer.
314 * u_char getNextChar()
316 * peekNextChar -- look at the next character in the global line buffer.
318 * u_char peekNextChar()
320 * getNum -- Grab hex num from the global line buffer.
322 * int getNum()
324 * printf -- Scaled down version of C library printf. Only %d, %x, %s, and %c
325 * are recognized.
327 * printhex -- prints rightmost <digs> hex digits of <val>
329 * printhex(val, digs)
330 * int val;
331 * int digs;
333 * abortEntry -- Entry for keyboard abort.
335 * abortEntry()
339 * Functions and defines to access the monitor.
342 #define mon_printf (romVectorPtr->printf)
343 #define mon_putchar (romVectorPtr->putChar)
344 #define mon_may_getchar (romVectorPtr->mayGet)
345 #define mon_exit_to_mon (romVectorPtr->exitToMon)
346 #define mon_reboot (romVectorPtr->reBoot)
350 * Sun3 specific stuff...
353 #ifdef _SUN3_
354 #define setcxsegmap mon_un.un3.un3_setcxsegmap
355 #define vector_cmd mon_un.un3.un3_vector_cmd
356 #define romVectorPtr ((struct sunromvec *) SUN3_PROM_BASE)
357 #endif /* SUN3 */
360 * MONSTART and MONEND denote the range used by the monitor.
361 * PROM_BASE is the virtual address of the PROM.
363 #define SUN3_MONSTART 0x0FE00000
364 #define SUN3_PROM_BASE 0x0FEF0000
365 #define SUN3_MONEND 0x0FF00000
368 * These describe the monitor's short segment (one it can reach using
369 * short PC-relative addressing) which it uses to map its data page.
370 * MONSHORTPAGE is the page; MONSHORTSEG is the containing segment.
371 * Its mapping must not be removed or the PROM monitor will fail.
372 * MONSHORTPAGE is also where the "ie" puts its SCP.
374 #define SUN3_MONSHORTPAGE 0x0FFFE000
375 #define SUN3_MONSHORTSEG 0x0FFE0000
377 #ifdef _SUN3_ /* XXX */
378 #define SUN_MONSTART SUN3_MONSTART
379 #define SUN_MONEND SUN3_MONEND
380 #endif /* _SUN3_ */
383 * Sun3X specific stuff...
386 #ifdef _SUN3X_
387 #define vector_cmd mon_un.un3x.un3x_vector_cmd
388 #define lomemptaddr mon_un.un3x.un3x_lomemptaddr
389 #define monptaddr mon_un.un3x.un3x_monptaddr
390 #define dvmaptaddr mon_un.un3x.un3x_dvmaptaddr
391 #define monptphysaddr mon_un.un3x.un3x_monptphysaddr
392 #define shadowpteaddr mon_un.un3x.un3x_shadowpteaddr
393 #define v_physmemory mon_un.un3x.un3x_physmemory
394 #define romVectorPtr ((struct sunromvec *) SUN3X_PROM_BASE)
395 #endif /* SUN3X */
398 * We don't have a separate kernel debugger like sun kadb,
399 * but this range is setup by the monitor for such a thing.
400 * We might as well preserve the mappings anyway.
402 #define SUN3X_MON_KDB_BASE 0xFEE00000
403 #define SUN3X_MON_KDB_SIZE 0x100000
406 * MONSTART and MONEND define the range used by the monitor.
407 * MONDATA is its data page (do not touch!)
408 * PROM_BASE is where the boot PROM lives.
410 #define SUN3X_MONSTART 0xFEF00000
411 #define SUN3X_MONDATA 0xFEF72000
412 #define SUN3X_PROM_BASE 0xFEFE0000
413 #define SUN3X_MONEND 0xFF000000
415 #ifdef _SUN3X_ /* XXX */
416 #define SUN_MONSTART SUN3X_MONSTART
417 #define SUN_MONEND SUN3X_MONEND
418 #endif /* _SUN3X_ */
421 * These define the CPU virtual address range mapped by the
422 * PROM for use as DVMA space. The physical pages mapped in
423 * this range are also mapped by the I/O MMU. Note that the
424 * last page is reserved for the PROM (really for the "ie").
426 #define SUN3X_MON_DVMA_BASE 0xFFF00000
427 #define SUN3X_MON_DVMA_SIZE 0x100000 /* 1MB */
429 #ifdef _STANDALONE
430 /* The libsa code uses a pointer... */
431 extern struct sunromvec *_romvec;
432 #undef romVectorPtr
433 #define romVectorPtr _romvec
434 #endif /* _STANDALONE */
436 #endif /* _MACHINE_MON_H */