xref: /titanic_41/usr/src/uts/common/sys/openpromio.h (revision dd49f125507979bb2ab505a8daf2a46d1be27051)
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  */
25 
26 #ifndef	_SYS_OPENPROMIO_H
27 #define	_SYS_OPENPROMIO_H
28 
29 /* From SunOS 4.1.1 <sundev/openpromio.h> */
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * XXX HACK ALERT
37  *
38  * You might think that this interface could support setting non-ASCII
39  * property values.  Unfortunately the 4.0.3c openprom driver SETOPT
40  * code ignores oprom_size and uses strlen() to compute the length of
41  * the value.  The 4.0.3c openprom eeprom command makes its contribution
42  * by not setting oprom_size to anything meaningful.  So, if we want the
43  * driver to trust oprom_size we have to use SETOPT2.  XXX.
44  */
45 struct openpromio {
46 	uint_t	oprom_size;		/* real size of following array */
47 	union {
48 		char	b[1];		/* For property names and values */
49 					/* NB: Adjacent, Null terminated */
50 		int	i;
51 	} opio_u;
52 };
53 
54 #define	oprom_array	opio_u.b
55 #define	oprom_node	opio_u.i
56 #define	oprom_len	opio_u.i
57 
58 /*
59  * OPROMMAXPARAM is used as a limit by the driver, and it has been
60  * increased to be 4 times the largest possible size of a property,
61  * which is 8K (nvramrc property).
62  */
63 #define	OPROMMAXPARAM	32768		/* max size of array */
64 
65 /*
66  * Note that all OPROM ioctl codes are type void. Since the amount
67  * of data copied in/out may (and does) vary, the openprom driver
68  * handles the copyin/copyout itself.
69  */
70 #define	OIOC	('O'<<8)
71 #define	OPROMGETOPT	(OIOC | 1)
72 #define	OPROMSETOPT	(OIOC | 2)
73 #define	OPROMNXTOPT	(OIOC | 3)
74 #define	OPROMSETOPT2	(OIOC | 4)	/* working OPROMSETOPT */
75 #define	OPROMNEXT	(OIOC | 5)	/* interface to raw config_ops */
76 #define	OPROMCHILD	(OIOC | 6)	/* interface to raw config_ops */
77 #define	OPROMGETPROP	(OIOC | 7)	/* interface to raw config_ops */
78 #define	OPROMNXTPROP	(OIOC | 8)	/* interface to raw config_ops */
79 #define	OPROMU2P	(OIOC | 9)	/* NOT SUPPORTED after 4.x */
80 #define	OPROMGETCONS	(OIOC | 10)	/* enquire which console device */
81 #define	OPROMGETFBNAME	(OIOC | 11)	/* Frame buffer OBP pathname */
82 #define	OPROMGETBOOTARGS (OIOC | 12)	/* Get boot arguments */
83 #define	OPROMGETVERSION	(OIOC | 13)	/* Get OpenProm Version string */
84 #define	OPROMPATH2DRV	(OIOC | 14)	/* Convert prom path to driver name */
85 #define	OPROMDEV2PROMNAME (OIOC | 15)	/* Convert devfs path to prom path */
86 #define	OPROMPROM2DEVNAME (OIOC | 16)	/* Convert devfs path to prom path */
87 #define	OPROMGETPROPLEN	(OIOC | 17)	/* interface to raw config_ops */
88 #define	OPROMREADY64	(OIOC | 18)	/* is prom 64-bit ready? */
89 #define	OPROMSETNODEID	(OIOC | 19)	/* set current node_id */
90 #define	OPROMSNAPSHOT	(OIOC | 20)	/* create a snapshot */
91 #define	OPROMCOPYOUT	(OIOC | 21)	/* copyout and free snapshot */
92 #define	OPROMLISTKEYS	(OIOC | 22)	/* asr-list-keys */
93 #define	OPROMLISTKEYSLEN (OIOC | 23)	/* asr-list-keys-len */
94 #define	OPROMEXPORT	(OIOC | 24)	/* asr-export */
95 #define	OPROMEXPORTLEN	(OIOC | 25)	/* asr-export-len */
96 #define	OPROMGETBOOTPATH	(OIOC | 26)	/* Get bootpath */
97 
98 /*
99  * Return values from OPROMGETCONS:
100  */
101 
102 #define	OPROMCONS_NOT_WSCONS	0
103 #define	OPROMCONS_STDIN_IS_KBD	0x1	/* stdin device is kbd */
104 #define	OPROMCONS_STDOUT_IS_FB	0x2	/* stdout is a framebuffer */
105 #define	OPROMCONS_OPENPROM	0x4	/* supports openboot */
106 
107 #if defined(__sparc)
108 
109 /*
110  * Data structure returned in oprom_array, from OPROMREADY64:
111  *
112  * With return codes 1 and 2, also returns nodeid, a nodeid
113  * of a flashprom node, and a message string with the minimum version
114  * requirement for this platform.
115  */
116 struct openprom_opr64 {
117 	int return_code;		/* See below */
118 	int nodeid;			/* Valid with positive return codes */
119 	char message[1];		/* NULL terminated message string */
120 };
121 
122 /*
123  * return_code values from OPROMREADY64:
124  */
125 #define	OP64R_READY			0	/* ready or not applicable */
126 #define	OP64R_UPGRADE_REQUIRED		1	/* Upgrade required */
127 #define	OP64R_UPGRADE_RECOMMENDED 	2	/* Upgrade recommended */
128 
129 #endif
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif	/* _SYS_OPENPROMIO_H */
136