openprom.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /* $Id: openprom.h,v 1.9 2001/03/16 10:22:02 davem Exp $ */
  2. #ifndef __SPARC64_OPENPROM_H
  3. #define __SPARC64_OPENPROM_H
  4. /* openprom.h: Prom structures and defines for access to the OPENBOOT
  5. * prom routines and data areas.
  6. *
  7. * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  8. */
  9. #ifndef __ASSEMBLY__
  10. /* V0 prom device operations. */
  11. struct linux_dev_v0_funcs {
  12. int (*v0_devopen)(char *device_str);
  13. int (*v0_devclose)(int dev_desc);
  14. int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
  15. int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
  16. int (*v0_wrnetdev)(int dev_desc, int num_bytes, char *buf);
  17. int (*v0_rdnetdev)(int dev_desc, int num_bytes, char *buf);
  18. int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
  19. int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
  20. int (*v0_seekdev)(int dev_desc, long logical_offst, int from);
  21. };
  22. /* V2 and later prom device operations. */
  23. struct linux_dev_v2_funcs {
  24. int (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */
  25. char * (*v2_dumb_mem_alloc)(char *va, unsigned sz);
  26. void (*v2_dumb_mem_free)(char *va, unsigned sz);
  27. /* To map devices into virtual I/O space. */
  28. char * (*v2_dumb_mmap)(char *virta, int which_io, unsigned paddr, unsigned sz);
  29. void (*v2_dumb_munmap)(char *virta, unsigned size);
  30. int (*v2_dev_open)(char *devpath);
  31. void (*v2_dev_close)(int d);
  32. int (*v2_dev_read)(int d, char *buf, int nbytes);
  33. int (*v2_dev_write)(int d, char *buf, int nbytes);
  34. int (*v2_dev_seek)(int d, int hi, int lo);
  35. /* Never issued (multistage load support) */
  36. void (*v2_wheee2)(void);
  37. void (*v2_wheee3)(void);
  38. };
  39. struct linux_mlist_v0 {
  40. struct linux_mlist_v0 *theres_more;
  41. unsigned start_adr;
  42. unsigned num_bytes;
  43. };
  44. struct linux_mem_v0 {
  45. struct linux_mlist_v0 **v0_totphys;
  46. struct linux_mlist_v0 **v0_prommap;
  47. struct linux_mlist_v0 **v0_available; /* What we can use */
  48. };
  49. /* Arguments sent to the kernel from the boot prompt. */
  50. struct linux_arguments_v0 {
  51. char *argv[8];
  52. char args[100];
  53. char boot_dev[2];
  54. int boot_dev_ctrl;
  55. int boot_dev_unit;
  56. int dev_partition;
  57. char *kernel_file_name;
  58. void *aieee1; /* XXX */
  59. };
  60. /* V2 and up boot things. */
  61. struct linux_bootargs_v2 {
  62. char **bootpath;
  63. char **bootargs;
  64. int *fd_stdin;
  65. int *fd_stdout;
  66. };
  67. /* The top level PROM vector. */
  68. struct linux_romvec {
  69. /* Version numbers. */
  70. unsigned int pv_magic_cookie;
  71. unsigned int pv_romvers;
  72. unsigned int pv_plugin_revision;
  73. unsigned int pv_printrev;
  74. /* Version 0 memory descriptors. */
  75. struct linux_mem_v0 pv_v0mem;
  76. /* Node operations. */
  77. struct linux_nodeops *pv_nodeops;
  78. char **pv_bootstr;
  79. struct linux_dev_v0_funcs pv_v0devops;
  80. char *pv_stdin;
  81. char *pv_stdout;
  82. #define PROMDEV_KBD 0 /* input from keyboard */
  83. #define PROMDEV_SCREEN 0 /* output to screen */
  84. #define PROMDEV_TTYA 1 /* in/out to ttya */
  85. #define PROMDEV_TTYB 2 /* in/out to ttyb */
  86. /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
  87. int (*pv_getchar)(void);
  88. void (*pv_putchar)(int ch);
  89. /* Non-blocking variants. */
  90. int (*pv_nbgetchar)(void);
  91. int (*pv_nbputchar)(int ch);
  92. void (*pv_putstr)(char *str, int len);
  93. /* Miscellany. */
  94. void (*pv_reboot)(char *bootstr);
  95. void (*pv_printf)(__const__ char *fmt, ...);
  96. void (*pv_abort)(void);
  97. __volatile__ int *pv_ticks;
  98. void (*pv_halt)(void);
  99. void (**pv_synchook)(void);
  100. /* Evaluate a forth string, not different proto for V0 and V2->up. */
  101. union {
  102. void (*v0_eval)(int len, char *str);
  103. void (*v2_eval)(char *str);
  104. } pv_fortheval;
  105. struct linux_arguments_v0 **pv_v0bootargs;
  106. /* Get ether address. */
  107. unsigned int (*pv_enaddr)(int d, char *enaddr);
  108. struct linux_bootargs_v2 pv_v2bootargs;
  109. struct linux_dev_v2_funcs pv_v2devops;
  110. int filler[15];
  111. /* This one is sun4c/sun4 only. */
  112. void (*pv_setctxt)(int ctxt, char *va, int pmeg);
  113. /* Prom version 3 Multiprocessor routines. This stuff is crazy.
  114. * No joke. Calling these when there is only one cpu probably
  115. * crashes the machine, have to test this. :-)
  116. */
  117. /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
  118. * 'thiscontext' executing at address 'prog_counter'
  119. */
  120. int (*v3_cpustart)(unsigned int whichcpu, int ctxtbl_ptr,
  121. int thiscontext, char *prog_counter);
  122. /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
  123. * until a resume cpu call is made.
  124. */
  125. int (*v3_cpustop)(unsigned int whichcpu);
  126. /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
  127. * resume cpu call is made.
  128. */
  129. int (*v3_cpuidle)(unsigned int whichcpu);
  130. /* v3_cpuresume() will resume processor 'whichcpu' executing
  131. * starting with whatever 'pc' and 'npc' were left at the
  132. * last 'idle' or 'stop' call.
  133. */
  134. int (*v3_cpuresume)(unsigned int whichcpu);
  135. };
  136. /* Routines for traversing the prom device tree. */
  137. struct linux_nodeops {
  138. int (*no_nextnode)(int node);
  139. int (*no_child)(int node);
  140. int (*no_proplen)(int node, char *name);
  141. int (*no_getprop)(int node, char *name, char *val);
  142. int (*no_setprop)(int node, char *name, char *val, int len);
  143. char * (*no_nextprop)(int node, char *name);
  144. };
  145. /* More fun PROM structures for device probing. */
  146. #define PROMREG_MAX 24
  147. #define PROMVADDR_MAX 16
  148. #define PROMINTR_MAX 32
  149. struct linux_prom_registers {
  150. unsigned which_io; /* hi part of physical address */
  151. unsigned phys_addr; /* The physical address of this register */
  152. int reg_size; /* How many bytes does this register take up? */
  153. };
  154. struct linux_prom64_registers {
  155. unsigned long phys_addr;
  156. unsigned long reg_size;
  157. };
  158. struct linux_prom_irqs {
  159. int pri; /* IRQ priority */
  160. int vector; /* This is foobar, what does it do? */
  161. };
  162. /* Element of the "ranges" vector */
  163. struct linux_prom_ranges {
  164. unsigned int ot_child_space;
  165. unsigned int ot_child_base; /* Bus feels this */
  166. unsigned int ot_parent_space;
  167. unsigned int ot_parent_base; /* CPU looks from here */
  168. unsigned int or_size;
  169. };
  170. struct linux_prom64_ranges {
  171. unsigned long ot_child_base; /* Bus feels this */
  172. unsigned long ot_parent_base; /* CPU looks from here */
  173. unsigned long or_size;
  174. };
  175. /* Ranges and reg properties are a bit different for PCI. */
  176. struct linux_prom_pci_registers {
  177. unsigned int phys_hi;
  178. unsigned int phys_mid;
  179. unsigned int phys_lo;
  180. unsigned int size_hi;
  181. unsigned int size_lo;
  182. };
  183. struct linux_prom_pci_ranges {
  184. unsigned int child_phys_hi; /* Only certain bits are encoded here. */
  185. unsigned int child_phys_mid;
  186. unsigned int child_phys_lo;
  187. unsigned int parent_phys_hi;
  188. unsigned int parent_phys_lo;
  189. unsigned int size_hi;
  190. unsigned int size_lo;
  191. };
  192. struct linux_prom_pci_intmap {
  193. unsigned int phys_hi;
  194. unsigned int phys_mid;
  195. unsigned int phys_lo;
  196. unsigned int interrupt;
  197. int cnode;
  198. unsigned int cinterrupt;
  199. };
  200. struct linux_prom_pci_intmask {
  201. unsigned int phys_hi;
  202. unsigned int phys_mid;
  203. unsigned int phys_lo;
  204. unsigned int interrupt;
  205. };
  206. struct linux_prom_ebus_ranges {
  207. unsigned int child_phys_hi;
  208. unsigned int child_phys_lo;
  209. unsigned int parent_phys_hi;
  210. unsigned int parent_phys_mid;
  211. unsigned int parent_phys_lo;
  212. unsigned int size;
  213. };
  214. struct linux_prom_ebus_intmap {
  215. unsigned int phys_hi;
  216. unsigned int phys_lo;
  217. unsigned int interrupt;
  218. int cnode;
  219. unsigned int cinterrupt;
  220. };
  221. struct linux_prom_ebus_intmask {
  222. unsigned int phys_hi;
  223. unsigned int phys_lo;
  224. unsigned int interrupt;
  225. };
  226. #endif /* !(__ASSEMBLY__) */
  227. #endif /* !(__SPARC64_OPENPROM_H) */