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