sparc32: Kill totally unused memory information tables.
[linux-2.6] / include / asm-sparc / oplib.h
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... */
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_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
28 extern enum prom_major_version prom_vers;
29 /* Revision, and firmware revision. */
30 extern unsigned int prom_rev, prom_prev;
31
32 /* Root node of the prom device tree, this stays constant after
33  * initialization is complete.
34  */
35 extern int prom_root_node;
36
37 /* PROM stdin and stdout */
38 extern 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  */
44 extern 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  */
51 extern void prom_init(struct linux_romvec *rom_ptr);
52
53 /* Boot argument acquisition, returns the boot command line string. */
54 extern 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  */
65 extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes);
66 extern 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  */
74 extern int prom_devopen(char *device_string);
75
76 /* Close a previously opened device described by the passed integer
77  * descriptor.
78  */
79 extern int prom_devclose(int device_handle);
80
81 /* Do a seek operation on the device described by the passed integer
82  * descriptor.
83  */
84 extern 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 available memory descriptor entry.
90  * This list is pre-sorted,
91  */
92 extern struct linux_mlist_v0 *prom_meminfo(void);
93
94 /* Miscellaneous routines, don't really fit in any category per se. */
95
96 /* Reboot the machine with the command line passed. */
97 extern void prom_reboot(char *boot_command);
98
99 /* Evaluate the forth string passed. */
100 extern void prom_feval(char *forth_string);
101
102 /* Enter the prom, with possibility of continuation with the 'go'
103  * command in newer proms.
104  */
105 extern void prom_cmdline(void);
106
107 /* Enter the prom, with no chance of continuation for the stand-alone
108  * which calls this.
109  */
110 extern void prom_halt(void) __attribute__ ((noreturn));
111
112 /* Set the PROM 'sync' callback function to the passed function pointer.
113  * When the user gives the 'sync' command at the prom prompt while the
114  * kernel is still active, the prom will call this routine.
115  *
116  * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX
117  */
118 typedef void (*sync_func_t)(void);
119 extern void prom_setsync(sync_func_t func_ptr);
120
121 /* Acquire the IDPROM of the root node in the prom device tree.  This
122  * gets passed a buffer where you would like it stuffed.  The return value
123  * is the format type of this idprom or 0xff on error.
124  */
125 extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
126
127 /* Get the prom major version. */
128 extern int prom_version(void);
129
130 /* Get the prom plugin revision. */
131 extern int prom_getrev(void);
132
133 /* Get the prom firmware revision. */
134 extern int prom_getprev(void);
135
136 /* Character operations to/from the console.... */
137
138 /* Non-blocking get character from console. */
139 extern int prom_nbgetchar(void);
140
141 /* Non-blocking put character to console. */
142 extern int prom_nbputchar(char character);
143
144 /* Blocking get character from console. */
145 extern char prom_getchar(void);
146
147 /* Blocking put character to console. */
148 extern void prom_putchar(char character);
149
150 /* Prom's internal routines, don't use in kernel/boot code. */
151 extern void prom_printf(char *fmt, ...);
152 extern void prom_write(const char *buf, unsigned int len);
153
154 /* Multiprocessor operations... */
155
156 /* Start the CPU with the given device tree node, context table, and context
157  * at the passed program counter.
158  */
159 extern int prom_startcpu(int cpunode, struct linux_prom_registers *context_table,
160                          int context, char *program_counter);
161
162 /* Stop the CPU with the passed device tree node. */
163 extern int prom_stopcpu(int cpunode);
164
165 /* Idle the CPU with the passed device tree node. */
166 extern int prom_idlecpu(int cpunode);
167
168 /* Re-Start the CPU with the passed device tree node. */
169 extern int prom_restartcpu(int cpunode);
170
171 /* PROM memory allocation facilities... */
172
173 /* Allocated at possibly the given virtual address a chunk of the
174  * indicated size.
175  */
176 extern char *prom_alloc(char *virt_hint, unsigned int size);
177
178 /* Free a previously allocated chunk. */
179 extern void prom_free(char *virt_addr, unsigned int size);
180
181 /* Sun4/sun4c specific memory-management startup hook. */
182
183 /* Map the passed segment in the given context at the passed
184  * virtual address.
185  */
186 extern void prom_putsegment(int context, unsigned long virt_addr,
187                             int physical_segment);
188
189
190 /* PROM device tree traversal functions... */
191
192 #ifdef PROMLIB_INTERNAL
193
194 /* Internal version of prom_getchild. */
195 extern int __prom_getchild(int parent_node);
196
197 /* Internal version of prom_getsibling. */
198 extern int __prom_getsibling(int node);
199
200 #endif
201
202
203 /* Get the child node of the given node, or zero if no child exists. */
204 extern int prom_getchild(int parent_node);
205
206 /* Get the next sibling node of the given node, or zero if no further
207  * siblings exist.
208  */
209 extern int prom_getsibling(int node);
210
211 /* Get the length, at the passed node, of the given property type.
212  * Returns -1 on error (ie. no such property at this node).
213  */
214 extern int prom_getproplen(int thisnode, char *property);
215
216 /* Fetch the requested property using the given buffer.  Returns
217  * the number of bytes the prom put into your buffer or -1 on error.
218  */
219 extern int __must_check prom_getproperty(int thisnode, char *property,
220                                          char *prop_buffer, int propbuf_size);
221
222 /* Acquire an integer property. */
223 extern int prom_getint(int node, char *property);
224
225 /* Acquire an integer property, with a default value. */
226 extern int prom_getintdefault(int node, char *property, int defval);
227
228 /* Acquire a boolean property, 0=FALSE 1=TRUE. */
229 extern int prom_getbool(int node, char *prop);
230
231 /* Acquire a string property, null string on error. */
232 extern void prom_getstring(int node, char *prop, char *buf, int bufsize);
233
234 /* Does the passed node have the given "name"? YES=1 NO=0 */
235 extern int prom_nodematch(int thisnode, char *name);
236
237 /* Search all siblings starting at the passed node for "name" matching
238  * the given string.  Returns the node on success, zero on failure.
239  */
240 extern int prom_searchsiblings(int node_start, char *name);
241
242 /* Return the first property type, as a string, for the given node.
243  * Returns a null string on error.
244  */
245 extern char *prom_firstprop(int node, char *buffer);
246
247 /* Returns the next property after the passed property for the given
248  * node.  Returns null string on failure.
249  */
250 extern char *prom_nextprop(int node, char *prev_property, char *buffer);
251
252 /* Returns phandle of the path specified */
253 extern int prom_finddevice(char *name);
254
255 /* Returns 1 if the specified node has given property. */
256 extern int prom_node_has_property(int node, char *property);
257
258 /* Set the indicated property at the given node with the passed value.
259  * Returns the number of bytes of your value that the prom took.
260  */
261 extern int prom_setprop(int node, char *prop_name, char *prop_value,
262                         int value_size);
263                         
264 extern int prom_pathtoinode(char *path);
265 extern int prom_inst2pkg(int);
266
267 /* Dorking with Bus ranges... */
268
269 /* Apply promlib probes OBIO ranges to registers. */
270 extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
271
272 /* Apply ranges of any prom node (and optionally parent node as well) to registers. */
273 extern void prom_apply_generic_ranges(int node, int parent, 
274                                       struct linux_prom_registers *sbusregs, int nregs);
275
276 /* CPU probing helpers.  */
277 int cpu_find_by_instance(int instance, int *prom_node, int *mid);
278 int cpu_find_by_mid(int mid, int *prom_node);
279 int cpu_get_hwmid(int prom_node);
280
281 extern spinlock_t prom_lock;
282
283 #endif /* !(__SPARC_OPLIB_H) */