xref: /illumos-gate/usr/src/uts/common/sys/openpromio.h (revision 0245b61fd282e95735b173b8d95be0d6688163b4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  * Copyright 2019 Peter Tribble.
25  */
26 
27 #ifndef	_SYS_OPENPROMIO_H
28 #define	_SYS_OPENPROMIO_H
29 
30 /* From SunOS 4.1.1 <sundev/openpromio.h> */
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * XXX HACK ALERT
38  *
39  * You might think that this interface could support setting non-ASCII
40  * property values.  Unfortunately the 4.0.3c openprom driver SETOPT
41  * code ignores oprom_size and uses strlen() to compute the length of
42  * the value.  The 4.0.3c openprom eeprom command makes its contribution
43  * by not setting oprom_size to anything meaningful.  So, if we want the
44  * driver to trust oprom_size we have to use SETOPT2.  XXX.
45  */
46 struct openpromio {
47 	uint_t	oprom_size;		/* real size of following array */
48 	union {
49 		char	b[1];		/* For property names and values */
50 					/* NB: Adjacent, Null terminated */
51 		int	i;
52 	} opio_u;
53 };
54 
55 #define	oprom_array	opio_u.b
56 #define	oprom_node	opio_u.i
57 #define	oprom_len	opio_u.i
58 
59 /*
60  * OPROMMAXPARAM is used as a limit by the driver, and it has been
61  * increased to be 4 times the largest possible size of a property,
62  * which is 8K (nvramrc property).
63  */
64 #define	OPROMMAXPARAM	32768		/* max size of array */
65 
66 /*
67  * Note that all OPROM ioctl codes are type void. Since the amount
68  * of data copied in/out may (and does) vary, the openprom driver
69  * handles the copyin/copyout itself.
70  */
71 #define	OIOC	('O'<<8)
72 #define	OPROMGETOPT	(OIOC | 1)
73 #define	OPROMSETOPT	(OIOC | 2)
74 #define	OPROMNXTOPT	(OIOC | 3)
75 #define	OPROMSETOPT2	(OIOC | 4)	/* working OPROMSETOPT */
76 #define	OPROMNEXT	(OIOC | 5)	/* interface to raw config_ops */
77 #define	OPROMCHILD	(OIOC | 6)	/* interface to raw config_ops */
78 #define	OPROMGETPROP	(OIOC | 7)	/* interface to raw config_ops */
79 #define	OPROMNXTPROP	(OIOC | 8)	/* interface to raw config_ops */
80 #define	OPROMU2P	(OIOC | 9)	/* NOT SUPPORTED after 4.x */
81 #define	OPROMGETCONS	(OIOC | 10)	/* enquire which console device */
82 #define	OPROMGETFBNAME	(OIOC | 11)	/* Frame buffer OBP pathname */
83 #define	OPROMGETBOOTARGS (OIOC | 12)	/* Get boot arguments */
84 #define	OPROMGETVERSION	(OIOC | 13)	/* Get OpenProm Version string */
85 #define	OPROMPATH2DRV	(OIOC | 14)	/* Convert prom path to driver name */
86 #define	OPROMDEV2PROMNAME (OIOC | 15)	/* Convert devfs path to prom path */
87 #define	OPROMPROM2DEVNAME (OIOC | 16)	/* Convert devfs path to prom path */
88 #define	OPROMGETPROPLEN	(OIOC | 17)	/* interface to raw config_ops */
89 #define	OPROMREADY64	(OIOC | 18)	/* DEPRECATED is prom 64-bit ready? */
90 #define	OPROMSETNODEID	(OIOC | 19)	/* set current node_id */
91 #define	OPROMSNAPSHOT	(OIOC | 20)	/* create a snapshot */
92 #define	OPROMCOPYOUT	(OIOC | 21)	/* copyout and free snapshot */
93 #define	OPROMLISTKEYS	(OIOC | 22)	/* asr-list-keys */
94 #define	OPROMLISTKEYSLEN (OIOC | 23)	/* asr-list-keys-len */
95 #define	OPROMEXPORT	(OIOC | 24)	/* asr-export */
96 #define	OPROMEXPORTLEN	(OIOC | 25)	/* asr-export-len */
97 #define	OPROMGETBOOTPATH	(OIOC | 26)	/* Get bootpath */
98 
99 /*
100  * Return values from OPROMGETCONS:
101  */
102 
103 #define	OPROMCONS_NOT_WSCONS	0
104 #define	OPROMCONS_STDIN_IS_KBD	0x1	/* stdin device is kbd */
105 #define	OPROMCONS_STDOUT_IS_FB	0x2	/* stdout is a framebuffer */
106 #define	OPROMCONS_OPENPROM	0x4	/* supports openboot */
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif	/* _SYS_OPENPROMIO_H */
113