Merge branch 'common/fbdev' of master.kernel.org:/pub/scm/linux/kernel/git/lethal...
[linux-2.6-block.git] / arch / sparc / include / asm / oplib_32.h
CommitLineData
f5e706ad
SR
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#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 */
f5e706ad
SR
24};
25
26extern enum prom_major_version prom_vers;
27/* Revision, and firmware revision. */
28extern unsigned int prom_rev, prom_prev;
29
30/* Root node of the prom device tree, this stays constant after
31 * initialization is complete.
32 */
8d125562 33extern phandle prom_root_node;
f5e706ad
SR
34
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!
38 */
39extern struct linux_nodeops *prom_nodeops;
40
41/* The functions... */
42
43/* You must call prom_init() before using any of the library services,
44 * preferably as early as possible. Pass it the romvec pointer.
45 */
46extern void prom_init(struct linux_romvec *rom_ptr);
47
48/* Boot argument acquisition, returns the boot command line string. */
49extern char *prom_getbootargs(void);
50
f5e706ad
SR
51/* Miscellaneous routines, don't really fit in any category per se. */
52
53/* Reboot the machine with the command line passed. */
54extern void prom_reboot(char *boot_command);
55
56/* Evaluate the forth string passed. */
57extern void prom_feval(char *forth_string);
58
59/* Enter the prom, with possibility of continuation with the 'go'
60 * command in newer proms.
61 */
62extern void prom_cmdline(void);
63
64/* Enter the prom, with no chance of continuation for the stand-alone
65 * which calls this.
66 */
5f66dd35 67extern void __noreturn prom_halt(void);
f5e706ad
SR
68
69/* Set the PROM 'sync' callback function to the passed function pointer.
70 * When the user gives the 'sync' command at the prom prompt while the
71 * kernel is still active, the prom will call this routine.
72 *
73 * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX
74 */
75typedef void (*sync_func_t)(void);
76extern void prom_setsync(sync_func_t func_ptr);
77
78/* Acquire the IDPROM of the root node in the prom device tree. This
79 * gets passed a buffer where you would like it stuffed. The return value
80 * is the format type of this idprom or 0xff on error.
81 */
82extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
83
84/* Get the prom major version. */
85extern int prom_version(void);
86
87/* Get the prom plugin revision. */
88extern int prom_getrev(void);
89
90/* Get the prom firmware revision. */
91extern int prom_getprev(void);
92
595a251c
DM
93/* Write a buffer of characters to the console. */
94extern void prom_console_write_buf(const char *buf, int len);
f5e706ad
SR
95
96/* Prom's internal routines, don't use in kernel/boot code. */
efe6c3dd 97extern void prom_printf(const char *fmt, ...);
f5e706ad
SR
98extern void prom_write(const char *buf, unsigned int len);
99
100/* Multiprocessor operations... */
101
102/* Start the CPU with the given device tree node, context table, and context
103 * at the passed program counter.
104 */
105extern int prom_startcpu(int cpunode, struct linux_prom_registers *context_table,
106 int context, char *program_counter);
107
f5e706ad
SR
108/* Sun4/sun4c specific memory-management startup hook. */
109
110/* Map the passed segment in the given context at the passed
111 * virtual address.
112 */
113extern void prom_putsegment(int context, unsigned long virt_addr,
114 int physical_segment);
115
5f66dd35
SR
116/* Initialize the memory lists based upon the prom version. */
117void prom_meminit(void);
f5e706ad
SR
118
119/* PROM device tree traversal functions... */
120
f5e706ad 121/* Get the child node of the given node, or zero if no child exists. */
8d125562 122extern phandle prom_getchild(phandle parent_node);
f5e706ad
SR
123
124/* Get the next sibling node of the given node, or zero if no further
125 * siblings exist.
126 */
8d125562 127extern phandle prom_getsibling(phandle node);
f5e706ad
SR
128
129/* Get the length, at the passed node, of the given property type.
130 * Returns -1 on error (ie. no such property at this node).
131 */
8d125562 132extern int prom_getproplen(phandle thisnode, const char *property);
f5e706ad
SR
133
134/* Fetch the requested property using the given buffer. Returns
135 * the number of bytes the prom put into your buffer or -1 on error.
136 */
8d125562 137extern int __must_check prom_getproperty(phandle thisnode, const char *property,
f5e706ad
SR
138 char *prop_buffer, int propbuf_size);
139
140/* Acquire an integer property. */
8d125562 141extern int prom_getint(phandle node, char *property);
f5e706ad
SR
142
143/* Acquire an integer property, with a default value. */
8d125562 144extern int prom_getintdefault(phandle node, char *property, int defval);
f5e706ad
SR
145
146/* Acquire a boolean property, 0=FALSE 1=TRUE. */
8d125562 147extern int prom_getbool(phandle node, char *prop);
f5e706ad
SR
148
149/* Acquire a string property, null string on error. */
8d125562 150extern void prom_getstring(phandle node, char *prop, char *buf, int bufsize);
f5e706ad 151
f5e706ad
SR
152/* Search all siblings starting at the passed node for "name" matching
153 * the given string. Returns the node on success, zero on failure.
154 */
8d125562 155extern phandle prom_searchsiblings(phandle node_start, char *name);
f5e706ad 156
f5e706ad
SR
157/* Returns the next property after the passed property for the given
158 * node. Returns null string on failure.
159 */
8d125562 160extern char *prom_nextprop(phandle node, char *prev_property, char *buffer);
f5e706ad
SR
161
162/* Returns phandle of the path specified */
8d125562 163extern phandle prom_finddevice(char *name);
f5e706ad 164
f5e706ad
SR
165/* Set the indicated property at the given node with the passed value.
166 * Returns the number of bytes of your value that the prom took.
167 */
8d125562 168extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,
f5e706ad
SR
169 int value_size);
170
8d125562 171extern phandle prom_inst2pkg(int);
f5e706ad
SR
172
173/* Dorking with Bus ranges... */
174
175/* Apply promlib probes OBIO ranges to registers. */
176extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
177
178/* Apply ranges of any prom node (and optionally parent node as well) to registers. */
8d125562 179extern void prom_apply_generic_ranges(phandle node, phandle parent,
f5e706ad
SR
180 struct linux_prom_registers *sbusregs, int nregs);
181
5f66dd35
SR
182void prom_ranges_init(void);
183
f5e706ad 184/* CPU probing helpers. */
8d125562
AS
185int cpu_find_by_instance(int instance, phandle *prom_node, int *mid);
186int cpu_find_by_mid(int mid, phandle *prom_node);
187int cpu_get_hwmid(phandle prom_node);
f5e706ad
SR
188
189extern spinlock_t prom_lock;
190
191#endif /* !(__SPARC_OPLIB_H) */