oldmon.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /* $OpenBSD: oldmon.h,v 1.9 2002/03/15 01:20:04 millert Exp $ */
  2. /* $NetBSD: oldmon.h,v 1.11 1996/03/31 22:21:38 pk Exp $ */
  3. /*
  4. * Copyright (C) 1985 Regents of the University of California
  5. * Copyright (c) 1993 Adam Glass
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. All advertising materials mentioning features or use of this software
  17. * must display the following acknowledgement:
  18. * This product includes software developed by Adam Glass.
  19. * 4. The name of the Author may not be used to endorse or promote products
  20. * derived from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * from: Sprite /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v
  35. * 9.1 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley)
  36. */
  37. #ifndef _MACHINE_OLDMON_H
  38. #define _MACHINE_OLDMON_H
  39. /*
  40. * Structures, constants and defines for access to the sun monitor.
  41. * These are translated from the sun monitor header file "sunromvec.h".
  42. *
  43. * The memory addresses for the PROM, and the EEPROM.
  44. * On the sun2 these addresses are actually 0x00EF??00
  45. * but only the bottom 24 bits are looked at so these still
  46. * work ok.
  47. */
  48. #define PROM_BASE 0xffe81000
  49. enum maptypes { /* Page map entry types. */
  50. MAP_MAINMEM,
  51. MAP_OBIO,
  52. MAP_MBMEM,
  53. MAP_MBIO,
  54. MAP_VME16A16D,
  55. MAP_VME16A32D,
  56. MAP_VME24A16D,
  57. MAP_VME24A32D,
  58. MAP_VME32A16D,
  59. MAP_VME32A32D
  60. };
  61. /*
  62. * This table gives information about the resources needed by a device.
  63. */
  64. struct devinfo {
  65. unsigned int d_devbytes; /* Bytes occupied by device in IO space.*/
  66. unsigned int d_dmabytes; /* Bytes needed by device in DMA memory.*/
  67. unsigned int d_localbytes;/* Bytes needed by device for local info.*/
  68. unsigned int d_stdcount; /* How many standard addresses. */
  69. unsigned long *d_stdaddrs; /* The vector of standard addresses. */
  70. enum maptypes d_devtype; /* What map space device is in. */
  71. unsigned int d_maxiobytes;/* Size to break big I/O's into. */
  72. };
  73. /*
  74. * A "stand alone I/O request".
  75. * This is passed as the main argument to the PROM I/O routines
  76. * in the `om_boottable' structure.
  77. */
  78. struct saioreq {
  79. char si_flgs;
  80. struct om_boottable *si_boottab;/* Points to boottab entry if any */
  81. char *si_devdata; /* Device-specific data pointer */
  82. int si_ctlr; /* Controller number or address */
  83. int si_unit; /* Unit number within controller */
  84. long si_boff; /* Partition number within unit */
  85. long si_cyloff;
  86. long si_offset;
  87. long si_bn; /* Block number to R/W */
  88. char *si_ma; /* Memory address to R/W */
  89. int si_cc; /* Character count to R/W */
  90. struct saif *si_sif; /* net if. pointer (set by b_open) */
  91. char *si_devaddr; /* Points to mapped in device */
  92. char *si_dmaaddr; /* Points to allocated DMA space */
  93. };
  94. #define SAIO_F_READ 0x01
  95. #define SAIO_F_WRITE 0x02
  96. #define SAIO_F_ALLOC 0x04
  97. #define SAIO_F_FILE 0x08
  98. #define SAIO_F_EOF 0x10 /* EOF on device */
  99. #define SAIO_F_AJAR 0x20 /* Descriptor "ajar" (stopped but not closed) */
  100. /*
  101. * The table entry that describes a device. It exists in the PROM; a
  102. * pointer to it is passed in MachMonBootParam. It can be used to locate
  103. * PROM subroutines for opening, reading, and writing the device.
  104. *
  105. * When using this interface, only one device can be open at once.
  106. *
  107. * NOTE: I am not sure what arguments boot, open, close, and strategy take.
  108. * What is here is just translated verbatim from the sun monitor code. We
  109. * should figure this out eventually if we need it.
  110. */
  111. struct om_boottable {
  112. char b_devname[2]; /* The name of the device */
  113. int (*b_probe)(void); /* probe() --> -1 or found controller
  114. number */
  115. int (*b_boot)(void); /* boot(bp) --> -1 or start address */
  116. int (*b_open)(struct saioreq *);/* open(iobp) --> -1 or 0 */
  117. int (*b_close)(struct saioreq *);/* close(iobp) --> -1 or 0 */
  118. int (*b_strategy)(struct saioreq *, int);/* strategy(iobp,rw) --> -1 or 0 */
  119. char *b_desc; /* Printable string describing dev */
  120. struct devinfo *b_devinfo; /* info to configure device. */
  121. };
  122. /*
  123. * Structure set up by the boot command to pass arguments to the program that
  124. * is booted.
  125. */
  126. struct om_bootparam {
  127. char *argPtr[8]; /* String arguments */
  128. char strings[100]; /* String table for string arguments */
  129. char devName[2]; /* Device name */
  130. int ctlrNum; /* Controller number */
  131. int unitNum; /* Unit number */
  132. int partNum; /* Partition/file number */
  133. char *fileName; /* File name, points into strings */
  134. struct om_boottable *bootTable; /* Points to table entry for device */
  135. };
  136. /*
  137. * Here is the structure of the vector table which is at the front of the boot
  138. * rom. The functions defined in here are explained below.
  139. *
  140. * NOTE: This struct has references to the structures keybuf and globram which
  141. * I have not translated. If anyone needs to use these they should
  142. * translate these structs into Sprite format.
  143. */
  144. struct om_vector {
  145. char *initSp; /* Initial system stack ptr for hardware */
  146. int (*startMon)(void);/* Initial PC for hardware */
  147. int *diagberr; /* Bus err handler for diags */
  148. /* Monitor and hardware revision and identification */
  149. struct om_bootparam **bootParam;/* Info for bootstrapped pgm */
  150. u_long *memorySize; /* Usable memory in bytes */
  151. /* Single-character input and output */
  152. int (*getChar)(void); /* Get char from input source */
  153. void (*putChar)(int); /* Put char to output sink */
  154. int (*mayGet)(void); /* Maybe get char, or -1 */
  155. int (*mayPut)(int); /* Maybe put char, or -1 */
  156. u_char *echo; /* Should getchar echo? */
  157. u_char *inSource; /* Input source selector */
  158. u_char *outSink; /* Output sink selector */
  159. #define PROMDEV_KBD 0 /* input from keyboard */
  160. #define PROMDEV_SCREEN 0 /* output to screen */
  161. #define PROMDEV_TTYA 1 /* in/out to ttya */
  162. #define PROMDEV_TTYB 2 /* in/out to ttyb */
  163. /* Keyboard input (scanned by monitor nmi routine) */
  164. int (*getKey)(void); /* Get next key if one exists */
  165. int (*initGetKey)(void); /* Initialize get key */
  166. u_int *translation; /* Kbd translation selector */
  167. u_char *keyBid; /* Keyboard ID byte */
  168. int *screen_x; /* V2: Screen x pos (R/O) */
  169. int *screen_y; /* V2: Screen y pos (R/O) */
  170. struct keybuf *keyBuf; /* Up/down keycode buffer */
  171. /* Monitor revision level. */
  172. char *monId;
  173. /* Frame buffer output and terminal emulation */
  174. int (*fbWriteChar)(void); /* Write a character to FB */
  175. int *fbAddr; /* Address of frame buffer */
  176. char **font; /* Font table for FB */
  177. void (*fbWriteStr)(char *, int);
  178. /* Quickly write string to FB */
  179. /* Reboot interface routine -- resets and reboots system. */
  180. void (*reBoot)(char *); /* e.g. reBoot("xy()vmunix") */
  181. /* Line input and parsing */
  182. u_char *lineBuf; /* The line input buffer */
  183. u_char **linePtr; /* Cur pointer into linebuf */
  184. int *lineSize; /* length of line in linebuf */
  185. int (*getLine)(void); /* Get line from user */
  186. u_char (*getNextChar)(void); /* Get next char from linebuf */
  187. u_char (*peekNextChar)(void); /* Peek at next char */
  188. int *fbThere; /* =1 if frame buffer there */
  189. int (*getNum)(void); /* Grab hex num from line */
  190. /* Print formatted output to current output sink */
  191. int (*printf)(void); /* Similar to "Kernel printf" */
  192. int (*printHex)(void); /* Format N digits in hex */
  193. /* Led stuff */
  194. u_char *leds; /* RAM copy of LED register */
  195. int (*setLeds)(void); /* Sets LED's and RAM copy */
  196. /* Non-maskable interrupt (nmi) information */
  197. int (*nmiAddr)(void); /* Addr for level 7 vector */
  198. void (*abortEntry)(void); /* Entry for keyboard abort */
  199. int *nmiClock; /* Counts up in msec */
  200. /* Frame buffer type: see <machine/fbio.h> */
  201. int *fbType;
  202. /* Assorted other things */
  203. u_long romvecVersion; /* Version # of Romvec */
  204. struct globram *globRam; /* monitor global variables */
  205. caddr_t kbdZscc; /* Addr of keyboard in use */
  206. int *keyrInit; /* ms before kbd repeat */
  207. u_char *keyrTick; /* ms between repetitions */
  208. u_long *memoryAvail; /* V1: Main mem usable size */
  209. long *resetAddr; /* where to jump on a reset */
  210. long *resetMap; /* pgmap entry for resetaddr */
  211. /* Really struct pgmapent * */
  212. /* Exit from user program */
  213. void (*exitToMon)(void) __attribute__((__noreturn__));
  214. u_char **memorybitmap; /* V1: &{0 or &bits} */
  215. /* Set seg in any context */
  216. void (*setcxsegmap)(int, caddr_t, int);
  217. void (**vector_cmd)(u_long, char *);/* V2: Handler for 'v' cmd */
  218. u_long *ExpectedTrapSig;
  219. u_long *TrapVectorTable;
  220. int dummy1z;
  221. int dummy2z;
  222. int dummy3z;
  223. int dummy4z;
  224. };
  225. #define romVectorPtr ((struct om_vector *)PROM_BASE)
  226. #define mon_printf (romVectorPtr->printf)
  227. #define mon_putchar (romVectorPtr->putChar)
  228. #define mon_may_getchar (romVectorPtr->mayGet)
  229. #define mon_exit_to_mon (romVectorPtr->exitToMon)
  230. #define mon_reboot (romVectorPtr->exitToMon)
  231. #define mon_panic(x) { mon_printf(x); mon_exit_to_mon();}
  232. #define mon_setcxsegmap(context, va, sme) \
  233. romVectorPtr->setcxsegmap(context, va, sme)
  234. #define romp (romVectorPtr)
  235. /*
  236. * OLDMON_STARTVADDR and OLDMON_ENDVADDR denote the range of the damn monitor.
  237. *
  238. * supposedly you can steal pmegs within this range that do not contain
  239. * valid pages.
  240. */
  241. #define OLDMON_STARTVADDR 0xFFD00000
  242. #define OLDMON_ENDVADDR 0xFFF00000
  243. /*
  244. * These describe the monitor's short segment which it basically uses to map
  245. * one stupid page that it uses for storage. MONSHORTPAGE is the page,
  246. * and MONSHORTSEG is the segment that it is in. If this sounds dumb to
  247. * you, it is. I can change the pmeg, but not the virtual address.
  248. * Sun defines these with the high nibble set to 0xF. I believe this was
  249. * for the monitor source which accesses this piece of memory with addressing
  250. * limitations or some such crud. I haven't replicated this here, because
  251. * it is confusing, and serves no obvious purpose if you aren't the monitor.
  252. *
  253. */
  254. #define MONSHORTPAGE 0x0FFFE000
  255. #define MONSHORTSEG 0x0FFE0000
  256. /*
  257. * Ethernet interface descriptor
  258. * First, set: saiop->si_devaddr, saiop->si_dmaaddr, etc.
  259. * Then: saiop->si_boottab->b_open() will set:
  260. * saiop->si_sif;
  261. * saiop->si_devdata;
  262. * The latter is the first arg to the following functions.
  263. * Note that the buffer must be in DVMA space...
  264. */
  265. struct saif {
  266. /* transmit packet, returns zero on success. */
  267. int (*sif_xmit)(void *devdata, char *buf, int len);
  268. /* wait for packet, zero if none arrived */
  269. int (*sif_poll)(void *devdata, char *buf);
  270. /* reset interface, set addresses, etc. */
  271. int (*sif_reset)(void *devdata, struct saioreq *sip);
  272. /* Later (sun4 only) proms have more stuff here. */
  273. };
  274. #if defined(SUN4)
  275. void oldmon_w_trace(u_long);
  276. void oldmon_w_cmd(u_long, char *);
  277. #endif
  278. #endif /* _MACHINE_OLDMON_H */