oplib_32.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * oplib.h: Describes the interface and available routines in the
  3. * Linux Prom library.
  4. *
  5. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6. */
  7. #ifndef __SPARC_OPLIB_H
  8. #define __SPARC_OPLIB_H
  9. #include <asm/openprom.h>
  10. #include <linux/spinlock.h>
  11. #include <linux/compiler.h>
  12. /* The master romvec pointer... */
  13. extern struct linux_romvec *romvec;
  14. /* Enumeration to describe the prom major version we have detected. */
  15. enum prom_major_version {
  16. PROM_V0, /* Original sun4c V0 prom */
  17. PROM_V2, /* sun4c and early sun4m V2 prom */
  18. PROM_V3, /* sun4m and later, up to sun4d/sun4e machines V3 */
  19. PROM_P1275, /* IEEE compliant ISA based Sun PROM, only sun4u */
  20. };
  21. extern enum prom_major_version prom_vers;
  22. /* Revision, and firmware revision. */
  23. extern unsigned int prom_rev, prom_prev;
  24. /* Root node of the prom device tree, this stays constant after
  25. * initialization is complete.
  26. */
  27. extern phandle prom_root_node;
  28. /* Pointer to prom structure containing the device tree traversal
  29. * and usage utility functions. Only prom-lib should use these,
  30. * users use the interface defined by the library only!
  31. */
  32. extern struct linux_nodeops *prom_nodeops;
  33. /* The functions... */
  34. /* You must call prom_init() before using any of the library services,
  35. * preferably as early as possible. Pass it the romvec pointer.
  36. */
  37. extern void prom_init(struct linux_romvec *rom_ptr);
  38. /* Boot argument acquisition, returns the boot command line string. */
  39. extern char *prom_getbootargs(void);
  40. /* Device utilities. */
  41. /* Map and unmap devices in IO space at virtual addresses. Note that the
  42. * virtual address you pass is a request and the prom may put your mappings
  43. * somewhere else, so check your return value as that is where your new
  44. * mappings really are!
  45. *
  46. * Another note, these are only available on V2 or higher proms!
  47. */
  48. extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes);
  49. extern void prom_unmapio(char *virt_addr, unsigned int num_bytes);
  50. /* Miscellaneous routines, don't really fit in any category per se. */
  51. /* Reboot the machine with the command line passed. */
  52. extern void prom_reboot(char *boot_command);
  53. /* Evaluate the forth string passed. */
  54. extern void prom_feval(char *forth_string);
  55. /* Enter the prom, with possibility of continuation with the 'go'
  56. * command in newer proms.
  57. */
  58. extern void prom_cmdline(void);
  59. /* Enter the prom, with no chance of continuation for the stand-alone
  60. * which calls this.
  61. */
  62. extern void prom_halt(void) __attribute__ ((noreturn));
  63. /* Set the PROM 'sync' callback function to the passed function pointer.
  64. * When the user gives the 'sync' command at the prom prompt while the
  65. * kernel is still active, the prom will call this routine.
  66. *
  67. * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX
  68. */
  69. typedef void (*sync_func_t)(void);
  70. extern void prom_setsync(sync_func_t func_ptr);
  71. /* Acquire the IDPROM of the root node in the prom device tree. This
  72. * gets passed a buffer where you would like it stuffed. The return value
  73. * is the format type of this idprom or 0xff on error.
  74. */
  75. extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
  76. /* Get the prom major version. */
  77. extern int prom_version(void);
  78. /* Get the prom plugin revision. */
  79. extern int prom_getrev(void);
  80. /* Get the prom firmware revision. */
  81. extern int prom_getprev(void);
  82. /* Write a buffer of characters to the console. */
  83. extern void prom_console_write_buf(const char *buf, int len);
  84. /* Prom's internal routines, don't use in kernel/boot code. */
  85. extern void prom_printf(const char *fmt, ...);
  86. extern void prom_write(const char *buf, unsigned int len);
  87. /* Multiprocessor operations... */
  88. /* Start the CPU with the given device tree node, context table, and context
  89. * at the passed program counter.
  90. */
  91. extern int prom_startcpu(int cpunode, struct linux_prom_registers *context_table,
  92. int context, char *program_counter);
  93. /* Stop the CPU with the passed device tree node. */
  94. extern int prom_stopcpu(int cpunode);
  95. /* Idle the CPU with the passed device tree node. */
  96. extern int prom_idlecpu(int cpunode);
  97. /* Re-Start the CPU with the passed device tree node. */
  98. extern int prom_restartcpu(int cpunode);
  99. /* PROM memory allocation facilities... */
  100. /* Allocated at possibly the given virtual address a chunk of the
  101. * indicated size.
  102. */
  103. extern char *prom_alloc(char *virt_hint, unsigned int size);
  104. /* Free a previously allocated chunk. */
  105. extern void prom_free(char *virt_addr, unsigned int size);
  106. /* Sun4/sun4c specific memory-management startup hook. */
  107. /* Map the passed segment in the given context at the passed
  108. * virtual address.
  109. */
  110. extern void prom_putsegment(int context, unsigned long virt_addr,
  111. int physical_segment);
  112. /* PROM device tree traversal functions... */
  113. /* Get the child node of the given node, or zero if no child exists. */
  114. extern phandle prom_getchild(phandle parent_node);
  115. /* Get the next sibling node of the given node, or zero if no further
  116. * siblings exist.
  117. */
  118. extern phandle prom_getsibling(phandle node);
  119. /* Get the length, at the passed node, of the given property type.
  120. * Returns -1 on error (ie. no such property at this node).
  121. */
  122. extern int prom_getproplen(phandle thisnode, const char *property);
  123. /* Fetch the requested property using the given buffer. Returns
  124. * the number of bytes the prom put into your buffer or -1 on error.
  125. */
  126. extern int __must_check prom_getproperty(phandle thisnode, const char *property,
  127. char *prop_buffer, int propbuf_size);
  128. /* Acquire an integer property. */
  129. extern int prom_getint(phandle node, char *property);
  130. /* Acquire an integer property, with a default value. */
  131. extern int prom_getintdefault(phandle node, char *property, int defval);
  132. /* Acquire a boolean property, 0=FALSE 1=TRUE. */
  133. extern int prom_getbool(phandle node, char *prop);
  134. /* Acquire a string property, null string on error. */
  135. extern void prom_getstring(phandle node, char *prop, char *buf, int bufsize);
  136. /* Does the passed node have the given "name"? YES=1 NO=0 */
  137. extern int prom_nodematch(phandle thisnode, char *name);
  138. /* Search all siblings starting at the passed node for "name" matching
  139. * the given string. Returns the node on success, zero on failure.
  140. */
  141. extern phandle prom_searchsiblings(phandle node_start, char *name);
  142. /* Return the first property type, as a string, for the given node.
  143. * Returns a null string on error.
  144. */
  145. extern char *prom_firstprop(phandle node, char *buffer);
  146. /* Returns the next property after the passed property for the given
  147. * node. Returns null string on failure.
  148. */
  149. extern char *prom_nextprop(phandle node, char *prev_property, char *buffer);
  150. /* Returns phandle of the path specified */
  151. extern phandle prom_finddevice(char *name);
  152. /* Returns 1 if the specified node has given property. */
  153. extern int prom_node_has_property(phandle node, char *property);
  154. /* Set the indicated property at the given node with the passed value.
  155. * Returns the number of bytes of your value that the prom took.
  156. */
  157. extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,
  158. int value_size);
  159. extern phandle prom_inst2pkg(int);
  160. /* Dorking with Bus ranges... */
  161. /* Apply promlib probes OBIO ranges to registers. */
  162. extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
  163. /* Apply ranges of any prom node (and optionally parent node as well) to registers. */
  164. extern void prom_apply_generic_ranges(phandle node, phandle parent,
  165. struct linux_prom_registers *sbusregs, int nregs);
  166. /* CPU probing helpers. */
  167. int cpu_find_by_instance(int instance, phandle *prom_node, int *mid);
  168. int cpu_find_by_mid(int mid, phandle *prom_node);
  169. int cpu_get_hwmid(phandle prom_node);
  170. extern spinlock_t prom_lock;
  171. #endif /* !(__SPARC_OPLIB_H) */