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