1 /* $Id: oplib.h,v 1.21 2000/08/26 02:38:04 anton Exp $
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
14 /* The master romvec pointer... */
15 extern struct linux_romvec *romvec;
16
17 /* Enumeration to describe the prom major version we have detected. */
18 enum prom_major_version {
19 PROM_V0, /* Original sun4c V0 prom */
20 PROM_V2, /* sun4c and early sun4m V2 prom */
21 PROM_V3, /* sun4m and later, up to sun4d/sun4e machines V3 */
22 PROM_P1275, /* IEEE compliant ISA based Sun PROM, only sun4u */
23 PROM_AP1000, /* actually no prom at all */
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 /* PROM stdin and stdout */
37 extern int prom_stdin, prom_stdout;
38
39 /* Pointer to prom structure containing the device tree traversal
40 * and usage utility functions. Only prom-lib should use these,
41 * users use the interface defined by the library only!
42 */
43 extern struct linux_nodeops *prom_nodeops;
44
45 /* The functions... */
46
47 /* You must call prom_init() before using any of the library services,
48 * preferably as early as possible. Pass it the romvec pointer.
49 */
50 extern void prom_init(struct linux_romvec *rom_ptr);
51
52 /* Boot argument acquisition, returns the boot command line string. */
53 extern char *prom_getbootargs(void);
54
55 /* Device utilities. */
56
57 /* Map and unmap devices in IO space at virtual addresses. Note that the
58 * virtual address you pass is a request and the prom may put your mappings
59 * somewhere else, so check your return value as that is where your new
60 * mappings really are!
61 *
62 * Another note, these are only available on V2 or higher proms!
63 */
64 extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes);
65 extern void prom_unmapio(char *virt_addr, unsigned int num_bytes);
66
67 /* Device operations. */
68
69 /* Open the device described by the passed string. Note, that the format
70 * of the string is different on V0 vs. V2->higher proms. The caller must
71 * know what he/she is doing! Returns the device descriptor, an int.
72 */
73 extern int prom_devopen(char *device_string);
74
75 /* Close a previously opened device described by the passed integer
76 * descriptor.
77 */
78 extern int prom_devclose(int device_handle);
79
80 /* Do a seek operation on the device described by the passed integer
81 * descriptor.
82 */
83 extern void prom_seek(int device_handle, unsigned int seek_hival,
84 unsigned int seek_lowval);
85
86 /* Machine memory configuration routine. */
87
88 /* This function returns a V0 format memory descriptor table, it has three
89 * entries. One for the total amount of physical ram on the machine, one
90 * for the amount of physical ram available, and one describing the virtual
91 * areas which are allocated by the prom. So, in a sense the physical
92 * available is a calculation of the total physical minus the physical mapped
93 * by the prom with virtual mappings.
94 *
95 * These lists are returned pre-sorted, this should make your life easier
96 * since the prom itself is way too lazy to do such nice things.
97 */
98 extern struct linux_mem_v0 *prom_meminfo(void);
99
100 /* Miscellaneous routines, don't really fit in any category per se. */
101
102 /* Reboot the machine with the command line passed. */
103 extern void prom_reboot(char *boot_command);
104
105 /* Evaluate the forth string passed. */
106 extern void prom_feval(char *forth_string);
107
108 /* Enter the prom, with possibility of continuation with the 'go'
109 * command in newer proms.
110 */
111 extern void prom_cmdline(void);
112
113 /* Enter the prom, with no chance of continuation for the stand-alone
114 * which calls this.
115 */
116 extern void prom_halt(void) __attribute__ ((noreturn));
117
118 /* Set the PROM 'sync' callback function to the passed function pointer.
119 * When the user gives the 'sync' command at the prom prompt while the
120 * kernel is still active, the prom will call this routine.
121 *
122 * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX
123 */
124 typedef void (*sync_func_t)(void);
125 extern void prom_setsync(sync_func_t func_ptr);
126
127 /* Acquire the IDPROM of the root node in the prom device tree. This
128 * gets passed a buffer where you would like it stuffed. The return value
129 * is the format type of this idprom or 0xff on error.
130 */
131 extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
132
133 /* Get the prom major version. */
134 extern int prom_version(void);
135
136 /* Get the prom plugin revision. */
137 extern int prom_getrev(void);
138
139 /* Get the prom firmware revision. */
140 extern int prom_getprev(void);
141
142 /* Character operations to/from the console.... */
143
144 /* Non-blocking get character from console. */
145 extern int prom_nbgetchar(void);
146
147 /* Non-blocking put character to console. */
148 extern int prom_nbputchar(char character);
149
150 /* Blocking get character from console. */
151 extern char prom_getchar(void);
152
153 /* Blocking put character to console. */
154 extern void prom_putchar(char character);
155
156 /* Prom's internal printf routine, don't use in kernel/boot code. */
157 void prom_printf(char *fmt, ...);
158
159 /* Query for input device type */
160
161 enum prom_input_device {
162 PROMDEV_IKBD, /* input from keyboard */
163 PROMDEV_ITTYA, /* input from ttya */
164 PROMDEV_ITTYB, /* input from ttyb */
165 PROMDEV_I_UNK,
166 };
167
168 extern enum prom_input_device prom_query_input_device(void);
169
170 /* Query for output device type */
171
172 enum prom_output_device {
173 PROMDEV_OSCREEN, /* to screen */
174 PROMDEV_OTTYA, /* to ttya */
175 PROMDEV_OTTYB, /* to ttyb */
176 PROMDEV_O_UNK,
177 };
178
179 extern enum prom_output_device prom_query_output_device(void);
180
181 /* Multiprocessor operations... */
182
183 /* Start the CPU with the given device tree node, context table, and context
184 * at the passed program counter.
185 */
186 extern int prom_startcpu(int cpunode, struct linux_prom_registers *context_table,
187 int context, char *program_counter);
188
189 /* Stop the CPU with the passed device tree node. */
190 extern int prom_stopcpu(int cpunode);
191
192 /* Idle the CPU with the passed device tree node. */
193 extern int prom_idlecpu(int cpunode);
194
195 /* Re-Start the CPU with the passed device tree node. */
196 extern int prom_restartcpu(int cpunode);
197
198 /* PROM memory allocation facilities... */
199
200 /* Allocated at possibly the given virtual address a chunk of the
201 * indicated size.
202 */
203 extern char *prom_alloc(char *virt_hint, unsigned int size);
204
205 /* Free a previously allocated chunk. */
206 extern void prom_free(char *virt_addr, unsigned int size);
207
208 /* Sun4/sun4c specific memory-management startup hook. */
209
210 /* Map the passed segment in the given context at the passed
211 * virtual address.
212 */
213 extern void prom_putsegment(int context, unsigned long virt_addr,
214 int physical_segment);
215
216
217 /* PROM device tree traversal functions... */
218
219 #ifdef PROMLIB_INTERNAL
220
221 /* Internal version of prom_getchild. */
222 extern int __prom_getchild(int parent_node);
223
224 /* Internal version of prom_getsibling. */
225 extern int __prom_getsibling(int node);
226
227 #endif
228
229
230 /* Get the child node of the given node, or zero if no child exists. */
231 extern int prom_getchild(int parent_node);
232
233 /* Get the next sibling node of the given node, or zero if no further
234 * siblings exist.
235 */
236 extern int prom_getsibling(int node);
237
238 /* Get the length, at the passed node, of the given property type.
239 * Returns -1 on error (ie. no such property at this node).
240 */
241 extern int prom_getproplen(int thisnode, char *property);
242
243 /* Fetch the requested property using the given buffer. Returns
244 * the number of bytes the prom put into your buffer or -1 on error.
245 */
246 extern int prom_getproperty(int thisnode, char *property,
247 char *prop_buffer, int propbuf_size);
248
249 /* Acquire an integer property. */
250 extern int prom_getint(int node, char *property);
251
252 /* Acquire an integer property, with a default value. */
253 extern int prom_getintdefault(int node, char *property, int defval);
254
255 /* Acquire a boolean property, 0=FALSE 1=TRUE. */
256 extern int prom_getbool(int node, char *prop);
257
258 /* Acquire a string property, null string on error. */
259 extern void prom_getstring(int node, char *prop, char *buf, int bufsize);
260
261 /* Does the passed node have the given "name"? YES=1 NO=0 */
262 extern int prom_nodematch(int thisnode, char *name);
263
264 /* Puts in buffer a prom name in the form name@x,y or name (x for which_io
265 * and y for first regs phys address
266 */
267 extern int prom_getname(int node, char *buf, int buflen);
268
269 /* Search all siblings starting at the passed node for "name" matching
270 * the given string. Returns the node on success, zero on failure.
271 */
272 extern int prom_searchsiblings(int node_start, char *name);
273
274 /* Return the first property type, as a string, for the given node.
275 * Returns a null string on error.
276 */
277 extern char *prom_firstprop(int node, char *buffer);
278
279 /* Returns the next property after the passed property for the given
280 * node. Returns null string on failure.
281 */
282 extern char *prom_nextprop(int node, char *prev_property, char *buffer);
283
284 /* Returns phandle of the path specified */
285 extern int prom_finddevice(char *name);
286
287 /* Returns 1 if the specified node has given property. */
288 extern int prom_node_has_property(int node, char *property);
289
290 /* Set the indicated property at the given node with the passed value.
291 * Returns the number of bytes of your value that the prom took.
292 */
293 extern int prom_setprop(int node, char *prop_name, char *prop_value,
294 int value_size);
295
296 extern int prom_pathtoinode(char *path);
297 extern int prom_inst2pkg(int);
298
299 /* Dorking with Bus ranges... */
300
301 /* Adjust reg values with the passed ranges. */
302 extern void prom_adjust_regs(struct linux_prom_registers *regp, int nregs,
303 struct linux_prom_ranges *rangep, int nranges);
304
305 /* Adjust child ranges with the passed parent ranges. */
306 extern void prom_adjust_ranges(struct linux_prom_ranges *cranges, int ncranges,
307 struct linux_prom_ranges *pranges, int npranges);
308
309 /* Apply promlib probed OBIO ranges to registers. */
310 extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
311
312 /* Apply ranges of any prom node (and optionally parent node as well) to registers. */
313 extern void prom_apply_generic_ranges(int node, int parent,
314 struct linux_prom_registers *sbusregs, int nregs);
315
316 extern spinlock_t prom_lock;
317
318 #endif /* !(__SPARC_OPLIB_H) */
319
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.