oplib_64.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /* oplib.h: Describes the interface and available routines in the
  2. * Linux Prom library.
  3. *
  4. * Copyright (C) 1995, 2007 David S. Miller ([email protected])
  5. * Copyright (C) 1996 Jakub Jelinek ([email protected])
  6. */
  7. #ifndef __SPARC64_OPLIB_H
  8. #define __SPARC64_OPLIB_H
  9. #include <asm/openprom.h>
  10. /* OBP version string. */
  11. extern char prom_version[];
  12. /* Root node of the prom device tree, this stays constant after
  13. * initialization is complete.
  14. */
  15. extern phandle prom_root_node;
  16. /* PROM stdout */
  17. extern int prom_stdout;
  18. /* /chosen node of the prom device tree, this stays constant after
  19. * initialization is complete.
  20. */
  21. extern phandle prom_chosen_node;
  22. /* Helper values and strings in arch/sparc64/kernel/head.S */
  23. extern const char prom_peer_name[];
  24. extern const char prom_compatible_name[];
  25. extern const char prom_root_compatible[];
  26. extern const char prom_cpu_compatible[];
  27. extern const char prom_finddev_name[];
  28. extern const char prom_chosen_path[];
  29. extern const char prom_cpu_path[];
  30. extern const char prom_getprop_name[];
  31. extern const char prom_mmu_name[];
  32. extern const char prom_callmethod_name[];
  33. extern const char prom_translate_name[];
  34. extern const char prom_map_name[];
  35. extern const char prom_unmap_name[];
  36. extern int prom_mmu_ihandle_cache;
  37. extern unsigned int prom_boot_mapped_pc;
  38. extern unsigned int prom_boot_mapping_mode;
  39. extern unsigned long prom_boot_mapping_phys_high, prom_boot_mapping_phys_low;
  40. struct linux_mlist_p1275 {
  41. struct linux_mlist_p1275 *theres_more;
  42. unsigned long start_adr;
  43. unsigned long num_bytes;
  44. };
  45. struct linux_mem_p1275 {
  46. struct linux_mlist_p1275 **p1275_totphys;
  47. struct linux_mlist_p1275 **p1275_prommap;
  48. struct linux_mlist_p1275 **p1275_available; /* What we can use */
  49. };
  50. /* The functions... */
  51. /* You must call prom_init() before using any of the library services,
  52. * preferably as early as possible. Pass it the romvec pointer.
  53. */
  54. void prom_init(void *cif_handler);
  55. void prom_init_report(void);
  56. /* Boot argument acquisition, returns the boot command line string. */
  57. char *prom_getbootargs(void);
  58. /* Miscellaneous routines, don't really fit in any category per se. */
  59. /* Reboot the machine with the command line passed. */
  60. void prom_reboot(const char *boot_command);
  61. /* Evaluate the forth string passed. */
  62. void prom_feval(const char *forth_string);
  63. /* Enter the prom, with possibility of continuation with the 'go'
  64. * command in newer proms.
  65. */
  66. void prom_cmdline(void);
  67. /* Enter the prom, with no chance of continuation for the stand-alone
  68. * which calls this.
  69. */
  70. void prom_halt(void) __attribute__ ((noreturn));
  71. /* Halt and power-off the machine. */
  72. void prom_halt_power_off(void) __attribute__ ((noreturn));
  73. /* Acquire the IDPROM of the root node in the prom device tree. This
  74. * gets passed a buffer where you would like it stuffed. The return value
  75. * is the format type of this idprom or 0xff on error.
  76. */
  77. unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
  78. /* Write a buffer of characters to the console. */
  79. void prom_console_write_buf(const char *buf, int len);
  80. /* Prom's internal routines, don't use in kernel/boot code. */
  81. __printf(1, 2) void prom_printf(const char *fmt, ...);
  82. void prom_write(const char *buf, unsigned int len);
  83. /* Multiprocessor operations... */
  84. #ifdef CONFIG_SMP
  85. /* Start the CPU with the given device tree node at the passed program
  86. * counter with the given arg passed in via register %o0.
  87. */
  88. void prom_startcpu(int cpunode, unsigned long pc, unsigned long arg);
  89. /* Start the CPU with the given cpu ID at the passed program
  90. * counter with the given arg passed in via register %o0.
  91. */
  92. void prom_startcpu_cpuid(int cpuid, unsigned long pc, unsigned long arg);
  93. /* Stop the CPU with the given cpu ID. */
  94. void prom_stopcpu_cpuid(int cpuid);
  95. /* Stop the current CPU. */
  96. void prom_stopself(void);
  97. /* Idle the current CPU. */
  98. void prom_idleself(void);
  99. /* Resume the CPU with the passed device tree node. */
  100. void prom_resumecpu(int cpunode);
  101. #endif
  102. /* Power management interfaces. */
  103. /* Put the current CPU to sleep. */
  104. void prom_sleepself(void);
  105. /* Put the entire system to sleep. */
  106. int prom_sleepsystem(void);
  107. /* Initiate a wakeup event. */
  108. int prom_wakeupsystem(void);
  109. /* MMU and memory related OBP interfaces. */
  110. /* Get unique string identifying SIMM at given physical address. */
  111. int prom_getunumber(int syndrome_code,
  112. unsigned long phys_addr,
  113. char *buf, int buflen);
  114. /* Retain physical memory to the caller across soft resets. */
  115. int prom_retain(const char *name, unsigned long size,
  116. unsigned long align, unsigned long *paddr);
  117. /* Load explicit I/D TLB entries into the calling processor. */
  118. long prom_itlb_load(unsigned long index,
  119. unsigned long tte_data,
  120. unsigned long vaddr);
  121. long prom_dtlb_load(unsigned long index,
  122. unsigned long tte_data,
  123. unsigned long vaddr);
  124. /* Map/Unmap client program address ranges. First the format of
  125. * the mapping mode argument.
  126. */
  127. #define PROM_MAP_WRITE 0x0001 /* Writable */
  128. #define PROM_MAP_READ 0x0002 /* Readable - sw */
  129. #define PROM_MAP_EXEC 0x0004 /* Executable - sw */
  130. #define PROM_MAP_LOCKED 0x0010 /* Locked, use i/dtlb load calls for this instead */
  131. #define PROM_MAP_CACHED 0x0020 /* Cacheable in both L1 and L2 caches */
  132. #define PROM_MAP_SE 0x0040 /* Side-Effects */
  133. #define PROM_MAP_GLOB 0x0080 /* Global */
  134. #define PROM_MAP_IE 0x0100 /* Invert-Endianness */
  135. #define PROM_MAP_DEFAULT (PROM_MAP_WRITE | PROM_MAP_READ | PROM_MAP_EXEC | PROM_MAP_CACHED)
  136. int prom_map(int mode, unsigned long size,
  137. unsigned long vaddr, unsigned long paddr);
  138. void prom_unmap(unsigned long size, unsigned long vaddr);
  139. /* PROM device tree traversal functions... */
  140. /* Get the child node of the given node, or zero if no child exists. */
  141. phandle prom_getchild(phandle parent_node);
  142. /* Get the next sibling node of the given node, or zero if no further
  143. * siblings exist.
  144. */
  145. phandle prom_getsibling(phandle node);
  146. /* Get the length, at the passed node, of the given property type.
  147. * Returns -1 on error (ie. no such property at this node).
  148. */
  149. int prom_getproplen(phandle thisnode, const char *property);
  150. /* Fetch the requested property using the given buffer. Returns
  151. * the number of bytes the prom put into your buffer or -1 on error.
  152. */
  153. int prom_getproperty(phandle thisnode, const char *property,
  154. char *prop_buffer, int propbuf_size);
  155. /* Acquire an integer property. */
  156. int prom_getint(phandle node, const char *property);
  157. /* Acquire an integer property, with a default value. */
  158. int prom_getintdefault(phandle node, const char *property, int defval);
  159. /* Acquire a boolean property, 0=FALSE 1=TRUE. */
  160. int prom_getbool(phandle node, const char *prop);
  161. /* Acquire a string property, null string on error. */
  162. void prom_getstring(phandle node, const char *prop, char *buf,
  163. int bufsize);
  164. /* Does the passed node have the given "name"? YES=1 NO=0 */
  165. int prom_nodematch(phandle thisnode, const char *name);
  166. /* Search all siblings starting at the passed node for "name" matching
  167. * the given string. Returns the node on success, zero on failure.
  168. */
  169. phandle prom_searchsiblings(phandle node_start, const char *name);
  170. /* Return the first property type, as a string, for the given node.
  171. * Returns a null string on error. Buffer should be at least 32B long.
  172. */
  173. char *prom_firstprop(phandle node, char *buffer);
  174. /* Returns the next property after the passed property for the given
  175. * node. Returns null string on failure. Buffer should be at least 32B long.
  176. */
  177. char *prom_nextprop(phandle node, const char *prev_property, char *buf);
  178. /* Returns 1 if the specified node has given property. */
  179. int prom_node_has_property(phandle node, const char *property);
  180. /* Returns phandle of the path specified */
  181. phandle prom_finddevice(const char *name);
  182. /* Set the indicated property at the given node with the passed value.
  183. * Returns the number of bytes of your value that the prom took.
  184. */
  185. int prom_setprop(phandle node, const char *prop_name, char *prop_value,
  186. int value_size);
  187. phandle prom_inst2pkg(int);
  188. void prom_sun4v_guest_soft_state(void);
  189. int prom_ihandle2path(int handle, char *buffer, int bufsize);
  190. /* Client interface level routines. */
  191. void p1275_cmd_direct(unsigned long *);
  192. #endif /* !(__SPARC64_OPLIB_H) */