diff options
Diffstat (limited to 'include/asm-sparc/oplib_32.h')
-rw-r--r-- | include/asm-sparc/oplib_32.h | 272 |
1 files changed, 272 insertions, 0 deletions
diff --git a/include/asm-sparc/oplib_32.h b/include/asm-sparc/oplib_32.h new file mode 100644 index 000000000000..b2631da259e0 --- /dev/null +++ b/include/asm-sparc/oplib_32.h | |||
@@ -0,0 +1,272 @@ | |||
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 | |||
8 | #ifndef __SPARC_OPLIB_H | ||
9 | #define __SPARC_OPLIB_H | ||
10 | |||
11 | #include <asm/openprom.h> | ||
12 | #include <linux/spinlock.h> | ||
13 | #include <linux/compiler.h> | ||
14 | |||
15 | /* The master romvec pointer... */ | ||
16 | extern struct linux_romvec *romvec; | ||
17 | |||
18 | /* Enumeration to describe the prom major version we have detected. */ | ||
19 | enum prom_major_version { | ||
20 | PROM_V0, /* Original sun4c V0 prom */ | ||
21 | PROM_V2, /* sun4c and early sun4m V2 prom */ | ||
22 | PROM_V3, /* sun4m and later, up to sun4d/sun4e machines V3 */ | ||
23 | PROM_P1275, /* IEEE compliant ISA based Sun PROM, only sun4u */ | ||
24 | PROM_SUN4, /* Old sun4 proms are totally different, but we'll shoehorn it to make it fit */ | ||
25 | }; | ||
26 | |||
27 | extern enum prom_major_version prom_vers; | ||
28 | /* Revision, and firmware revision. */ | ||
29 | extern unsigned int prom_rev, prom_prev; | ||
30 | |||
31 | /* Root node of the prom device tree, this stays constant after | ||
32 | * initialization is complete. | ||
33 | */ | ||
34 | extern int prom_root_node; | ||
35 | |||
36 | /* Pointer to prom structure containing the device tree traversal | ||
37 | * and usage utility functions. Only prom-lib should use these, | ||
38 | * users use the interface defined by the library only! | ||
39 | */ | ||
40 | extern struct linux_nodeops *prom_nodeops; | ||
41 | |||
42 | /* The functions... */ | ||
43 | |||
44 | /* You must call prom_init() before using any of the library services, | ||
45 | * preferably as early as possible. Pass it the romvec pointer. | ||
46 | */ | ||
47 | extern void prom_init(struct linux_romvec *rom_ptr); | ||
48 | |||
49 | /* Boot argument acquisition, returns the boot command line string. */ | ||
50 | extern char *prom_getbootargs(void); | ||
51 | |||
52 | /* Device utilities. */ | ||
53 | |||
54 | /* Map and unmap devices in IO space at virtual addresses. Note that the | ||
55 | * virtual address you pass is a request and the prom may put your mappings | ||
56 | * somewhere else, so check your return value as that is where your new | ||
57 | * mappings really are! | ||
58 | * | ||
59 | * Another note, these are only available on V2 or higher proms! | ||
60 | */ | ||
61 | extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes); | ||
62 | extern void prom_unmapio(char *virt_addr, unsigned int num_bytes); | ||
63 | |||
64 | /* Device operations. */ | ||
65 | |||
66 | /* Open the device described by the passed string. Note, that the format | ||
67 | * of the string is different on V0 vs. V2->higher proms. The caller must | ||
68 | * know what he/she is doing! Returns the device descriptor, an int. | ||
69 | */ | ||
70 | extern int prom_devopen(char *device_string); | ||
71 | |||
72 | /* Close a previously opened device described by the passed integer | ||
73 | * descriptor. | ||
74 | */ | ||
75 | extern int prom_devclose(int device_handle); | ||
76 | |||
77 | /* Do a seek operation on the device described by the passed integer | ||
78 | * descriptor. | ||
79 | */ | ||
80 | extern void prom_seek(int device_handle, unsigned int seek_hival, | ||
81 | unsigned int seek_lowval); | ||
82 | |||
83 | /* Miscellaneous routines, don't really fit in any category per se. */ | ||
84 | |||
85 | /* Reboot the machine with the command line passed. */ | ||
86 | extern void prom_reboot(char *boot_command); | ||
87 | |||
88 | /* Evaluate the forth string passed. */ | ||
89 | extern void prom_feval(char *forth_string); | ||
90 | |||
91 | /* Enter the prom, with possibility of continuation with the 'go' | ||
92 | * command in newer proms. | ||
93 | */ | ||
94 | extern void prom_cmdline(void); | ||
95 | |||
96 | /* Enter the prom, with no chance of continuation for the stand-alone | ||
97 | * which calls this. | ||
98 | */ | ||
99 | extern void prom_halt(void) __attribute__ ((noreturn)); | ||
100 | |||
101 | /* Set the PROM 'sync' callback function to the passed function pointer. | ||
102 | * When the user gives the 'sync' command at the prom prompt while the | ||
103 | * kernel is still active, the prom will call this routine. | ||
104 | * | ||
105 | * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX | ||
106 | */ | ||
107 | typedef void (*sync_func_t)(void); | ||
108 | extern void prom_setsync(sync_func_t func_ptr); | ||
109 | |||
110 | /* Acquire the IDPROM of the root node in the prom device tree. This | ||
111 | * gets passed a buffer where you would like it stuffed. The return value | ||
112 | * is the format type of this idprom or 0xff on error. | ||
113 | */ | ||
114 | extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size); | ||
115 | |||
116 | /* Get the prom major version. */ | ||
117 | extern int prom_version(void); | ||
118 | |||
119 | /* Get the prom plugin revision. */ | ||
120 | extern int prom_getrev(void); | ||
121 | |||
122 | /* Get the prom firmware revision. */ | ||
123 | extern int prom_getprev(void); | ||
124 | |||
125 | /* Character operations to/from the console.... */ | ||
126 | |||
127 | /* Non-blocking get character from console. */ | ||
128 | extern int prom_nbgetchar(void); | ||
129 | |||
130 | /* Non-blocking put character to console. */ | ||
131 | extern int prom_nbputchar(char character); | ||
132 | |||
133 | /* Blocking get character from console. */ | ||
134 | extern char prom_getchar(void); | ||
135 | |||
136 | /* Blocking put character to console. */ | ||
137 | extern void prom_putchar(char character); | ||
138 | |||
139 | /* Prom's internal routines, don't use in kernel/boot code. */ | ||
140 | extern void prom_printf(char *fmt, ...); | ||
141 | extern void prom_write(const char *buf, unsigned int len); | ||
142 | |||
143 | /* Multiprocessor operations... */ | ||
144 | |||
145 | /* Start the CPU with the given device tree node, context table, and context | ||
146 | * at the passed program counter. | ||
147 | */ | ||
148 | extern int prom_startcpu(int cpunode, struct linux_prom_registers *context_table, | ||
149 | int context, char *program_counter); | ||
150 | |||
151 | /* Stop the CPU with the passed device tree node. */ | ||
152 | extern int prom_stopcpu(int cpunode); | ||
153 | |||
154 | /* Idle the CPU with the passed device tree node. */ | ||
155 | extern int prom_idlecpu(int cpunode); | ||
156 | |||
157 | /* Re-Start the CPU with the passed device tree node. */ | ||
158 | extern int prom_restartcpu(int cpunode); | ||
159 | |||
160 | /* PROM memory allocation facilities... */ | ||
161 | |||
162 | /* Allocated at possibly the given virtual address a chunk of the | ||
163 | * indicated size. | ||
164 | */ | ||
165 | extern char *prom_alloc(char *virt_hint, unsigned int size); | ||
166 | |||
167 | /* Free a previously allocated chunk. */ | ||
168 | extern void prom_free(char *virt_addr, unsigned int size); | ||
169 | |||
170 | /* Sun4/sun4c specific memory-management startup hook. */ | ||
171 | |||
172 | /* Map the passed segment in the given context at the passed | ||
173 | * virtual address. | ||
174 | */ | ||
175 | extern void prom_putsegment(int context, unsigned long virt_addr, | ||
176 | int physical_segment); | ||
177 | |||
178 | |||
179 | /* PROM device tree traversal functions... */ | ||
180 | |||
181 | #ifdef PROMLIB_INTERNAL | ||
182 | |||
183 | /* Internal version of prom_getchild. */ | ||
184 | extern int __prom_getchild(int parent_node); | ||
185 | |||
186 | /* Internal version of prom_getsibling. */ | ||
187 | extern int __prom_getsibling(int node); | ||
188 | |||
189 | #endif | ||
190 | |||
191 | |||
192 | /* Get the child node of the given node, or zero if no child exists. */ | ||
193 | extern int prom_getchild(int parent_node); | ||
194 | |||
195 | /* Get the next sibling node of the given node, or zero if no further | ||
196 | * siblings exist. | ||
197 | */ | ||
198 | extern int prom_getsibling(int node); | ||
199 | |||
200 | /* Get the length, at the passed node, of the given property type. | ||
201 | * Returns -1 on error (ie. no such property at this node). | ||
202 | */ | ||
203 | extern int prom_getproplen(int thisnode, char *property); | ||
204 | |||
205 | /* Fetch the requested property using the given buffer. Returns | ||
206 | * the number of bytes the prom put into your buffer or -1 on error. | ||
207 | */ | ||
208 | extern int __must_check prom_getproperty(int thisnode, char *property, | ||
209 | char *prop_buffer, int propbuf_size); | ||
210 | |||
211 | /* Acquire an integer property. */ | ||
212 | extern int prom_getint(int node, char *property); | ||
213 | |||
214 | /* Acquire an integer property, with a default value. */ | ||
215 | extern int prom_getintdefault(int node, char *property, int defval); | ||
216 | |||
217 | /* Acquire a boolean property, 0=FALSE 1=TRUE. */ | ||
218 | extern int prom_getbool(int node, char *prop); | ||
219 | |||
220 | /* Acquire a string property, null string on error. */ | ||
221 | extern void prom_getstring(int node, char *prop, char *buf, int bufsize); | ||
222 | |||
223 | /* Does the passed node have the given "name"? YES=1 NO=0 */ | ||
224 | extern int prom_nodematch(int thisnode, char *name); | ||
225 | |||
226 | /* Search all siblings starting at the passed node for "name" matching | ||
227 | * the given string. Returns the node on success, zero on failure. | ||
228 | */ | ||
229 | extern int prom_searchsiblings(int node_start, char *name); | ||
230 | |||
231 | /* Return the first property type, as a string, for the given node. | ||
232 | * Returns a null string on error. | ||
233 | */ | ||
234 | extern char *prom_firstprop(int node, char *buffer); | ||
235 | |||
236 | /* Returns the next property after the passed property for the given | ||
237 | * node. Returns null string on failure. | ||
238 | */ | ||
239 | extern char *prom_nextprop(int node, char *prev_property, char *buffer); | ||
240 | |||
241 | /* Returns phandle of the path specified */ | ||
242 | extern int prom_finddevice(char *name); | ||
243 | |||
244 | /* Returns 1 if the specified node has given property. */ | ||
245 | extern int prom_node_has_property(int node, char *property); | ||
246 | |||
247 | /* Set the indicated property at the given node with the passed value. | ||
248 | * Returns the number of bytes of your value that the prom took. | ||
249 | */ | ||
250 | extern int prom_setprop(int node, char *prop_name, char *prop_value, | ||
251 | int value_size); | ||
252 | |||
253 | extern int prom_pathtoinode(char *path); | ||
254 | extern int prom_inst2pkg(int); | ||
255 | |||
256 | /* Dorking with Bus ranges... */ | ||
257 | |||
258 | /* Apply promlib probes OBIO ranges to registers. */ | ||
259 | extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs); | ||
260 | |||
261 | /* Apply ranges of any prom node (and optionally parent node as well) to registers. */ | ||
262 | extern void prom_apply_generic_ranges(int node, int parent, | ||
263 | struct linux_prom_registers *sbusregs, int nregs); | ||
264 | |||
265 | /* CPU probing helpers. */ | ||
266 | int cpu_find_by_instance(int instance, int *prom_node, int *mid); | ||
267 | int cpu_find_by_mid(int mid, int *prom_node); | ||
268 | int cpu_get_hwmid(int prom_node); | ||
269 | |||
270 | extern spinlock_t prom_lock; | ||
271 | |||
272 | #endif /* !(__SPARC_OPLIB_H) */ | ||