openprom.h 8.0 KB

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