xref: /freebsd/sys/dev/ofw/openfirmio.h (revision 26869ad14c70306313405029229a1e2fd94510cd)
1de540622SThomas Moestl /*	$NetBSD: openfirmio.h,v 1.4 2002/09/06 13:23:19 gehenna Exp $ */
2de540622SThomas Moestl 
3098ca2bdSWarner Losh /*-
47282444bSPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
57282444bSPedro F. Giffuni  *
6de540622SThomas Moestl  * Copyright (c) 1992, 1993
7de540622SThomas Moestl  *	The Regents of the University of California.  All rights reserved.
8de540622SThomas Moestl  *
9de540622SThomas Moestl  * This software was developed by the Computer Systems Engineering group
10de540622SThomas Moestl  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
11de540622SThomas Moestl  * contributed to Berkeley.
12de540622SThomas Moestl  *
13de540622SThomas Moestl  * Redistribution and use in source and binary forms, with or without
14de540622SThomas Moestl  * modification, are permitted provided that the following conditions
15de540622SThomas Moestl  * are met:
16de540622SThomas Moestl  * 1. Redistributions of source code must retain the above copyright
17de540622SThomas Moestl  *    notice, this list of conditions and the following disclaimer.
18de540622SThomas Moestl  * 2. Redistributions in binary form must reproduce the above copyright
19de540622SThomas Moestl  *    notice, this list of conditions and the following disclaimer in the
20de540622SThomas Moestl  *    documentation and/or other materials provided with the distribution.
21fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
22de540622SThomas Moestl  *    may be used to endorse or promote products derived from this software
23de540622SThomas Moestl  *    without specific prior written permission.
24de540622SThomas Moestl  *
25de540622SThomas Moestl  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26de540622SThomas Moestl  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27de540622SThomas Moestl  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28de540622SThomas Moestl  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29de540622SThomas Moestl  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30de540622SThomas Moestl  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31de540622SThomas Moestl  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32de540622SThomas Moestl  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33de540622SThomas Moestl  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34de540622SThomas Moestl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35de540622SThomas Moestl  * SUCH DAMAGE.
36de540622SThomas Moestl  *
37de540622SThomas Moestl  *	@(#)openpromio.h	8.1 (Berkeley) 6/11/93
38de540622SThomas Moestl  *
39de540622SThomas Moestl  * $FreeBSD$
40de540622SThomas Moestl  */
41de540622SThomas Moestl 
42de540622SThomas Moestl #ifndef _DEV_OFW_OPENFIRMIO_H_
43de540622SThomas Moestl #define _DEV_OFW_OPENFIRMIO_H_
44de540622SThomas Moestl 
45de540622SThomas Moestl #include <dev/ofw/openfirm.h>
46de540622SThomas Moestl 
47de540622SThomas Moestl struct ofiocdesc {
48de540622SThomas Moestl 	phandle_t	of_nodeid;	/* passed or returned node id */
492ad15420SMarius Strobl 	int		of_namelen;	/* length of of_name */
50de540622SThomas Moestl 	const char	*of_name;	/* pointer to field name */
512ad15420SMarius Strobl 	int		of_buflen;	/* length of of_buf (value-result) */
52de540622SThomas Moestl 	char		*of_buf;	/* pointer to field value */
53de540622SThomas Moestl };
54de540622SThomas Moestl 
55de540622SThomas Moestl #define	OFIOC_BASE	'O'
56de540622SThomas Moestl 
57de540622SThomas Moestl /* Get openprom field. */
58de540622SThomas Moestl #define	OFIOCGET	_IOWR(OFIOC_BASE, 1, struct ofiocdesc)
59de540622SThomas Moestl /* Set openprom field. */
60073e8552SMarius Strobl #define	OFIOCSET	_IOWR(OFIOC_BASE, 2, struct ofiocdesc)
61de540622SThomas Moestl /* Get next property. */
62de540622SThomas Moestl #define	OFIOCNEXTPROP	_IOWR(OFIOC_BASE, 3, struct ofiocdesc)
63de540622SThomas Moestl /* Get options node. */
64de540622SThomas Moestl #define	OFIOCGETOPTNODE	_IOR(OFIOC_BASE, 4, phandle_t)
65de540622SThomas Moestl /* Get next node of node. */
66de540622SThomas Moestl #define	OFIOCGETNEXT	_IOWR(OFIOC_BASE, 5, phandle_t)
67de540622SThomas Moestl /* Get first child of node. */
68de540622SThomas Moestl #define	OFIOCGETCHILD	_IOWR(OFIOC_BASE, 6, phandle_t)
69de540622SThomas Moestl /* Find a specific device. */
70de540622SThomas Moestl #define	OFIOCFINDDEVICE	_IOWR(OFIOC_BASE, 7, struct ofiocdesc)
71933c9a14SThomas Moestl /* Retrieve the size of a property. */
72933c9a14SThomas Moestl #define	OFIOCGETPROPLEN	_IOWR(OFIOC_BASE, 8, struct ofiocdesc)
73de540622SThomas Moestl 
74073e8552SMarius Strobl /* Maximum accepted name length. */
75073e8552SMarius Strobl #define	OFIOCMAXNAME	8191
76073e8552SMarius Strobl /* Maximum accepted value length (maximum of nvramrc property). */
77073e8552SMarius Strobl #define	OFIOCMAXVALUE	8192
78073e8552SMarius Strobl 
79*26869ad1SBrandon Bergren /*
80*26869ad1SBrandon Bergren  * While IEEE 1275-1994 states in 3.2.2.1.1 that property names are 1-31
81*26869ad1SBrandon Bergren  * printable characters, in practice, this limit has been ignored.
82*26869ad1SBrandon Bergren  * Noncompliant properties have been codified in standards such as LoPAPR.
83*26869ad1SBrandon Bergren  *
84*26869ad1SBrandon Bergren  * This is a suggested buffer length that should be large enough to hold
85*26869ad1SBrandon Bergren  * any property name currently seen in device trees, without being overly
86*26869ad1SBrandon Bergren  * wasteful of memory.
87*26869ad1SBrandon Bergren  *
88*26869ad1SBrandon Bergren  * If a future version of the Devicetree specification updates the property
89*26869ad1SBrandon Bergren  * names length requirement, this value will be updated to match.
90*26869ad1SBrandon Bergren  */
91*26869ad1SBrandon Bergren #define	OFIOCSUGGPROPNAMELEN	64
92*26869ad1SBrandon Bergren 
93de540622SThomas Moestl #endif /* _DEV_OFW_OPENFIRMIO_H_ */
94