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 57b93957cSeota * Common Development and Distribution License (the "License"). 67b93957cSeota * 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 */ 217b93957cSeota 227c478bd9Sstevel@tonic-gate /* 23*3d7072f8Seschrock * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_DDITYPES_H 287c478bd9Sstevel@tonic-gate #define _SYS_DDITYPES_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 33*3d7072f8Seschrock #ifndef _ASM 34*3d7072f8Seschrock #include <sys/types.h> 35*3d7072f8Seschrock #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifndef _ASM 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * DMA types 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * A DMA handle represent a "DMA object". A DMA object is an abstraction 467c478bd9Sstevel@tonic-gate * that represents the potential source or destination of DMA transfers to 477c478bd9Sstevel@tonic-gate * or from a device. The DMA object is the highest level description of 487c478bd9Sstevel@tonic-gate * the source or destination and is not suitable for the actual transfer. 497c478bd9Sstevel@tonic-gate * 507c478bd9Sstevel@tonic-gate * Note, that we avoid the specific references to "mapping". The fact that 517c478bd9Sstevel@tonic-gate * a transfer requires mapping is an artifact of the specific architectural 527c478bd9Sstevel@tonic-gate * implementation. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate typedef struct __ddi_dma_handle *ddi_dma_handle_t; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* 577c478bd9Sstevel@tonic-gate * A dma window type represents a "DMA window". A DMA window is a portion 587c478bd9Sstevel@tonic-gate * of a dma object or might be the entire object. A DMA window has had system 597c478bd9Sstevel@tonic-gate * resources allocated to it and is prepared to be transferred into or 607c478bd9Sstevel@tonic-gate * out of. Examples of system resources are DVMA mapping resources and 617c478bd9Sstevel@tonic-gate * intermediate transfer buffer resources. 627c478bd9Sstevel@tonic-gate * 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate typedef struct __ddi_dma_win *ddi_dma_win_t; 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * A dma segment type represents a "DMA segment". A dma segment is a 697c478bd9Sstevel@tonic-gate * contiguous portion of a DMA window which is entirely addressable by the 707c478bd9Sstevel@tonic-gate * device for a transfer operation. One example where DMA segments are 717c478bd9Sstevel@tonic-gate * required is where the system does not contain DVMA capability and 727c478bd9Sstevel@tonic-gate * the object or window may be non-contiguous. In this example the 737c478bd9Sstevel@tonic-gate * object or window will be broken into smaller contiguous segments. 747c478bd9Sstevel@tonic-gate * Another example is where a device or some intermediary bus adapter has 757c478bd9Sstevel@tonic-gate * some upper limit on its transfer size (i.e. an 8-bit address register). 767c478bd9Sstevel@tonic-gate * In this example the object or window will be broken into smaller 777c478bd9Sstevel@tonic-gate * addressable segments. 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate typedef struct __ddi_dma_seg *ddi_dma_seg_t; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * A DMA cookie contains DMA address information required to 837c478bd9Sstevel@tonic-gate * program a DMA engine 847c478bd9Sstevel@tonic-gate */ 857c478bd9Sstevel@tonic-gate typedef struct { 867c478bd9Sstevel@tonic-gate union { 877c478bd9Sstevel@tonic-gate uint64_t _dmac_ll; /* 64 bit DMA address */ 887c478bd9Sstevel@tonic-gate uint32_t _dmac_la[2]; /* 2 x 32 bit address */ 897c478bd9Sstevel@tonic-gate } _dmu; 907c478bd9Sstevel@tonic-gate size_t dmac_size; /* DMA cookie size */ 917c478bd9Sstevel@tonic-gate uint_t dmac_type; /* bus specific type bits */ 927c478bd9Sstevel@tonic-gate } ddi_dma_cookie_t; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #define dmac_laddress _dmu._dmac_ll 957c478bd9Sstevel@tonic-gate #ifdef _LONG_LONG_HTOL 967c478bd9Sstevel@tonic-gate #define dmac_notused _dmu._dmac_la[0] 977c478bd9Sstevel@tonic-gate #define dmac_address _dmu._dmac_la[1] 987c478bd9Sstevel@tonic-gate #else 997c478bd9Sstevel@tonic-gate #define dmac_address _dmu._dmac_la[0] 1007c478bd9Sstevel@tonic-gate #define dmac_notused _dmu._dmac_la[1] 1017c478bd9Sstevel@tonic-gate #endif 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * Interrupt types 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* 108a195726fSgovinda * Both ddi_iblock_cookie_t and ddi_idevice_cookie_t are 109a195726fSgovinda * obsolete data structures. 110a195726fSgovinda * 1117c478bd9Sstevel@tonic-gate * lock initialization type 1127c478bd9Sstevel@tonic-gate */ 1137c478bd9Sstevel@tonic-gate typedef struct __ddi_iblock_cookie *ddi_iblock_cookie_t; 1147c478bd9Sstevel@tonic-gate typedef union { 1157c478bd9Sstevel@tonic-gate struct { 1167c478bd9Sstevel@tonic-gate ushort_t _idev_vector; /* vector - bus dependent */ 1177c478bd9Sstevel@tonic-gate ushort_t _idev_priority; /* priority - bus dependent */ 1187c478bd9Sstevel@tonic-gate } idu; 1197c478bd9Sstevel@tonic-gate uint_t idev_softint; /* Soft interrupt register bit(s) */ 1207c478bd9Sstevel@tonic-gate } ddi_idevice_cookie_t; 1217c478bd9Sstevel@tonic-gate #define idev_vector idu._idev_vector 1227c478bd9Sstevel@tonic-gate #define idev_priority idu._idev_priority 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * register specification 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate typedef struct __ddi_regspec *ddi_regspec_t; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* 1307c478bd9Sstevel@tonic-gate * interrupt specification 1317c478bd9Sstevel@tonic-gate */ 1327c478bd9Sstevel@tonic-gate typedef struct __ddi_intrspec *ddi_intrspec_t; 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* 135a195726fSgovinda * ddi_softintr_t is an obsolete data structure. 136a195726fSgovinda * 1377c478bd9Sstevel@tonic-gate * soft interrupt id 1387c478bd9Sstevel@tonic-gate */ 1397c478bd9Sstevel@tonic-gate typedef struct __ddi_softintr *ddi_softintr_t; 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate /* 1427c478bd9Sstevel@tonic-gate * opaque device info handle 1437c478bd9Sstevel@tonic-gate */ 1447c478bd9Sstevel@tonic-gate typedef struct __dev_info *dev_info_t; 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate /* 1477c478bd9Sstevel@tonic-gate * Mapping cookie for devmap(9E) 1487c478bd9Sstevel@tonic-gate */ 1497c478bd9Sstevel@tonic-gate typedef struct __ddi_devmap_data *ddi_devmap_data_t; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* 1527c478bd9Sstevel@tonic-gate * Opaque Device id 1537c478bd9Sstevel@tonic-gate */ 1547c478bd9Sstevel@tonic-gate typedef struct __ddi_devid *ddi_devid_t; 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate /* 1577c478bd9Sstevel@tonic-gate * Device id types 1587c478bd9Sstevel@tonic-gate */ 1597c478bd9Sstevel@tonic-gate #define DEVID_NONE 0 1607c478bd9Sstevel@tonic-gate #define DEVID_SCSI3_WWN 1 1617c478bd9Sstevel@tonic-gate #define DEVID_SCSI_SERIAL 2 1627c478bd9Sstevel@tonic-gate #define DEVID_FAB 3 1637c478bd9Sstevel@tonic-gate #define DEVID_ENCAP 4 1647c478bd9Sstevel@tonic-gate #define DEVID_ATA_SERIAL 5 1657c478bd9Sstevel@tonic-gate #define DEVID_SCSI3_VPD_T10 6 1667c478bd9Sstevel@tonic-gate #define DEVID_SCSI3_VPD_EUI 7 1677c478bd9Sstevel@tonic-gate #define DEVID_SCSI3_VPD_NAA 8 1687c478bd9Sstevel@tonic-gate #define DEVID_MAXTYPE 8 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate /* 1717c478bd9Sstevel@tonic-gate * Device id scsi encode versions 1727c478bd9Sstevel@tonic-gate */ 1737c478bd9Sstevel@tonic-gate #define DEVID_SCSI_ENCODE_VERSION1 0 1747c478bd9Sstevel@tonic-gate #define DEVID_SCSI_ENCODE_VERSION2 1 1757c478bd9Sstevel@tonic-gate #define DEVID_SCSI_ENCODE_VERSION_LATEST DEVID_SCSI_ENCODE_VERSION2 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate /* minor name values for devid lookup interfaces */ 1787c478bd9Sstevel@tonic-gate #define DEVID_MINOR_NAME_ALL ((char *)0) 1797c478bd9Sstevel@tonic-gate #define DEVID_MINOR_NAME_ALL_CHR ((char *)1) 1807c478bd9Sstevel@tonic-gate #define DEVID_MINOR_NAME_ALL_BLK ((char *)2) 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * Define ddi_devmap_cmd types. This should probably be elsewhere. 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate typedef enum { 1867c478bd9Sstevel@tonic-gate DDI_DEVMAP_VALIDATE = 0 /* Check mapping, but do nothing */ 1877c478bd9Sstevel@tonic-gate } ddi_devmap_cmd_t; 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate /* 190737d277aScth * Definitions for node state. 191737d277aScth * 192737d277aScth * NOTE: DS_ATTACHED and DS_READY should only be used by the devcfg.c state 193737d277aScth * model code itself, other code should use i_ddi_devi_attached() to avoid 194737d277aScth * logic errors associated with transient DS_READY->DS_ATTACHED->DS_READY 195737d277aScth * state changes while the node is attached. 1967c478bd9Sstevel@tonic-gate */ 1977c478bd9Sstevel@tonic-gate typedef enum { 1987c478bd9Sstevel@tonic-gate DS_INVAL = -1, 1997c478bd9Sstevel@tonic-gate DS_PROTO = 0, 2007c478bd9Sstevel@tonic-gate DS_LINKED, /* in orphan list */ 2017c478bd9Sstevel@tonic-gate DS_BOUND, /* in per-driver list */ 2027c478bd9Sstevel@tonic-gate DS_INITIALIZED, /* bus address assigned */ 2037c478bd9Sstevel@tonic-gate DS_PROBED, /* device known to exist */ 204737d277aScth DS_ATTACHED, /* don't use, see NOTE above: driver attached */ 205737d277aScth DS_READY /* don't use, see NOTE above: post attach complete */ 2067c478bd9Sstevel@tonic-gate } ddi_node_state_t; 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* 2097c478bd9Sstevel@tonic-gate * NDI Event Service 2107c478bd9Sstevel@tonic-gate */ 2117c478bd9Sstevel@tonic-gate typedef enum {EPL_KERNEL, EPL_INTERRUPT, EPL_HIGHLEVEL} ddi_plevel_t; 2127c478bd9Sstevel@tonic-gate typedef struct ddi_event_cookie *ddi_eventcookie_t; 2137c478bd9Sstevel@tonic-gate typedef struct ddi_event_callbacks *ddi_callback_id_t; 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2187c478bd9Sstevel@tonic-gate #ifndef _ASM 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate /* 2217c478bd9Sstevel@tonic-gate * Device Access Attributes 2227c478bd9Sstevel@tonic-gate */ 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate typedef struct ddi_device_acc_attr { 2257c478bd9Sstevel@tonic-gate ushort_t devacc_attr_version; 2267c478bd9Sstevel@tonic-gate uchar_t devacc_attr_endian_flags; 2277c478bd9Sstevel@tonic-gate uchar_t devacc_attr_dataorder; 2287c478bd9Sstevel@tonic-gate uchar_t devacc_attr_access; /* access error protection */ 2297c478bd9Sstevel@tonic-gate } ddi_device_acc_attr_t; 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate #define DDI_DEVICE_ATTR_V0 0x0001 2327c478bd9Sstevel@tonic-gate #define DDI_DEVICE_ATTR_V1 0x0002 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate /* 2357c478bd9Sstevel@tonic-gate * endian-ness flags 2367c478bd9Sstevel@tonic-gate */ 2377c478bd9Sstevel@tonic-gate #define DDI_NEVERSWAP_ACC 0x00 2387c478bd9Sstevel@tonic-gate #define DDI_STRUCTURE_LE_ACC 0x01 2397c478bd9Sstevel@tonic-gate #define DDI_STRUCTURE_BE_ACC 0x02 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate /* 2427c478bd9Sstevel@tonic-gate * Data ordering values 2437c478bd9Sstevel@tonic-gate */ 2447c478bd9Sstevel@tonic-gate #define DDI_STRICTORDER_ACC 0x00 2457c478bd9Sstevel@tonic-gate #define DDI_UNORDERED_OK_ACC 0x01 2467c478bd9Sstevel@tonic-gate #define DDI_MERGING_OK_ACC 0x02 2477c478bd9Sstevel@tonic-gate #define DDI_LOADCACHING_OK_ACC 0x03 2487c478bd9Sstevel@tonic-gate #define DDI_STORECACHING_OK_ACC 0x04 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate /* 2517c478bd9Sstevel@tonic-gate * Data size 2527c478bd9Sstevel@tonic-gate */ 2537c478bd9Sstevel@tonic-gate #define DDI_DATA_SZ01_ACC 1 2547c478bd9Sstevel@tonic-gate #define DDI_DATA_SZ02_ACC 2 2557c478bd9Sstevel@tonic-gate #define DDI_DATA_SZ04_ACC 4 2567c478bd9Sstevel@tonic-gate #define DDI_DATA_SZ08_ACC 8 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate /* 2597c478bd9Sstevel@tonic-gate * Data Access Handle 2607c478bd9Sstevel@tonic-gate */ 2617c478bd9Sstevel@tonic-gate #define VERS_ACCHDL 0x0001 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate typedef struct __ddi_acc_handle *ddi_acc_handle_t; 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate typedef struct ddi_acc_hdl { 2667c478bd9Sstevel@tonic-gate int ah_vers; /* version number */ 2677c478bd9Sstevel@tonic-gate void *ah_bus_private; /* bus private pointer */ 2687c478bd9Sstevel@tonic-gate void *ah_platform_private; /* platform private pointer */ 2697c478bd9Sstevel@tonic-gate dev_info_t *ah_dip; /* requesting device */ 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate uint_t ah_rnumber; /* register number */ 2727c478bd9Sstevel@tonic-gate caddr_t ah_addr; /* address of mapping */ 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate off_t ah_offset; /* offset of mapping */ 2757c478bd9Sstevel@tonic-gate off_t ah_len; /* length of mapping */ 2767c478bd9Sstevel@tonic-gate uint_t ah_hat_flags; /* hat flags used to map object */ 2777c478bd9Sstevel@tonic-gate pfn_t ah_pfn; /* physical page frame number */ 2787c478bd9Sstevel@tonic-gate uint_t ah_pnum; /* number of contiguous pages */ 2797b93957cSeota ulong_t ah_xfermodes; /* data transfer modes, etc */ 2807c478bd9Sstevel@tonic-gate ddi_device_acc_attr_t ah_acc; /* device access attributes */ 2817c478bd9Sstevel@tonic-gate } ddi_acc_hdl_t; 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate /* 2847c478bd9Sstevel@tonic-gate * Used by DDI_CTLOPS_POKE and DDI_CTLOPS_PEEK for peek/poke and cautious acc 2857c478bd9Sstevel@tonic-gate */ 2867c478bd9Sstevel@tonic-gate typedef struct { 2877c478bd9Sstevel@tonic-gate size_t size; 2887c478bd9Sstevel@tonic-gate uintptr_t dev_addr; 2897c478bd9Sstevel@tonic-gate uintptr_t host_addr; 2907c478bd9Sstevel@tonic-gate ddi_acc_handle_t handle; 2917c478bd9Sstevel@tonic-gate size_t repcount; 2927c478bd9Sstevel@tonic-gate uint_t flags; 2937c478bd9Sstevel@tonic-gate } peekpoke_ctlops_t; 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate /* 2987c478bd9Sstevel@tonic-gate * devacc_attr_access error protection types 2997c478bd9Sstevel@tonic-gate */ 3007c478bd9Sstevel@tonic-gate #define DDI_DEFAULT_ACC 0x01 /* take default action */ 3017c478bd9Sstevel@tonic-gate #define DDI_FLAGERR_ACC 0x02 /* protected against access faults */ 3027c478bd9Sstevel@tonic-gate #define DDI_CAUTIOUS_ACC 0x03 /* high protection against faults */ 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3077c478bd9Sstevel@tonic-gate } 3087c478bd9Sstevel@tonic-gate #endif 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate #endif /* _SYS_DDITYPES_H */ 311