17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55e3f6b1fScth * Common Development and Distribution License (the "License"). 65e3f6b1fScth * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*4c06356bSdh142964 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_DEVCTL_H 277c478bd9Sstevel@tonic-gate #define _SYS_DEVCTL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * Device control interfaces 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate #include <sys/nvpair.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* 407c478bd9Sstevel@tonic-gate * structure used to pass IOCTL data between the libdevice interfaces 417c478bd9Sstevel@tonic-gate * and nexus driver devctl IOCTL interface. 427c478bd9Sstevel@tonic-gate * 437c478bd9Sstevel@tonic-gate * Applications and nexus drivers may not access the contents of this 44*4c06356bSdh142964 * structure directly. Instead, drivers must use the ndi_dc_*(9n) 457c478bd9Sstevel@tonic-gate * interfaces, while applications must use the interfaces provided by 467c478bd9Sstevel@tonic-gate * libdevice.so.1. 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate struct devctl_iocdata { 497c478bd9Sstevel@tonic-gate uint_t cmd; /* ioctl cmd */ 507c478bd9Sstevel@tonic-gate uint_t flags; /* command-specific flags */ 517c478bd9Sstevel@tonic-gate void *cpyout_buf; /* copyout vector */ 527c478bd9Sstevel@tonic-gate nvlist_t *nvl_user; /* application defined attributes */ 537c478bd9Sstevel@tonic-gate size_t nvl_usersz; 547c478bd9Sstevel@tonic-gate char *c_nodename; /* child device nodename */ 557c478bd9Sstevel@tonic-gate char *c_unitaddr; /* child device unit address */ 567c478bd9Sstevel@tonic-gate }; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 597c478bd9Sstevel@tonic-gate /* 607c478bd9Sstevel@tonic-gate * Structure to pass/return data from 32-bit program's. 617c478bd9Sstevel@tonic-gate */ 627c478bd9Sstevel@tonic-gate struct devctl_iocdata32 { 637c478bd9Sstevel@tonic-gate uint32_t cmd; 647c478bd9Sstevel@tonic-gate uint32_t flags; 657c478bd9Sstevel@tonic-gate caddr32_t cpyout_buf; 667c478bd9Sstevel@tonic-gate caddr32_t nvl_user; 677c478bd9Sstevel@tonic-gate uint32_t nvl_usersz; 687c478bd9Sstevel@tonic-gate caddr32_t c_nodename; 697c478bd9Sstevel@tonic-gate caddr32_t c_unitaddr; 707c478bd9Sstevel@tonic-gate }; 717c478bd9Sstevel@tonic-gate #endif 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate /* 745e3f6b1fScth * Limit size of packed application defined attributes (nvl_user) to prevent 755e3f6b1fScth * user application from requesting excessive kernel memory allocation. 765e3f6b1fScth */ 775e3f6b1fScth #define DEVCTL_MAX_NVL_USERSZ 0x10000 785e3f6b1fScth 795e3f6b1fScth /* 807c478bd9Sstevel@tonic-gate * State of receptacle for an Attachment Point. 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate typedef enum { 837c478bd9Sstevel@tonic-gate AP_RSTATE_EMPTY, 847c478bd9Sstevel@tonic-gate AP_RSTATE_DISCONNECTED, 857c478bd9Sstevel@tonic-gate AP_RSTATE_CONNECTED 867c478bd9Sstevel@tonic-gate } ap_rstate_t; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * State of occupant for an Attachment Point. 907c478bd9Sstevel@tonic-gate */ 917c478bd9Sstevel@tonic-gate typedef enum { 927c478bd9Sstevel@tonic-gate AP_OSTATE_UNCONFIGURED, 937c478bd9Sstevel@tonic-gate AP_OSTATE_CONFIGURED 947c478bd9Sstevel@tonic-gate } ap_ostate_t; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * condition of an Attachment Point. 987c478bd9Sstevel@tonic-gate */ 997c478bd9Sstevel@tonic-gate typedef enum { 1007c478bd9Sstevel@tonic-gate AP_COND_UNKNOWN, 1017c478bd9Sstevel@tonic-gate AP_COND_OK, 1027c478bd9Sstevel@tonic-gate AP_COND_FAILING, 1037c478bd9Sstevel@tonic-gate AP_COND_FAILED, 1047c478bd9Sstevel@tonic-gate AP_COND_UNUSABLE 1057c478bd9Sstevel@tonic-gate } ap_condition_t; 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* 1087c478bd9Sstevel@tonic-gate * structure used to return the state of Attachment Point (AP) thru 1097c478bd9Sstevel@tonic-gate * devctl_ap_getstate() interface. 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate typedef struct devctl_ap_state { 1137c478bd9Sstevel@tonic-gate ap_rstate_t ap_rstate; /* receptacle state */ 1147c478bd9Sstevel@tonic-gate ap_ostate_t ap_ostate; /* occupant state */ 1157c478bd9Sstevel@tonic-gate ap_condition_t ap_condition; /* condition of AP */ 1167c478bd9Sstevel@tonic-gate time_t ap_last_change; 1177c478bd9Sstevel@tonic-gate uint32_t ap_error_code; /* error code */ 1187c478bd9Sstevel@tonic-gate uint8_t ap_in_transition; 1197c478bd9Sstevel@tonic-gate } devctl_ap_state_t; 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 1227c478bd9Sstevel@tonic-gate /* 1237c478bd9Sstevel@tonic-gate * Structure to pass/return data from 32-bit program's. 1247c478bd9Sstevel@tonic-gate */ 1257c478bd9Sstevel@tonic-gate typedef struct devctl_ap_state32 { 1267c478bd9Sstevel@tonic-gate ap_rstate_t ap_rstate; /* receptacle state */ 1277c478bd9Sstevel@tonic-gate ap_ostate_t ap_ostate; /* occupant state */ 1287c478bd9Sstevel@tonic-gate ap_condition_t ap_condition; /* condition of AP */ 1297c478bd9Sstevel@tonic-gate time32_t ap_last_change; 1307c478bd9Sstevel@tonic-gate uint32_t ap_error_code; /* error code */ 1317c478bd9Sstevel@tonic-gate uint8_t ap_in_transition; 1327c478bd9Sstevel@tonic-gate } devctl_ap_state32_t; 1337c478bd9Sstevel@tonic-gate #endif 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate #define DEVCTL_IOC (0xDC << 16) 1367c478bd9Sstevel@tonic-gate #define DEVCTL_IOC_MAX (DEVCTL_IOC | 0xFFFF) 1377c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_QUIESCE (DEVCTL_IOC | 1) 1387c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_UNQUIESCE (DEVCTL_IOC | 2) 1397c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_RESETALL (DEVCTL_IOC | 3) 1407c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_RESET (DEVCTL_IOC | 4) 1417c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_GETSTATE (DEVCTL_IOC | 5) 1427c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_ONLINE (DEVCTL_IOC | 6) 1437c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_OFFLINE (DEVCTL_IOC | 7) 1447c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_GETSTATE (DEVCTL_IOC | 9) 1457c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_RESET (DEVCTL_IOC | 10) 1467c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_CONFIGURE (DEVCTL_IOC | 11) 1477c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_UNCONFIGURE (DEVCTL_IOC | 12) 1487c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_REMOVE (DEVCTL_IOC | 13) 1497c478bd9Sstevel@tonic-gate #define DEVCTL_AP_CONNECT (DEVCTL_IOC | 14) 1507c478bd9Sstevel@tonic-gate #define DEVCTL_AP_DISCONNECT (DEVCTL_IOC | 15) 1517c478bd9Sstevel@tonic-gate #define DEVCTL_AP_INSERT (DEVCTL_IOC | 16) 1527c478bd9Sstevel@tonic-gate #define DEVCTL_AP_REMOVE (DEVCTL_IOC | 17) 1537c478bd9Sstevel@tonic-gate #define DEVCTL_AP_CONFIGURE (DEVCTL_IOC | 18) 1547c478bd9Sstevel@tonic-gate #define DEVCTL_AP_UNCONFIGURE (DEVCTL_IOC | 19) 1557c478bd9Sstevel@tonic-gate #define DEVCTL_AP_GETSTATE (DEVCTL_IOC | 20) 1567c478bd9Sstevel@tonic-gate #define DEVCTL_AP_CONTROL (DEVCTL_IOC | 21) 1577c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_DEV_CREATE (DEVCTL_IOC | 22) 1587c478bd9Sstevel@tonic-gate #define DEVCTL_PM_BUSY_COMP (DEVCTL_IOC | 23) 1597c478bd9Sstevel@tonic-gate #define DEVCTL_PM_IDLE_COMP (DEVCTL_IOC | 24) 1607c478bd9Sstevel@tonic-gate #define DEVCTL_PM_RAISE_PWR (DEVCTL_IOC | 25) 1617c478bd9Sstevel@tonic-gate #define DEVCTL_PM_LOWER_PWR (DEVCTL_IOC | 26) 1627c478bd9Sstevel@tonic-gate #define DEVCTL_PM_CHANGE_PWR_LOW (DEVCTL_IOC | 27) 1637c478bd9Sstevel@tonic-gate #define DEVCTL_PM_CHANGE_PWR_HIGH (DEVCTL_IOC | 28) 1647c478bd9Sstevel@tonic-gate #define DEVCTL_PM_POWER (DEVCTL_IOC | 29) 1657c478bd9Sstevel@tonic-gate #define DEVCTL_PM_PROM_PRINTF (DEVCTL_IOC | 30) 1667c478bd9Sstevel@tonic-gate #define DEVCTL_PM_FAIL_SUSPEND (DEVCTL_IOC | 31) 1677c478bd9Sstevel@tonic-gate #define DEVCTL_PM_PWR_HAS_CHANGED_ON_RESUME (DEVCTL_IOC | 32) 1687c478bd9Sstevel@tonic-gate #define DEVCTL_PM_PUP_WITH_PWR_HAS_CHANGED (DEVCTL_IOC | 34) 1697c478bd9Sstevel@tonic-gate #define DEVCTL_PM_BUSY_COMP_TEST (DEVCTL_IOC | 35) 1707c478bd9Sstevel@tonic-gate #define DEVCTL_PM_BUS_STRICT_TEST (DEVCTL_IOC | 36) 1717c478bd9Sstevel@tonic-gate #define DEVCTL_PM_NO_LOWER_POWER (DEVCTL_IOC | 37) 1727c478bd9Sstevel@tonic-gate #define DEVCTL_PM_BUS_NO_INVOL (DEVCTL_IOC | 38) 1733f318a28SAlan Perry #define DEVCTL_SET_LED (DEVCTL_IOC | 39) 1743f318a28SAlan Perry #define DEVCTL_GET_LED (DEVCTL_IOC | 40) 1753f318a28SAlan Perry #define DEVCTL_NUM_LEDS (DEVCTL_IOC | 41) 1763f318a28SAlan Perry 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* 1797c478bd9Sstevel@tonic-gate * is (c) in the range of possible devctl IOCTL commands? 1807c478bd9Sstevel@tonic-gate */ 1817c478bd9Sstevel@tonic-gate #define IS_DEVCTL(c) (((c) >= DEVCTL_IOC) && ((c) <= DEVCTL_IOC_MAX)) 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate /* 1847c478bd9Sstevel@tonic-gate * Device and Bus State definitions 1857c478bd9Sstevel@tonic-gate * 1867c478bd9Sstevel@tonic-gate * Device state is returned as a set of bit-flags that indicate the current 1877c478bd9Sstevel@tonic-gate * operational state of a device node. 1887c478bd9Sstevel@tonic-gate * 1897c478bd9Sstevel@tonic-gate * Device nodes for leaf devices only contain state information for the 1907c478bd9Sstevel@tonic-gate * device itself. Nexus device nodes contain both Bus and Device state 1917c478bd9Sstevel@tonic-gate * information. 1927c478bd9Sstevel@tonic-gate * 1937c478bd9Sstevel@tonic-gate * DEVICE_ONLINE - Device is available for use by the system. Mutually 1947c478bd9Sstevel@tonic-gate * exclusive with DEVICE_OFFLINE. 1957c478bd9Sstevel@tonic-gate * 1967c478bd9Sstevel@tonic-gate * DEVICE_OFFLINE - Device is unavailable for use by the system. 1977c478bd9Sstevel@tonic-gate * Mutually exclusive with DEVICE_ONLINE and DEVICE_BUSY. 1987c478bd9Sstevel@tonic-gate * 1997c478bd9Sstevel@tonic-gate * DEVICE_DOWN - Device has been placed in the "DOWN" state by 2007c478bd9Sstevel@tonic-gate * its controlling driver. 2017c478bd9Sstevel@tonic-gate * 2027c478bd9Sstevel@tonic-gate * DEVICE_BUSY - Device has open instances or nexus has INITALIZED 2037c478bd9Sstevel@tonic-gate * children (nexi). A device in this state is by 2047c478bd9Sstevel@tonic-gate * definition Online. 2057c478bd9Sstevel@tonic-gate * 2067c478bd9Sstevel@tonic-gate * Bus state is returned as a set of bit-flags which indicates the 2077c478bd9Sstevel@tonic-gate * operational state of a bus associated with the nexus dev_info node. 2087c478bd9Sstevel@tonic-gate * 2097c478bd9Sstevel@tonic-gate * BUS_ACTIVE - The bus associated with the device node is Active. 2107c478bd9Sstevel@tonic-gate * I/O requests from child devices attached to the 2117c478bd9Sstevel@tonic-gate * are initiated (or queued for initiation) as they 2127c478bd9Sstevel@tonic-gate * are received. 2137c478bd9Sstevel@tonic-gate * 2147c478bd9Sstevel@tonic-gate * BUS_QUIESCED - The bus associated with the device node has been 2157c478bd9Sstevel@tonic-gate * Quieced. I/O requests from child devices attached 2167c478bd9Sstevel@tonic-gate * to the bus are held pending until the bus nexus is 2177c478bd9Sstevel@tonic-gate * Unquiesced. 2187c478bd9Sstevel@tonic-gate * 2197c478bd9Sstevel@tonic-gate * BUS_SHUTDOWN - The bus associated with the device node has been 2207c478bd9Sstevel@tonic-gate * shutdown by the nexus driver. I/O requests from 2217c478bd9Sstevel@tonic-gate * child devices are returned with an error indicating 2227c478bd9Sstevel@tonic-gate * the requested operation failed. 2237c478bd9Sstevel@tonic-gate */ 2247c478bd9Sstevel@tonic-gate #define DEVICE_ONLINE 0x1 2257c478bd9Sstevel@tonic-gate #define DEVICE_BUSY 0x2 2267c478bd9Sstevel@tonic-gate #define DEVICE_OFFLINE 0x4 2277c478bd9Sstevel@tonic-gate #define DEVICE_DOWN 0x8 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate #define BUS_ACTIVE 0x10 2307c478bd9Sstevel@tonic-gate #define BUS_QUIESCED 0x20 2317c478bd9Sstevel@tonic-gate #define BUS_SHUTDOWN 0x40 2327c478bd9Sstevel@tonic-gate 233*4c06356bSdh142964 #define DEVICE_STATES_ASCII "Dev_Online", "Dev_Busy", "Dev_Offline", \ 234*4c06356bSdh142964 "Dev_Down", "Bus_Active", "Bus_Quiesced", "Bus_Shutdown" 235*4c06356bSdh142964 2367c478bd9Sstevel@tonic-gate #define DC_DEVI_NODENAME "ndi_dc.devi_nodename" 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate #define DEVCTL_CONSTRUCT 0x1 2397c478bd9Sstevel@tonic-gate #define DEVCTL_OFFLINE 0x2 2407c478bd9Sstevel@tonic-gate 2413f318a28SAlan Perry /* 2423f318a28SAlan Perry * Drive status LED control 2433f318a28SAlan Perry */ 2443f318a28SAlan Perry struct dc_led_ctl { 2453f318a28SAlan Perry uint32_t led_number : 16; /* LED/device number */ 2463f318a28SAlan Perry uint32_t led_ctl_active : 1; /* Control active */ 2473f318a28SAlan Perry uint32_t led_type : 9; /* LED type */ 2483f318a28SAlan Perry uint32_t led_state : 6; /* LED ON/OFF/Blink state */ 2493f318a28SAlan Perry }; 2503f318a28SAlan Perry 2513f318a28SAlan Perry /* Control active field */ 2523f318a28SAlan Perry #define DCL_CNTRL_OFF 0 /* Control inactive */ 2533f318a28SAlan Perry #define DCL_CNTRL_ON 1 /* Control active */ 2543f318a28SAlan Perry 2553f318a28SAlan Perry /* LED type field */ 2563f318a28SAlan Perry #define DCL_TYPE_DEVICE_FAIL 1 /* Device FAIL LED type */ 2573f318a28SAlan Perry #define DCL_TYPE_DEVICE_OK2RM 2 /* Device OK2RM LED type */ 2583f318a28SAlan Perry 2593f318a28SAlan Perry /* LED state field */ 2603f318a28SAlan Perry #define DCL_STATE_OFF 0 /* LED state OFF */ 2613f318a28SAlan Perry #define DCL_STATE_ON 1 /* LED state ON */ 2623f318a28SAlan Perry #define DCL_STATE_SLOW_BLNK 2 /* LED slow blink */ 2633f318a28SAlan Perry #define DCL_STATE_FAST_BLNK 3 /* LED fast blink */ 2643f318a28SAlan Perry 2657c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2667c478bd9Sstevel@tonic-gate } 2677c478bd9Sstevel@tonic-gate #endif 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate #endif /* _SYS_DEVCTL_H */ 270