RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / sparc / include / asm / oplib_32.h
blob88232c03dd6c95300c88980e13897d9978944155
1 /*
2 * oplib.h: Describes the interface and available routines in the
3 * Linux Prom library.
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
8 #ifndef __SPARC_OPLIB_H
9 #define __SPARC_OPLIB_H
11 #include <asm/openprom.h>
12 #include <linux/spinlock.h>
13 #include <linux/compiler.h>
15 /* The master romvec pointer... */
16 extern struct linux_romvec *romvec;
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 */
26 extern enum prom_major_version prom_vers;
27 /* Revision, and firmware revision. */
28 extern unsigned int prom_rev, prom_prev;
30 /* Root node of the prom device tree, this stays constant after
31 * initialization is complete.
33 extern int prom_root_node;
35 /* Pointer to prom structure containing the device tree traversal
36 * and usage utility functions. Only prom-lib should use these,
37 * users use the interface defined by the library only!
39 extern struct linux_nodeops *prom_nodeops;
41 /* The functions... */
43 /* You must call prom_init() before using any of the library services,
44 * preferably as early as possible. Pass it the romvec pointer.
46 extern void prom_init(struct linux_romvec *rom_ptr);
48 /* Boot argument acquisition, returns the boot command line string. */
49 extern char *prom_getbootargs(void);
51 /* Device utilities. */
53 /* Map and unmap devices in IO space at virtual addresses. Note that the
54 * virtual address you pass is a request and the prom may put your mappings
55 * somewhere else, so check your return value as that is where your new
56 * mappings really are!
58 * Another note, these are only available on V2 or higher proms!
60 extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes);
61 extern void prom_unmapio(char *virt_addr, unsigned int num_bytes);
63 /* Miscellaneous routines, don't really fit in any category per se. */
65 /* Reboot the machine with the command line passed. */
66 extern void prom_reboot(char *boot_command);
68 /* Evaluate the forth string passed. */
69 extern void prom_feval(char *forth_string);
71 /* Enter the prom, with possibility of continuation with the 'go'
72 * command in newer proms.
74 extern void prom_cmdline(void);
76 /* Enter the prom, with no chance of continuation for the stand-alone
77 * which calls this.
79 extern void prom_halt(void) __attribute__ ((noreturn));
81 typedef void (*sync_func_t)(void);
82 extern void prom_setsync(sync_func_t func_ptr);
84 /* Acquire the IDPROM of the root node in the prom device tree. This
85 * gets passed a buffer where you would like it stuffed. The return value
86 * is the format type of this idprom or 0xff on error.
88 extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
90 /* Get the prom major version. */
91 extern int prom_version(void);
93 /* Get the prom plugin revision. */
94 extern int prom_getrev(void);
96 /* Get the prom firmware revision. */
97 extern int prom_getprev(void);
99 /* Write a buffer of characters to the console. */
100 extern void prom_console_write_buf(const char *buf, int len);
102 /* Prom's internal routines, don't use in kernel/boot code. */
103 extern void prom_printf(const char *fmt, ...);
104 extern void prom_write(const char *buf, unsigned int len);
106 /* Multiprocessor operations... */
108 /* Start the CPU with the given device tree node, context table, and context
109 * at the passed program counter.
111 extern int prom_startcpu(int cpunode, struct linux_prom_registers *context_table,
112 int context, char *program_counter);
114 /* Stop the CPU with the passed device tree node. */
115 extern int prom_stopcpu(int cpunode);
117 /* Idle the CPU with the passed device tree node. */
118 extern int prom_idlecpu(int cpunode);
120 /* Re-Start the CPU with the passed device tree node. */
121 extern int prom_restartcpu(int cpunode);
123 /* PROM memory allocation facilities... */
125 /* Allocated at possibly the given virtual address a chunk of the
126 * indicated size.
128 extern char *prom_alloc(char *virt_hint, unsigned int size);
130 /* Free a previously allocated chunk. */
131 extern void prom_free(char *virt_addr, unsigned int size);
133 /* Sun4/sun4c specific memory-management startup hook. */
135 /* Map the passed segment in the given context at the passed
136 * virtual address.
138 extern void prom_putsegment(int context, unsigned long virt_addr,
139 int physical_segment);
142 /* PROM device tree traversal functions... */
144 /* Get the child node of the given node, or zero if no child exists. */
145 extern int prom_getchild(int parent_node);
147 /* Get the next sibling node of the given node, or zero if no further
148 * siblings exist.
150 extern int prom_getsibling(int node);
152 /* Get the length, at the passed node, of the given property type.
153 * Returns -1 on error (ie. no such property at this node).
155 extern int prom_getproplen(int thisnode, const char *property);
157 /* Fetch the requested property using the given buffer. Returns
158 * the number of bytes the prom put into your buffer or -1 on error.
160 extern int __must_check prom_getproperty(int thisnode, const char *property,
161 char *prop_buffer, int propbuf_size);
163 /* Acquire an integer property. */
164 extern int prom_getint(int node, char *property);
166 /* Acquire an integer property, with a default value. */
167 extern int prom_getintdefault(int node, char *property, int defval);
169 /* Acquire a boolean property, 0=FALSE 1=TRUE. */
170 extern int prom_getbool(int node, char *prop);
172 /* Acquire a string property, null string on error. */
173 extern void prom_getstring(int node, char *prop, char *buf, int bufsize);
175 /* Does the passed node have the given "name"? YES=1 NO=0 */
176 extern int prom_nodematch(int thisnode, char *name);
178 /* Search all siblings starting at the passed node for "name" matching
179 * the given string. Returns the node on success, zero on failure.
181 extern int prom_searchsiblings(int node_start, char *name);
183 /* Return the first property type, as a string, for the given node.
184 * Returns a null string on error.
186 extern char *prom_firstprop(int node, char *buffer);
188 /* Returns the next property after the passed property for the given
189 * node. Returns null string on failure.
191 extern char *prom_nextprop(int node, char *prev_property, char *buffer);
193 /* Returns phandle of the path specified */
194 extern int prom_finddevice(char *name);
196 /* Returns 1 if the specified node has given property. */
197 extern int prom_node_has_property(int node, char *property);
199 /* Set the indicated property at the given node with the passed value.
200 * Returns the number of bytes of your value that the prom took.
202 extern int prom_setprop(int node, const char *prop_name, char *prop_value,
203 int value_size);
205 extern int prom_inst2pkg(int);
207 /* Dorking with Bus ranges... */
209 /* Apply promlib probes OBIO ranges to registers. */
210 extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
212 /* Apply ranges of any prom node (and optionally parent node as well) to registers. */
213 extern void prom_apply_generic_ranges(int node, int parent,
214 struct linux_prom_registers *sbusregs, int nregs);
216 /* CPU probing helpers. */
217 int cpu_find_by_instance(int instance, int *prom_node, int *mid);
218 int cpu_find_by_mid(int mid, int *prom_node);
219 int cpu_get_hwmid(int prom_node);
221 extern spinlock_t prom_lock;
223 #endif /* !(__SPARC_OPLIB_H) */