openprom.h 6.8 KB

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