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 5*5e3f6b1fScth * Common Development and Distribution License (the "License"). 6*5e3f6b1fScth * 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*5e3f6b1fScth * Copyright 2008 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 #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate /* 327c478bd9Sstevel@tonic-gate * Device control interfaces 337c478bd9Sstevel@tonic-gate */ 347c478bd9Sstevel@tonic-gate #include <sys/types.h> 357c478bd9Sstevel@tonic-gate #include <sys/nvpair.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * structure used to pass IOCTL data between the libdevice interfaces 437c478bd9Sstevel@tonic-gate * and nexus driver devctl IOCTL interface. 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * Applications and nexus drivers may not access the contents of this 467c478bd9Sstevel@tonic-gate * structure directly. Instead, drivers must use the ndi_dc_XXX(9n) 477c478bd9Sstevel@tonic-gate * interfaces, while applications must use the interfaces provided by 487c478bd9Sstevel@tonic-gate * libdevice.so.1. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate struct devctl_iocdata { 517c478bd9Sstevel@tonic-gate uint_t cmd; /* ioctl cmd */ 527c478bd9Sstevel@tonic-gate uint_t flags; /* command-specific flags */ 537c478bd9Sstevel@tonic-gate void *cpyout_buf; /* copyout vector */ 547c478bd9Sstevel@tonic-gate nvlist_t *nvl_user; /* application defined attributes */ 557c478bd9Sstevel@tonic-gate size_t nvl_usersz; 567c478bd9Sstevel@tonic-gate char *c_nodename; /* child device nodename */ 577c478bd9Sstevel@tonic-gate char *c_unitaddr; /* child device unit address */ 587c478bd9Sstevel@tonic-gate }; 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * Structure to pass/return data from 32-bit program's. 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate struct devctl_iocdata32 { 657c478bd9Sstevel@tonic-gate uint32_t cmd; 667c478bd9Sstevel@tonic-gate uint32_t flags; 677c478bd9Sstevel@tonic-gate caddr32_t cpyout_buf; 687c478bd9Sstevel@tonic-gate caddr32_t nvl_user; 697c478bd9Sstevel@tonic-gate uint32_t nvl_usersz; 707c478bd9Sstevel@tonic-gate caddr32_t c_nodename; 717c478bd9Sstevel@tonic-gate caddr32_t c_unitaddr; 727c478bd9Sstevel@tonic-gate }; 737c478bd9Sstevel@tonic-gate #endif 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* 76*5e3f6b1fScth * Limit size of packed application defined attributes (nvl_user) to prevent 77*5e3f6b1fScth * user application from requesting excessive kernel memory allocation. 78*5e3f6b1fScth */ 79*5e3f6b1fScth #define DEVCTL_MAX_NVL_USERSZ 0x10000 80*5e3f6b1fScth 81*5e3f6b1fScth /* 827c478bd9Sstevel@tonic-gate * State of receptacle for an Attachment Point. 837c478bd9Sstevel@tonic-gate */ 847c478bd9Sstevel@tonic-gate typedef enum { 857c478bd9Sstevel@tonic-gate AP_RSTATE_EMPTY, 867c478bd9Sstevel@tonic-gate AP_RSTATE_DISCONNECTED, 877c478bd9Sstevel@tonic-gate AP_RSTATE_CONNECTED 887c478bd9Sstevel@tonic-gate } ap_rstate_t; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate /* 917c478bd9Sstevel@tonic-gate * State of occupant for an Attachment Point. 927c478bd9Sstevel@tonic-gate */ 937c478bd9Sstevel@tonic-gate typedef enum { 947c478bd9Sstevel@tonic-gate AP_OSTATE_UNCONFIGURED, 957c478bd9Sstevel@tonic-gate AP_OSTATE_CONFIGURED 967c478bd9Sstevel@tonic-gate } ap_ostate_t; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * condition of an Attachment Point. 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate typedef enum { 1027c478bd9Sstevel@tonic-gate AP_COND_UNKNOWN, 1037c478bd9Sstevel@tonic-gate AP_COND_OK, 1047c478bd9Sstevel@tonic-gate AP_COND_FAILING, 1057c478bd9Sstevel@tonic-gate AP_COND_FAILED, 1067c478bd9Sstevel@tonic-gate AP_COND_UNUSABLE 1077c478bd9Sstevel@tonic-gate } ap_condition_t; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate /* 1107c478bd9Sstevel@tonic-gate * structure used to return the state of Attachment Point (AP) thru 1117c478bd9Sstevel@tonic-gate * devctl_ap_getstate() interface. 1127c478bd9Sstevel@tonic-gate */ 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate typedef struct devctl_ap_state { 1157c478bd9Sstevel@tonic-gate ap_rstate_t ap_rstate; /* receptacle state */ 1167c478bd9Sstevel@tonic-gate ap_ostate_t ap_ostate; /* occupant state */ 1177c478bd9Sstevel@tonic-gate ap_condition_t ap_condition; /* condition of AP */ 1187c478bd9Sstevel@tonic-gate time_t ap_last_change; 1197c478bd9Sstevel@tonic-gate uint32_t ap_error_code; /* error code */ 1207c478bd9Sstevel@tonic-gate uint8_t ap_in_transition; 1217c478bd9Sstevel@tonic-gate } devctl_ap_state_t; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * Structure to pass/return data from 32-bit program's. 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate typedef struct devctl_ap_state32 { 1287c478bd9Sstevel@tonic-gate ap_rstate_t ap_rstate; /* receptacle state */ 1297c478bd9Sstevel@tonic-gate ap_ostate_t ap_ostate; /* occupant state */ 1307c478bd9Sstevel@tonic-gate ap_condition_t ap_condition; /* condition of AP */ 1317c478bd9Sstevel@tonic-gate time32_t ap_last_change; 1327c478bd9Sstevel@tonic-gate uint32_t ap_error_code; /* error code */ 1337c478bd9Sstevel@tonic-gate uint8_t ap_in_transition; 1347c478bd9Sstevel@tonic-gate } devctl_ap_state32_t; 1357c478bd9Sstevel@tonic-gate #endif 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #define DEVCTL_IOC (0xDC << 16) 1387c478bd9Sstevel@tonic-gate #define DEVCTL_IOC_MAX (DEVCTL_IOC | 0xFFFF) 1397c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_QUIESCE (DEVCTL_IOC | 1) 1407c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_UNQUIESCE (DEVCTL_IOC | 2) 1417c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_RESETALL (DEVCTL_IOC | 3) 1427c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_RESET (DEVCTL_IOC | 4) 1437c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_GETSTATE (DEVCTL_IOC | 5) 1447c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_ONLINE (DEVCTL_IOC | 6) 1457c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_OFFLINE (DEVCTL_IOC | 7) 1467c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_GETSTATE (DEVCTL_IOC | 9) 1477c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_RESET (DEVCTL_IOC | 10) 1487c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_CONFIGURE (DEVCTL_IOC | 11) 1497c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_UNCONFIGURE (DEVCTL_IOC | 12) 1507c478bd9Sstevel@tonic-gate #define DEVCTL_DEVICE_REMOVE (DEVCTL_IOC | 13) 1517c478bd9Sstevel@tonic-gate #define DEVCTL_AP_CONNECT (DEVCTL_IOC | 14) 1527c478bd9Sstevel@tonic-gate #define DEVCTL_AP_DISCONNECT (DEVCTL_IOC | 15) 1537c478bd9Sstevel@tonic-gate #define DEVCTL_AP_INSERT (DEVCTL_IOC | 16) 1547c478bd9Sstevel@tonic-gate #define DEVCTL_AP_REMOVE (DEVCTL_IOC | 17) 1557c478bd9Sstevel@tonic-gate #define DEVCTL_AP_CONFIGURE (DEVCTL_IOC | 18) 1567c478bd9Sstevel@tonic-gate #define DEVCTL_AP_UNCONFIGURE (DEVCTL_IOC | 19) 1577c478bd9Sstevel@tonic-gate #define DEVCTL_AP_GETSTATE (DEVCTL_IOC | 20) 1587c478bd9Sstevel@tonic-gate #define DEVCTL_AP_CONTROL (DEVCTL_IOC | 21) 1597c478bd9Sstevel@tonic-gate #define DEVCTL_BUS_DEV_CREATE (DEVCTL_IOC | 22) 1607c478bd9Sstevel@tonic-gate #define DEVCTL_PM_BUSY_COMP (DEVCTL_IOC | 23) 1617c478bd9Sstevel@tonic-gate #define DEVCTL_PM_IDLE_COMP (DEVCTL_IOC | 24) 1627c478bd9Sstevel@tonic-gate #define DEVCTL_PM_RAISE_PWR (DEVCTL_IOC | 25) 1637c478bd9Sstevel@tonic-gate #define DEVCTL_PM_LOWER_PWR (DEVCTL_IOC | 26) 1647c478bd9Sstevel@tonic-gate #define DEVCTL_PM_CHANGE_PWR_LOW (DEVCTL_IOC | 27) 1657c478bd9Sstevel@tonic-gate #define DEVCTL_PM_CHANGE_PWR_HIGH (DEVCTL_IOC | 28) 1667c478bd9Sstevel@tonic-gate #define DEVCTL_PM_POWER (DEVCTL_IOC | 29) 1677c478bd9Sstevel@tonic-gate #define DEVCTL_PM_PROM_PRINTF (DEVCTL_IOC | 30) 1687c478bd9Sstevel@tonic-gate #define DEVCTL_PM_FAIL_SUSPEND (DEVCTL_IOC | 31) 1697c478bd9Sstevel@tonic-gate #define DEVCTL_PM_PWR_HAS_CHANGED_ON_RESUME (DEVCTL_IOC | 32) 1707c478bd9Sstevel@tonic-gate #define DEVCTL_PM_PUP_WITH_PWR_HAS_CHANGED (DEVCTL_IOC | 34) 1717c478bd9Sstevel@tonic-gate #define DEVCTL_PM_BUSY_COMP_TEST (DEVCTL_IOC | 35) 1727c478bd9Sstevel@tonic-gate #define DEVCTL_PM_BUS_STRICT_TEST (DEVCTL_IOC | 36) 1737c478bd9Sstevel@tonic-gate #define DEVCTL_PM_NO_LOWER_POWER (DEVCTL_IOC | 37) 1747c478bd9Sstevel@tonic-gate #define DEVCTL_PM_BUS_NO_INVOL (DEVCTL_IOC | 38) 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate /* 1777c478bd9Sstevel@tonic-gate * is (c) in the range of possible devctl IOCTL commands? 1787c478bd9Sstevel@tonic-gate */ 1797c478bd9Sstevel@tonic-gate #define IS_DEVCTL(c) (((c) >= DEVCTL_IOC) && ((c) <= DEVCTL_IOC_MAX)) 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate /* 1827c478bd9Sstevel@tonic-gate * Device and Bus State definitions 1837c478bd9Sstevel@tonic-gate * 1847c478bd9Sstevel@tonic-gate * Device state is returned as a set of bit-flags that indicate the current 1857c478bd9Sstevel@tonic-gate * operational state of a device node. 1867c478bd9Sstevel@tonic-gate * 1877c478bd9Sstevel@tonic-gate * Device nodes for leaf devices only contain state information for the 1887c478bd9Sstevel@tonic-gate * device itself. Nexus device nodes contain both Bus and Device state 1897c478bd9Sstevel@tonic-gate * information. 1907c478bd9Sstevel@tonic-gate * 1917c478bd9Sstevel@tonic-gate * DEVICE_ONLINE - Device is available for use by the system. Mutually 1927c478bd9Sstevel@tonic-gate * exclusive with DEVICE_OFFLINE. 1937c478bd9Sstevel@tonic-gate * 1947c478bd9Sstevel@tonic-gate * DEVICE_OFFLINE - Device is unavailable for use by the system. 1957c478bd9Sstevel@tonic-gate * Mutually exclusive with DEVICE_ONLINE and DEVICE_BUSY. 1967c478bd9Sstevel@tonic-gate * 1977c478bd9Sstevel@tonic-gate * DEVICE_DOWN - Device has been placed in the "DOWN" state by 1987c478bd9Sstevel@tonic-gate * its controlling driver. 1997c478bd9Sstevel@tonic-gate * 2007c478bd9Sstevel@tonic-gate * DEVICE_BUSY - Device has open instances or nexus has INITALIZED 2017c478bd9Sstevel@tonic-gate * children (nexi). A device in this state is by 2027c478bd9Sstevel@tonic-gate * definition Online. 2037c478bd9Sstevel@tonic-gate * 2047c478bd9Sstevel@tonic-gate * Bus state is returned as a set of bit-flags which indicates the 2057c478bd9Sstevel@tonic-gate * operational state of a bus associated with the nexus dev_info node. 2067c478bd9Sstevel@tonic-gate * 2077c478bd9Sstevel@tonic-gate * BUS_ACTIVE - The bus associated with the device node is Active. 2087c478bd9Sstevel@tonic-gate * I/O requests from child devices attached to the 2097c478bd9Sstevel@tonic-gate * are initiated (or queued for initiation) as they 2107c478bd9Sstevel@tonic-gate * are received. 2117c478bd9Sstevel@tonic-gate * 2127c478bd9Sstevel@tonic-gate * BUS_QUIESCED - The bus associated with the device node has been 2137c478bd9Sstevel@tonic-gate * Quieced. I/O requests from child devices attached 2147c478bd9Sstevel@tonic-gate * to the bus are held pending until the bus nexus is 2157c478bd9Sstevel@tonic-gate * Unquiesced. 2167c478bd9Sstevel@tonic-gate * 2177c478bd9Sstevel@tonic-gate * BUS_SHUTDOWN - The bus associated with the device node has been 2187c478bd9Sstevel@tonic-gate * shutdown by the nexus driver. I/O requests from 2197c478bd9Sstevel@tonic-gate * child devices are returned with an error indicating 2207c478bd9Sstevel@tonic-gate * the requested operation failed. 2217c478bd9Sstevel@tonic-gate */ 2227c478bd9Sstevel@tonic-gate #define DEVICE_ONLINE 0x1 2237c478bd9Sstevel@tonic-gate #define DEVICE_BUSY 0x2 2247c478bd9Sstevel@tonic-gate #define DEVICE_OFFLINE 0x4 2257c478bd9Sstevel@tonic-gate #define DEVICE_DOWN 0x8 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate #define BUS_ACTIVE 0x10 2287c478bd9Sstevel@tonic-gate #define BUS_QUIESCED 0x20 2297c478bd9Sstevel@tonic-gate #define BUS_SHUTDOWN 0x40 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate #define DC_DEVI_NODENAME "ndi_dc.devi_nodename" 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate #define DEVCTL_CONSTRUCT 0x1 2347c478bd9Sstevel@tonic-gate #define DEVCTL_OFFLINE 0x2 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2377c478bd9Sstevel@tonic-gate } 2387c478bd9Sstevel@tonic-gate #endif 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate #endif /* _SYS_DEVCTL_H */ 241