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