OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-sparc/] [oplib.h] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.