xref: /onnv-gate/usr/src/uts/common/sys/ddidmareq.h (revision 13050:515b1e9bea30)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51772Sjl139090  * Common Development and Distribution License (the "License").
61772Sjl139090  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*13050Sfrank.van.der.linden@oracle.com  * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_SYS_DDIDMAREQ_H
260Sstevel@tonic-gate #define	_SYS_DDIDMAREQ_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #ifdef	__cplusplus
290Sstevel@tonic-gate extern "C" {
300Sstevel@tonic-gate #endif
310Sstevel@tonic-gate 
320Sstevel@tonic-gate /*
330Sstevel@tonic-gate  * Memory Objects
340Sstevel@tonic-gate  *
350Sstevel@tonic-gate  * Definitions of structures that can describe
360Sstevel@tonic-gate  * an object that can be mapped for DMA.
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * Structure describing a virtual address
410Sstevel@tonic-gate  */
420Sstevel@tonic-gate struct v_address {
430Sstevel@tonic-gate 	caddr_t		v_addr;		/* base virtual address */
440Sstevel@tonic-gate 	struct	as	*v_as;		/* pointer to address space */
450Sstevel@tonic-gate 	void 		*v_priv;	/* priv data for shadow I/O */
460Sstevel@tonic-gate };
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * Structure describing a page-based address
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate struct pp_address {
520Sstevel@tonic-gate 	/*
530Sstevel@tonic-gate 	 * A pointer to a circularly linked list of page structures.
540Sstevel@tonic-gate 	 */
550Sstevel@tonic-gate 	struct page *pp_pp;
560Sstevel@tonic-gate 	uint_t pp_offset;	/* offset within first page */
570Sstevel@tonic-gate };
580Sstevel@tonic-gate 
590Sstevel@tonic-gate /*
600Sstevel@tonic-gate  * Structure to describe a physical memory address.
610Sstevel@tonic-gate  */
620Sstevel@tonic-gate struct phy_address {
630Sstevel@tonic-gate 	ulong_t	p_addr;		/* base physical address */
640Sstevel@tonic-gate 	ulong_t	p_memtype;	/* memory type */
650Sstevel@tonic-gate };
660Sstevel@tonic-gate 
670Sstevel@tonic-gate /*
68*13050Sfrank.van.der.linden@oracle.com  * Structure to describe an array DVMA addresses.
69*13050Sfrank.van.der.linden@oracle.com  * Under normal circumstances, dv_nseg will be 1.
70*13050Sfrank.van.der.linden@oracle.com  * dvs_start is always page aligned.
71*13050Sfrank.van.der.linden@oracle.com  */
72*13050Sfrank.van.der.linden@oracle.com struct dvma_address {
73*13050Sfrank.van.der.linden@oracle.com 	size_t dv_off;
74*13050Sfrank.van.der.linden@oracle.com 	size_t dv_nseg;
75*13050Sfrank.van.der.linden@oracle.com 	struct dvmaseg {
76*13050Sfrank.van.der.linden@oracle.com 		uint64_t dvs_start;
77*13050Sfrank.van.der.linden@oracle.com 		size_t dvs_len;
78*13050Sfrank.van.der.linden@oracle.com 	} *dv_seg;
79*13050Sfrank.van.der.linden@oracle.com };
80*13050Sfrank.van.der.linden@oracle.com 
81*13050Sfrank.van.der.linden@oracle.com /*
820Sstevel@tonic-gate  * A union of all of the above structures.
830Sstevel@tonic-gate  *
840Sstevel@tonic-gate  * This union describes the relationship between
850Sstevel@tonic-gate  * the kind of an address description and an object.
860Sstevel@tonic-gate  */
870Sstevel@tonic-gate typedef union {
880Sstevel@tonic-gate 	struct v_address virt_obj;	/* Some virtual address		*/
890Sstevel@tonic-gate 	struct pp_address pp_obj;	/* Some page-based address	*/
900Sstevel@tonic-gate 	struct phy_address phys_obj;	/* Some physical address	*/
91*13050Sfrank.van.der.linden@oracle.com 	struct dvma_address dvma_obj;
920Sstevel@tonic-gate } ddi_dma_aobj_t;
930Sstevel@tonic-gate 
940Sstevel@tonic-gate /*
950Sstevel@tonic-gate  * DMA object types - used to select how the object
960Sstevel@tonic-gate  * being mapped is being addressed by the IU.
970Sstevel@tonic-gate  */
980Sstevel@tonic-gate typedef enum {
990Sstevel@tonic-gate 	DMA_OTYP_VADDR = 0,	/* enforce starting value of zero */
1000Sstevel@tonic-gate 	DMA_OTYP_PAGES,
1010Sstevel@tonic-gate 	DMA_OTYP_PADDR,
102*13050Sfrank.van.der.linden@oracle.com 	DMA_OTYP_BUFVADDR,
103*13050Sfrank.van.der.linden@oracle.com 	DMA_OTYP_DVADDR
1040Sstevel@tonic-gate } ddi_dma_atyp_t;
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate /*
1070Sstevel@tonic-gate  * A compact package to describe an object that is to be mapped for DMA.
1080Sstevel@tonic-gate  */
1090Sstevel@tonic-gate typedef struct {
1100Sstevel@tonic-gate 	uint_t		dmao_size;	/* size, in bytes, of the object */
1110Sstevel@tonic-gate 	ddi_dma_atyp_t	dmao_type;	/* type of object */
1120Sstevel@tonic-gate 	ddi_dma_aobj_t	dmao_obj;	/* the object described */
1130Sstevel@tonic-gate } ddi_dma_obj_t;
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate /*
1160Sstevel@tonic-gate  * DMA addressing limits.
1170Sstevel@tonic-gate  *
1180Sstevel@tonic-gate  * This structure describes the constraints that a particular device's
1190Sstevel@tonic-gate  * DMA engine has to its parent so that the parent may correctly set
1200Sstevel@tonic-gate  * things up for a DMA mapping. Each parent may in turn modify the
1210Sstevel@tonic-gate  * constraints listed in a DMA request structure in order to describe
1220Sstevel@tonic-gate  * to its parent any changed or additional constraints. The rules
1230Sstevel@tonic-gate  * are that each parent may modify a constraint in order to further
1240Sstevel@tonic-gate  * constrain things (e.g., picking a more limited address range than
1250Sstevel@tonic-gate  * that permitted by the child), but that the parent may not ignore
1260Sstevel@tonic-gate  * a child's constraints.
1270Sstevel@tonic-gate  *
1280Sstevel@tonic-gate  * A particular constraint that we do *not* address is whether or not
1290Sstevel@tonic-gate  * a requested mapping is too large for a DMA engine's counter to
1300Sstevel@tonic-gate  * correctly track. It is still up to each driver to explicitly handle
1310Sstevel@tonic-gate  * transfers that are too large for its own hardware to deal with directly.
1320Sstevel@tonic-gate  *
1330Sstevel@tonic-gate  * The mapping routines that are cognizant of this structure will
1340Sstevel@tonic-gate  * copy any user defined limits structure if they need to modify
1350Sstevel@tonic-gate  * the fields (as alluded to above).
1360Sstevel@tonic-gate  *
1370Sstevel@tonic-gate  * A note as to how to define constraints:
1380Sstevel@tonic-gate  *
1390Sstevel@tonic-gate  * How you define the constraints for your device depends on how you
1400Sstevel@tonic-gate  * define your device. For example, you may have an SBus card with a
1410Sstevel@tonic-gate  * device on it that address only the bottom 16mb of virtual DMA space.
1420Sstevel@tonic-gate  * However, if the card also has ancillary circuitry that pulls the high 8
1430Sstevel@tonic-gate  * bits of address lines high, the more correct expression for your device
1440Sstevel@tonic-gate  * is that it address [0xff000000..0xffffffff] rather than [0..0x00ffffff].
1450Sstevel@tonic-gate  */
1460Sstevel@tonic-gate #if defined(__sparc)
1470Sstevel@tonic-gate typedef struct ddi_dma_lim {
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate 	/*
1500Sstevel@tonic-gate 	 * Low range of 32 bit addressing capability.
1510Sstevel@tonic-gate 	 */
1520Sstevel@tonic-gate 	uint_t	dlim_addr_lo;
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate 	/*
1550Sstevel@tonic-gate 	 * Upper inclusive bound of addressing capability. It is an
1560Sstevel@tonic-gate 	 * inclusive boundary limit to allow for the addressing range
1570Sstevel@tonic-gate 	 * [0..0xffffffff] to be specified in preference to [0..0].
1580Sstevel@tonic-gate 	 */
1590Sstevel@tonic-gate 	uint_t	dlim_addr_hi;
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate 	/*
1620Sstevel@tonic-gate 	 * Inclusive upper bound with which The DMA engine's counter acts as
1630Sstevel@tonic-gate 	 * a register.
1640Sstevel@tonic-gate 	 *
1650Sstevel@tonic-gate 	 * This handles the case where an upper portion of a DMA address
1660Sstevel@tonic-gate 	 * register is a latch instead of being a full 32 bit register
1670Sstevel@tonic-gate 	 * (e.g., the upper 8 bits may remain constant while the lower
1680Sstevel@tonic-gate 	 * 24 bits are the real address register).
1690Sstevel@tonic-gate 	 *
1700Sstevel@tonic-gate 	 * This essentially gives a hint about segment limitations
1710Sstevel@tonic-gate 	 * to the mapping routines.
1720Sstevel@tonic-gate 	 */
1730Sstevel@tonic-gate 	uint_t	dlim_cntr_max;
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate 	/*
1760Sstevel@tonic-gate 	 * DMA burst sizes.
1770Sstevel@tonic-gate 	 *
1780Sstevel@tonic-gate 	 * At the time of a mapping request, this tag defines the possible
1790Sstevel@tonic-gate 	 * DMA burst cycle sizes that the requestor's DMA engine can
1800Sstevel@tonic-gate 	 * emit. The format of the data is binary encoding of burst sizes
1810Sstevel@tonic-gate 	 * assumed to be powers of two. That is, if a DMA engine is capable
1820Sstevel@tonic-gate 	 * of doing 1, 2, 4 and 16 byte transfers, the encoding would be 0x17.
1830Sstevel@tonic-gate 	 *
1840Sstevel@tonic-gate 	 * As the mapping request is handled by intervening nexi, the
1850Sstevel@tonic-gate 	 * burstsizes value may be modified. Prior to enabling DMA for
1860Sstevel@tonic-gate 	 * the specific device, the driver that owns the DMA engine should
1870Sstevel@tonic-gate 	 * check (via ddi_dma_burstsizes(9F)) what the allowed burstsizes
1880Sstevel@tonic-gate 	 * have become and program their DMA engine appropriately.
1890Sstevel@tonic-gate 	 */
1900Sstevel@tonic-gate 	uint_t	dlim_burstsizes;
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate 	/*
1930Sstevel@tonic-gate 	 * Minimum effective DMA transfer size, in units of bytes.
1940Sstevel@tonic-gate 	 *
1950Sstevel@tonic-gate 	 * This value specifies the minimum effective granularity of the
1960Sstevel@tonic-gate 	 * DMA engine. It is distinct from dlim_burtsizes in that it
1970Sstevel@tonic-gate 	 * describes the minimum amount of access a DMA transfer will
1980Sstevel@tonic-gate 	 * effect. dlim_burtsizes describes in what electrical fashion
1990Sstevel@tonic-gate 	 * the DMA engine might perform its accesses, while dlim_minxfer
2000Sstevel@tonic-gate 	 * describes the minimum amount of memory that can be touched by
2010Sstevel@tonic-gate 	 * the DMA transfer.
2020Sstevel@tonic-gate 	 *
2030Sstevel@tonic-gate 	 * As the mapping request is handled by intervening nexi, the
2040Sstevel@tonic-gate 	 * dlim_minxfer value may be modifed contingent upon the presence
2050Sstevel@tonic-gate 	 * (and use) of I/O caches and DMA write buffers in between the
2060Sstevel@tonic-gate 	 * DMA engine and the object that DMA is being performed on.
2070Sstevel@tonic-gate 	 *
2080Sstevel@tonic-gate 	 */
2090Sstevel@tonic-gate 	uint_t	dlim_minxfer;
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate 	/*
2120Sstevel@tonic-gate 	 * Expected average data rate for this DMA engine
2130Sstevel@tonic-gate 	 * while transferring data.
2140Sstevel@tonic-gate 	 *
2150Sstevel@tonic-gate 	 * This is used as a hint for a number of operations that might
2160Sstevel@tonic-gate 	 * want to know the possible optimal latency requirements of this
2170Sstevel@tonic-gate 	 * device. A value of zero will be interpreted as a 'do not care'.
2180Sstevel@tonic-gate 	 */
2190Sstevel@tonic-gate 	uint_t	dlim_dmaspeed;
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate } ddi_dma_lim_t;
2220Sstevel@tonic-gate 
2230Sstevel@tonic-gate #elif defined(__x86)
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate /*
2260Sstevel@tonic-gate  * values for dlim_minxfer
2270Sstevel@tonic-gate  */
2280Sstevel@tonic-gate #define	DMA_UNIT_8  1
2290Sstevel@tonic-gate #define	DMA_UNIT_16 2
2300Sstevel@tonic-gate #define	DMA_UNIT_32 4
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate /*
2330Sstevel@tonic-gate  * Version number
2340Sstevel@tonic-gate  */
2350Sstevel@tonic-gate #define	DMALIM_VER0	((0x86000000) + 0)
2360Sstevel@tonic-gate 
2370Sstevel@tonic-gate typedef struct ddi_dma_lim {
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate 	/*
2400Sstevel@tonic-gate 	 * Low range of 32 bit addressing capability.
2410Sstevel@tonic-gate 	 */
2420Sstevel@tonic-gate 	uint_t	dlim_addr_lo;
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate 	/*
2450Sstevel@tonic-gate 	 * Upper Inclusive bound of 32 bit addressing capability.
2460Sstevel@tonic-gate 	 *
2470Sstevel@tonic-gate 	 * The ISA nexus restricts this to 0x00ffffff, since this bus has
2480Sstevel@tonic-gate 	 * only 24 address lines.  This enforces the 16 Mb address limitation.
2490Sstevel@tonic-gate 	 * The EISA nexus restricts this to 0xffffffff.
2500Sstevel@tonic-gate 	 */
2510Sstevel@tonic-gate 	uint_t	dlim_addr_hi;
2520Sstevel@tonic-gate 
2530Sstevel@tonic-gate 	/*
2540Sstevel@tonic-gate 	 * DMA engine counter not used; set to 0
2550Sstevel@tonic-gate 	 */
2560Sstevel@tonic-gate 	uint_t	dlim_cntr_max;
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate 	/*
2590Sstevel@tonic-gate 	 *  DMA burst sizes not used; set to 1
2600Sstevel@tonic-gate 	 */
2610Sstevel@tonic-gate 	uint_t	dlim_burstsizes;
2620Sstevel@tonic-gate 
2630Sstevel@tonic-gate 	/*
2640Sstevel@tonic-gate 	 * Minimum effective DMA transfer size.
2650Sstevel@tonic-gate 	 *
2660Sstevel@tonic-gate 	 * This value specifies the minimum effective granularity of the
2670Sstevel@tonic-gate 	 * DMA engine. It is distinct from dlim_burstsizes in that it
2680Sstevel@tonic-gate 	 * describes the minimum amount of access a DMA transfer will
2690Sstevel@tonic-gate 	 * effect. dlim_burstsizes describes in what electrical fashion
2700Sstevel@tonic-gate 	 * the DMA engine might perform its accesses, while dlim_minxfer
2710Sstevel@tonic-gate 	 * describes the minimum amount of memory that can be touched by
2720Sstevel@tonic-gate 	 * the DMA transfer.
2730Sstevel@tonic-gate 	 *
2740Sstevel@tonic-gate 	 * This value also implies the required address alignment.
2750Sstevel@tonic-gate 	 * The number of bytes transferred is assumed to be
2760Sstevel@tonic-gate 	 * 	dlim_minxfer * (DMA engine count)
2770Sstevel@tonic-gate 	 *
2780Sstevel@tonic-gate 	 * It should be set to DMA_UNIT_8, DMA_UNIT_16, or DMA_UNIT_32.
2790Sstevel@tonic-gate 	 */
2800Sstevel@tonic-gate 	uint_t	dlim_minxfer;
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate 	/*
2830Sstevel@tonic-gate 	 * Expected average data rate for this DMA engine
2840Sstevel@tonic-gate 	 * while transferring data.
2850Sstevel@tonic-gate 	 *
2860Sstevel@tonic-gate 	 * This is used as a hint for a number of operations that might
2870Sstevel@tonic-gate 	 * want to know the possible optimal latency requirements of this
2880Sstevel@tonic-gate 	 * device. A value of zero will be interpreted as a 'do not care'.
2890Sstevel@tonic-gate 	 */
2900Sstevel@tonic-gate 	uint_t	dlim_dmaspeed;
2910Sstevel@tonic-gate 
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate 	/*
2940Sstevel@tonic-gate 	 * Version number of this structure
2950Sstevel@tonic-gate 	 */
2960Sstevel@tonic-gate 	uint_t	dlim_version;	/* = 0x86 << 24 + 0 */
2970Sstevel@tonic-gate 
2980Sstevel@tonic-gate 	/*
2990Sstevel@tonic-gate 	 * Inclusive upper bound with which the DMA engine's Address acts as
3000Sstevel@tonic-gate 	 * a register.
3010Sstevel@tonic-gate 	 * This handles the case where an upper portion of a DMA address
3020Sstevel@tonic-gate 	 * register is a latch instead of being a full 32 bit register
3030Sstevel@tonic-gate 	 * (e.g., the upper 16 bits remain constant while the lower 16 bits
3040Sstevel@tonic-gate 	 * are incremented for each DMA transfer).
3050Sstevel@tonic-gate 	 *
3060Sstevel@tonic-gate 	 * The ISA nexus restricts only 3rd-party DMA requests to 0x0000ffff,
3070Sstevel@tonic-gate 	 * since the ISA DMA engine has a 16-bit register for low address and
3080Sstevel@tonic-gate 	 * an 8-bit latch for high address.  This enforces the first 64 Kb
3090Sstevel@tonic-gate 	 * limitation (address boundary).
3100Sstevel@tonic-gate 	 * The EISA nexus restricts only 3rd-party DMA requests to 0xffffffff.
3110Sstevel@tonic-gate 	 */
3120Sstevel@tonic-gate 	uint_t	dlim_adreg_max;
3130Sstevel@tonic-gate 
3140Sstevel@tonic-gate 	/*
3150Sstevel@tonic-gate 	 * Maximum transfer count that the DMA engine can handle.
3160Sstevel@tonic-gate 	 *
3170Sstevel@tonic-gate 	 * The ISA nexus restricts only 3rd-party DMA requests to 0x0000ffff,
3180Sstevel@tonic-gate 	 * since the ISA DMA engine has a 16-bit register for counting.
3190Sstevel@tonic-gate 	 * This enforces the other 64 Kb limitation (count size).
3200Sstevel@tonic-gate 	 * The EISA nexus restricts only 3rd-party DMA requests to 0x00ffffff,
3210Sstevel@tonic-gate 	 * since the EISA DMA engine has a 24-bit register for counting.
3220Sstevel@tonic-gate 	 *
3230Sstevel@tonic-gate 	 * This transfer count limitation is a per segment limitation.
3240Sstevel@tonic-gate 	 * It can also be used to restrict the size of segments.
3250Sstevel@tonic-gate 	 *
3260Sstevel@tonic-gate 	 * This is used as a bit mask, so it must be a power of 2, minus 1.
3270Sstevel@tonic-gate 	 */
3280Sstevel@tonic-gate 	uint_t	dlim_ctreg_max;
3290Sstevel@tonic-gate 
3300Sstevel@tonic-gate 	/*
3310Sstevel@tonic-gate 	 * Granularity of DMA transfer, in units of bytes.
3320Sstevel@tonic-gate 	 *
3330Sstevel@tonic-gate 	 * Breakup sizes must be multiples of this value.
3340Sstevel@tonic-gate 	 * If no scatter/gather capabilty is specified, then the size of
3350Sstevel@tonic-gate 	 * each DMA transfer must be a multiple of this value.
3360Sstevel@tonic-gate 	 *
3370Sstevel@tonic-gate 	 * If there is scatter/gather capability, then a single cookie cannot
3380Sstevel@tonic-gate 	 * be smaller in size than the minimum xfer value, and may be less
3390Sstevel@tonic-gate 	 * than the granularity value.  The total transfer length of the
3400Sstevel@tonic-gate 	 * scatter/gather list should be a multiple of the granularity value;
3410Sstevel@tonic-gate 	 * use dlim_sgllen to specify the length of the scatter/gather list.
3420Sstevel@tonic-gate 	 *
3430Sstevel@tonic-gate 	 * This value should be equal to the sector size of the device.
3440Sstevel@tonic-gate 	 */
3450Sstevel@tonic-gate 	uint_t	dlim_granular;
3460Sstevel@tonic-gate 
3470Sstevel@tonic-gate 	/*
3480Sstevel@tonic-gate 	 * Length of scatter/gather list
3490Sstevel@tonic-gate 	 *
3500Sstevel@tonic-gate 	 * This value specifies the number of segments or cookies that a DMA
3510Sstevel@tonic-gate 	 * engine can consume in one i/o request to the device.  For 3rd-party
3520Sstevel@tonic-gate 	 * DMA that uses the bus nexus this should be set to 1.  Devices with
3530Sstevel@tonic-gate 	 * 1st-party DMA capability should specify the number of entries in
3540Sstevel@tonic-gate 	 * its scatter/gather list.  The breakup routine will ensure that each
3550Sstevel@tonic-gate 	 * group of dlim_sgllen cookies (within a DMA window) will have a
3560Sstevel@tonic-gate 	 * total transfer length that is a multiple of dlim_granular.
3570Sstevel@tonic-gate 	 *
3580Sstevel@tonic-gate 	 *	< 0  :  tbd
3590Sstevel@tonic-gate 	 *	= 0  :  breakup is for PIO.
3600Sstevel@tonic-gate 	 *	= 1  :  breakup is for DMA engine with no scatter/gather
3610Sstevel@tonic-gate 	 *		capability.
3620Sstevel@tonic-gate 	 *	>= 2 :  breakup is for DMA engine with scatter/gather
3630Sstevel@tonic-gate 	 *		capability; value is max number of entries in list.
3640Sstevel@tonic-gate 	 *
3650Sstevel@tonic-gate 	 * Note that this list length is not dependent on the DMA window
3660Sstevel@tonic-gate 	 * size.  The size of the DMA window is based on resources consumed,
3670Sstevel@tonic-gate 	 * such as intermediate buffers.  Several s/g lists may exist within
3680Sstevel@tonic-gate 	 * a window.  But the end of a window does imply the end of the s/g
3690Sstevel@tonic-gate 	 * list.
3700Sstevel@tonic-gate 	 */
3710Sstevel@tonic-gate 	short	dlim_sgllen;
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate 	/*
3740Sstevel@tonic-gate 	 * Size of device i/o request
3750Sstevel@tonic-gate 	 *
3760Sstevel@tonic-gate 	 * This value indicates the maximum number of bytes the device
3770Sstevel@tonic-gate 	 * can transmit/receive for one i/o command.  This limitation is
3780Sstevel@tonic-gate 	 * significant ony if it is less than (dlim_ctreg_max * dlim_sgllen).
3790Sstevel@tonic-gate 	 */
3800Sstevel@tonic-gate 	uint_t	dlim_reqsize;
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate } ddi_dma_lim_t;
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate #else
3850Sstevel@tonic-gate #error "struct ddi_dma_lim not defined for this architecture"
3860Sstevel@tonic-gate #endif	/* defined(__sparc) */
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate /*
3890Sstevel@tonic-gate  * Flags definition for dma_attr_flags
3900Sstevel@tonic-gate  */
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate /*
3930Sstevel@tonic-gate  * return physical DMA address on platforms
3940Sstevel@tonic-gate  * which support DVMA
3950Sstevel@tonic-gate  */
3960Sstevel@tonic-gate #define	DDI_DMA_FORCE_PHYSICAL		0x0100
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate /*
3990Sstevel@tonic-gate  * An error will be flagged for DMA data path errors
4000Sstevel@tonic-gate  */
4010Sstevel@tonic-gate #define	DDI_DMA_FLAGERR			0x200
4020Sstevel@tonic-gate 
4031772Sjl139090 /*
4041772Sjl139090  * Enable relaxed ordering
4051772Sjl139090  */
4061772Sjl139090 #define	DDI_DMA_RELAXED_ORDERING	0x400
4071772Sjl139090 
40811793SMark.Johnson@Sun.COM 
40911793SMark.Johnson@Sun.COM /*
41011793SMark.Johnson@Sun.COM  * Consolidation private x86 only flag which will cause a bounce buffer
41111793SMark.Johnson@Sun.COM  * (paddr < dma_attr_seg) to be used if the buffer passed to the bind
41211793SMark.Johnson@Sun.COM  * operation contains pages both above and below dma_attr_seg. If this flag
41311793SMark.Johnson@Sun.COM  * is set, dma_attr_seg must be <= dma_attr_addr_hi.
41411793SMark.Johnson@Sun.COM  */
41511793SMark.Johnson@Sun.COM #define	_DDI_DMA_BOUNCE_ON_SEG		0x8000
41611793SMark.Johnson@Sun.COM 
4170Sstevel@tonic-gate #define	DMA_ATTR_V0		0
4180Sstevel@tonic-gate #define	DMA_ATTR_VERSION	DMA_ATTR_V0
4190Sstevel@tonic-gate 
4200Sstevel@tonic-gate typedef struct ddi_dma_attr {
4210Sstevel@tonic-gate 	uint_t		dma_attr_version;	/* version number */
4220Sstevel@tonic-gate 	uint64_t	dma_attr_addr_lo;	/* low DMA address range */
4230Sstevel@tonic-gate 	uint64_t	dma_attr_addr_hi;	/* high DMA address range */
4240Sstevel@tonic-gate 	uint64_t	dma_attr_count_max;	/* DMA counter register */
4250Sstevel@tonic-gate 	uint64_t	dma_attr_align;		/* DMA address alignment */
4260Sstevel@tonic-gate 	uint_t		dma_attr_burstsizes;	/* DMA burstsizes */
4270Sstevel@tonic-gate 	uint32_t	dma_attr_minxfer;	/* min effective DMA size */
4280Sstevel@tonic-gate 	uint64_t 	dma_attr_maxxfer;	/* max DMA xfer size */
4290Sstevel@tonic-gate 	uint64_t 	dma_attr_seg;		/* segment boundary */
4300Sstevel@tonic-gate 	int		dma_attr_sgllen;	/* s/g length */
4310Sstevel@tonic-gate 	uint32_t	dma_attr_granular;	/* granularity of device */
4320Sstevel@tonic-gate 	uint_t		dma_attr_flags;		/* Bus specific DMA flags */
4330Sstevel@tonic-gate } ddi_dma_attr_t;
4340Sstevel@tonic-gate 
4350Sstevel@tonic-gate /*
4360Sstevel@tonic-gate  * Handy macro to set a maximum bit value (should be elsewhere)
4370Sstevel@tonic-gate  *
4380Sstevel@tonic-gate  * Clear off all bits lower then 'mybit' in val; if there are no
4390Sstevel@tonic-gate  * bits higher than or equal to mybit in val then set mybit. Assumes
4400Sstevel@tonic-gate  * mybit equals some power of 2 and is not zero.
4410Sstevel@tonic-gate  */
4420Sstevel@tonic-gate #define	maxbit(val, mybit)	\
4430Sstevel@tonic-gate 	((val) & ~((mybit)-1)) | ((((val) & ~((mybit)-1)) == 0) ? (mybit) : 0)
4440Sstevel@tonic-gate 
4450Sstevel@tonic-gate /*
4460Sstevel@tonic-gate  * Handy macro to set a minimum bit value (should be elsewhere)
4470Sstevel@tonic-gate  *
4480Sstevel@tonic-gate  * Clear off all bits higher then 'mybit' in val; if there are no
4490Sstevel@tonic-gate  * bits lower than or equal to mybit in val then set mybit. Assumes
4500Sstevel@tonic-gate  * mybit equals some pow2 and is not zero.
4510Sstevel@tonic-gate  */
4520Sstevel@tonic-gate #define	minbit(val, mybit)	\
4530Sstevel@tonic-gate 	(((val)&((mybit)|((mybit)-1))) | \
4540Sstevel@tonic-gate 	((((val) & ((mybit)-1)) == 0) ? (mybit) : 0))
4550Sstevel@tonic-gate 
4560Sstevel@tonic-gate /*
4570Sstevel@tonic-gate  * Structure of a request to map an object for DMA.
4580Sstevel@tonic-gate  */
4590Sstevel@tonic-gate typedef struct ddi_dma_req {
4600Sstevel@tonic-gate 	/*
4610Sstevel@tonic-gate 	 * Caller's DMA engine constraints.
4620Sstevel@tonic-gate 	 *
4630Sstevel@tonic-gate 	 * If there are no particular constraints to the caller's DMA
4640Sstevel@tonic-gate 	 * engine, this field may be set to NULL. The implementation DMA
4650Sstevel@tonic-gate 	 * setup functions will then select a set of standard beginning
4660Sstevel@tonic-gate 	 * constraints.
4670Sstevel@tonic-gate 	 *
4680Sstevel@tonic-gate 	 * In either case, as the mapping proceeds, the initial DMA
4690Sstevel@tonic-gate 	 * constraints may become more restrictive as each intervening
4700Sstevel@tonic-gate 	 * nexus might add further restrictions.
4710Sstevel@tonic-gate 	 */
4720Sstevel@tonic-gate 	ddi_dma_lim_t	*dmar_limits;
4730Sstevel@tonic-gate 
4740Sstevel@tonic-gate 	/*
4750Sstevel@tonic-gate 	 * Contains the information passed to the DMA mapping allocation
4760Sstevel@tonic-gate 	 * routine(s).
4770Sstevel@tonic-gate 	 */
4780Sstevel@tonic-gate 	uint_t		dmar_flags;
4790Sstevel@tonic-gate 
4800Sstevel@tonic-gate 	/*
4810Sstevel@tonic-gate 	 * Callback function. A caller of the DMA mapping functions must
4820Sstevel@tonic-gate 	 * specify by filling in this field whether the allocation routines
4830Sstevel@tonic-gate 	 * can sleep awaiting mapping resources, must *not* sleep awaiting
4840Sstevel@tonic-gate 	 * resources, or may *not* sleep awaiting any resources and must
4850Sstevel@tonic-gate 	 * call the function specified by dmar_fp with the the argument
4860Sstevel@tonic-gate 	 * dmar_arg when resources might have become available at a future
4870Sstevel@tonic-gate 	 * time.
4880Sstevel@tonic-gate 	 */
4890Sstevel@tonic-gate 	int		(*dmar_fp)();
4900Sstevel@tonic-gate 
4910Sstevel@tonic-gate 	caddr_t		dmar_arg;	/* Callback function argument */
4920Sstevel@tonic-gate 
4930Sstevel@tonic-gate 	/*
4940Sstevel@tonic-gate 	 * Description of the object to be mapped for DMA.
4950Sstevel@tonic-gate 	 * Must be last in this structure in case that the
4960Sstevel@tonic-gate 	 * union ddi_dma_obj_t changes in the future.
4970Sstevel@tonic-gate 	 */
4980Sstevel@tonic-gate 	ddi_dma_obj_t	dmar_object;
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate } ddi_dma_req_t;
5010Sstevel@tonic-gate 
5020Sstevel@tonic-gate /*
5030Sstevel@tonic-gate  * Defines for the DMA mapping allocation functions
5040Sstevel@tonic-gate  *
5050Sstevel@tonic-gate  * If a DMA callback funtion is set to anything other than the following
5060Sstevel@tonic-gate  * defines then it is assumed that one wishes a callback and is providing
5070Sstevel@tonic-gate  * a function address.
5080Sstevel@tonic-gate  */
5090Sstevel@tonic-gate #ifdef __STDC__
5100Sstevel@tonic-gate #define	DDI_DMA_DONTWAIT	((int (*)(caddr_t))0)
5110Sstevel@tonic-gate #define	DDI_DMA_SLEEP		((int (*)(caddr_t))1)
5120Sstevel@tonic-gate #else
5130Sstevel@tonic-gate #define	DDI_DMA_DONTWAIT	((int (*)())0)
5140Sstevel@tonic-gate #define	DDI_DMA_SLEEP		((int (*)())1)
5150Sstevel@tonic-gate #endif
5160Sstevel@tonic-gate 
5170Sstevel@tonic-gate /*
5180Sstevel@tonic-gate  * Return values from callback functions.
5190Sstevel@tonic-gate  */
5200Sstevel@tonic-gate #define	DDI_DMA_CALLBACK_RUNOUT	0
5210Sstevel@tonic-gate #define	DDI_DMA_CALLBACK_DONE	1
5220Sstevel@tonic-gate 
5230Sstevel@tonic-gate /*
5240Sstevel@tonic-gate  * Flag definitions for the allocation functions.
5250Sstevel@tonic-gate  */
5260Sstevel@tonic-gate #define	DDI_DMA_WRITE		0x0001	/* Direction memory --> IO 	*/
5270Sstevel@tonic-gate #define	DDI_DMA_READ		0x0002	/* Direction IO --> memory	*/
5280Sstevel@tonic-gate #define	DDI_DMA_RDWR		(DDI_DMA_READ | DDI_DMA_WRITE)
5290Sstevel@tonic-gate 
5300Sstevel@tonic-gate /*
5310Sstevel@tonic-gate  * If possible, establish a MMU redzone after the mapping (to protect
5320Sstevel@tonic-gate  * against cheap DMA hardware that might get out of control).
5330Sstevel@tonic-gate  */
5340Sstevel@tonic-gate #define	DDI_DMA_REDZONE		0x0004
5350Sstevel@tonic-gate 
5360Sstevel@tonic-gate /*
5370Sstevel@tonic-gate  * A partial allocation is allowed. That is, if the size of the object
5380Sstevel@tonic-gate  * exceeds the mapping resources available, only map a portion of the
5390Sstevel@tonic-gate  * object and return status indicating that this took place. The caller
5400Sstevel@tonic-gate  * can use the functions ddi_dma_numwin(9F) and ddi_dma_getwin(9F) to
5410Sstevel@tonic-gate  * change, at a later point, the actual mapped portion of the object.
5420Sstevel@tonic-gate  *
5430Sstevel@tonic-gate  * The mapped portion begins at offset 0 of the object.
5440Sstevel@tonic-gate  *
5450Sstevel@tonic-gate  */
5460Sstevel@tonic-gate #define	DDI_DMA_PARTIAL		0x0008
5470Sstevel@tonic-gate 
5480Sstevel@tonic-gate /*
5490Sstevel@tonic-gate  * Map the object for byte consistent access. Note that explicit
5500Sstevel@tonic-gate  * synchronization (via ddi_dma_sync(9F)) will still be required.
5510Sstevel@tonic-gate  * Consider this flag to be a hint to the mapping routines as to
5520Sstevel@tonic-gate  * the intended use of the mapping.
5530Sstevel@tonic-gate  *
5540Sstevel@tonic-gate  * Normal data transfers can be usually consider to use 'streaming'
5550Sstevel@tonic-gate  * modes of operations. They start at a specific point, transfer a
5560Sstevel@tonic-gate  * fairly large amount of data sequentially, and then stop (usually
5570Sstevel@tonic-gate  * on a well aligned boundary).
5580Sstevel@tonic-gate  *
5590Sstevel@tonic-gate  * Control mode data transfers (for memory resident device control blocks,
5600Sstevel@tonic-gate  * e.g., ethernet message descriptors) do not access memory in such
5610Sstevel@tonic-gate  * a streaming sequential fashion. Instead, they tend to modify a few
5620Sstevel@tonic-gate  * words or bytes, move around and maybe modify a few more.
5630Sstevel@tonic-gate  *
5640Sstevel@tonic-gate  * There are many machine implementations that make this difficult to
5650Sstevel@tonic-gate  * control in a generic and seamless fashion. Therefore, explicit synch-
5660Sstevel@tonic-gate  * ronization steps (via ddi_dma_sync(9F)) are still required (even if you
5670Sstevel@tonic-gate  * ask for a byte-consistent mapping) in order to make the view of the
5680Sstevel@tonic-gate  * memory object shared between a CPU and a DMA master in consistent.
5690Sstevel@tonic-gate  * However, judicious use of this flag can give sufficient hints to
5700Sstevel@tonic-gate  * the mapping routines to attempt to pick the most efficacious mapping
5710Sstevel@tonic-gate  * such that the synchronization steps are as efficient as possible.
5720Sstevel@tonic-gate  *
5730Sstevel@tonic-gate  */
5740Sstevel@tonic-gate #define	DDI_DMA_CONSISTENT	0x0010
5750Sstevel@tonic-gate 
5760Sstevel@tonic-gate /*
5770Sstevel@tonic-gate  * Some DMA mappings have to be 'exclusive' access.
5780Sstevel@tonic-gate  */
5790Sstevel@tonic-gate #define	DDI_DMA_EXCLUSIVE	0x0020
5800Sstevel@tonic-gate 
5810Sstevel@tonic-gate /*
5820Sstevel@tonic-gate  * Sequential, unidirectional, block-sized and block aligned transfers
5830Sstevel@tonic-gate  */
5840Sstevel@tonic-gate #define	DDI_DMA_STREAMING	0x0040
5850Sstevel@tonic-gate 
5860Sstevel@tonic-gate /*
5870Sstevel@tonic-gate  * Support for 64-bit SBus devices
5880Sstevel@tonic-gate  */
5890Sstevel@tonic-gate #define	DDI_DMA_SBUS_64BIT	0x2000
5900Sstevel@tonic-gate 
5910Sstevel@tonic-gate /*
5920Sstevel@tonic-gate  * Return values from the mapping allocation functions.
5930Sstevel@tonic-gate  */
5940Sstevel@tonic-gate 
5950Sstevel@tonic-gate /*
5960Sstevel@tonic-gate  * succeeded in satisfying request
5970Sstevel@tonic-gate  */
5980Sstevel@tonic-gate #define	DDI_DMA_MAPPED		0
5990Sstevel@tonic-gate 
6000Sstevel@tonic-gate /*
6010Sstevel@tonic-gate  * Mapping is legitimate (for advisory calls).
6020Sstevel@tonic-gate  */
6030Sstevel@tonic-gate #define	DDI_DMA_MAPOK		0
6040Sstevel@tonic-gate 
6050Sstevel@tonic-gate /*
6060Sstevel@tonic-gate  * Succeeded in mapping a portion of the request.
6070Sstevel@tonic-gate  */
6080Sstevel@tonic-gate #define	DDI_DMA_PARTIAL_MAP	1
6090Sstevel@tonic-gate 
6100Sstevel@tonic-gate /*
6110Sstevel@tonic-gate  * indicates end of window/segment list
6120Sstevel@tonic-gate  */
6130Sstevel@tonic-gate #define	DDI_DMA_DONE		2
6140Sstevel@tonic-gate 
6150Sstevel@tonic-gate /*
6160Sstevel@tonic-gate  * No resources to map request.
6170Sstevel@tonic-gate  */
6180Sstevel@tonic-gate #define	DDI_DMA_NORESOURCES	-1
6190Sstevel@tonic-gate 
6200Sstevel@tonic-gate /*
6210Sstevel@tonic-gate  * Can't establish a mapping to the specified object
6220Sstevel@tonic-gate  * (no specific reason).
6230Sstevel@tonic-gate  */
6240Sstevel@tonic-gate #define	DDI_DMA_NOMAPPING	-2
6250Sstevel@tonic-gate 
6260Sstevel@tonic-gate /*
6270Sstevel@tonic-gate  * The request is too big to be mapped.
6280Sstevel@tonic-gate  */
6290Sstevel@tonic-gate #define	DDI_DMA_TOOBIG		-3
6300Sstevel@tonic-gate 
6310Sstevel@tonic-gate /*
6320Sstevel@tonic-gate  * The request is too small to be mapped.
6330Sstevel@tonic-gate  */
6340Sstevel@tonic-gate #define	DDI_DMA_TOOSMALL	-4
6350Sstevel@tonic-gate 
6360Sstevel@tonic-gate /*
6370Sstevel@tonic-gate  * The request cannot be mapped because the object
6380Sstevel@tonic-gate  * is locked against mapping by another DMA master.
6390Sstevel@tonic-gate  */
6400Sstevel@tonic-gate #define	DDI_DMA_LOCKED		-5
6410Sstevel@tonic-gate 
6420Sstevel@tonic-gate /*
6430Sstevel@tonic-gate  * The request cannot be mapped because the limits
6440Sstevel@tonic-gate  * structure has bogus values.
6450Sstevel@tonic-gate  */
6460Sstevel@tonic-gate #define	DDI_DMA_BADLIMITS	-6
6470Sstevel@tonic-gate 
6480Sstevel@tonic-gate /*
6490Sstevel@tonic-gate  * the segment/window pointer is stale
6500Sstevel@tonic-gate  */
6510Sstevel@tonic-gate #define	DDI_DMA_STALE		-7
6520Sstevel@tonic-gate 
6530Sstevel@tonic-gate /*
6540Sstevel@tonic-gate  * The system can't allocate DMA resources using
6550Sstevel@tonic-gate  * the given DMA attributes
6560Sstevel@tonic-gate  */
6570Sstevel@tonic-gate #define	DDI_DMA_BADATTR		-8
6580Sstevel@tonic-gate 
6590Sstevel@tonic-gate /*
6600Sstevel@tonic-gate  * A DMA handle is already used for a DMA
6610Sstevel@tonic-gate  */
6620Sstevel@tonic-gate #define	DDI_DMA_INUSE		-9
6630Sstevel@tonic-gate 
66411600SVikram.Hegde@Sun.COM 
66511600SVikram.Hegde@Sun.COM /*
66611600SVikram.Hegde@Sun.COM  * DVMA disabled or not supported. use physical DMA
66711600SVikram.Hegde@Sun.COM  */
66811600SVikram.Hegde@Sun.COM #define	DDI_DMA_USE_PHYSICAL		-10
66911600SVikram.Hegde@Sun.COM 
67011600SVikram.Hegde@Sun.COM 
6710Sstevel@tonic-gate /*
6720Sstevel@tonic-gate  * In order for the access to a memory object to be consistent
6730Sstevel@tonic-gate  * between a device and a CPU, the function ddi_dma_sync(9F)
6740Sstevel@tonic-gate  * must be called upon the DMA handle. The following flags
6750Sstevel@tonic-gate  * define whose view of the object should be made consistent.
6760Sstevel@tonic-gate  * There are different flags here because on different machines
6770Sstevel@tonic-gate  * there are definite performance implications of how long
6780Sstevel@tonic-gate  * such synchronization takes.
6790Sstevel@tonic-gate  *
6800Sstevel@tonic-gate  * DDI_DMA_SYNC_FORDEV makes all device references to the object
6810Sstevel@tonic-gate  * mapped by the DMA handle up to date. It should be used by a
6820Sstevel@tonic-gate  * driver after a cpu modifies the memory object (over the range
6830Sstevel@tonic-gate  * specified by the other arguments to the ddi_dma_sync(9F) call).
6840Sstevel@tonic-gate  *
6850Sstevel@tonic-gate  * DDI_DMA_SYNC_FORCPU makes all cpu references to the object
6860Sstevel@tonic-gate  * mapped by the DMA handle up to date. It should be used
6870Sstevel@tonic-gate  * by a driver after the receipt of data from the device to
6880Sstevel@tonic-gate  * the memory object is done (over the range specified by
6890Sstevel@tonic-gate  * the other arguments to the ddi_dma_sync(9F) call).
6900Sstevel@tonic-gate  *
6910Sstevel@tonic-gate  * If the only mapping that concerns the driver is one for the
6920Sstevel@tonic-gate  * kernel (such as memory allocated by ddi_iopb_alloc(9F)), the
6930Sstevel@tonic-gate  * flag DDI_DMA_SYNC_FORKERNEL can be used. This is a hint to the
6940Sstevel@tonic-gate  * system that if it can synchronize the kernel's view faster
6950Sstevel@tonic-gate  * that the CPU's view, it can do so, otherwise it acts the
6960Sstevel@tonic-gate  * same as DDI_DMA_SYNC_FORCPU. DDI_DMA_SYNC_FORKERNEL might
6970Sstevel@tonic-gate  * speed up the synchronization of kernel mappings in case of
6980Sstevel@tonic-gate  * non IO-coherent CPU caches.
6990Sstevel@tonic-gate  */
7000Sstevel@tonic-gate #define	DDI_DMA_SYNC_FORDEV	0x0
7010Sstevel@tonic-gate #define	DDI_DMA_SYNC_FORCPU	0x1
7020Sstevel@tonic-gate #define	DDI_DMA_SYNC_FORKERNEL	0x2
7030Sstevel@tonic-gate 
7040Sstevel@tonic-gate /*
7050Sstevel@tonic-gate  * Bus nexus control functions for DMA
7060Sstevel@tonic-gate  */
7070Sstevel@tonic-gate 
7080Sstevel@tonic-gate /*
7090Sstevel@tonic-gate  * Control operations, defined here so that devops.h can be included
7100Sstevel@tonic-gate  * by drivers without having to include a specific SYSDDI implementation
7110Sstevel@tonic-gate  * header file.
7120Sstevel@tonic-gate  */
7130Sstevel@tonic-gate 
7140Sstevel@tonic-gate enum ddi_dma_ctlops {
7150Sstevel@tonic-gate 	DDI_DMA_FREE,		/* free reference to object		*/
7160Sstevel@tonic-gate 	DDI_DMA_SYNC,		/* synchronize cache references		*/
7170Sstevel@tonic-gate 	DDI_DMA_HTOC,		/* return DMA cookie for handle		*/
7180Sstevel@tonic-gate 	DDI_DMA_KVADDR,		/* return kernel virtual address	*/
7190Sstevel@tonic-gate 	DDI_DMA_MOVWIN,		/* change mapped DMA window on object	*/
7200Sstevel@tonic-gate 	DDI_DMA_REPWIN,		/* report current window on DMA object	*/
7210Sstevel@tonic-gate 	DDI_DMA_GETERR,		/* report any post-transfer DMA errors	*/
7220Sstevel@tonic-gate 	DDI_DMA_COFF,		/* convert a DMA cookie to an offset	*/
7230Sstevel@tonic-gate 	DDI_DMA_NEXTWIN,	/* get next window within object	*/
7240Sstevel@tonic-gate 	DDI_DMA_NEXTSEG,	/* get next segment within window	*/
7250Sstevel@tonic-gate 	DDI_DMA_SEGTOC,		/* return segment DMA cookie		*/
7260Sstevel@tonic-gate 	DDI_DMA_RESERVE,	/* reserve some DVMA range		*/
7270Sstevel@tonic-gate 	DDI_DMA_RELEASE,	/* free preallocated DVMA range		*/
7280Sstevel@tonic-gate 	DDI_DMA_RESETH,		/* reset next cookie ptr in handle	*/
7290Sstevel@tonic-gate 	DDI_DMA_CKSYNC,		/* sync intermediate buffer to cookies	*/
7300Sstevel@tonic-gate 	DDI_DMA_IOPB_ALLOC,	/* get contiguous DMA-able memory	*/
7310Sstevel@tonic-gate 	DDI_DMA_IOPB_FREE,	/* return contiguous DMA-able memory	*/
7320Sstevel@tonic-gate 	DDI_DMA_SMEM_ALLOC,	/* get contiguous DMA-able memory	*/
7330Sstevel@tonic-gate 	DDI_DMA_SMEM_FREE,	/* return contiguous DMA-able memory	*/
7340Sstevel@tonic-gate 	DDI_DMA_SET_SBUS64,	/* 64 bit SBus support			*/
7350Sstevel@tonic-gate 	DDI_DMA_REMAP,		/* remap DMA buffers after relocation	*/
7360Sstevel@tonic-gate 
7370Sstevel@tonic-gate 		/*
7380Sstevel@tonic-gate 		 * control ops for DMA engine on motherboard
7390Sstevel@tonic-gate 		 */
7400Sstevel@tonic-gate 	DDI_DMA_E_ACQUIRE,	/* get channel for exclusive use	*/
7410Sstevel@tonic-gate 	DDI_DMA_E_FREE,		/* release channel			*/
7420Sstevel@tonic-gate 	DDI_DMA_E_1STPTY,	/* setup channel for 1st party DMA	*/
7430Sstevel@tonic-gate 	DDI_DMA_E_GETCB,	/* get control block for DMA engine	*/
7440Sstevel@tonic-gate 	DDI_DMA_E_FREECB,	/* free control blk for DMA engine	*/
7450Sstevel@tonic-gate 	DDI_DMA_E_PROG,		/* program channel of DMA engine	*/
7460Sstevel@tonic-gate 	DDI_DMA_E_SWSETUP,	/* setup channel for software control	*/
7470Sstevel@tonic-gate 	DDI_DMA_E_SWSTART,	/* software operation of DMA channel	*/
7480Sstevel@tonic-gate 	DDI_DMA_E_ENABLE,	/* enable channel of DMA engine		*/
7490Sstevel@tonic-gate 	DDI_DMA_E_STOP,		/* stop a channel of DMA engine		*/
7500Sstevel@tonic-gate 	DDI_DMA_E_DISABLE,	/* disable channel of DMA engine	*/
7510Sstevel@tonic-gate 	DDI_DMA_E_GETCNT,	/* get remaining xfer count		*/
7520Sstevel@tonic-gate 	DDI_DMA_E_GETLIM,	/* get DMA engine limits		*/
7530Sstevel@tonic-gate 	DDI_DMA_E_GETATTR	/* get DMA engine attributes		*/
7540Sstevel@tonic-gate };
7550Sstevel@tonic-gate 
7561900Seota /*
7571900Seota  * Cache attribute flags:
7581900Seota  *
7591900Seota  * IOMEM_DATA_CACHED
7601900Seota  *   The CPU can cache the data it fetches and push it to memory at a later
7611900Seota  *   time. This is the default attribute and used if no cache attributes is
7621900Seota  *   specified.
7631900Seota  *
7641900Seota  * IOMEM_DATA_UC_WR_COMBINE
7651900Seota  *   The CPU never caches the data but writes may occur out of order or be
7661900Seota  *   combined. It implies re-ordering.
7671900Seota  *
7681900Seota  * IOMEM_DATA_UNCACHED
7691900Seota  *   The CPU never caches the data and has uncacheable access to memory.
7701900Seota  *   It also implies strict ordering.
7711900Seota  *
7721900Seota  * The cache attributes are mutually exclusive, and any combination of the
7731900Seota  * values leads to a failure. On the sparc architecture, only IOMEM_DATA_CACHED
7741900Seota  * is meaningful, but others lead to a failure.
7751900Seota  */
7761900Seota #define	IOMEM_DATA_CACHED		0x10000 /* data is cached */
7771900Seota #define	IOMEM_DATA_UC_WR_COMBINE	0x20000 /* data is not cached, but */
7781900Seota 						/* writes might be combined */
7791900Seota #define	IOMEM_DATA_UNCACHED		0x40000 /* data is not cached. */
7801900Seota #define	IOMEM_DATA_MASK			0xF0000	/* cache attrs mask */
7811900Seota 
7821900Seota /*
7831900Seota  * Check if either uncacheable or write-combining specified. (those flags are
7841900Seota  * mutually exclusive) This macro is used to override hat attributes if either
7851900Seota  * one is set.
7861900Seota  */
7871900Seota #define	OVERRIDE_CACHE_ATTR(attr)	\
7881900Seota 	(attr & (IOMEM_DATA_UNCACHED | IOMEM_DATA_UC_WR_COMBINE))
7891900Seota 
7901900Seota /*
7911900Seota  * Get the cache attribute from flags. If there is no attributes,
7921900Seota  * return IOMEM_DATA_CACHED (default attribute).
7931900Seota  */
7941900Seota #define	IOMEM_CACHE_ATTR(flags)	\
7951900Seota 	((flags & IOMEM_DATA_MASK) ? (flags & IOMEM_DATA_MASK) : \
7961900Seota 	    IOMEM_DATA_CACHED)
7971900Seota 
7980Sstevel@tonic-gate #ifdef	__cplusplus
7990Sstevel@tonic-gate }
8000Sstevel@tonic-gate #endif
8010Sstevel@tonic-gate 
8020Sstevel@tonic-gate #endif	/* _SYS_DDIDMAREQ_H */
803