oplib_64.h 8.1 KB

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