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