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