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