Linux Audio

Check our new training course

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