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