oplib_32.h 5.9 KB

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