prom.h 7.6 KB

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