mon.h revision 1.22 1 1.22 gwr /* $NetBSD: mon.h,v 1.22 1997/02/05 14:51:23 gwr 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.1 glass /*
54 1.1 glass * machMon.h --
55 1.1 glass *
56 1.1 glass * Structures, constants and defines for access to the sun monitor.
57 1.1 glass * These are translated from the sun monitor header file "sunromvec.h".
58 1.1 glass *
59 1.1 glass * NOTE: The file keyboard.h in the monitor directory has all sorts of useful
60 1.1 glass * keyboard stuff defined. I haven't attempted to translate that file
61 1.1 glass * because I don't need it. If anyone wants to use it, be my guest.
62 1.1 glass *
63 1.1 glass * Copyright (C) 1985 Regents of the University of California
64 1.1 glass * All rights reserved.
65 1.1 glass *
66 1.1 glass *
67 1.22 gwr * Header: /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v 9.1
68 1.22 gwr * 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley)
69 1.1 glass */
70 1.1 glass
71 1.1 glass #ifndef _MACHMON
72 1.1 glass #define _MACHMON
73 1.1 glass
74 1.1 glass /*
75 1.1 glass * Structure set up by the boot command to pass arguments to the program that
76 1.1 glass * is booted.
77 1.1 glass */
78 1.16 gwr typedef struct bootparam {
79 1.1 glass char *argPtr[8]; /* String arguments */
80 1.1 glass char strings[100]; /* String table for string arguments */
81 1.1 glass char devName[2]; /* Device name */
82 1.1 glass int ctlrNum; /* Controller number */
83 1.1 glass int unitNum; /* Unit number */
84 1.1 glass int partNum; /* Partition/file number */
85 1.1 glass char *fileName; /* File name, points into strings */
86 1.22 gwr struct boottab *bootDevice; /* Defined in saio.h */
87 1.1 glass } MachMonBootParam;
88 1.1 glass
89 1.22 gwr #ifdef sun3x
90 1.22 gwr /*
91 1.22 gwr * This structure defines a segment of physical memory. To support
92 1.22 gwr * sparse physical memory, the PROM constructs a linked list of
93 1.22 gwr * these at power-on-self-test time.
94 1.22 gwr */
95 1.22 gwr struct physmemory {
96 1.22 gwr unsigned int address;
97 1.22 gwr unsigned int size;
98 1.22 gwr struct physmemory *next;
99 1.22 gwr };
100 1.22 gwr #endif /* sun3x */
101 1.22 gwr
102 1.1 glass /*
103 1.22 gwr * Here is the structure of the vector table found at the front of the boot
104 1.1 glass * rom. The functions defined in here are explained below.
105 1.1 glass *
106 1.1 glass * NOTE: This struct has references to the structures keybuf and globram which
107 1.1 glass * I have not translated. If anyone needs to use these they should
108 1.1 glass * translate these structs into Sprite format.
109 1.1 glass */
110 1.1 glass typedef struct {
111 1.20 gwr char *initSp; /* Initial system stack ptr
112 1.20 gwr * for hardware */
113 1.20 gwr int (*startMon)__P((void)); /* Initial PC for hardware */
114 1.1 glass
115 1.20 gwr int *diagberr; /* Bus err handler for diags */
116 1.1 glass
117 1.22 gwr /*
118 1.1 glass * Monitor and hardware revision and identification
119 1.1 glass */
120 1.1 glass
121 1.20 gwr struct bootparam **bootParam; /* Info for bootstrapped pgm */
122 1.22 gwr u_int *memorySize; /* Usable memory in bytes */
123 1.1 glass
124 1.22 gwr /*
125 1.22 gwr * Single-character input and output
126 1.1 glass */
127 1.1 glass
128 1.20 gwr u_char (*getChar)__P((void)); /* Get char from input source */
129 1.20 gwr int (*putChar)__P((int)); /* Put char to output sink */
130 1.20 gwr int (*mayGet)__P((void)); /* Maybe get char, or -1 */
131 1.20 gwr int (*mayPut)__P((int)); /* Maybe put char, or -1 */
132 1.20 gwr u_char *echo; /* Should getchar echo? */
133 1.20 gwr u_char *inSource; /* Input source selector */
134 1.20 gwr u_char *outSink; /* Output sink selector */
135 1.1 glass
136 1.22 gwr /*
137 1.22 gwr * Keyboard input (scanned by monitor nmi routine)
138 1.1 glass */
139 1.1 glass
140 1.20 gwr int (*getKey)__P((void)); /* Get next key if one exists */
141 1.20 gwr int (*initGetKey)__P((void*)); /* Initialize get key */
142 1.22 gwr u_int *translation; /* Kbd translation selector
143 1.22 gwr (see keyboard.h in sun
144 1.20 gwr monitor code) */
145 1.20 gwr u_char *keyBid; /* Keyboard ID byte */
146 1.20 gwr int *screen_x; /* V2: Screen x pos (R/O) */
147 1.20 gwr int *screen_y; /* V2: Screen y pos (R/O) */
148 1.20 gwr struct keybuf *keyBuf; /* Up/down keycode buffer */
149 1.1 glass
150 1.1 glass /*
151 1.1 glass * Monitor revision level.
152 1.1 glass */
153 1.1 glass
154 1.1 glass char *monId;
155 1.1 glass
156 1.22 gwr /*
157 1.22 gwr * Frame buffer output and terminal emulation
158 1.1 glass */
159 1.1 glass
160 1.20 gwr int (*fbWriteChar)__P((int)); /* Write a character to FB */
161 1.20 gwr int *fbAddr; /* Address of frame buffer */
162 1.20 gwr char **font; /* Font table for FB */
163 1.20 gwr /* Quickly write string to FB */
164 1.20 gwr int (*fbWriteStr)__P((char *buf, int len));
165 1.1 glass
166 1.22 gwr /*
167 1.22 gwr * Reboot interface routine -- resets and reboots system. No return.
168 1.1 glass */
169 1.1 glass
170 1.20 gwr int (*reBoot)__P((char *)); /* e.g. reBoot("xy()vmunix") */
171 1.1 glass
172 1.22 gwr /*
173 1.22 gwr * Line input and parsing
174 1.1 glass */
175 1.1 glass
176 1.20 gwr u_char *lineBuf; /* The line input buffer */
177 1.20 gwr u_char **linePtr; /* Cur pointer into linebuf */
178 1.20 gwr int *lineSize; /* length of line in linebuf */
179 1.20 gwr int (*getLine)__P((int)); /* Get line from user */
180 1.20 gwr u_char (*getNextChar)__P((void)); /* Get next char from linebuf */
181 1.20 gwr u_char (*peekNextChar)__P((void)); /* Peek at next char */
182 1.1 glass int *fbThere; /* =1 if frame buffer there */
183 1.20 gwr int (*getNum)__P((void)); /* Grab hex num from line */
184 1.1 glass
185 1.22 gwr /*
186 1.22 gwr * Print formatted output to current output sink
187 1.1 glass */
188 1.1 glass
189 1.20 gwr int (*printf)__P((char *, ...)); /* Like kernel printf */
190 1.20 gwr int (*printHex)__P((int,int)); /* Format N digits in hex */
191 1.1 glass
192 1.1 glass /*
193 1.22 gwr * Led stuff
194 1.1 glass */
195 1.1 glass
196 1.20 gwr u_char *leds; /* RAM copy of LED register */
197 1.20 gwr int (*setLeds)__P((int)); /* Sets LED's and RAM copy */
198 1.1 glass
199 1.22 gwr /*
200 1.1 glass * Non-maskable interrupt (nmi) information
201 1.22 gwr */
202 1.1 glass
203 1.20 gwr int (*nmiAddr)__P((void*)); /* Addr for level 7 vector */
204 1.20 gwr int (*abortEntry)__P((void*)); /* Entry for keyboard abort */
205 1.20 gwr int *nmiClock; /* Counts up in msec */
206 1.1 glass
207 1.1 glass /*
208 1.1 glass * Frame buffer type: see <sun/fbio.h>
209 1.1 glass */
210 1.1 glass
211 1.1 glass int *fbType;
212 1.1 glass
213 1.22 gwr /*
214 1.22 gwr * Assorted other things
215 1.1 glass */
216 1.1 glass
217 1.22 gwr u_int romvecVersion; /* Version # of Romvec */
218 1.20 gwr struct globram *globRam; /* monitor global variables */
219 1.20 gwr caddr_t kbdZscc; /* Addr of keyboard in use */
220 1.20 gwr
221 1.20 gwr int *keyrInit; /* ms before kbd repeat */
222 1.20 gwr u_char *keyrTick; /* ms between repetitions */
223 1.20 gwr u_int *memoryAvail; /* V1: Main mem usable size */
224 1.20 gwr long *resetAddr; /* where to jump on a reset */
225 1.20 gwr long *resetMap; /* pgmap entry for resetaddr */
226 1.20 gwr /* Really struct pgmapent * */
227 1.20 gwr int (*exitToMon)__P((void)); /* Exit from user program */
228 1.20 gwr u_char **memorybitmap; /* V1: &{0 or &bits} */
229 1.20 gwr
230 1.22 gwr /****************************************************************
231 1.22 gwr * Note: from here on, things vary per-architecture!
232 1.22 gwr ****************************************************************/
233 1.22 gwr
234 1.22 gwr #ifdef sun3
235 1.20 gwr /* Set seg in all contexts */
236 1.20 gwr void (*setcxsegmap)__P((int,int,int));
237 1.20 gwr
238 1.20 gwr /* V2: Handler for 'v' cmd */
239 1.20 gwr void (**vector_cmd)__P((int, char*));
240 1.22 gwr
241 1.22 gwr int pad[6];
242 1.22 gwr #endif /* sun3 */
243 1.22 gwr #ifdef sun3x
244 1.22 gwr
245 1.22 gwr /* V2: Handler for 'v' cmd */
246 1.22 gwr void (**vector_cmd)__P((int, char*));
247 1.22 gwr
248 1.22 gwr /* Address of low memory PTEs (maps at least 4MB) */
249 1.22 gwr int **lomemptaddr;
250 1.22 gwr
251 1.22 gwr /*
252 1.22 gwr * Address of debug/mon PTEs which map the 2MB space
253 1.22 gwr * starting at MON_KDB_START, ending at MONEND.
254 1.22 gwr */
255 1.22 gwr int **monptaddr;
256 1.22 gwr
257 1.22 gwr /*
258 1.22 gwr * Address of dvma PTEs. This is a VA that maps the I/O MMU
259 1.22 gwr * page table, but only the last part, which corresponds to
260 1.22 gwr * the CPU virtual space at MON_DVMA_BASE (see below).
261 1.22 gwr */
262 1.22 gwr int **dvmaptaddr;
263 1.22 gwr
264 1.22 gwr /*
265 1.22 gwr * Physical Address of the debug/mon PTEs found at the
266 1.22 gwr * virtual address given by *romVectorPtr->monptaddr;
267 1.22 gwr */
268 1.22 gwr int **monptphysaddr;
269 1.22 gwr
270 1.22 gwr /*
271 1.22 gwr * Address of shadow copy of DVMA PTEs. This is a VA that
272 1.22 gwr * maps the PTEs used by the CPU to map the same physical
273 1.22 gwr * pages as the I/O MMU into the CPU virtual space starting
274 1.22 gwr * at MON_DVMA_BASE, length MON_DVMA_SIZE (see below).
275 1.22 gwr */
276 1.22 gwr int **shadowpteaddr;
277 1.22 gwr
278 1.22 gwr struct physmemory *v_physmemory; /* Ptr to memory list for 3/80 */
279 1.22 gwr
280 1.22 gwr int pad[1];
281 1.22 gwr
282 1.22 gwr #endif /* sun3x */
283 1.1 glass } MachMonRomVector;
284 1.1 glass
285 1.1 glass /*
286 1.1 glass * Functions defined in the vector:
287 1.1 glass *
288 1.1 glass *
289 1.1 glass * getChar -- Return the next character from the input source
290 1.1 glass *
291 1.20 gwr * u_char getChar()
292 1.1 glass *
293 1.1 glass * putChar -- Write the given character to the output source.
294 1.1 glass *
295 1.1 glass * void putChar(ch)
296 1.1 glass * char ch;
297 1.1 glass *
298 1.22 gwr * mayGet -- Maybe get a character from the current input source. Return -1
299 1.1 glass * if don't return a character.
300 1.1 glass *
301 1.1 glass * int mayGet()
302 1.1 glass *
303 1.1 glass * mayPut -- Maybe put a character to the current output source. Return -1
304 1.1 glass * if no character output.
305 1.1 glass *
306 1.1 glass * int mayPut(ch)
307 1.1 glass * char ch;
308 1.1 glass *
309 1.1 glass * getKey -- Returns a key code (if up/down codes being returned),
310 1.1 glass * a byte of ASCII (if that's requested),
311 1.1 glass * NOKEY (if no key has been hit).
312 1.1 glass *
313 1.1 glass * int getKey()
314 1.1 glass *
315 1.1 glass * initGetKey -- Initialize things for get key.
316 1.1 glass *
317 1.1 glass * void initGetKey()
318 1.1 glass *
319 1.1 glass * fbWriteChar -- Write a character to the frame buffer
320 1.1 glass *
321 1.1 glass * void fwritechar(ch)
322 1.20 gwr * u_char ch;
323 1.1 glass *
324 1.1 glass * fbWriteStr -- Write a string to the frame buffer.
325 1.1 glass *
326 1.1 glass * void fwritestr(addr,len)
327 1.20 gwr * register u_char *addr; / * String to be written * /
328 1.1 glass * register short len; / * Length of string * /
329 1.1 glass *
330 1.1 glass * getLine -- read the next input line into a global buffer
331 1.1 glass *
332 1.1 glass * getline(echop)
333 1.1 glass * int echop; / * 1 if should echo input, 0 if not * /
334 1.1 glass *
335 1.1 glass * getNextChar -- return the next character from the global line buffer.
336 1.1 glass *
337 1.20 gwr * u_char getNextChar()
338 1.1 glass *
339 1.1 glass * peekNextChar -- look at the next character in the global line buffer.
340 1.1 glass *
341 1.20 gwr * u_char peekNextChar()
342 1.1 glass *
343 1.1 glass * getNum -- Grab hex num from the global line buffer.
344 1.1 glass *
345 1.1 glass * int getNum()
346 1.1 glass *
347 1.18 christos * printf -- Scaled down version of C library printf. Only %d, %x, %s, and %c
348 1.1 glass * are recognized.
349 1.1 glass *
350 1.1 glass * printhex -- prints rightmost <digs> hex digits of <val>
351 1.1 glass *
352 1.1 glass * printhex(val,digs)
353 1.1 glass * register int val;
354 1.1 glass * register int digs;
355 1.1 glass *
356 1.1 glass * abortEntry -- Entry for keyboard abort.
357 1.1 glass *
358 1.1 glass * abortEntry()
359 1.1 glass */
360 1.1 glass
361 1.1 glass /*
362 1.1 glass * Where the rom vector is defined.
363 1.1 glass */
364 1.1 glass
365 1.1 glass #define romVectorPtr ((MachMonRomVector *) PROM_BASE)
366 1.22 gwr /* #define romp romVectorPtr XXX - Too prone to conflicts. */
367 1.1 glass
368 1.1 glass /*
369 1.1 glass * Functions and defines to access the monitor.
370 1.1 glass */
371 1.1 glass
372 1.18 christos #define mon_printf (romVectorPtr->printf)
373 1.9 glass #define mon_putchar (romVectorPtr->putChar)
374 1.12 glass #define mon_may_getchar (romVectorPtr->mayGet)
375 1.1 glass #define mon_exit_to_mon (romVectorPtr->exitToMon)
376 1.13 gwr #define mon_reboot (romVectorPtr->reBoot)
377 1.8 glass #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();}
378 1.8 glass
379 1.22 gwr #ifdef sun3
380 1.22 gwr
381 1.7 glass #define mon_setcxsegmap(context, va, sme) \
382 1.7 glass romVectorPtr->setcxsegmap(context, va, sme)
383 1.4 glass
384 1.6 glass /*
385 1.22 gwr * The memory addresses for the PROM, and the EEPROM.
386 1.22 gwr * On the sun2 these addresses are actually 0x00EF??00
387 1.22 gwr * but only the bottom 24 bits are looked at so these still
388 1.22 gwr * work ok.
389 1.22 gwr */
390 1.22 gwr
391 1.22 gwr #define PROM_BASE 0x0fef0000
392 1.22 gwr
393 1.22 gwr /*
394 1.22 gwr * MONSTART and MONEND denote the range used by the monitor.
395 1.6 glass */
396 1.22 gwr #define MONSTART 0x0FE00000
397 1.22 gwr #define MONEND 0x0FF00000
398 1.4 glass
399 1.6 glass /*
400 1.6 glass * These describe the monitor's short segment which it basically uses to map
401 1.6 glass * one stupid page that it uses for storage. MONSHORTPAGE is the page,
402 1.22 gwr * and MONSHORTSEG is the segment that it is in. Its mapping must not
403 1.22 gwr * be removed (or the PROM monitor will be unhappy).
404 1.22 gwr */
405 1.22 gwr
406 1.22 gwr #define MONSHORTPAGE 0x0FFFE000
407 1.22 gwr #define MONSHORTSEG 0x0FFE0000
408 1.22 gwr
409 1.22 gwr #endif /* sun3 */
410 1.22 gwr #ifdef sun3x
411 1.22 gwr
412 1.22 gwr /*
413 1.22 gwr * We don't have a separate kernel debugger like sun kadb,
414 1.22 gwr * but this range is setup by the monitor for such a thing.
415 1.22 gwr * We might as well preserve the mappings anyway.
416 1.6 glass */
417 1.22 gwr #define MON_KDB_START 0xFEE00000
418 1.22 gwr #define MON_KDB_SIZE 0x100000
419 1.6 glass
420 1.22 gwr /*
421 1.22 gwr * MONSTART and MONEND define the range used by the monitor.
422 1.22 gwr * MONDATA is its data page (do not touch!)
423 1.22 gwr * PROM_BASE is where the boot PROM lives.
424 1.22 gwr */
425 1.22 gwr #define MONSTART 0xFEF00000
426 1.22 gwr #define MONDATA 0xFEF72000
427 1.22 gwr #define PROM_BASE 0xFEFE0000
428 1.22 gwr #define MONEND 0xFF000000
429 1.6 glass
430 1.22 gwr /*
431 1.22 gwr * These define the CPU virtual address range mapped by the
432 1.22 gwr * PROM for use as DVMA space. The physical pages mapped in
433 1.22 gwr * this range are also mapped by the I/O MMU.
434 1.22 gwr */
435 1.22 gwr #define MON_DVMA_BASE 0xFFF00000
436 1.22 gwr #define MON_DVMA_SIZE 0x100000 /* 1MB */
437 1.22 gwr
438 1.22 gwr #endif /* sun3x */
439 1.22 gwr #endif /* _MACHMON */
440 1.22 gwr #endif /* MACHINE_MON_H */
441