mon.h revision 1.24 1 1.24 chs /* $NetBSD: mon.h,v 1.24 2001/02/22 07:11:09 chs Exp $ */
2 1.14 cgd
3 1.19 gwr /*-
4 1.19 gwr * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 1.10 glass * All rights reserved.
6 1.10 glass *
7 1.19 gwr * This code is derived from software contributed to The NetBSD Foundation
8 1.19 gwr * by Adam Glass.
9 1.19 gwr *
10 1.10 glass * Redistribution and use in source and binary forms, with or without
11 1.10 glass * modification, are permitted provided that the following conditions
12 1.10 glass * are met:
13 1.10 glass * 1. Redistributions of source code must retain the above copyright
14 1.10 glass * notice, this list of conditions and the following disclaimer.
15 1.10 glass * 2. Redistributions in binary form must reproduce the above copyright
16 1.10 glass * notice, this list of conditions and the following disclaimer in the
17 1.10 glass * documentation and/or other materials provided with the distribution.
18 1.10 glass * 3. All advertising materials mentioning features or use of this software
19 1.10 glass * must display the following acknowledgement:
20 1.19 gwr * This product includes software developed by the NetBSD
21 1.19 gwr * Foundation, Inc. and its contributors.
22 1.19 gwr * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.19 gwr * contributors may be used to endorse or promote products derived
24 1.19 gwr * from this software without specific prior written permission.
25 1.10 glass *
26 1.19 gwr * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.19 gwr * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.19 gwr * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.21 gwr * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.21 gwr * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.19 gwr * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.19 gwr * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.19 gwr * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.19 gwr * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.19 gwr * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.19 gwr * POSSIBILITY OF SUCH DAMAGE.
37 1.10 glass */
38 1.15 gwr
39 1.10 glass /*
40 1.1 glass * This file derived from kernel/mach/sun3.md/machMon.h from the
41 1.1 glass * sprite distribution.
42 1.1 glass *
43 1.1 glass * In particular, this file came out of the Walnut Creek cdrom collection
44 1.16 gwr * which contained no warnings about any possible copyright infringement.
45 1.1 glass * It was also indentical to a file in the sprite kernel tar file found on
46 1.1 glass * allspice.berkeley.edu.
47 1.1 glass * It also written in the annoying sprite coding style. I've made
48 1.1 glass * efforts not to heavily edit their file, just ifdef parts out. -- glass
49 1.1 glass */
50 1.1 glass
51 1.6 glass #ifndef _MACHINE_MON_H
52 1.6 glass #define _MACHINE_MON_H
53 1.23 gwr
54 1.1 glass /*
55 1.1 glass * machMon.h --
56 1.1 glass *
57 1.1 glass * Structures, constants and defines for access to the sun monitor.
58 1.1 glass * These are translated from the sun monitor header file "sunromvec.h".
59 1.1 glass *
60 1.1 glass * NOTE: The file keyboard.h in the monitor directory has all sorts of useful
61 1.1 glass * keyboard stuff defined. I haven't attempted to translate that file
62 1.1 glass * because I don't need it. If anyone wants to use it, be my guest.
63 1.1 glass *
64 1.1 glass * Copyright (C) 1985 Regents of the University of California
65 1.1 glass * All rights reserved.
66 1.1 glass *
67 1.1 glass *
68 1.23 gwr * Header: /sprite/src/kernel/mach/sun3.md/RCS/machMon.h,v 9.1
69 1.22 gwr * 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley)
70 1.1 glass */
71 1.1 glass
72 1.1 glass /*
73 1.1 glass * Structure set up by the boot command to pass arguments to the program that
74 1.1 glass * is booted.
75 1.1 glass */
76 1.23 gwr struct bootparam {
77 1.1 glass char *argPtr[8]; /* String arguments */
78 1.1 glass char strings[100]; /* String table for string arguments */
79 1.1 glass char devName[2]; /* Device name */
80 1.1 glass int ctlrNum; /* Controller number */
81 1.1 glass int unitNum; /* Unit number */
82 1.1 glass int partNum; /* Partition/file number */
83 1.1 glass char *fileName; /* File name, points into strings */
84 1.22 gwr struct boottab *bootDevice; /* Defined in saio.h */
85 1.24 chs } __attribute__((packed));
86 1.1 glass
87 1.22 gwr /*
88 1.22 gwr * This structure defines a segment of physical memory. To support
89 1.22 gwr * sparse physical memory, the PROM constructs a linked list of
90 1.22 gwr * these at power-on-self-test time.
91 1.22 gwr */
92 1.22 gwr struct physmemory {
93 1.23 gwr u_int address;
94 1.23 gwr u_int size;
95 1.22 gwr struct physmemory *next;
96 1.22 gwr };
97 1.22 gwr
98 1.1 glass /*
99 1.22 gwr * Here is the structure of the vector table found at the front of the boot
100 1.1 glass * rom. The functions defined in here are explained below.
101 1.1 glass *
102 1.1 glass * NOTE: This struct has references to the structures keybuf and globram which
103 1.1 glass * I have not translated. If anyone needs to use these they should
104 1.1 glass * translate these structs into Sprite format.
105 1.1 glass */
106 1.23 gwr struct sunromvec {
107 1.23 gwr char *init_SP; /* Initial SP for hardware */
108 1.23 gwr char *init_PC; /* Initial PC for hardware */
109 1.20 gwr int *diagberr; /* Bus err handler for diags */
110 1.1 glass
111 1.22 gwr /*
112 1.1 glass * Monitor and hardware revision and identification
113 1.1 glass */
114 1.1 glass
115 1.20 gwr struct bootparam **bootParam; /* Info for bootstrapped pgm */
116 1.22 gwr u_int *memorySize; /* Usable memory in bytes */
117 1.1 glass
118 1.22 gwr /*
119 1.22 gwr * Single-character input and output
120 1.1 glass */
121 1.1 glass
122 1.20 gwr u_char (*getChar)__P((void)); /* Get char from input source */
123 1.20 gwr int (*putChar)__P((int)); /* Put char to output sink */
124 1.20 gwr int (*mayGet)__P((void)); /* Maybe get char, or -1 */
125 1.20 gwr int (*mayPut)__P((int)); /* Maybe put char, or -1 */
126 1.20 gwr u_char *echo; /* Should getchar echo? */
127 1.20 gwr u_char *inSource; /* Input source selector */
128 1.20 gwr u_char *outSink; /* Output sink selector */
129 1.1 glass
130 1.22 gwr /*
131 1.22 gwr * Keyboard input (scanned by monitor nmi routine)
132 1.1 glass */
133 1.1 glass
134 1.20 gwr int (*getKey)__P((void)); /* Get next key if one exists */
135 1.20 gwr int (*initGetKey)__P((void*)); /* Initialize get key */
136 1.22 gwr u_int *translation; /* Kbd translation selector
137 1.22 gwr (see keyboard.h in sun
138 1.20 gwr monitor code) */
139 1.20 gwr u_char *keyBid; /* Keyboard ID byte */
140 1.20 gwr int *screen_x; /* V2: Screen x pos (R/O) */
141 1.20 gwr int *screen_y; /* V2: Screen y pos (R/O) */
142 1.20 gwr struct keybuf *keyBuf; /* Up/down keycode buffer */
143 1.1 glass
144 1.1 glass /*
145 1.1 glass * Monitor revision level.
146 1.1 glass */
147 1.1 glass
148 1.1 glass char *monId;
149 1.1 glass
150 1.22 gwr /*
151 1.22 gwr * Frame buffer output and terminal emulation
152 1.1 glass */
153 1.1 glass
154 1.20 gwr int (*fbWriteChar)__P((int)); /* Write a character to FB */
155 1.20 gwr int *fbAddr; /* Address of frame buffer */
156 1.20 gwr char **font; /* Font table for FB */
157 1.20 gwr /* Quickly write string to FB */
158 1.20 gwr int (*fbWriteStr)__P((char *buf, int len));
159 1.1 glass
160 1.22 gwr /*
161 1.22 gwr * Reboot interface routine -- resets and reboots system. No return.
162 1.1 glass */
163 1.1 glass
164 1.20 gwr int (*reBoot)__P((char *)); /* e.g. reBoot("xy()vmunix") */
165 1.1 glass
166 1.22 gwr /*
167 1.22 gwr * Line input and parsing
168 1.1 glass */
169 1.1 glass
170 1.20 gwr u_char *lineBuf; /* The line input buffer */
171 1.20 gwr u_char **linePtr; /* Cur pointer into linebuf */
172 1.20 gwr int *lineSize; /* length of line in linebuf */
173 1.20 gwr int (*getLine)__P((int)); /* Get line from user */
174 1.20 gwr u_char (*getNextChar)__P((void)); /* Get next char from linebuf */
175 1.20 gwr u_char (*peekNextChar)__P((void)); /* Peek at next char */
176 1.1 glass int *fbThere; /* =1 if frame buffer there */
177 1.20 gwr int (*getNum)__P((void)); /* Grab hex num from line */
178 1.1 glass
179 1.22 gwr /*
180 1.22 gwr * Print formatted output to current output sink
181 1.1 glass */
182 1.1 glass
183 1.20 gwr int (*printf)__P((char *, ...)); /* Like kernel printf */
184 1.20 gwr int (*printHex)__P((int,int)); /* Format N digits in hex */
185 1.1 glass
186 1.1 glass /*
187 1.22 gwr * Led stuff
188 1.1 glass */
189 1.1 glass
190 1.20 gwr u_char *leds; /* RAM copy of LED register */
191 1.20 gwr int (*setLeds)__P((int)); /* Sets LED's and RAM copy */
192 1.1 glass
193 1.22 gwr /*
194 1.1 glass * Non-maskable interrupt (nmi) information
195 1.22 gwr */
196 1.1 glass
197 1.20 gwr int (*nmiAddr)__P((void*)); /* Addr for level 7 vector */
198 1.20 gwr int (*abortEntry)__P((void*)); /* Entry for keyboard abort */
199 1.20 gwr int *nmiClock; /* Counts up in msec */
200 1.1 glass
201 1.1 glass /*
202 1.1 glass * Frame buffer type: see <sun/fbio.h>
203 1.1 glass */
204 1.1 glass
205 1.1 glass int *fbType;
206 1.1 glass
207 1.22 gwr /*
208 1.22 gwr * Assorted other things
209 1.1 glass */
210 1.1 glass
211 1.22 gwr u_int romvecVersion; /* Version # of Romvec */
212 1.20 gwr struct globram *globRam; /* monitor global variables */
213 1.23 gwr void *kbdZscc; /* Addr of keyboard in use */
214 1.20 gwr
215 1.20 gwr int *keyrInit; /* ms before kbd repeat */
216 1.20 gwr u_char *keyrTick; /* ms between repetitions */
217 1.20 gwr u_int *memoryAvail; /* V1: Main mem usable size */
218 1.20 gwr long *resetAddr; /* where to jump on a reset */
219 1.20 gwr long *resetMap; /* pgmap entry for resetaddr */
220 1.20 gwr /* Really struct pgmapent * */
221 1.20 gwr int (*exitToMon)__P((void)); /* Exit from user program */
222 1.20 gwr u_char **memorybitmap; /* V1: &{0 or &bits} */
223 1.20 gwr
224 1.22 gwr /****************************************************************
225 1.22 gwr * Note: from here on, things vary per-architecture!
226 1.22 gwr ****************************************************************/
227 1.23 gwr union {
228 1.23 gwr void *un_pad[8]; /* this determines the size */
229 1.23 gwr struct {
230 1.23 gwr /* Set seg in all contexts (ctx, va, sme) */
231 1.23 gwr void (*un3_setcxsegmap)__P((int,int,int));
232 1.23 gwr /* V2: Handler for 'v' cmd */
233 1.23 gwr void (**un3_vector_cmd)__P((int, char*));
234 1.23 gwr } un3;
235 1.23 gwr struct {
236 1.23 gwr /* V2: Handler for 'v' cmd */
237 1.23 gwr void (**un3x_vector_cmd)__P((int, char*));
238 1.23 gwr /* Address of low memory PTEs (maps at least 4MB) */
239 1.23 gwr int **un3x_lomemptaddr;
240 1.23 gwr /*
241 1.23 gwr * Address of debug/mon PTEs which map the 2MB space
242 1.23 gwr * starting at MON_KDB_BASE, ending at MONEND.
243 1.23 gwr */
244 1.23 gwr int **un3x_monptaddr;
245 1.23 gwr /*
246 1.23 gwr * Address of dvma PTEs. This is a VA that maps the I/O MMU
247 1.23 gwr * page table, but only the last part, which corresponds to
248 1.23 gwr * the CPU virtual space at MON_DVMA_BASE (see below).
249 1.23 gwr */
250 1.23 gwr int **un3x_dvmaptaddr;
251 1.23 gwr /*
252 1.23 gwr * Physical Address of the debug/mon PTEs found at the
253 1.23 gwr * virtual address given by *romVectorPtr->monptaddr;
254 1.23 gwr */
255 1.23 gwr int **un3x_monptphysaddr;
256 1.23 gwr /*
257 1.23 gwr * Address of shadow copy of DVMA PTEs. This is a VA that
258 1.23 gwr * maps the PTEs used by the CPU to map the same physical
259 1.23 gwr * pages as the I/O MMU into the CPU virtual space starting
260 1.23 gwr * at MON_DVMA_BASE, length MON_DVMA_SIZE (see below).
261 1.23 gwr */
262 1.23 gwr int **un3x_shadowpteaddr;
263 1.23 gwr /* Ptr to memory list for 3/80 */
264 1.23 gwr struct physmemory *un3x_physmemory;
265 1.23 gwr } un3x;
266 1.23 gwr } mon_un;
267 1.24 chs } __attribute__((packed));
268 1.1 glass
269 1.1 glass /*
270 1.1 glass * Functions defined in the vector:
271 1.1 glass *
272 1.1 glass *
273 1.1 glass * getChar -- Return the next character from the input source
274 1.1 glass *
275 1.20 gwr * u_char getChar()
276 1.1 glass *
277 1.1 glass * putChar -- Write the given character to the output source.
278 1.1 glass *
279 1.1 glass * void putChar(ch)
280 1.1 glass * char ch;
281 1.1 glass *
282 1.22 gwr * mayGet -- Maybe get a character from the current input source. Return -1
283 1.1 glass * if don't return a character.
284 1.1 glass *
285 1.1 glass * int mayGet()
286 1.1 glass *
287 1.1 glass * mayPut -- Maybe put a character to the current output source. Return -1
288 1.1 glass * if no character output.
289 1.1 glass *
290 1.1 glass * int mayPut(ch)
291 1.1 glass * char ch;
292 1.1 glass *
293 1.1 glass * getKey -- Returns a key code (if up/down codes being returned),
294 1.1 glass * a byte of ASCII (if that's requested),
295 1.1 glass * NOKEY (if no key has been hit).
296 1.1 glass *
297 1.1 glass * int getKey()
298 1.1 glass *
299 1.1 glass * initGetKey -- Initialize things for get key.
300 1.1 glass *
301 1.1 glass * void initGetKey()
302 1.1 glass *
303 1.1 glass * fbWriteChar -- Write a character to the frame buffer
304 1.1 glass *
305 1.1 glass * void fwritechar(ch)
306 1.20 gwr * u_char ch;
307 1.1 glass *
308 1.1 glass * fbWriteStr -- Write a string to the frame buffer.
309 1.1 glass *
310 1.1 glass * void fwritestr(addr,len)
311 1.20 gwr * register u_char *addr; / * String to be written * /
312 1.23 gwr * register short len; / * Length of string * /
313 1.1 glass *
314 1.1 glass * getLine -- read the next input line into a global buffer
315 1.1 glass *
316 1.1 glass * getline(echop)
317 1.1 glass * int echop; / * 1 if should echo input, 0 if not * /
318 1.1 glass *
319 1.1 glass * getNextChar -- return the next character from the global line buffer.
320 1.1 glass *
321 1.20 gwr * u_char getNextChar()
322 1.1 glass *
323 1.1 glass * peekNextChar -- look at the next character in the global line buffer.
324 1.1 glass *
325 1.20 gwr * u_char peekNextChar()
326 1.1 glass *
327 1.1 glass * getNum -- Grab hex num from the global line buffer.
328 1.1 glass *
329 1.1 glass * int getNum()
330 1.1 glass *
331 1.18 christos * printf -- Scaled down version of C library printf. Only %d, %x, %s, and %c
332 1.1 glass * are recognized.
333 1.1 glass *
334 1.1 glass * printhex -- prints rightmost <digs> hex digits of <val>
335 1.1 glass *
336 1.1 glass * printhex(val,digs)
337 1.1 glass * register int val;
338 1.1 glass * register int digs;
339 1.1 glass *
340 1.1 glass * abortEntry -- Entry for keyboard abort.
341 1.1 glass *
342 1.1 glass * abortEntry()
343 1.1 glass */
344 1.1 glass
345 1.1 glass /*
346 1.1 glass * Functions and defines to access the monitor.
347 1.1 glass */
348 1.1 glass
349 1.18 christos #define mon_printf (romVectorPtr->printf)
350 1.9 glass #define mon_putchar (romVectorPtr->putChar)
351 1.12 glass #define mon_may_getchar (romVectorPtr->mayGet)
352 1.1 glass #define mon_exit_to_mon (romVectorPtr->exitToMon)
353 1.13 gwr #define mon_reboot (romVectorPtr->reBoot)
354 1.8 glass
355 1.4 glass
356 1.6 glass /*
357 1.23 gwr * Sun3 specific stuff...
358 1.22 gwr */
359 1.22 gwr
360 1.23 gwr #ifdef _SUN3_
361 1.23 gwr #define setcxsegmap mon_un.un3.un3_setcxsegmap
362 1.23 gwr #define vector_cmd mon_un.un3.un3_vector_cmd
363 1.23 gwr #define romVectorPtr ((struct sunromvec *) SUN3_PROM_BASE)
364 1.23 gwr #endif /* SUN3 */
365 1.22 gwr
366 1.22 gwr /*
367 1.22 gwr * MONSTART and MONEND denote the range used by the monitor.
368 1.23 gwr * PROM_BASE is the virtual address of the PROM.
369 1.6 glass */
370 1.24 chs #define SUN3_MONSTART 0x0FE00000
371 1.24 chs #define SUN3_PROM_BASE 0x0FEF0000
372 1.24 chs #define SUN3_MONEND 0x0FF00000
373 1.4 glass
374 1.6 glass /*
375 1.23 gwr * These describe the monitor's short segment (one it can reach using
376 1.23 gwr * short PC-relative addressing) which it uses to map its data page.
377 1.23 gwr * MONSHORTPAGE is the page; MONSHORTSEG is the containing segment.
378 1.23 gwr * Its mapping must not be removed or the PROM monitor will fail.
379 1.23 gwr * MONSHORTPAGE is also where the "ie" puts its SCP.
380 1.22 gwr */
381 1.23 gwr #define SUN3_MONSHORTPAGE 0x0FFFE000
382 1.24 chs #define SUN3_MONSHORTSEG 0x0FFE0000
383 1.22 gwr
384 1.23 gwr /*
385 1.23 gwr * Sun3X specific stuff...
386 1.23 gwr */
387 1.22 gwr
388 1.23 gwr #ifdef _SUN3X_
389 1.23 gwr #define vector_cmd mon_un.un3x.un3x_vector_cmd
390 1.23 gwr #define lomemptaddr mon_un.un3x.un3x_lomemptaddr
391 1.23 gwr #define monptaddr mon_un.un3x.un3x_monptaddr
392 1.23 gwr #define dvmaptaddr mon_un.un3x.un3x_dvmaptaddr
393 1.23 gwr #define monptphysaddr mon_un.un3x.un3x_monptphysaddr
394 1.23 gwr #define shadowpteaddr mon_un.un3x.un3x_shadowpteaddr
395 1.23 gwr #define v_physmemory mon_un.un3x.un3x_physmemory
396 1.23 gwr #define romVectorPtr ((struct sunromvec *) SUN3X_PROM_BASE)
397 1.23 gwr #endif /* SUN3X */
398 1.22 gwr
399 1.22 gwr /*
400 1.22 gwr * We don't have a separate kernel debugger like sun kadb,
401 1.22 gwr * but this range is setup by the monitor for such a thing.
402 1.22 gwr * We might as well preserve the mappings anyway.
403 1.6 glass */
404 1.23 gwr #define SUN3X_MON_KDB_BASE 0xFEE00000
405 1.23 gwr #define SUN3X_MON_KDB_SIZE 0x100000
406 1.6 glass
407 1.22 gwr /*
408 1.22 gwr * MONSTART and MONEND define the range used by the monitor.
409 1.22 gwr * MONDATA is its data page (do not touch!)
410 1.22 gwr * PROM_BASE is where the boot PROM lives.
411 1.22 gwr */
412 1.23 gwr #define SUN3X_MONSTART 0xFEF00000
413 1.23 gwr #define SUN3X_MONDATA 0xFEF72000
414 1.23 gwr #define SUN3X_PROM_BASE 0xFEFE0000
415 1.23 gwr #define SUN3X_MONEND 0xFF000000
416 1.6 glass
417 1.22 gwr /*
418 1.22 gwr * These define the CPU virtual address range mapped by the
419 1.22 gwr * PROM for use as DVMA space. The physical pages mapped in
420 1.23 gwr * this range are also mapped by the I/O MMU. Note that the
421 1.23 gwr * last page is reserved for the PROM (really for the "ie").
422 1.22 gwr */
423 1.23 gwr #define SUN3X_MON_DVMA_BASE 0xFFF00000
424 1.23 gwr #define SUN3X_MON_DVMA_SIZE 0x100000 /* 1MB */
425 1.23 gwr
426 1.23 gwr #ifdef _STANDALONE
427 1.23 gwr /* The libsa code uses a pointer... */
428 1.23 gwr extern struct sunromvec *_romvec;
429 1.23 gwr #undef romVectorPtr
430 1.23 gwr #define romVectorPtr _romvec
431 1.23 gwr #endif /* _STANDALONE */
432 1.22 gwr
433 1.23 gwr #endif /* _MACHINE_MON_H */
434