prom.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /* OpenProm defines mainly taken from linux kernel header files
  2. *
  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. * Copyright (C) 2007 Daniel Hellstrom (daniel@gaisler.com)
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. *
  24. */
  25. #ifndef __SPARC_OPENPROM_H__
  26. #define __SPARC_OPENPROM_H__
  27. /* Empirical constants... */
  28. #define LINUX_OPPROM_MAGIC 0x10010407
  29. #ifndef __ASSEMBLY__
  30. /* V0 prom device operations. */
  31. struct linux_dev_v0_funcs {
  32. int (*v0_devopen) (char *device_str);
  33. int (*v0_devclose) (int dev_desc);
  34. int (*v0_rdblkdev) (int dev_desc, int num_blks, int blk_st, char *buf);
  35. int (*v0_wrblkdev) (int dev_desc, int num_blks, int blk_st, char *buf);
  36. int (*v0_wrnetdev) (int dev_desc, int num_bytes, char *buf);
  37. int (*v0_rdnetdev) (int dev_desc, int num_bytes, char *buf);
  38. int (*v0_rdchardev) (int dev_desc, int num_bytes, int dummy, char *buf);
  39. int (*v0_wrchardev) (int dev_desc, int num_bytes, int dummy, char *buf);
  40. int (*v0_seekdev) (int dev_desc, long logical_offst, int from);
  41. };
  42. /* V2 and later prom device operations. */
  43. struct linux_dev_v2_funcs {
  44. int (*v2_inst2pkg) (int d); /* Convert ihandle to phandle */
  45. char *(*v2_dumb_mem_alloc) (char *va, unsigned sz);
  46. void (*v2_dumb_mem_free) (char *va, unsigned sz);
  47. /* To map devices into virtual I/O space. */
  48. char *(*v2_dumb_mmap) (char *virta, int which_io, unsigned paddr,
  49. unsigned sz);
  50. void (*v2_dumb_munmap) (char *virta, unsigned size);
  51. int (*v2_dev_open) (char *devpath);
  52. void (*v2_dev_close) (int d);
  53. int (*v2_dev_read) (int d, char *buf, int nbytes);
  54. int (*v2_dev_write) (int d, char *buf, int nbytes);
  55. int (*v2_dev_seek) (int d, int hi, int lo);
  56. /* Never issued (multistage load support) */
  57. void (*v2_wheee2) (void);
  58. void (*v2_wheee3) (void);
  59. };
  60. struct linux_mlist_v0 {
  61. struct linux_mlist_v0 *theres_more;
  62. char *start_adr;
  63. unsigned num_bytes;
  64. };
  65. struct linux_mem_v0 {
  66. struct linux_mlist_v0 **v0_totphys;
  67. struct linux_mlist_v0 **v0_prommap;
  68. struct linux_mlist_v0 **v0_available; /* What we can use */
  69. };
  70. /* Arguments sent to the kernel from the boot prompt. */
  71. struct linux_arguments_v0 {
  72. char *argv[8];
  73. char args[100];
  74. char boot_dev[2];
  75. int boot_dev_ctrl;
  76. int boot_dev_unit;
  77. int dev_partition;
  78. char *kernel_file_name;
  79. void *aieee1; /* XXX */
  80. };
  81. /* V2 and up boot things. */
  82. struct linux_bootargs_v2 {
  83. char **bootpath;
  84. char **bootargs;
  85. int *fd_stdin;
  86. int *fd_stdout;
  87. };
  88. /* The top level PROM vector. */
  89. struct linux_romvec {
  90. /* Version numbers. */
  91. unsigned int pv_magic_cookie;
  92. unsigned int pv_romvers;
  93. unsigned int pv_plugin_revision;
  94. unsigned int pv_printrev;
  95. /* Version 0 memory descriptors. */
  96. struct linux_mem_v0 pv_v0mem;
  97. /* Node operations. */
  98. struct linux_nodeops *pv_nodeops;
  99. char **pv_bootstr;
  100. struct linux_dev_v0_funcs pv_v0devops;
  101. char *pv_stdin;
  102. char *pv_stdout;
  103. #define PROMDEV_KBD 0 /* input from keyboard */
  104. #define PROMDEV_SCREEN 0 /* output to screen */
  105. #define PROMDEV_TTYA 1 /* in/out to ttya */
  106. #define PROMDEV_TTYB 2 /* in/out to ttyb */
  107. /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
  108. int (*pv_getchar) (void);
  109. void (*pv_putchar) (int ch);
  110. /* Non-blocking variants. */
  111. int (*pv_nbgetchar) (void);
  112. int (*pv_nbputchar) (int ch);
  113. void (*pv_putstr) (char *str, int len);
  114. /* Miscellany. */
  115. void (*pv_reboot) (char *bootstr);
  116. void (*pv_printf) (__const__ char *fmt, ...);
  117. void (*pv_abort) (void);
  118. __volatile__ int *pv_ticks;
  119. void (*pv_halt) (void);
  120. void (**pv_synchook) (void);
  121. /* Evaluate a forth string, not different proto for V0 and V2->up. */
  122. union {
  123. void (*v0_eval) (int len, char *str);
  124. void (*v2_eval) (char *str);
  125. } pv_fortheval;
  126. struct linux_arguments_v0 **pv_v0bootargs;
  127. /* Get ether address. */
  128. unsigned int (*pv_enaddr) (int d, char *enaddr);
  129. struct linux_bootargs_v2 pv_v2bootargs;
  130. struct linux_dev_v2_funcs pv_v2devops;
  131. int filler[15];
  132. /* This one is sun4c/sun4 only. */
  133. void (*pv_setctxt) (int ctxt, char *va, int pmeg);
  134. /* Prom version 3 Multiprocessor routines. This stuff is crazy.
  135. * No joke. Calling these when there is only one cpu probably
  136. * crashes the machine, have to test this. :-)
  137. */
  138. /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
  139. * 'thiscontext' executing at address 'prog_counter'
  140. */
  141. int (*v3_cpustart) (unsigned int whichcpu, int ctxtbl_ptr,
  142. int thiscontext, char *prog_counter);
  143. /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
  144. * until a resume cpu call is made.
  145. */
  146. int (*v3_cpustop) (unsigned int whichcpu);
  147. /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
  148. * resume cpu call is made.
  149. */
  150. int (*v3_cpuidle) (unsigned int whichcpu);
  151. /* v3_cpuresume() will resume processor 'whichcpu' executing
  152. * starting with whatever 'pc' and 'npc' were left at the
  153. * last 'idle' or 'stop' call.
  154. */
  155. int (*v3_cpuresume) (unsigned int whichcpu);
  156. };
  157. /* Routines for traversing the prom device tree. */
  158. struct linux_nodeops {
  159. int (*no_nextnode) (int node);
  160. int (*no_child) (int node);
  161. int (*no_proplen) (int node, char *name);
  162. int (*no_getprop) (int node, char *name, char *val);
  163. int (*no_setprop) (int node, char *name, char *val, int len);
  164. char *(*no_nextprop) (int node, char *name);
  165. };
  166. /* More fun PROM structures for device probing. */
  167. #define PROMREG_MAX 16
  168. #define PROMVADDR_MAX 16
  169. #define PROMINTR_MAX 15
  170. struct linux_prom_registers {
  171. unsigned int which_io; /* is this in OBIO space? */
  172. unsigned int phys_addr; /* The physical address of this register */
  173. unsigned int reg_size; /* How many bytes does this register take up? */
  174. };
  175. struct linux_prom_irqs {
  176. int pri; /* IRQ priority */
  177. int vector; /* This is foobar, what does it do? */
  178. };
  179. /* Element of the "ranges" vector */
  180. struct linux_prom_ranges {
  181. unsigned int ot_child_space;
  182. unsigned int ot_child_base; /* Bus feels this */
  183. unsigned int ot_parent_space;
  184. unsigned int ot_parent_base; /* CPU looks from here */
  185. unsigned int or_size;
  186. };
  187. /* Ranges and reg properties are a bit different for PCI. */
  188. struct linux_prom_pci_registers {
  189. /*
  190. * We don't know what information this field contain.
  191. * We guess, PCI device function is in bits 15:8
  192. * So, ...
  193. */
  194. unsigned int which_io; /* Let it be which_io */
  195. unsigned int phys_hi;
  196. unsigned int phys_lo;
  197. unsigned int size_hi;
  198. unsigned int size_lo;
  199. };
  200. struct linux_prom_pci_ranges {
  201. unsigned int child_phys_hi; /* Only certain bits are encoded here. */
  202. unsigned int child_phys_mid;
  203. unsigned int child_phys_lo;
  204. unsigned int parent_phys_hi;
  205. unsigned int parent_phys_lo;
  206. unsigned int size_hi;
  207. unsigned int size_lo;
  208. };
  209. struct linux_prom_pci_assigned_addresses {
  210. unsigned int which_io;
  211. unsigned int phys_hi;
  212. unsigned int phys_lo;
  213. unsigned int size_hi;
  214. unsigned int size_lo;
  215. };
  216. struct linux_prom_ebus_ranges {
  217. unsigned int child_phys_hi;
  218. unsigned int child_phys_lo;
  219. unsigned int parent_phys_hi;
  220. unsigned int parent_phys_mid;
  221. unsigned int parent_phys_lo;
  222. unsigned int size;
  223. };
  224. /* Offset into the EEPROM where the id PROM is located on the 4c */
  225. #define IDPROM_OFFSET 0x7d8
  226. /* On sun4m; physical. */
  227. /* MicroSPARC(-II) does not decode 31rd bit, but it works. */
  228. #define IDPROM_OFFSET_M 0xfd8
  229. struct idprom {
  230. unsigned char id_format; /* Format identifier (always 0x01) */
  231. unsigned char id_machtype; /* Machine type */
  232. unsigned char id_ethaddr[6]; /* Hardware ethernet address */
  233. long id_date; /* Date of manufacture */
  234. unsigned int id_sernum:24; /* Unique serial number */
  235. unsigned char id_cksum; /* Checksum - xor of the data bytes */
  236. unsigned char reserved[16];
  237. };
  238. extern struct idprom *idprom;
  239. extern void idprom_init(void);
  240. #define IDPROM_SIZE (sizeof(struct idprom))
  241. #endif /* !(__ASSEMBLY__) */
  242. #endif