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 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_DEVCTL_H 27 #define _SYS_DEVCTL_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 /* 32 * Device control interfaces 33 */ 34 #include <sys/types.h> 35 #include <sys/nvpair.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* 42 * structure used to pass IOCTL data between the libdevice interfaces 43 * and nexus driver devctl IOCTL interface. 44 * 45 * Applications and nexus drivers may not access the contents of this 46 * structure directly. Instead, drivers must use the ndi_dc_XXX(9n) 47 * interfaces, while applications must use the interfaces provided by 48 * libdevice.so.1. 49 */ 50 struct devctl_iocdata { 51 uint_t cmd; /* ioctl cmd */ 52 uint_t flags; /* command-specific flags */ 53 void *cpyout_buf; /* copyout vector */ 54 nvlist_t *nvl_user; /* application defined attributes */ 55 size_t nvl_usersz; 56 char *c_nodename; /* child device nodename */ 57 char *c_unitaddr; /* child device unit address */ 58 }; 59 60 #if defined(_SYSCALL32) 61 /* 62 * Structure to pass/return data from 32-bit program's. 63 */ 64 struct devctl_iocdata32 { 65 uint32_t cmd; 66 uint32_t flags; 67 caddr32_t cpyout_buf; 68 caddr32_t nvl_user; 69 uint32_t nvl_usersz; 70 caddr32_t c_nodename; 71 caddr32_t c_unitaddr; 72 }; 73 #endif 74 75 /* 76 * Limit size of packed application defined attributes (nvl_user) to prevent 77 * user application from requesting excessive kernel memory allocation. 78 */ 79 #define DEVCTL_MAX_NVL_USERSZ 0x10000 80 81 /* 82 * State of receptacle for an Attachment Point. 83 */ 84 typedef enum { 85 AP_RSTATE_EMPTY, 86 AP_RSTATE_DISCONNECTED, 87 AP_RSTATE_CONNECTED 88 } ap_rstate_t; 89 90 /* 91 * State of occupant for an Attachment Point. 92 */ 93 typedef enum { 94 AP_OSTATE_UNCONFIGURED, 95 AP_OSTATE_CONFIGURED 96 } ap_ostate_t; 97 98 /* 99 * condition of an Attachment Point. 100 */ 101 typedef enum { 102 AP_COND_UNKNOWN, 103 AP_COND_OK, 104 AP_COND_FAILING, 105 AP_COND_FAILED, 106 AP_COND_UNUSABLE 107 } ap_condition_t; 108 109 /* 110 * structure used to return the state of Attachment Point (AP) thru 111 * devctl_ap_getstate() interface. 112 */ 113 114 typedef struct devctl_ap_state { 115 ap_rstate_t ap_rstate; /* receptacle state */ 116 ap_ostate_t ap_ostate; /* occupant state */ 117 ap_condition_t ap_condition; /* condition of AP */ 118 time_t ap_last_change; 119 uint32_t ap_error_code; /* error code */ 120 uint8_t ap_in_transition; 121 } devctl_ap_state_t; 122 123 #if defined(_SYSCALL32) 124 /* 125 * Structure to pass/return data from 32-bit program's. 126 */ 127 typedef struct devctl_ap_state32 { 128 ap_rstate_t ap_rstate; /* receptacle state */ 129 ap_ostate_t ap_ostate; /* occupant state */ 130 ap_condition_t ap_condition; /* condition of AP */ 131 time32_t ap_last_change; 132 uint32_t ap_error_code; /* error code */ 133 uint8_t ap_in_transition; 134 } devctl_ap_state32_t; 135 #endif 136 137 #define DEVCTL_IOC (0xDC << 16) 138 #define DEVCTL_IOC_MAX (DEVCTL_IOC | 0xFFFF) 139 #define DEVCTL_BUS_QUIESCE (DEVCTL_IOC | 1) 140 #define DEVCTL_BUS_UNQUIESCE (DEVCTL_IOC | 2) 141 #define DEVCTL_BUS_RESETALL (DEVCTL_IOC | 3) 142 #define DEVCTL_BUS_RESET (DEVCTL_IOC | 4) 143 #define DEVCTL_BUS_GETSTATE (DEVCTL_IOC | 5) 144 #define DEVCTL_DEVICE_ONLINE (DEVCTL_IOC | 6) 145 #define DEVCTL_DEVICE_OFFLINE (DEVCTL_IOC | 7) 146 #define DEVCTL_DEVICE_GETSTATE (DEVCTL_IOC | 9) 147 #define DEVCTL_DEVICE_RESET (DEVCTL_IOC | 10) 148 #define DEVCTL_BUS_CONFIGURE (DEVCTL_IOC | 11) 149 #define DEVCTL_BUS_UNCONFIGURE (DEVCTL_IOC | 12) 150 #define DEVCTL_DEVICE_REMOVE (DEVCTL_IOC | 13) 151 #define DEVCTL_AP_CONNECT (DEVCTL_IOC | 14) 152 #define DEVCTL_AP_DISCONNECT (DEVCTL_IOC | 15) 153 #define DEVCTL_AP_INSERT (DEVCTL_IOC | 16) 154 #define DEVCTL_AP_REMOVE (DEVCTL_IOC | 17) 155 #define DEVCTL_AP_CONFIGURE (DEVCTL_IOC | 18) 156 #define DEVCTL_AP_UNCONFIGURE (DEVCTL_IOC | 19) 157 #define DEVCTL_AP_GETSTATE (DEVCTL_IOC | 20) 158 #define DEVCTL_AP_CONTROL (DEVCTL_IOC | 21) 159 #define DEVCTL_BUS_DEV_CREATE (DEVCTL_IOC | 22) 160 #define DEVCTL_PM_BUSY_COMP (DEVCTL_IOC | 23) 161 #define DEVCTL_PM_IDLE_COMP (DEVCTL_IOC | 24) 162 #define DEVCTL_PM_RAISE_PWR (DEVCTL_IOC | 25) 163 #define DEVCTL_PM_LOWER_PWR (DEVCTL_IOC | 26) 164 #define DEVCTL_PM_CHANGE_PWR_LOW (DEVCTL_IOC | 27) 165 #define DEVCTL_PM_CHANGE_PWR_HIGH (DEVCTL_IOC | 28) 166 #define DEVCTL_PM_POWER (DEVCTL_IOC | 29) 167 #define DEVCTL_PM_PROM_PRINTF (DEVCTL_IOC | 30) 168 #define DEVCTL_PM_FAIL_SUSPEND (DEVCTL_IOC | 31) 169 #define DEVCTL_PM_PWR_HAS_CHANGED_ON_RESUME (DEVCTL_IOC | 32) 170 #define DEVCTL_PM_PUP_WITH_PWR_HAS_CHANGED (DEVCTL_IOC | 34) 171 #define DEVCTL_PM_BUSY_COMP_TEST (DEVCTL_IOC | 35) 172 #define DEVCTL_PM_BUS_STRICT_TEST (DEVCTL_IOC | 36) 173 #define DEVCTL_PM_NO_LOWER_POWER (DEVCTL_IOC | 37) 174 #define DEVCTL_PM_BUS_NO_INVOL (DEVCTL_IOC | 38) 175 176 /* 177 * is (c) in the range of possible devctl IOCTL commands? 178 */ 179 #define IS_DEVCTL(c) (((c) >= DEVCTL_IOC) && ((c) <= DEVCTL_IOC_MAX)) 180 181 /* 182 * Device and Bus State definitions 183 * 184 * Device state is returned as a set of bit-flags that indicate the current 185 * operational state of a device node. 186 * 187 * Device nodes for leaf devices only contain state information for the 188 * device itself. Nexus device nodes contain both Bus and Device state 189 * information. 190 * 191 * DEVICE_ONLINE - Device is available for use by the system. Mutually 192 * exclusive with DEVICE_OFFLINE. 193 * 194 * DEVICE_OFFLINE - Device is unavailable for use by the system. 195 * Mutually exclusive with DEVICE_ONLINE and DEVICE_BUSY. 196 * 197 * DEVICE_DOWN - Device has been placed in the "DOWN" state by 198 * its controlling driver. 199 * 200 * DEVICE_BUSY - Device has open instances or nexus has INITALIZED 201 * children (nexi). A device in this state is by 202 * definition Online. 203 * 204 * Bus state is returned as a set of bit-flags which indicates the 205 * operational state of a bus associated with the nexus dev_info node. 206 * 207 * BUS_ACTIVE - The bus associated with the device node is Active. 208 * I/O requests from child devices attached to the 209 * are initiated (or queued for initiation) as they 210 * are received. 211 * 212 * BUS_QUIESCED - The bus associated with the device node has been 213 * Quieced. I/O requests from child devices attached 214 * to the bus are held pending until the bus nexus is 215 * Unquiesced. 216 * 217 * BUS_SHUTDOWN - The bus associated with the device node has been 218 * shutdown by the nexus driver. I/O requests from 219 * child devices are returned with an error indicating 220 * the requested operation failed. 221 */ 222 #define DEVICE_ONLINE 0x1 223 #define DEVICE_BUSY 0x2 224 #define DEVICE_OFFLINE 0x4 225 #define DEVICE_DOWN 0x8 226 227 #define BUS_ACTIVE 0x10 228 #define BUS_QUIESCED 0x20 229 #define BUS_SHUTDOWN 0x40 230 231 #define DC_DEVI_NODENAME "ndi_dc.devi_nodename" 232 233 #define DEVCTL_CONSTRUCT 0x1 234 #define DEVCTL_OFFLINE 0x2 235 236 #ifdef __cplusplus 237 } 238 #endif 239 240 #endif /* _SYS_DEVCTL_H */ 241