xref: /illumos-gate/usr/src/uts/common/sys/dditypes.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_DDITYPES_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_DDITYPES_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
35*7c478bd9Sstevel@tonic-gate extern "C" {
36*7c478bd9Sstevel@tonic-gate #endif
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
39*7c478bd9Sstevel@tonic-gate /*
40*7c478bd9Sstevel@tonic-gate  * DMA types
41*7c478bd9Sstevel@tonic-gate  *
42*7c478bd9Sstevel@tonic-gate  * A DMA handle represent a "DMA object".  A DMA object is an abstraction
43*7c478bd9Sstevel@tonic-gate  * that represents the potential source or destination of DMA transfers to
44*7c478bd9Sstevel@tonic-gate  * or from a device.  The DMA object is the highest level description of
45*7c478bd9Sstevel@tonic-gate  * the source or destination and is not suitable for the actual transfer.
46*7c478bd9Sstevel@tonic-gate  *
47*7c478bd9Sstevel@tonic-gate  * Note, that we avoid the specific references to "mapping". The fact that
48*7c478bd9Sstevel@tonic-gate  * a transfer requires mapping is an artifact of the specific architectural
49*7c478bd9Sstevel@tonic-gate  * implementation.
50*7c478bd9Sstevel@tonic-gate  */
51*7c478bd9Sstevel@tonic-gate typedef	struct __ddi_dma_handle *ddi_dma_handle_t;
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate /*
54*7c478bd9Sstevel@tonic-gate  * A dma window type represents a "DMA window".  A DMA window is a portion
55*7c478bd9Sstevel@tonic-gate  * of a dma object or might be the entire object. A DMA window has had system
56*7c478bd9Sstevel@tonic-gate  * resources allocated to it and is prepared to be transferred into or
57*7c478bd9Sstevel@tonic-gate  * out of. Examples of system resources are DVMA mapping resources and
58*7c478bd9Sstevel@tonic-gate  * intermediate transfer buffer resources.
59*7c478bd9Sstevel@tonic-gate  *
60*7c478bd9Sstevel@tonic-gate  */
61*7c478bd9Sstevel@tonic-gate typedef	struct __ddi_dma_win *ddi_dma_win_t;
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate /*
65*7c478bd9Sstevel@tonic-gate  * A dma segment type represents a "DMA segment".  A dma segment is a
66*7c478bd9Sstevel@tonic-gate  * contiguous portion of a DMA window which is entirely addressable by the
67*7c478bd9Sstevel@tonic-gate  * device for a transfer operation.  One example where DMA segments are
68*7c478bd9Sstevel@tonic-gate  * required is where the system does not contain DVMA capability and
69*7c478bd9Sstevel@tonic-gate  * the object or window may be non-contiguous.  In this example the
70*7c478bd9Sstevel@tonic-gate  * object or window will be broken into smaller contiguous segments.
71*7c478bd9Sstevel@tonic-gate  * Another example is where a device or some intermediary bus adapter has
72*7c478bd9Sstevel@tonic-gate  * some upper limit on its transfer size (i.e. an 8-bit address register).
73*7c478bd9Sstevel@tonic-gate  * In this example the object or window will be broken into smaller
74*7c478bd9Sstevel@tonic-gate  * addressable segments.
75*7c478bd9Sstevel@tonic-gate  */
76*7c478bd9Sstevel@tonic-gate typedef	struct __ddi_dma_seg *ddi_dma_seg_t;
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate /*
79*7c478bd9Sstevel@tonic-gate  * A DMA cookie contains DMA address information required to
80*7c478bd9Sstevel@tonic-gate  * program a DMA engine
81*7c478bd9Sstevel@tonic-gate  */
82*7c478bd9Sstevel@tonic-gate typedef struct {
83*7c478bd9Sstevel@tonic-gate 	union {
84*7c478bd9Sstevel@tonic-gate 		uint64_t	_dmac_ll;	/* 64 bit DMA address */
85*7c478bd9Sstevel@tonic-gate 		uint32_t 	_dmac_la[2];    /* 2 x 32 bit address */
86*7c478bd9Sstevel@tonic-gate 	} _dmu;
87*7c478bd9Sstevel@tonic-gate 	size_t		dmac_size;	/* DMA cookie size */
88*7c478bd9Sstevel@tonic-gate 	uint_t		dmac_type;	/* bus specific type bits */
89*7c478bd9Sstevel@tonic-gate } ddi_dma_cookie_t;
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate #define	dmac_laddress	_dmu._dmac_ll
92*7c478bd9Sstevel@tonic-gate #ifdef _LONG_LONG_HTOL
93*7c478bd9Sstevel@tonic-gate #define	dmac_notused    _dmu._dmac_la[0]
94*7c478bd9Sstevel@tonic-gate #define	dmac_address    _dmu._dmac_la[1]
95*7c478bd9Sstevel@tonic-gate #else
96*7c478bd9Sstevel@tonic-gate #define	dmac_address	_dmu._dmac_la[0]
97*7c478bd9Sstevel@tonic-gate #define	dmac_notused	_dmu._dmac_la[1]
98*7c478bd9Sstevel@tonic-gate #endif
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate /*
101*7c478bd9Sstevel@tonic-gate  * Interrupt types
102*7c478bd9Sstevel@tonic-gate  */
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate /*
105*7c478bd9Sstevel@tonic-gate  * lock initialization type
106*7c478bd9Sstevel@tonic-gate  */
107*7c478bd9Sstevel@tonic-gate typedef struct __ddi_iblock_cookie *ddi_iblock_cookie_t;
108*7c478bd9Sstevel@tonic-gate typedef union {
109*7c478bd9Sstevel@tonic-gate 	struct {
110*7c478bd9Sstevel@tonic-gate 		ushort_t	_idev_vector;	/* vector - bus dependent */
111*7c478bd9Sstevel@tonic-gate 		ushort_t	_idev_priority;	/* priority - bus dependent */
112*7c478bd9Sstevel@tonic-gate 	} idu;
113*7c478bd9Sstevel@tonic-gate 	uint_t	idev_softint;	/* Soft interrupt register bit(s) */
114*7c478bd9Sstevel@tonic-gate } ddi_idevice_cookie_t;
115*7c478bd9Sstevel@tonic-gate #define	idev_vector	idu._idev_vector
116*7c478bd9Sstevel@tonic-gate #define	idev_priority	idu._idev_priority
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate /*
119*7c478bd9Sstevel@tonic-gate  * register specification
120*7c478bd9Sstevel@tonic-gate  */
121*7c478bd9Sstevel@tonic-gate typedef struct __ddi_regspec *ddi_regspec_t;
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate /*
124*7c478bd9Sstevel@tonic-gate  * interrupt specification
125*7c478bd9Sstevel@tonic-gate  */
126*7c478bd9Sstevel@tonic-gate typedef struct __ddi_intrspec *ddi_intrspec_t;
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate /*
129*7c478bd9Sstevel@tonic-gate  * soft interrupt id
130*7c478bd9Sstevel@tonic-gate  */
131*7c478bd9Sstevel@tonic-gate typedef struct __ddi_softintr *ddi_softintr_t;
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate /*
134*7c478bd9Sstevel@tonic-gate  * opaque device info handle
135*7c478bd9Sstevel@tonic-gate  */
136*7c478bd9Sstevel@tonic-gate typedef struct __dev_info *dev_info_t;
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate /*
139*7c478bd9Sstevel@tonic-gate  * Mapping cookie for devmap(9E)
140*7c478bd9Sstevel@tonic-gate  */
141*7c478bd9Sstevel@tonic-gate typedef struct __ddi_devmap_data *ddi_devmap_data_t;
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate /*
144*7c478bd9Sstevel@tonic-gate  * Opaque Device id
145*7c478bd9Sstevel@tonic-gate  */
146*7c478bd9Sstevel@tonic-gate typedef struct __ddi_devid *ddi_devid_t;
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate /*
149*7c478bd9Sstevel@tonic-gate  * Device id types
150*7c478bd9Sstevel@tonic-gate  */
151*7c478bd9Sstevel@tonic-gate #define	DEVID_NONE		0
152*7c478bd9Sstevel@tonic-gate #define	DEVID_SCSI3_WWN		1
153*7c478bd9Sstevel@tonic-gate #define	DEVID_SCSI_SERIAL	2
154*7c478bd9Sstevel@tonic-gate #define	DEVID_FAB		3
155*7c478bd9Sstevel@tonic-gate #define	DEVID_ENCAP		4
156*7c478bd9Sstevel@tonic-gate #define	DEVID_ATA_SERIAL	5
157*7c478bd9Sstevel@tonic-gate #define	DEVID_SCSI3_VPD_T10	6
158*7c478bd9Sstevel@tonic-gate #define	DEVID_SCSI3_VPD_EUI	7
159*7c478bd9Sstevel@tonic-gate #define	DEVID_SCSI3_VPD_NAA	8
160*7c478bd9Sstevel@tonic-gate #define	DEVID_MAXTYPE		8
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate /*
163*7c478bd9Sstevel@tonic-gate  * Device id scsi encode versions
164*7c478bd9Sstevel@tonic-gate  */
165*7c478bd9Sstevel@tonic-gate #define	DEVID_SCSI_ENCODE_VERSION1		0
166*7c478bd9Sstevel@tonic-gate #define	DEVID_SCSI_ENCODE_VERSION2		1
167*7c478bd9Sstevel@tonic-gate #define	DEVID_SCSI_ENCODE_VERSION_LATEST	DEVID_SCSI_ENCODE_VERSION2
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate /* minor name values for devid lookup interfaces */
170*7c478bd9Sstevel@tonic-gate #define	DEVID_MINOR_NAME_ALL		((char *)0)
171*7c478bd9Sstevel@tonic-gate #define	DEVID_MINOR_NAME_ALL_CHR	((char *)1)
172*7c478bd9Sstevel@tonic-gate #define	DEVID_MINOR_NAME_ALL_BLK	((char *)2)
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate /*
175*7c478bd9Sstevel@tonic-gate  * Define ddi_devmap_cmd types. This should probably be elsewhere.
176*7c478bd9Sstevel@tonic-gate  */
177*7c478bd9Sstevel@tonic-gate typedef enum {
178*7c478bd9Sstevel@tonic-gate 	DDI_DEVMAP_VALIDATE = 0		/* Check mapping, but do nothing */
179*7c478bd9Sstevel@tonic-gate } ddi_devmap_cmd_t;
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate /*
182*7c478bd9Sstevel@tonic-gate  * Definitions for node state
183*7c478bd9Sstevel@tonic-gate  */
184*7c478bd9Sstevel@tonic-gate typedef enum {
185*7c478bd9Sstevel@tonic-gate 	DS_INVAL = -1,
186*7c478bd9Sstevel@tonic-gate 	DS_PROTO = 0,
187*7c478bd9Sstevel@tonic-gate 	DS_LINKED,	/* in orphan list */
188*7c478bd9Sstevel@tonic-gate 	DS_BOUND,	/* in per-driver list */
189*7c478bd9Sstevel@tonic-gate 	DS_INITIALIZED, /* bus address assigned */
190*7c478bd9Sstevel@tonic-gate 	DS_PROBED,	/* device known to exist */
191*7c478bd9Sstevel@tonic-gate 	DS_ATTACHED,	/* driver attached */
192*7c478bd9Sstevel@tonic-gate 	DS_READY	/* post attach complete */
193*7c478bd9Sstevel@tonic-gate } ddi_node_state_t;
194*7c478bd9Sstevel@tonic-gate 
195*7c478bd9Sstevel@tonic-gate /*
196*7c478bd9Sstevel@tonic-gate  * NDI Event Service
197*7c478bd9Sstevel@tonic-gate  */
198*7c478bd9Sstevel@tonic-gate typedef enum {EPL_KERNEL, EPL_INTERRUPT, EPL_HIGHLEVEL} ddi_plevel_t;
199*7c478bd9Sstevel@tonic-gate typedef struct ddi_event_cookie *ddi_eventcookie_t;
200*7c478bd9Sstevel@tonic-gate typedef struct ddi_event_callbacks *ddi_callback_id_t;
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
205*7c478bd9Sstevel@tonic-gate #ifndef _ASM
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate /*
208*7c478bd9Sstevel@tonic-gate  * Device Access Attributes
209*7c478bd9Sstevel@tonic-gate  */
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate typedef struct ddi_device_acc_attr {
212*7c478bd9Sstevel@tonic-gate 	ushort_t devacc_attr_version;
213*7c478bd9Sstevel@tonic-gate 	uchar_t devacc_attr_endian_flags;
214*7c478bd9Sstevel@tonic-gate 	uchar_t devacc_attr_dataorder;
215*7c478bd9Sstevel@tonic-gate 	uchar_t devacc_attr_access;		/* access error protection */
216*7c478bd9Sstevel@tonic-gate } ddi_device_acc_attr_t;
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate #define	DDI_DEVICE_ATTR_V0 	0x0001
219*7c478bd9Sstevel@tonic-gate #define	DDI_DEVICE_ATTR_V1 	0x0002
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate /*
222*7c478bd9Sstevel@tonic-gate  * endian-ness flags
223*7c478bd9Sstevel@tonic-gate  */
224*7c478bd9Sstevel@tonic-gate #define	 DDI_NEVERSWAP_ACC	0x00
225*7c478bd9Sstevel@tonic-gate #define	 DDI_STRUCTURE_LE_ACC	0x01
226*7c478bd9Sstevel@tonic-gate #define	 DDI_STRUCTURE_BE_ACC	0x02
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate /*
229*7c478bd9Sstevel@tonic-gate  * Data ordering values
230*7c478bd9Sstevel@tonic-gate  */
231*7c478bd9Sstevel@tonic-gate #define	DDI_STRICTORDER_ACC	0x00
232*7c478bd9Sstevel@tonic-gate #define	DDI_UNORDERED_OK_ACC    0x01
233*7c478bd9Sstevel@tonic-gate #define	DDI_MERGING_OK_ACC	0x02
234*7c478bd9Sstevel@tonic-gate #define	DDI_LOADCACHING_OK_ACC  0x03
235*7c478bd9Sstevel@tonic-gate #define	DDI_STORECACHING_OK_ACC 0x04
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate /*
238*7c478bd9Sstevel@tonic-gate  * Data size
239*7c478bd9Sstevel@tonic-gate  */
240*7c478bd9Sstevel@tonic-gate #define	DDI_DATA_SZ01_ACC	1
241*7c478bd9Sstevel@tonic-gate #define	DDI_DATA_SZ02_ACC	2
242*7c478bd9Sstevel@tonic-gate #define	DDI_DATA_SZ04_ACC	4
243*7c478bd9Sstevel@tonic-gate #define	DDI_DATA_SZ08_ACC	8
244*7c478bd9Sstevel@tonic-gate 
245*7c478bd9Sstevel@tonic-gate /*
246*7c478bd9Sstevel@tonic-gate  * Data Access Handle
247*7c478bd9Sstevel@tonic-gate  */
248*7c478bd9Sstevel@tonic-gate #define	VERS_ACCHDL 			0x0001
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate typedef struct __ddi_acc_handle *ddi_acc_handle_t;
251*7c478bd9Sstevel@tonic-gate 
252*7c478bd9Sstevel@tonic-gate typedef struct ddi_acc_hdl {
253*7c478bd9Sstevel@tonic-gate 	int	ah_vers;		/* version number */
254*7c478bd9Sstevel@tonic-gate 	void	*ah_bus_private;	/* bus private pointer */
255*7c478bd9Sstevel@tonic-gate 	void 	*ah_platform_private; 	/* platform private pointer */
256*7c478bd9Sstevel@tonic-gate 	dev_info_t *ah_dip;		/* requesting device */
257*7c478bd9Sstevel@tonic-gate 
258*7c478bd9Sstevel@tonic-gate 	uint_t	ah_rnumber;		/* register number */
259*7c478bd9Sstevel@tonic-gate 	caddr_t	ah_addr;		/* address of mapping */
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate 	off_t	ah_offset;		/* offset of mapping */
262*7c478bd9Sstevel@tonic-gate 	off_t	ah_len;			/* length of mapping */
263*7c478bd9Sstevel@tonic-gate 	uint_t	ah_hat_flags;		/* hat flags used to map object */
264*7c478bd9Sstevel@tonic-gate 	pfn_t	ah_pfn;			/* physical page frame number */
265*7c478bd9Sstevel@tonic-gate 	uint_t	ah_pnum;		/* number of contiguous pages */
266*7c478bd9Sstevel@tonic-gate 	ulong_t	ah_xfermodes;		/* data transfer modes */
267*7c478bd9Sstevel@tonic-gate 	ddi_device_acc_attr_t ah_acc;	/* device access attributes */
268*7c478bd9Sstevel@tonic-gate } ddi_acc_hdl_t;
269*7c478bd9Sstevel@tonic-gate 
270*7c478bd9Sstevel@tonic-gate /*
271*7c478bd9Sstevel@tonic-gate  * Used by DDI_CTLOPS_POKE and DDI_CTLOPS_PEEK for peek/poke and cautious acc
272*7c478bd9Sstevel@tonic-gate  */
273*7c478bd9Sstevel@tonic-gate typedef struct {
274*7c478bd9Sstevel@tonic-gate 	size_t			size;
275*7c478bd9Sstevel@tonic-gate 	uintptr_t		dev_addr;
276*7c478bd9Sstevel@tonic-gate 	uintptr_t		host_addr;
277*7c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	handle;
278*7c478bd9Sstevel@tonic-gate 	size_t			repcount;
279*7c478bd9Sstevel@tonic-gate 	uint_t			flags;
280*7c478bd9Sstevel@tonic-gate } peekpoke_ctlops_t;
281*7c478bd9Sstevel@tonic-gate 
282*7c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
283*7c478bd9Sstevel@tonic-gate 
284*7c478bd9Sstevel@tonic-gate /*
285*7c478bd9Sstevel@tonic-gate  * devacc_attr_access error protection types
286*7c478bd9Sstevel@tonic-gate  */
287*7c478bd9Sstevel@tonic-gate #define	DDI_DEFAULT_ACC		0x01	/* take default action */
288*7c478bd9Sstevel@tonic-gate #define	DDI_FLAGERR_ACC		0x02	/* protected against access faults */
289*7c478bd9Sstevel@tonic-gate #define	DDI_CAUTIOUS_ACC	0x03	/* high protection against faults */
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
294*7c478bd9Sstevel@tonic-gate }
295*7c478bd9Sstevel@tonic-gate #endif
296*7c478bd9Sstevel@tonic-gate 
297*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_DDITYPES_H */
298