openprom.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. #ifndef __SPARC_OPENPROM_H
  2. #define __SPARC_OPENPROM_H
  3. /* openprom.h: Prom structures and defines for access to the OPENBOOT
  4. * prom routines and data areas.
  5. *
  6. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  7. */
  8. /* Empirical constants... */
  9. #ifdef CONFIG_SUN3
  10. #define KADB_DEBUGGER_BEGVM 0x0fee0000 /* There is no kadb yet but...*/
  11. #define LINUX_OPPROM_BEGVM 0x0fef0000
  12. #define LINUX_OPPROM_ENDVM 0x0ff10000 /* I think this is right - tm */
  13. #else
  14. #define KADB_DEBUGGER_BEGVM 0xffc00000 /* Where kern debugger is in virt-mem */
  15. #define LINUX_OPPROM_BEGVM 0xffd00000
  16. #define LINUX_OPPROM_ENDVM 0xfff00000
  17. #define LINUX_OPPROM_MAGIC 0x10010407
  18. #endif
  19. #ifndef __ASSEMBLY__
  20. /* V0 prom device operations. */
  21. struct linux_dev_v0_funcs {
  22. int (*v0_devopen)(char *device_str);
  23. int (*v0_devclose)(int dev_desc);
  24. int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
  25. int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
  26. int (*v0_wrnetdev)(int dev_desc, int num_bytes, char *buf);
  27. int (*v0_rdnetdev)(int dev_desc, int num_bytes, char *buf);
  28. int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
  29. int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
  30. int (*v0_seekdev)(int dev_desc, long logical_offst, int from);
  31. };
  32. /* V2 and later prom device operations. */
  33. struct linux_dev_v2_funcs {
  34. int (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */
  35. char * (*v2_dumb_mem_alloc)(char *va, unsigned sz);
  36. void (*v2_dumb_mem_free)(char *va, unsigned sz);
  37. /* To map devices into virtual I/O space. */
  38. char * (*v2_dumb_mmap)(char *virta, int which_io, unsigned paddr, unsigned sz);
  39. void (*v2_dumb_munmap)(char *virta, unsigned size);
  40. int (*v2_dev_open)(char *devpath);
  41. void (*v2_dev_close)(int d);
  42. int (*v2_dev_read)(int d, char *buf, int nbytes);
  43. int (*v2_dev_write)(int d, char *buf, int nbytes);
  44. int (*v2_dev_seek)(int d, int hi, int lo);
  45. /* Never issued (multistage load support) */
  46. void (*v2_wheee2)(void);
  47. void (*v2_wheee3)(void);
  48. };
  49. struct linux_mlist_v0 {
  50. struct linux_mlist_v0 *theres_more;
  51. char *start_adr;
  52. unsigned num_bytes;
  53. };
  54. struct linux_mem_v0 {
  55. struct linux_mlist_v0 **v0_totphys;
  56. struct linux_mlist_v0 **v0_prommap;
  57. struct linux_mlist_v0 **v0_available; /* What we can use */
  58. };
  59. /* Arguments sent to the kernel from the boot prompt. */
  60. struct linux_arguments_v0 {
  61. char *argv[8];
  62. char args[100];
  63. char boot_dev[2];
  64. int boot_dev_ctrl;
  65. int boot_dev_unit;
  66. int dev_partition;
  67. char *kernel_file_name;
  68. void *aieee1; /* XXX */
  69. };
  70. /* V2 and up boot things. */
  71. struct linux_bootargs_v2 {
  72. char **bootpath;
  73. char **bootargs;
  74. int *fd_stdin;
  75. int *fd_stdout;
  76. };
  77. #if defined(CONFIG_SUN3) || defined(CONFIG_SUN3X)
  78. struct linux_romvec {
  79. char *pv_initsp;
  80. int (*pv_startmon)(void);
  81. int *diagberr;
  82. struct linux_arguments_v0 **pv_v0bootargs;
  83. unsigned *pv_sun3mem;
  84. unsigned char (*pv_getchar)(void);
  85. int (*pv_putchar)(int ch);
  86. int (*pv_nbgetchar)(void);
  87. int (*pv_nbputchar)(int ch);
  88. unsigned char *pv_echo;
  89. unsigned char *pv_insource;
  90. unsigned char *pv_outsink;
  91. int (*pv_getkey)(void);
  92. int (*pv_initgetkey)(void);
  93. unsigned int *pv_translation;
  94. unsigned char *pv_keybid;
  95. int *pv_screen_x;
  96. int *pv_screen_y;
  97. struct keybuf *pv_keybuf;
  98. char *pv_monid;
  99. /*
  100. * Frame buffer output and terminal emulation
  101. */
  102. int (*pv_fbwritechar)(char);
  103. int *pv_fbaddr;
  104. char **pv_font;
  105. int (*pv_fbwritestr)(char);
  106. void (*pv_reboot)(char *bootstr);
  107. /*
  108. * Line input and parsing
  109. */
  110. unsigned char *pv_linebuf;
  111. unsigned char **pv_lineptr;
  112. int *pv_linesize;
  113. int (*pv_getline)(void);
  114. unsigned char (*pv_getnextchar)(void);
  115. unsigned char (*pv_peeknextchar)(void);
  116. int *pv_fbthere;
  117. int (*pv_getnum)(void);
  118. void (*pv_printf)(const char *fmt, ...);
  119. int (*pv_printhex)(void);
  120. unsigned char *pv_leds;
  121. int (*pv_setleds)(void);
  122. /*
  123. * Non-maskable interrupt (nmi) information
  124. */
  125. int (*pv_nmiaddr)(void);
  126. int (*pv_abortentry)(void);
  127. int *pv_nmiclock;
  128. int *pv_fbtype;
  129. /*
  130. * Assorted other things
  131. */
  132. unsigned pv_romvers;
  133. struct globram *pv_globram;
  134. char *pv_kbdzscc;
  135. int *pv_keyrinit;
  136. unsigned char *pv_keyrtick;
  137. unsigned *pv_memoryavail;
  138. long *pv_resetaddr;
  139. long *pv_resetmap;
  140. void (*pv_halt)(void);
  141. unsigned char *pv_memorybitmap;
  142. #ifdef CONFIG_SUN3
  143. void (*pv_setctxt)(int ctxt, char *va, int pmeg);
  144. void (*pv_vector_cmd)(void);
  145. int dummy1z;
  146. int dummy2z;
  147. int dummy3z;
  148. int dummy4z;
  149. #endif
  150. };
  151. #else
  152. /* The top level PROM vector. */
  153. struct linux_romvec {
  154. /* Version numbers. */
  155. unsigned int pv_magic_cookie;
  156. unsigned int pv_romvers;
  157. unsigned int pv_plugin_revision;
  158. unsigned int pv_printrev;
  159. /* Version 0 memory descriptors. */
  160. struct linux_mem_v0 pv_v0mem;
  161. /* Node operations. */
  162. struct linux_nodeops *pv_nodeops;
  163. char **pv_bootstr;
  164. struct linux_dev_v0_funcs pv_v0devops;
  165. char *pv_stdin;
  166. char *pv_stdout;
  167. #define PROMDEV_KBD 0 /* input from keyboard */
  168. #define PROMDEV_SCREEN 0 /* output to screen */
  169. #define PROMDEV_TTYA 1 /* in/out to ttya */
  170. #define PROMDEV_TTYB 2 /* in/out to ttyb */
  171. /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
  172. int (*pv_getchar)(void);
  173. void (*pv_putchar)(int ch);
  174. /* Non-blocking variants. */
  175. int (*pv_nbgetchar)(void);
  176. int (*pv_nbputchar)(int ch);
  177. void (*pv_putstr)(char *str, int len);
  178. /* Miscellany. */
  179. void (*pv_reboot)(char *bootstr);
  180. void (*pv_printf)(__const__ char *fmt, ...);
  181. void (*pv_abort)(void);
  182. __volatile__ int *pv_ticks;
  183. void (*pv_halt)(void);
  184. void (**pv_synchook)(void);
  185. /* Evaluate a forth string, not different proto for V0 and V2->up. */
  186. union {
  187. void (*v0_eval)(int len, char *str);
  188. void (*v2_eval)(char *str);
  189. } pv_fortheval;
  190. struct linux_arguments_v0 **pv_v0bootargs;
  191. /* Get ether address. */
  192. unsigned int (*pv_enaddr)(int d, char *enaddr);
  193. struct linux_bootargs_v2 pv_v2bootargs;
  194. struct linux_dev_v2_funcs pv_v2devops;
  195. int filler[15];
  196. /* This one is sun4c/sun4 only. */
  197. void (*pv_setctxt)(int ctxt, char *va, int pmeg);
  198. /* Prom version 3 Multiprocessor routines. This stuff is crazy.
  199. * No joke. Calling these when there is only one cpu probably
  200. * crashes the machine, have to test this. :-)
  201. */
  202. /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
  203. * 'thiscontext' executing at address 'prog_counter'
  204. */
  205. int (*v3_cpustart)(unsigned int whichcpu, int ctxtbl_ptr,
  206. int thiscontext, char *prog_counter);
  207. /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
  208. * until a resume cpu call is made.
  209. */
  210. int (*v3_cpustop)(unsigned int whichcpu);
  211. /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
  212. * resume cpu call is made.
  213. */
  214. int (*v3_cpuidle)(unsigned int whichcpu);
  215. /* v3_cpuresume() will resume processor 'whichcpu' executing
  216. * starting with whatever 'pc' and 'npc' were left at the
  217. * last 'idle' or 'stop' call.
  218. */
  219. int (*v3_cpuresume)(unsigned int whichcpu);
  220. };
  221. #endif
  222. /* Routines for traversing the prom device tree. */
  223. struct linux_nodeops {
  224. int (*no_nextnode)(int node);
  225. int (*no_child)(int node);
  226. int (*no_proplen)(int node, char *name);
  227. int (*no_getprop)(int node, char *name, char *val);
  228. int (*no_setprop)(int node, char *name, char *val, int len);
  229. char * (*no_nextprop)(int node, char *name);
  230. };
  231. /* More fun PROM structures for device probing. */
  232. #define PROMREG_MAX 16
  233. #define PROMVADDR_MAX 16
  234. #define PROMINTR_MAX 15
  235. struct linux_prom_registers {
  236. int which_io; /* is this in OBIO space? */
  237. char *phys_addr; /* The physical address of this register */
  238. int reg_size; /* How many bytes does this register take up? */
  239. };
  240. struct linux_prom_irqs {
  241. int pri; /* IRQ priority */
  242. int vector; /* This is foobar, what does it do? */
  243. };
  244. /* Element of the "ranges" vector */
  245. struct linux_prom_ranges {
  246. unsigned int ot_child_space;
  247. unsigned int ot_child_base; /* Bus feels this */
  248. unsigned int ot_parent_space;
  249. unsigned int ot_parent_base; /* CPU looks from here */
  250. unsigned int or_size;
  251. };
  252. #endif /* !(__ASSEMBLY__) */
  253. #endif /* !(__SPARC_OPENPROM_H) */