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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
30 * Device control interfaces
32 #include <sys/types.h>
33 #include <sys/nvpair.h>
40 * structure used to pass IOCTL data between the libdevice interfaces
41 * and nexus driver devctl IOCTL interface.
43 * Applications and nexus drivers may not access the contents of this
44 * structure directly. Instead, drivers must use the ndi_dc_*(9n)
45 * interfaces, while applications must use the interfaces provided by
48 struct devctl_iocdata
{
49 uint_t cmd
; /* ioctl cmd */
50 uint_t flags
; /* command-specific flags */
51 void *cpyout_buf
; /* copyout vector */
52 nvlist_t
*nvl_user
; /* application defined attributes */
54 char *c_nodename
; /* child device nodename */
55 char *c_unitaddr
; /* child device unit address */
58 #if defined(_SYSCALL32)
60 * Structure to pass/return data from 32-bit program's.
62 struct devctl_iocdata32
{
74 * Limit size of packed application defined attributes (nvl_user) to prevent
75 * user application from requesting excessive kernel memory allocation.
77 #define DEVCTL_MAX_NVL_USERSZ 0x10000
80 * State of receptacle for an Attachment Point.
84 AP_RSTATE_DISCONNECTED
,
89 * State of occupant for an Attachment Point.
92 AP_OSTATE_UNCONFIGURED
,
97 * condition of an Attachment Point.
108 * structure used to return the state of Attachment Point (AP) thru
109 * devctl_ap_getstate() interface.
112 typedef struct devctl_ap_state
{
113 ap_rstate_t ap_rstate
; /* receptacle state */
114 ap_ostate_t ap_ostate
; /* occupant state */
115 ap_condition_t ap_condition
; /* condition of AP */
116 time_t ap_last_change
;
117 uint32_t ap_error_code
; /* error code */
118 uint8_t ap_in_transition
;
121 #if defined(_SYSCALL32)
123 * Structure to pass/return data from 32-bit program's.
125 typedef struct devctl_ap_state32
{
126 ap_rstate_t ap_rstate
; /* receptacle state */
127 ap_ostate_t ap_ostate
; /* occupant state */
128 ap_condition_t ap_condition
; /* condition of AP */
129 time32_t ap_last_change
;
130 uint32_t ap_error_code
; /* error code */
131 uint8_t ap_in_transition
;
132 } devctl_ap_state32_t
;
135 #define DEVCTL_IOC (0xDC << 16)
136 #define DEVCTL_IOC_MAX (DEVCTL_IOC | 0xFFFF)
137 #define DEVCTL_BUS_QUIESCE (DEVCTL_IOC | 1)
138 #define DEVCTL_BUS_UNQUIESCE (DEVCTL_IOC | 2)
139 #define DEVCTL_BUS_RESETALL (DEVCTL_IOC | 3)
140 #define DEVCTL_BUS_RESET (DEVCTL_IOC | 4)
141 #define DEVCTL_BUS_GETSTATE (DEVCTL_IOC | 5)
142 #define DEVCTL_DEVICE_ONLINE (DEVCTL_IOC | 6)
143 #define DEVCTL_DEVICE_OFFLINE (DEVCTL_IOC | 7)
144 #define DEVCTL_DEVICE_GETSTATE (DEVCTL_IOC | 9)
145 #define DEVCTL_DEVICE_RESET (DEVCTL_IOC | 10)
146 #define DEVCTL_BUS_CONFIGURE (DEVCTL_IOC | 11)
147 #define DEVCTL_BUS_UNCONFIGURE (DEVCTL_IOC | 12)
148 #define DEVCTL_DEVICE_REMOVE (DEVCTL_IOC | 13)
149 #define DEVCTL_AP_CONNECT (DEVCTL_IOC | 14)
150 #define DEVCTL_AP_DISCONNECT (DEVCTL_IOC | 15)
151 #define DEVCTL_AP_INSERT (DEVCTL_IOC | 16)
152 #define DEVCTL_AP_REMOVE (DEVCTL_IOC | 17)
153 #define DEVCTL_AP_CONFIGURE (DEVCTL_IOC | 18)
154 #define DEVCTL_AP_UNCONFIGURE (DEVCTL_IOC | 19)
155 #define DEVCTL_AP_GETSTATE (DEVCTL_IOC | 20)
156 #define DEVCTL_AP_CONTROL (DEVCTL_IOC | 21)
157 #define DEVCTL_BUS_DEV_CREATE (DEVCTL_IOC | 22)
158 #define DEVCTL_PM_BUSY_COMP (DEVCTL_IOC | 23)
159 #define DEVCTL_PM_IDLE_COMP (DEVCTL_IOC | 24)
160 #define DEVCTL_PM_RAISE_PWR (DEVCTL_IOC | 25)
161 #define DEVCTL_PM_LOWER_PWR (DEVCTL_IOC | 26)
162 #define DEVCTL_PM_CHANGE_PWR_LOW (DEVCTL_IOC | 27)
163 #define DEVCTL_PM_CHANGE_PWR_HIGH (DEVCTL_IOC | 28)
164 #define DEVCTL_PM_POWER (DEVCTL_IOC | 29)
165 #define DEVCTL_PM_PROM_PRINTF (DEVCTL_IOC | 30)
166 #define DEVCTL_PM_FAIL_SUSPEND (DEVCTL_IOC | 31)
167 #define DEVCTL_PM_PWR_HAS_CHANGED_ON_RESUME (DEVCTL_IOC | 32)
168 #define DEVCTL_PM_PUP_WITH_PWR_HAS_CHANGED (DEVCTL_IOC | 34)
169 #define DEVCTL_PM_BUSY_COMP_TEST (DEVCTL_IOC | 35)
170 #define DEVCTL_PM_BUS_STRICT_TEST (DEVCTL_IOC | 36)
171 #define DEVCTL_PM_NO_LOWER_POWER (DEVCTL_IOC | 37)
172 #define DEVCTL_PM_BUS_NO_INVOL (DEVCTL_IOC | 38)
173 #define DEVCTL_SET_LED (DEVCTL_IOC | 39)
174 #define DEVCTL_GET_LED (DEVCTL_IOC | 40)
175 #define DEVCTL_NUM_LEDS (DEVCTL_IOC | 41)
179 * is (c) in the range of possible devctl IOCTL commands?
181 #define IS_DEVCTL(c) (((c) >= DEVCTL_IOC) && ((c) <= DEVCTL_IOC_MAX))
184 * Device and Bus State definitions
186 * Device state is returned as a set of bit-flags that indicate the current
187 * operational state of a device node.
189 * Device nodes for leaf devices only contain state information for the
190 * device itself. Nexus device nodes contain both Bus and Device state
193 * DEVICE_ONLINE - Device is available for use by the system. Mutually
194 * exclusive with DEVICE_OFFLINE.
196 * DEVICE_OFFLINE - Device is unavailable for use by the system.
197 * Mutually exclusive with DEVICE_ONLINE and DEVICE_BUSY.
199 * DEVICE_DOWN - Device has been placed in the "DOWN" state by
200 * its controlling driver.
202 * DEVICE_BUSY - Device has open instances or nexus has INITALIZED
203 * children (nexi). A device in this state is by
206 * Bus state is returned as a set of bit-flags which indicates the
207 * operational state of a bus associated with the nexus dev_info node.
209 * BUS_ACTIVE - The bus associated with the device node is Active.
210 * I/O requests from child devices attached to the
211 * are initiated (or queued for initiation) as they
214 * BUS_QUIESCED - The bus associated with the device node has been
215 * Quieced. I/O requests from child devices attached
216 * to the bus are held pending until the bus nexus is
219 * BUS_SHUTDOWN - The bus associated with the device node has been
220 * shutdown by the nexus driver. I/O requests from
221 * child devices are returned with an error indicating
222 * the requested operation failed.
224 #define DEVICE_ONLINE 0x1
225 #define DEVICE_BUSY 0x2
226 #define DEVICE_OFFLINE 0x4
227 #define DEVICE_DOWN 0x8
229 #define BUS_ACTIVE 0x10
230 #define BUS_QUIESCED 0x20
231 #define BUS_SHUTDOWN 0x40
233 #define DEVICE_STATES_ASCII "Dev_Online", "Dev_Busy", "Dev_Offline", \
234 "Dev_Down", "Bus_Active", "Bus_Quiesced", "Bus_Shutdown"
236 #define DC_DEVI_NODENAME "ndi_dc.devi_nodename"
238 #define DEVCTL_CONSTRUCT 0x1
239 #define DEVCTL_OFFLINE 0x2
242 * Drive status LED control
245 uint32_t led_number
: 16; /* LED/device number */
246 uint32_t led_ctl_active
: 1; /* Control active */
247 uint32_t led_type
: 9; /* LED type */
248 uint32_t led_state
: 6; /* LED ON/OFF/Blink state */
251 /* Control active field */
252 #define DCL_CNTRL_OFF 0 /* Control inactive */
253 #define DCL_CNTRL_ON 1 /* Control active */
256 #define DCL_TYPE_DEVICE_FAIL 1 /* Device FAIL LED type */
257 #define DCL_TYPE_DEVICE_OK2RM 2 /* Device OK2RM LED type */
259 /* LED state field */
260 #define DCL_STATE_OFF 0 /* LED state OFF */
261 #define DCL_STATE_ON 1 /* LED state ON */
262 #define DCL_STATE_SLOW_BLNK 2 /* LED slow blink */
263 #define DCL_STATE_FAST_BLNK 3 /* LED fast blink */
269 #endif /* _SYS_DEVCTL_H */