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 /* 2396c4a178SChris Horne * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25b8f43eb6SHans Rosenfeld * Copyright 2022 Tintri by DDN, Inc. All rights reserved. 26*d5ebc493SDan Cross * Copyright 2023 Oxide Computer Company 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _SYS_DDITYPES_H 307c478bd9Sstevel@tonic-gate #define _SYS_DDITYPES_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 333d7072f8Seschrock #ifndef _ASM 343d7072f8Seschrock #include <sys/types.h> 353d7072f8Seschrock #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 */ 88b8f43eb6SHans Rosenfeld 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 168b8f43eb6SHans Rosenfeld #define DEVID_NVME_NSID 9 169b8f43eb6SHans Rosenfeld #define DEVID_NVME_EUI64 10 170b8f43eb6SHans Rosenfeld #define DEVID_NVME_NGUID 11 171b8f43eb6SHans Rosenfeld #define DEVID_MAXTYPE 11 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate /* 17496c4a178SChris Horne * Device id scsi encode versions (version of encode interface, not devid) 1757c478bd9Sstevel@tonic-gate */ 1767c478bd9Sstevel@tonic-gate #define DEVID_SCSI_ENCODE_VERSION1 0 1777c478bd9Sstevel@tonic-gate #define DEVID_SCSI_ENCODE_VERSION2 1 1787c478bd9Sstevel@tonic-gate #define DEVID_SCSI_ENCODE_VERSION_LATEST DEVID_SCSI_ENCODE_VERSION2 1797c478bd9Sstevel@tonic-gate 18096c4a178SChris Horne /* 18196c4a178SChris Horne * Device id smp encode versions (version of encode interface, not devid) 18296c4a178SChris Horne */ 18396c4a178SChris Horne #define DEVID_SMP_ENCODE_VERSION1 0 18496c4a178SChris Horne #define DEVID_SMP_ENCODE_VERSION_LATEST DEVID_SMP_ENCODE_VERSION1 18596c4a178SChris Horne 1867c478bd9Sstevel@tonic-gate /* minor name values for devid lookup interfaces */ 1877c478bd9Sstevel@tonic-gate #define DEVID_MINOR_NAME_ALL ((char *)0) 1887c478bd9Sstevel@tonic-gate #define DEVID_MINOR_NAME_ALL_CHR ((char *)1) 1897c478bd9Sstevel@tonic-gate #define DEVID_MINOR_NAME_ALL_BLK ((char *)2) 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate /* 1927c478bd9Sstevel@tonic-gate * Define ddi_devmap_cmd types. This should probably be elsewhere. 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate typedef enum { 1957c478bd9Sstevel@tonic-gate DDI_DEVMAP_VALIDATE = 0 /* Check mapping, but do nothing */ 1967c478bd9Sstevel@tonic-gate } ddi_devmap_cmd_t; 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate /* 199737d277aScth * Definitions for node state. 200737d277aScth * 201737d277aScth * NOTE: DS_ATTACHED and DS_READY should only be used by the devcfg.c state 202737d277aScth * model code itself, other code should use i_ddi_devi_attached() to avoid 203737d277aScth * logic errors associated with transient DS_READY->DS_ATTACHED->DS_READY 204737d277aScth * state changes while the node is attached. 2057c478bd9Sstevel@tonic-gate */ 2067c478bd9Sstevel@tonic-gate typedef enum { 2077c478bd9Sstevel@tonic-gate DS_INVAL = -1, 2087c478bd9Sstevel@tonic-gate DS_PROTO = 0, 2097c478bd9Sstevel@tonic-gate DS_LINKED, /* in orphan list */ 2107c478bd9Sstevel@tonic-gate DS_BOUND, /* in per-driver list */ 2117c478bd9Sstevel@tonic-gate DS_INITIALIZED, /* bus address assigned */ 2127c478bd9Sstevel@tonic-gate DS_PROBED, /* device known to exist */ 213737d277aScth DS_ATTACHED, /* don't use, see NOTE above: driver attached */ 214737d277aScth DS_READY /* don't use, see NOTE above: post attach complete */ 2157c478bd9Sstevel@tonic-gate } ddi_node_state_t; 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate /* 2187c478bd9Sstevel@tonic-gate * NDI Event Service 2197c478bd9Sstevel@tonic-gate */ 2207c478bd9Sstevel@tonic-gate typedef enum {EPL_KERNEL, EPL_INTERRUPT, EPL_HIGHLEVEL} ddi_plevel_t; 2217c478bd9Sstevel@tonic-gate typedef struct ddi_event_cookie *ddi_eventcookie_t; 2227c478bd9Sstevel@tonic-gate typedef struct ddi_event_callbacks *ddi_callback_id_t; 223*d5ebc493SDan Cross typedef void (*ddi_event_cb_f)(dev_info_t *, ddi_eventcookie_t, 224*d5ebc493SDan Cross void *arg, void *impldata); 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2297c478bd9Sstevel@tonic-gate #ifndef _ASM 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate /* 2327c478bd9Sstevel@tonic-gate * Device Access Attributes 2337c478bd9Sstevel@tonic-gate */ 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate typedef struct ddi_device_acc_attr { 2367c478bd9Sstevel@tonic-gate ushort_t devacc_attr_version; 2377c478bd9Sstevel@tonic-gate uchar_t devacc_attr_endian_flags; 2387c478bd9Sstevel@tonic-gate uchar_t devacc_attr_dataorder; 2397c478bd9Sstevel@tonic-gate uchar_t devacc_attr_access; /* access error protection */ 2407c478bd9Sstevel@tonic-gate } ddi_device_acc_attr_t; 2417c478bd9Sstevel@tonic-gate 242b8f43eb6SHans Rosenfeld #define DDI_DEVICE_ATTR_V0 0x0001 243b8f43eb6SHans Rosenfeld #define DDI_DEVICE_ATTR_V1 0x0002 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate /* 2467c478bd9Sstevel@tonic-gate * endian-ness flags 2477c478bd9Sstevel@tonic-gate */ 2487c478bd9Sstevel@tonic-gate #define DDI_NEVERSWAP_ACC 0x00 2497c478bd9Sstevel@tonic-gate #define DDI_STRUCTURE_LE_ACC 0x01 2507c478bd9Sstevel@tonic-gate #define DDI_STRUCTURE_BE_ACC 0x02 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate /* 2537c478bd9Sstevel@tonic-gate * Data ordering values 2547c478bd9Sstevel@tonic-gate */ 2557c478bd9Sstevel@tonic-gate #define DDI_STRICTORDER_ACC 0x00 2567c478bd9Sstevel@tonic-gate #define DDI_UNORDERED_OK_ACC 0x01 2577c478bd9Sstevel@tonic-gate #define DDI_MERGING_OK_ACC 0x02 2587c478bd9Sstevel@tonic-gate #define DDI_LOADCACHING_OK_ACC 0x03 2597c478bd9Sstevel@tonic-gate #define DDI_STORECACHING_OK_ACC 0x04 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate /* 2627c478bd9Sstevel@tonic-gate * Data size 2637c478bd9Sstevel@tonic-gate */ 2647c478bd9Sstevel@tonic-gate #define DDI_DATA_SZ01_ACC 1 2657c478bd9Sstevel@tonic-gate #define DDI_DATA_SZ02_ACC 2 2667c478bd9Sstevel@tonic-gate #define DDI_DATA_SZ04_ACC 4 2677c478bd9Sstevel@tonic-gate #define DDI_DATA_SZ08_ACC 8 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate /* 2707c478bd9Sstevel@tonic-gate * Data Access Handle 2717c478bd9Sstevel@tonic-gate */ 272b8f43eb6SHans Rosenfeld #define VERS_ACCHDL 0x0001 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate typedef struct __ddi_acc_handle *ddi_acc_handle_t; 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate typedef struct ddi_acc_hdl { 2777c478bd9Sstevel@tonic-gate int ah_vers; /* version number */ 2787c478bd9Sstevel@tonic-gate void *ah_bus_private; /* bus private pointer */ 279b8f43eb6SHans Rosenfeld void *ah_platform_private; /* platform private pointer */ 2807c478bd9Sstevel@tonic-gate dev_info_t *ah_dip; /* requesting device */ 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate uint_t ah_rnumber; /* register number */ 2837c478bd9Sstevel@tonic-gate caddr_t ah_addr; /* address of mapping */ 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate off_t ah_offset; /* offset of mapping */ 2867c478bd9Sstevel@tonic-gate off_t ah_len; /* length of mapping */ 2877c478bd9Sstevel@tonic-gate uint_t ah_hat_flags; /* hat flags used to map object */ 2887c478bd9Sstevel@tonic-gate pfn_t ah_pfn; /* physical page frame number */ 2897c478bd9Sstevel@tonic-gate uint_t ah_pnum; /* number of contiguous pages */ 2907b93957cSeota ulong_t ah_xfermodes; /* data transfer modes, etc */ 2917c478bd9Sstevel@tonic-gate ddi_device_acc_attr_t ah_acc; /* device access attributes */ 2927c478bd9Sstevel@tonic-gate } ddi_acc_hdl_t; 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate /* 2957c478bd9Sstevel@tonic-gate * Used by DDI_CTLOPS_POKE and DDI_CTLOPS_PEEK for peek/poke and cautious acc 2967c478bd9Sstevel@tonic-gate */ 2977c478bd9Sstevel@tonic-gate typedef struct { 2987c478bd9Sstevel@tonic-gate size_t size; 2997c478bd9Sstevel@tonic-gate uintptr_t dev_addr; 3007c478bd9Sstevel@tonic-gate uintptr_t host_addr; 3017c478bd9Sstevel@tonic-gate ddi_acc_handle_t handle; 3027c478bd9Sstevel@tonic-gate size_t repcount; 3037c478bd9Sstevel@tonic-gate uint_t flags; 3047c478bd9Sstevel@tonic-gate } peekpoke_ctlops_t; 3057c478bd9Sstevel@tonic-gate 306dd4eeefdSeota /* 307dd4eeefdSeota * Used by the high resolution timeout functions 308dd4eeefdSeota */ 309dd4eeefdSeota typedef struct __ddi_periodic *ddi_periodic_t; 310dd4eeefdSeota 3117c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate /* 3147c478bd9Sstevel@tonic-gate * devacc_attr_access error protection types 3157c478bd9Sstevel@tonic-gate */ 3167c478bd9Sstevel@tonic-gate #define DDI_DEFAULT_ACC 0x01 /* take default action */ 3177c478bd9Sstevel@tonic-gate #define DDI_FLAGERR_ACC 0x02 /* protected against access faults */ 3187c478bd9Sstevel@tonic-gate #define DDI_CAUTIOUS_ACC 0x03 /* high protection against faults */ 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 3217c478bd9Sstevel@tonic-gate 3227c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3237c478bd9Sstevel@tonic-gate } 3247c478bd9Sstevel@tonic-gate #endif 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate #endif /* _SYS_DDITYPES_H */ 327