10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57263Scth * Common Development and Distribution License (the "License"). 67263Scth * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*10696SDavid.Hollister@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_DEVCTL_H 270Sstevel@tonic-gate #define _SYS_DEVCTL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * Device control interfaces 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate #include <sys/nvpair.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate #ifdef __cplusplus 360Sstevel@tonic-gate extern "C" { 370Sstevel@tonic-gate #endif 380Sstevel@tonic-gate 390Sstevel@tonic-gate /* 400Sstevel@tonic-gate * structure used to pass IOCTL data between the libdevice interfaces 410Sstevel@tonic-gate * and nexus driver devctl IOCTL interface. 420Sstevel@tonic-gate * 430Sstevel@tonic-gate * Applications and nexus drivers may not access the contents of this 44*10696SDavid.Hollister@Sun.COM * structure directly. Instead, drivers must use the ndi_dc_*(9n) 450Sstevel@tonic-gate * interfaces, while applications must use the interfaces provided by 460Sstevel@tonic-gate * libdevice.so.1. 470Sstevel@tonic-gate */ 480Sstevel@tonic-gate struct devctl_iocdata { 490Sstevel@tonic-gate uint_t cmd; /* ioctl cmd */ 500Sstevel@tonic-gate uint_t flags; /* command-specific flags */ 510Sstevel@tonic-gate void *cpyout_buf; /* copyout vector */ 520Sstevel@tonic-gate nvlist_t *nvl_user; /* application defined attributes */ 530Sstevel@tonic-gate size_t nvl_usersz; 540Sstevel@tonic-gate char *c_nodename; /* child device nodename */ 550Sstevel@tonic-gate char *c_unitaddr; /* child device unit address */ 560Sstevel@tonic-gate }; 570Sstevel@tonic-gate 580Sstevel@tonic-gate #if defined(_SYSCALL32) 590Sstevel@tonic-gate /* 600Sstevel@tonic-gate * Structure to pass/return data from 32-bit program's. 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate struct devctl_iocdata32 { 630Sstevel@tonic-gate uint32_t cmd; 640Sstevel@tonic-gate uint32_t flags; 650Sstevel@tonic-gate caddr32_t cpyout_buf; 660Sstevel@tonic-gate caddr32_t nvl_user; 670Sstevel@tonic-gate uint32_t nvl_usersz; 680Sstevel@tonic-gate caddr32_t c_nodename; 690Sstevel@tonic-gate caddr32_t c_unitaddr; 700Sstevel@tonic-gate }; 710Sstevel@tonic-gate #endif 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* 747263Scth * Limit size of packed application defined attributes (nvl_user) to prevent 757263Scth * user application from requesting excessive kernel memory allocation. 767263Scth */ 777263Scth #define DEVCTL_MAX_NVL_USERSZ 0x10000 787263Scth 797263Scth /* 800Sstevel@tonic-gate * State of receptacle for an Attachment Point. 810Sstevel@tonic-gate */ 820Sstevel@tonic-gate typedef enum { 830Sstevel@tonic-gate AP_RSTATE_EMPTY, 840Sstevel@tonic-gate AP_RSTATE_DISCONNECTED, 850Sstevel@tonic-gate AP_RSTATE_CONNECTED 860Sstevel@tonic-gate } ap_rstate_t; 870Sstevel@tonic-gate 880Sstevel@tonic-gate /* 890Sstevel@tonic-gate * State of occupant for an Attachment Point. 900Sstevel@tonic-gate */ 910Sstevel@tonic-gate typedef enum { 920Sstevel@tonic-gate AP_OSTATE_UNCONFIGURED, 930Sstevel@tonic-gate AP_OSTATE_CONFIGURED 940Sstevel@tonic-gate } ap_ostate_t; 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate * condition of an Attachment Point. 980Sstevel@tonic-gate */ 990Sstevel@tonic-gate typedef enum { 1000Sstevel@tonic-gate AP_COND_UNKNOWN, 1010Sstevel@tonic-gate AP_COND_OK, 1020Sstevel@tonic-gate AP_COND_FAILING, 1030Sstevel@tonic-gate AP_COND_FAILED, 1040Sstevel@tonic-gate AP_COND_UNUSABLE 1050Sstevel@tonic-gate } ap_condition_t; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate /* 1080Sstevel@tonic-gate * structure used to return the state of Attachment Point (AP) thru 1090Sstevel@tonic-gate * devctl_ap_getstate() interface. 1100Sstevel@tonic-gate */ 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate typedef struct devctl_ap_state { 1130Sstevel@tonic-gate ap_rstate_t ap_rstate; /* receptacle state */ 1140Sstevel@tonic-gate ap_ostate_t ap_ostate; /* occupant state */ 1150Sstevel@tonic-gate ap_condition_t ap_condition; /* condition of AP */ 1160Sstevel@tonic-gate time_t ap_last_change; 1170Sstevel@tonic-gate uint32_t ap_error_code; /* error code */ 1180Sstevel@tonic-gate uint8_t ap_in_transition; 1190Sstevel@tonic-gate } devctl_ap_state_t; 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate #if defined(_SYSCALL32) 1220Sstevel@tonic-gate /* 1230Sstevel@tonic-gate * Structure to pass/return data from 32-bit program's. 1240Sstevel@tonic-gate */ 1250Sstevel@tonic-gate typedef struct devctl_ap_state32 { 1260Sstevel@tonic-gate ap_rstate_t ap_rstate; /* receptacle state */ 1270Sstevel@tonic-gate ap_ostate_t ap_ostate; /* occupant state */ 1280Sstevel@tonic-gate ap_condition_t ap_condition; /* condition of AP */ 1290Sstevel@tonic-gate time32_t ap_last_change; 1300Sstevel@tonic-gate uint32_t ap_error_code; /* error code */ 1310Sstevel@tonic-gate uint8_t ap_in_transition; 1320Sstevel@tonic-gate } devctl_ap_state32_t; 1330Sstevel@tonic-gate #endif 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate #define DEVCTL_IOC (0xDC << 16) 1360Sstevel@tonic-gate #define DEVCTL_IOC_MAX (DEVCTL_IOC | 0xFFFF) 1370Sstevel@tonic-gate #define DEVCTL_BUS_QUIESCE (DEVCTL_IOC | 1) 1380Sstevel@tonic-gate #define DEVCTL_BUS_UNQUIESCE (DEVCTL_IOC | 2) 1390Sstevel@tonic-gate #define DEVCTL_BUS_RESETALL (DEVCTL_IOC | 3) 1400Sstevel@tonic-gate #define DEVCTL_BUS_RESET (DEVCTL_IOC | 4) 1410Sstevel@tonic-gate #define DEVCTL_BUS_GETSTATE (DEVCTL_IOC | 5) 1420Sstevel@tonic-gate #define DEVCTL_DEVICE_ONLINE (DEVCTL_IOC | 6) 1430Sstevel@tonic-gate #define DEVCTL_DEVICE_OFFLINE (DEVCTL_IOC | 7) 1440Sstevel@tonic-gate #define DEVCTL_DEVICE_GETSTATE (DEVCTL_IOC | 9) 1450Sstevel@tonic-gate #define DEVCTL_DEVICE_RESET (DEVCTL_IOC | 10) 1460Sstevel@tonic-gate #define DEVCTL_BUS_CONFIGURE (DEVCTL_IOC | 11) 1470Sstevel@tonic-gate #define DEVCTL_BUS_UNCONFIGURE (DEVCTL_IOC | 12) 1480Sstevel@tonic-gate #define DEVCTL_DEVICE_REMOVE (DEVCTL_IOC | 13) 1490Sstevel@tonic-gate #define DEVCTL_AP_CONNECT (DEVCTL_IOC | 14) 1500Sstevel@tonic-gate #define DEVCTL_AP_DISCONNECT (DEVCTL_IOC | 15) 1510Sstevel@tonic-gate #define DEVCTL_AP_INSERT (DEVCTL_IOC | 16) 1520Sstevel@tonic-gate #define DEVCTL_AP_REMOVE (DEVCTL_IOC | 17) 1530Sstevel@tonic-gate #define DEVCTL_AP_CONFIGURE (DEVCTL_IOC | 18) 1540Sstevel@tonic-gate #define DEVCTL_AP_UNCONFIGURE (DEVCTL_IOC | 19) 1550Sstevel@tonic-gate #define DEVCTL_AP_GETSTATE (DEVCTL_IOC | 20) 1560Sstevel@tonic-gate #define DEVCTL_AP_CONTROL (DEVCTL_IOC | 21) 1570Sstevel@tonic-gate #define DEVCTL_BUS_DEV_CREATE (DEVCTL_IOC | 22) 1580Sstevel@tonic-gate #define DEVCTL_PM_BUSY_COMP (DEVCTL_IOC | 23) 1590Sstevel@tonic-gate #define DEVCTL_PM_IDLE_COMP (DEVCTL_IOC | 24) 1600Sstevel@tonic-gate #define DEVCTL_PM_RAISE_PWR (DEVCTL_IOC | 25) 1610Sstevel@tonic-gate #define DEVCTL_PM_LOWER_PWR (DEVCTL_IOC | 26) 1620Sstevel@tonic-gate #define DEVCTL_PM_CHANGE_PWR_LOW (DEVCTL_IOC | 27) 1630Sstevel@tonic-gate #define DEVCTL_PM_CHANGE_PWR_HIGH (DEVCTL_IOC | 28) 1640Sstevel@tonic-gate #define DEVCTL_PM_POWER (DEVCTL_IOC | 29) 1650Sstevel@tonic-gate #define DEVCTL_PM_PROM_PRINTF (DEVCTL_IOC | 30) 1660Sstevel@tonic-gate #define DEVCTL_PM_FAIL_SUSPEND (DEVCTL_IOC | 31) 1670Sstevel@tonic-gate #define DEVCTL_PM_PWR_HAS_CHANGED_ON_RESUME (DEVCTL_IOC | 32) 1680Sstevel@tonic-gate #define DEVCTL_PM_PUP_WITH_PWR_HAS_CHANGED (DEVCTL_IOC | 34) 1690Sstevel@tonic-gate #define DEVCTL_PM_BUSY_COMP_TEST (DEVCTL_IOC | 35) 1700Sstevel@tonic-gate #define DEVCTL_PM_BUS_STRICT_TEST (DEVCTL_IOC | 36) 1710Sstevel@tonic-gate #define DEVCTL_PM_NO_LOWER_POWER (DEVCTL_IOC | 37) 1720Sstevel@tonic-gate #define DEVCTL_PM_BUS_NO_INVOL (DEVCTL_IOC | 38) 1737523SAlan.Perry@Sun.COM #define DEVCTL_SET_LED (DEVCTL_IOC | 39) 1747523SAlan.Perry@Sun.COM #define DEVCTL_GET_LED (DEVCTL_IOC | 40) 1757523SAlan.Perry@Sun.COM #define DEVCTL_NUM_LEDS (DEVCTL_IOC | 41) 1767523SAlan.Perry@Sun.COM 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate /* 1790Sstevel@tonic-gate * is (c) in the range of possible devctl IOCTL commands? 1800Sstevel@tonic-gate */ 1810Sstevel@tonic-gate #define IS_DEVCTL(c) (((c) >= DEVCTL_IOC) && ((c) <= DEVCTL_IOC_MAX)) 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* 1840Sstevel@tonic-gate * Device and Bus State definitions 1850Sstevel@tonic-gate * 1860Sstevel@tonic-gate * Device state is returned as a set of bit-flags that indicate the current 1870Sstevel@tonic-gate * operational state of a device node. 1880Sstevel@tonic-gate * 1890Sstevel@tonic-gate * Device nodes for leaf devices only contain state information for the 1900Sstevel@tonic-gate * device itself. Nexus device nodes contain both Bus and Device state 1910Sstevel@tonic-gate * information. 1920Sstevel@tonic-gate * 1930Sstevel@tonic-gate * DEVICE_ONLINE - Device is available for use by the system. Mutually 1940Sstevel@tonic-gate * exclusive with DEVICE_OFFLINE. 1950Sstevel@tonic-gate * 1960Sstevel@tonic-gate * DEVICE_OFFLINE - Device is unavailable for use by the system. 1970Sstevel@tonic-gate * Mutually exclusive with DEVICE_ONLINE and DEVICE_BUSY. 1980Sstevel@tonic-gate * 1990Sstevel@tonic-gate * DEVICE_DOWN - Device has been placed in the "DOWN" state by 2000Sstevel@tonic-gate * its controlling driver. 2010Sstevel@tonic-gate * 2020Sstevel@tonic-gate * DEVICE_BUSY - Device has open instances or nexus has INITALIZED 2030Sstevel@tonic-gate * children (nexi). A device in this state is by 2040Sstevel@tonic-gate * definition Online. 2050Sstevel@tonic-gate * 2060Sstevel@tonic-gate * Bus state is returned as a set of bit-flags which indicates the 2070Sstevel@tonic-gate * operational state of a bus associated with the nexus dev_info node. 2080Sstevel@tonic-gate * 2090Sstevel@tonic-gate * BUS_ACTIVE - The bus associated with the device node is Active. 2100Sstevel@tonic-gate * I/O requests from child devices attached to the 2110Sstevel@tonic-gate * are initiated (or queued for initiation) as they 2120Sstevel@tonic-gate * are received. 2130Sstevel@tonic-gate * 2140Sstevel@tonic-gate * BUS_QUIESCED - The bus associated with the device node has been 2150Sstevel@tonic-gate * Quieced. I/O requests from child devices attached 2160Sstevel@tonic-gate * to the bus are held pending until the bus nexus is 2170Sstevel@tonic-gate * Unquiesced. 2180Sstevel@tonic-gate * 2190Sstevel@tonic-gate * BUS_SHUTDOWN - The bus associated with the device node has been 2200Sstevel@tonic-gate * shutdown by the nexus driver. I/O requests from 2210Sstevel@tonic-gate * child devices are returned with an error indicating 2220Sstevel@tonic-gate * the requested operation failed. 2230Sstevel@tonic-gate */ 2240Sstevel@tonic-gate #define DEVICE_ONLINE 0x1 2250Sstevel@tonic-gate #define DEVICE_BUSY 0x2 2260Sstevel@tonic-gate #define DEVICE_OFFLINE 0x4 2270Sstevel@tonic-gate #define DEVICE_DOWN 0x8 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate #define BUS_ACTIVE 0x10 2300Sstevel@tonic-gate #define BUS_QUIESCED 0x20 2310Sstevel@tonic-gate #define BUS_SHUTDOWN 0x40 2320Sstevel@tonic-gate 233*10696SDavid.Hollister@Sun.COM #define DEVICE_STATES_ASCII "Dev_Online", "Dev_Busy", "Dev_Offline", \ 234*10696SDavid.Hollister@Sun.COM "Dev_Down", "Bus_Active", "Bus_Quiesced", "Bus_Shutdown" 235*10696SDavid.Hollister@Sun.COM 2360Sstevel@tonic-gate #define DC_DEVI_NODENAME "ndi_dc.devi_nodename" 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate #define DEVCTL_CONSTRUCT 0x1 2390Sstevel@tonic-gate #define DEVCTL_OFFLINE 0x2 2400Sstevel@tonic-gate 2417523SAlan.Perry@Sun.COM /* 2427523SAlan.Perry@Sun.COM * Drive status LED control 2437523SAlan.Perry@Sun.COM */ 2447523SAlan.Perry@Sun.COM struct dc_led_ctl { 2457523SAlan.Perry@Sun.COM uint32_t led_number : 16; /* LED/device number */ 2467523SAlan.Perry@Sun.COM uint32_t led_ctl_active : 1; /* Control active */ 2477523SAlan.Perry@Sun.COM uint32_t led_type : 9; /* LED type */ 2487523SAlan.Perry@Sun.COM uint32_t led_state : 6; /* LED ON/OFF/Blink state */ 2497523SAlan.Perry@Sun.COM }; 2507523SAlan.Perry@Sun.COM 2517523SAlan.Perry@Sun.COM /* Control active field */ 2527523SAlan.Perry@Sun.COM #define DCL_CNTRL_OFF 0 /* Control inactive */ 2537523SAlan.Perry@Sun.COM #define DCL_CNTRL_ON 1 /* Control active */ 2547523SAlan.Perry@Sun.COM 2557523SAlan.Perry@Sun.COM /* LED type field */ 2567523SAlan.Perry@Sun.COM #define DCL_TYPE_DEVICE_FAIL 1 /* Device FAIL LED type */ 2577523SAlan.Perry@Sun.COM #define DCL_TYPE_DEVICE_OK2RM 2 /* Device OK2RM LED type */ 2587523SAlan.Perry@Sun.COM 2597523SAlan.Perry@Sun.COM /* LED state field */ 2607523SAlan.Perry@Sun.COM #define DCL_STATE_OFF 0 /* LED state OFF */ 2617523SAlan.Perry@Sun.COM #define DCL_STATE_ON 1 /* LED state ON */ 2627523SAlan.Perry@Sun.COM #define DCL_STATE_SLOW_BLNK 2 /* LED slow blink */ 2637523SAlan.Perry@Sun.COM #define DCL_STATE_FAST_BLNK 3 /* LED fast blink */ 2647523SAlan.Perry@Sun.COM 2650Sstevel@tonic-gate #ifdef __cplusplus 2660Sstevel@tonic-gate } 2670Sstevel@tonic-gate #endif 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate #endif /* _SYS_DEVCTL_H */ 270