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