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 5*7263Scth * Common Development and Distribution License (the "License"). 6*7263Scth * 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*7263Scth * Copyright 2008 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 #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* 320Sstevel@tonic-gate * Device control interfaces 330Sstevel@tonic-gate */ 340Sstevel@tonic-gate #include <sys/types.h> 350Sstevel@tonic-gate #include <sys/nvpair.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef __cplusplus 380Sstevel@tonic-gate extern "C" { 390Sstevel@tonic-gate #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate /* 420Sstevel@tonic-gate * structure used to pass IOCTL data between the libdevice interfaces 430Sstevel@tonic-gate * and nexus driver devctl IOCTL interface. 440Sstevel@tonic-gate * 450Sstevel@tonic-gate * Applications and nexus drivers may not access the contents of this 460Sstevel@tonic-gate * structure directly. Instead, drivers must use the ndi_dc_XXX(9n) 470Sstevel@tonic-gate * interfaces, while applications must use the interfaces provided by 480Sstevel@tonic-gate * libdevice.so.1. 490Sstevel@tonic-gate */ 500Sstevel@tonic-gate struct devctl_iocdata { 510Sstevel@tonic-gate uint_t cmd; /* ioctl cmd */ 520Sstevel@tonic-gate uint_t flags; /* command-specific flags */ 530Sstevel@tonic-gate void *cpyout_buf; /* copyout vector */ 540Sstevel@tonic-gate nvlist_t *nvl_user; /* application defined attributes */ 550Sstevel@tonic-gate size_t nvl_usersz; 560Sstevel@tonic-gate char *c_nodename; /* child device nodename */ 570Sstevel@tonic-gate char *c_unitaddr; /* child device unit address */ 580Sstevel@tonic-gate }; 590Sstevel@tonic-gate 600Sstevel@tonic-gate #if defined(_SYSCALL32) 610Sstevel@tonic-gate /* 620Sstevel@tonic-gate * Structure to pass/return data from 32-bit program's. 630Sstevel@tonic-gate */ 640Sstevel@tonic-gate struct devctl_iocdata32 { 650Sstevel@tonic-gate uint32_t cmd; 660Sstevel@tonic-gate uint32_t flags; 670Sstevel@tonic-gate caddr32_t cpyout_buf; 680Sstevel@tonic-gate caddr32_t nvl_user; 690Sstevel@tonic-gate uint32_t nvl_usersz; 700Sstevel@tonic-gate caddr32_t c_nodename; 710Sstevel@tonic-gate caddr32_t c_unitaddr; 720Sstevel@tonic-gate }; 730Sstevel@tonic-gate #endif 740Sstevel@tonic-gate 750Sstevel@tonic-gate /* 76*7263Scth * Limit size of packed application defined attributes (nvl_user) to prevent 77*7263Scth * user application from requesting excessive kernel memory allocation. 78*7263Scth */ 79*7263Scth #define DEVCTL_MAX_NVL_USERSZ 0x10000 80*7263Scth 81*7263Scth /* 820Sstevel@tonic-gate * State of receptacle for an Attachment Point. 830Sstevel@tonic-gate */ 840Sstevel@tonic-gate typedef enum { 850Sstevel@tonic-gate AP_RSTATE_EMPTY, 860Sstevel@tonic-gate AP_RSTATE_DISCONNECTED, 870Sstevel@tonic-gate AP_RSTATE_CONNECTED 880Sstevel@tonic-gate } ap_rstate_t; 890Sstevel@tonic-gate 900Sstevel@tonic-gate /* 910Sstevel@tonic-gate * State of occupant for an Attachment Point. 920Sstevel@tonic-gate */ 930Sstevel@tonic-gate typedef enum { 940Sstevel@tonic-gate AP_OSTATE_UNCONFIGURED, 950Sstevel@tonic-gate AP_OSTATE_CONFIGURED 960Sstevel@tonic-gate } ap_ostate_t; 970Sstevel@tonic-gate 980Sstevel@tonic-gate /* 990Sstevel@tonic-gate * condition of an Attachment Point. 1000Sstevel@tonic-gate */ 1010Sstevel@tonic-gate typedef enum { 1020Sstevel@tonic-gate AP_COND_UNKNOWN, 1030Sstevel@tonic-gate AP_COND_OK, 1040Sstevel@tonic-gate AP_COND_FAILING, 1050Sstevel@tonic-gate AP_COND_FAILED, 1060Sstevel@tonic-gate AP_COND_UNUSABLE 1070Sstevel@tonic-gate } ap_condition_t; 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate /* 1100Sstevel@tonic-gate * structure used to return the state of Attachment Point (AP) thru 1110Sstevel@tonic-gate * devctl_ap_getstate() interface. 1120Sstevel@tonic-gate */ 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate typedef struct devctl_ap_state { 1150Sstevel@tonic-gate ap_rstate_t ap_rstate; /* receptacle state */ 1160Sstevel@tonic-gate ap_ostate_t ap_ostate; /* occupant state */ 1170Sstevel@tonic-gate ap_condition_t ap_condition; /* condition of AP */ 1180Sstevel@tonic-gate time_t ap_last_change; 1190Sstevel@tonic-gate uint32_t ap_error_code; /* error code */ 1200Sstevel@tonic-gate uint8_t ap_in_transition; 1210Sstevel@tonic-gate } devctl_ap_state_t; 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate #if defined(_SYSCALL32) 1240Sstevel@tonic-gate /* 1250Sstevel@tonic-gate * Structure to pass/return data from 32-bit program's. 1260Sstevel@tonic-gate */ 1270Sstevel@tonic-gate typedef struct devctl_ap_state32 { 1280Sstevel@tonic-gate ap_rstate_t ap_rstate; /* receptacle state */ 1290Sstevel@tonic-gate ap_ostate_t ap_ostate; /* occupant state */ 1300Sstevel@tonic-gate ap_condition_t ap_condition; /* condition of AP */ 1310Sstevel@tonic-gate time32_t ap_last_change; 1320Sstevel@tonic-gate uint32_t ap_error_code; /* error code */ 1330Sstevel@tonic-gate uint8_t ap_in_transition; 1340Sstevel@tonic-gate } devctl_ap_state32_t; 1350Sstevel@tonic-gate #endif 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate #define DEVCTL_IOC (0xDC << 16) 1380Sstevel@tonic-gate #define DEVCTL_IOC_MAX (DEVCTL_IOC | 0xFFFF) 1390Sstevel@tonic-gate #define DEVCTL_BUS_QUIESCE (DEVCTL_IOC | 1) 1400Sstevel@tonic-gate #define DEVCTL_BUS_UNQUIESCE (DEVCTL_IOC | 2) 1410Sstevel@tonic-gate #define DEVCTL_BUS_RESETALL (DEVCTL_IOC | 3) 1420Sstevel@tonic-gate #define DEVCTL_BUS_RESET (DEVCTL_IOC | 4) 1430Sstevel@tonic-gate #define DEVCTL_BUS_GETSTATE (DEVCTL_IOC | 5) 1440Sstevel@tonic-gate #define DEVCTL_DEVICE_ONLINE (DEVCTL_IOC | 6) 1450Sstevel@tonic-gate #define DEVCTL_DEVICE_OFFLINE (DEVCTL_IOC | 7) 1460Sstevel@tonic-gate #define DEVCTL_DEVICE_GETSTATE (DEVCTL_IOC | 9) 1470Sstevel@tonic-gate #define DEVCTL_DEVICE_RESET (DEVCTL_IOC | 10) 1480Sstevel@tonic-gate #define DEVCTL_BUS_CONFIGURE (DEVCTL_IOC | 11) 1490Sstevel@tonic-gate #define DEVCTL_BUS_UNCONFIGURE (DEVCTL_IOC | 12) 1500Sstevel@tonic-gate #define DEVCTL_DEVICE_REMOVE (DEVCTL_IOC | 13) 1510Sstevel@tonic-gate #define DEVCTL_AP_CONNECT (DEVCTL_IOC | 14) 1520Sstevel@tonic-gate #define DEVCTL_AP_DISCONNECT (DEVCTL_IOC | 15) 1530Sstevel@tonic-gate #define DEVCTL_AP_INSERT (DEVCTL_IOC | 16) 1540Sstevel@tonic-gate #define DEVCTL_AP_REMOVE (DEVCTL_IOC | 17) 1550Sstevel@tonic-gate #define DEVCTL_AP_CONFIGURE (DEVCTL_IOC | 18) 1560Sstevel@tonic-gate #define DEVCTL_AP_UNCONFIGURE (DEVCTL_IOC | 19) 1570Sstevel@tonic-gate #define DEVCTL_AP_GETSTATE (DEVCTL_IOC | 20) 1580Sstevel@tonic-gate #define DEVCTL_AP_CONTROL (DEVCTL_IOC | 21) 1590Sstevel@tonic-gate #define DEVCTL_BUS_DEV_CREATE (DEVCTL_IOC | 22) 1600Sstevel@tonic-gate #define DEVCTL_PM_BUSY_COMP (DEVCTL_IOC | 23) 1610Sstevel@tonic-gate #define DEVCTL_PM_IDLE_COMP (DEVCTL_IOC | 24) 1620Sstevel@tonic-gate #define DEVCTL_PM_RAISE_PWR (DEVCTL_IOC | 25) 1630Sstevel@tonic-gate #define DEVCTL_PM_LOWER_PWR (DEVCTL_IOC | 26) 1640Sstevel@tonic-gate #define DEVCTL_PM_CHANGE_PWR_LOW (DEVCTL_IOC | 27) 1650Sstevel@tonic-gate #define DEVCTL_PM_CHANGE_PWR_HIGH (DEVCTL_IOC | 28) 1660Sstevel@tonic-gate #define DEVCTL_PM_POWER (DEVCTL_IOC | 29) 1670Sstevel@tonic-gate #define DEVCTL_PM_PROM_PRINTF (DEVCTL_IOC | 30) 1680Sstevel@tonic-gate #define DEVCTL_PM_FAIL_SUSPEND (DEVCTL_IOC | 31) 1690Sstevel@tonic-gate #define DEVCTL_PM_PWR_HAS_CHANGED_ON_RESUME (DEVCTL_IOC | 32) 1700Sstevel@tonic-gate #define DEVCTL_PM_PUP_WITH_PWR_HAS_CHANGED (DEVCTL_IOC | 34) 1710Sstevel@tonic-gate #define DEVCTL_PM_BUSY_COMP_TEST (DEVCTL_IOC | 35) 1720Sstevel@tonic-gate #define DEVCTL_PM_BUS_STRICT_TEST (DEVCTL_IOC | 36) 1730Sstevel@tonic-gate #define DEVCTL_PM_NO_LOWER_POWER (DEVCTL_IOC | 37) 1740Sstevel@tonic-gate #define DEVCTL_PM_BUS_NO_INVOL (DEVCTL_IOC | 38) 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate /* 1770Sstevel@tonic-gate * is (c) in the range of possible devctl IOCTL commands? 1780Sstevel@tonic-gate */ 1790Sstevel@tonic-gate #define IS_DEVCTL(c) (((c) >= DEVCTL_IOC) && ((c) <= DEVCTL_IOC_MAX)) 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate /* 1820Sstevel@tonic-gate * Device and Bus State definitions 1830Sstevel@tonic-gate * 1840Sstevel@tonic-gate * Device state is returned as a set of bit-flags that indicate the current 1850Sstevel@tonic-gate * operational state of a device node. 1860Sstevel@tonic-gate * 1870Sstevel@tonic-gate * Device nodes for leaf devices only contain state information for the 1880Sstevel@tonic-gate * device itself. Nexus device nodes contain both Bus and Device state 1890Sstevel@tonic-gate * information. 1900Sstevel@tonic-gate * 1910Sstevel@tonic-gate * DEVICE_ONLINE - Device is available for use by the system. Mutually 1920Sstevel@tonic-gate * exclusive with DEVICE_OFFLINE. 1930Sstevel@tonic-gate * 1940Sstevel@tonic-gate * DEVICE_OFFLINE - Device is unavailable for use by the system. 1950Sstevel@tonic-gate * Mutually exclusive with DEVICE_ONLINE and DEVICE_BUSY. 1960Sstevel@tonic-gate * 1970Sstevel@tonic-gate * DEVICE_DOWN - Device has been placed in the "DOWN" state by 1980Sstevel@tonic-gate * its controlling driver. 1990Sstevel@tonic-gate * 2000Sstevel@tonic-gate * DEVICE_BUSY - Device has open instances or nexus has INITALIZED 2010Sstevel@tonic-gate * children (nexi). A device in this state is by 2020Sstevel@tonic-gate * definition Online. 2030Sstevel@tonic-gate * 2040Sstevel@tonic-gate * Bus state is returned as a set of bit-flags which indicates the 2050Sstevel@tonic-gate * operational state of a bus associated with the nexus dev_info node. 2060Sstevel@tonic-gate * 2070Sstevel@tonic-gate * BUS_ACTIVE - The bus associated with the device node is Active. 2080Sstevel@tonic-gate * I/O requests from child devices attached to the 2090Sstevel@tonic-gate * are initiated (or queued for initiation) as they 2100Sstevel@tonic-gate * are received. 2110Sstevel@tonic-gate * 2120Sstevel@tonic-gate * BUS_QUIESCED - The bus associated with the device node has been 2130Sstevel@tonic-gate * Quieced. I/O requests from child devices attached 2140Sstevel@tonic-gate * to the bus are held pending until the bus nexus is 2150Sstevel@tonic-gate * Unquiesced. 2160Sstevel@tonic-gate * 2170Sstevel@tonic-gate * BUS_SHUTDOWN - The bus associated with the device node has been 2180Sstevel@tonic-gate * shutdown by the nexus driver. I/O requests from 2190Sstevel@tonic-gate * child devices are returned with an error indicating 2200Sstevel@tonic-gate * the requested operation failed. 2210Sstevel@tonic-gate */ 2220Sstevel@tonic-gate #define DEVICE_ONLINE 0x1 2230Sstevel@tonic-gate #define DEVICE_BUSY 0x2 2240Sstevel@tonic-gate #define DEVICE_OFFLINE 0x4 2250Sstevel@tonic-gate #define DEVICE_DOWN 0x8 2260Sstevel@tonic-gate 2270Sstevel@tonic-gate #define BUS_ACTIVE 0x10 2280Sstevel@tonic-gate #define BUS_QUIESCED 0x20 2290Sstevel@tonic-gate #define BUS_SHUTDOWN 0x40 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate #define DC_DEVI_NODENAME "ndi_dc.devi_nodename" 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate #define DEVCTL_CONSTRUCT 0x1 2340Sstevel@tonic-gate #define DEVCTL_OFFLINE 0x2 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate #ifdef __cplusplus 2370Sstevel@tonic-gate } 2380Sstevel@tonic-gate #endif 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate #endif /* _SYS_DEVCTL_H */ 241