summaryrefslogtreecommitdiffstats
path: root/share/man/man4/man4.sparc64/openfirm.4
blob: 9ccee39d0920a462a8358eb8db167800b9f167f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
.\"-
.\" Copyright (c) 1992, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" This software was developed by the Computer Systems Engineering group
.\" at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
.\" contributed to Berkeley.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"	from: @(#)openprom.4	8.1 (Berkeley) 6/5/93
.\"	from: OpenBSD: openprom.4,v 1.9 2004/03/22 22:07:21 miod Exp
.\"
.\"-
.\" Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd June 18, 2005
.Dt OPENFIRM 4 sparc64
.Os
.Sh NAME
.Nm openfirm
.Nd "Open Firmware interface"
.Sh SYNOPSIS
.In sys/types.h
.In sys/ioctl.h
.In dev/ofw/openfirmio.h
.Sh DESCRIPTION
The
.Pa /dev/openfirm
device is an interface to the
.Tn Open Firmware
device tree.
This interface is similar to the
.Tn SunOS /
.Tn Solaris
compatible
.Xr openprom 4
interface and highly stylized.
It uses
.Xr ioctl 2
calls for all operations.
These calls refer to the nodes in the
.Tn Open Firmware
device tree.
The nodes are represented by package handles,
which are simply integer values describing data areas.
Occasionally a package handle of 0 may be used or returned instead,
as described below.
.Pp
The calls that only take and/or return the package handle of a node
use a pointer to a
.Vt phandle_t
for this purpose.
The others use a pointer to a
.Vt "struct ofiocdesc"
descriptor,
which has the following definition:
.Bd -literal
struct ofiocdesc {
	phandle_t	of_nodeid;
	int		of_namelen;
	const char	*of_name;
	int		of_buflen;
	char		*of_buf;
};
.Ed
.Pp
The
.Va of_nodeid
member is the package handle of the node that is passed in or returned.
Strings are passed in via the
.Va of_name
member of
.Va of_namelen
length.
The maximum accepted length of
.Va of_name
is
.Dv OFIOCMAXNAME .
The
.Va of_buf
member is used to return strings except for the
.Dv OFIOCSET
call where it is also used to pass in a string.
In the latter case the maximum accepted length of
.Va of_buf
is
.Dv OFIOCMAXVALUE .
Generally,
.Va of_buf
works in a value-result fashion.
At entry to the
.Xr ioctl 2
call,
.Va of_buflen
is expected to reflect the buffer size.
On return,
.Va of_buflen
is updated to reflect the buffer contents.
.Pp
The following
.Xr ioctl 2
calls are supported:
.Bl -tag -width ".Dv OFIOCGETOPTNODE"
.It Dv OFIOCGETOPTNODE
Uses a
.Vt phandle_t .
Takes nothing and returns the package handle of the
.Pa /options
node.
.It Dv OFIOCGETNEXT
Uses a
.Vt phandle_t .
Takes the package handle of a node and returns the package handle of the next
node in the
.Tn Open Firmware
device tree.
The node following the last node has a package handle of 0.
The node following the node with the package handle of 0 is the first node.
.It Dv OFIOCGETCHILD
Uses a
.Vt phandle_t .
Takes the package handle of a node and returns the package handle of the first
child of that node.
This child may have siblings.
These can be determined by using
.Dv OFIOCGETNEXT .
If the node does not have a child,
a package handle of 0 is returned.
.It Dv OFIOCGET
Uses a
.Vt "struct ofiocdesc" .
Takes the package handle of a node and the name of a property.
Returns the property value and its length.
If no such property is associated with that node,
the length of the value is set to \-1.
If the named property exists but has no value,
the length of the value is set to 0.
.It Dv OFIOCGETPROPLEN
Uses a
.Vt "struct ofiocdesc" .
Takes the package handle of a node and the name of a property.
Returns the length of the property value.
This call is the same as
.Dv OFIOCGET
except that only the length of the property value is returned.
It can be used to determine whether a node has a particular property or whether
a property has a value without the need to provide memory for storing the value.
.It Dv OFIOCSET
Uses a
.Vt "struct ofiocdesc" .
Takes the package handle of a node,
the name of a property and a property value.
Returns the property value and the length that actually have been written.
The
.Tn Open Firmware
may choose to truncate the value if it is too long or write a valid value
instead if the given value is invalid for the particular property.
Therefore the returned value should be checked.
The
.Tn Open Firmware
may also completely refuse to write the given value to the property.
In this case
.Er EINVAL
is returned.
.It Dv OFIOCNEXTPROP
Uses a
.Vt "struct ofiocdesc" .
Takes the package handle of a node and the name of a property.
Returns the name and the length of the next property of the node.
If the property referenced by the given name is the last property of the node,
.Er ENOENT
is returned.
.It Dv OFIOCFINDDEVICE
Uses a
.Vt "struct ofiocdesc" .
Takes the name or alias name of a device node.
Returns package handle of the node.
If no matching node is found,
.Er ENOENT
is returned.
.El
.Sh FILES
.Bl -tag -width ".Pa /dev/openfirm"
.It Pa /dev/openfirm
Open Firmware interface node
.El
.Sh ERRORS
The following may result in rejection of an operation:
.Bl -tag -width Er
.It Bq Er EBADF
The requested operation requires permissions not specified at the call to
.Fn open .
.It Bq Er EINVAL
The given package handle is not 0 and does not correspond to any valid node,
or the given package handle is 0 where 0 is not allowed.
.It Bq Er ENAMETOOLONG
The given name or value exceeds the maximum allowed length of
.Dv OFIOCMAXNAME
and
.Dv OFIOCMAXVALUE
bytes respectively.
.It Bq Er ENOMEM
The kernel could not allocate memory to copy in data from user-space or to
retrieve data from the
.Tn Open Firmware .
.El
.Sh CAVEATS
Due to limitations within
.Tn Open Firmware
itself,
these functions run at elevated priority and may adversely affect system
performance.
.Pp
For at least the
.Pa /options
node the property value passed in to the
.Dv OFIOCSET
call has to be null-terminated and the value length passed in has to include
the terminating
.Ql \e0.
However, as with the
.Dv OFIOCGET
call,
the returned value length does not include the terminating
.Ql \e0.
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr openprom 4 ,
.Xr eeprom 8 ,
.Xr ofwdump 8
.Rs
.%Q "IEEE Standards Organization"
.%B "IEEE Std 1275-1994:"
.%B "IEEE Standard for Boot Firmware (Initialization Configuration) Firmware:"
.%B Core Requirements and Practices"
.%O ISBN 1-55937-426-8
.Re
.Sh HISTORY
The
.Nm
interface first appeared in
.Nx 1.6 .
The first
.Fx
version to include it was
.Fx 5.0 .
.Sh AUTHORS
The
.Nm
interface was ported to
.Fx
by
.An "Thomas Moestl" Aq tmm@FreeBSD.org .
OpenPOWER on IntegriCloud