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 525cf1a30Sjl139090 * Common Development and Distribution License (the "License"). 625cf1a30Sjl139090 * 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 */ 217c478bd9Sstevel@tonic-gate /* 223a634bfcSVikram Hegde * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_DDIDMAREQ_H 277c478bd9Sstevel@tonic-gate #define _SYS_DDIDMAREQ_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * Memory Objects 357c478bd9Sstevel@tonic-gate * 367c478bd9Sstevel@tonic-gate * Definitions of structures that can describe 377c478bd9Sstevel@tonic-gate * an object that can be mapped for DMA. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* 417c478bd9Sstevel@tonic-gate * Structure describing a virtual address 427c478bd9Sstevel@tonic-gate */ 437c478bd9Sstevel@tonic-gate struct v_address { 447c478bd9Sstevel@tonic-gate caddr_t v_addr; /* base virtual address */ 457c478bd9Sstevel@tonic-gate struct as *v_as; /* pointer to address space */ 467c478bd9Sstevel@tonic-gate void *v_priv; /* priv data for shadow I/O */ 477c478bd9Sstevel@tonic-gate }; 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * Structure describing a page-based address 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate struct pp_address { 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * A pointer to a circularly linked list of page structures. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate struct page *pp_pp; 577c478bd9Sstevel@tonic-gate uint_t pp_offset; /* offset within first page */ 587c478bd9Sstevel@tonic-gate }; 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate /* 617c478bd9Sstevel@tonic-gate * Structure to describe a physical memory address. 627c478bd9Sstevel@tonic-gate */ 637c478bd9Sstevel@tonic-gate struct phy_address { 647c478bd9Sstevel@tonic-gate ulong_t p_addr; /* base physical address */ 657c478bd9Sstevel@tonic-gate ulong_t p_memtype; /* memory type */ 667c478bd9Sstevel@tonic-gate }; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * A union of all of the above structures. 707c478bd9Sstevel@tonic-gate * 717c478bd9Sstevel@tonic-gate * This union describes the relationship between 727c478bd9Sstevel@tonic-gate * the kind of an address description and an object. 737c478bd9Sstevel@tonic-gate */ 747c478bd9Sstevel@tonic-gate typedef union { 757c478bd9Sstevel@tonic-gate struct v_address virt_obj; /* Some virtual address */ 767c478bd9Sstevel@tonic-gate struct pp_address pp_obj; /* Some page-based address */ 777c478bd9Sstevel@tonic-gate struct phy_address phys_obj; /* Some physical address */ 787c478bd9Sstevel@tonic-gate } ddi_dma_aobj_t; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* 817c478bd9Sstevel@tonic-gate * DMA object types - used to select how the object 827c478bd9Sstevel@tonic-gate * being mapped is being addressed by the IU. 837c478bd9Sstevel@tonic-gate */ 847c478bd9Sstevel@tonic-gate typedef enum { 857c478bd9Sstevel@tonic-gate DMA_OTYP_VADDR = 0, /* enforce starting value of zero */ 867c478bd9Sstevel@tonic-gate DMA_OTYP_PAGES, 877c478bd9Sstevel@tonic-gate DMA_OTYP_PADDR, 887c478bd9Sstevel@tonic-gate DMA_OTYP_BUFVADDR 897c478bd9Sstevel@tonic-gate } ddi_dma_atyp_t; 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * A compact package to describe an object that is to be mapped for DMA. 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate typedef struct { 957c478bd9Sstevel@tonic-gate uint_t dmao_size; /* size, in bytes, of the object */ 967c478bd9Sstevel@tonic-gate ddi_dma_atyp_t dmao_type; /* type of object */ 977c478bd9Sstevel@tonic-gate ddi_dma_aobj_t dmao_obj; /* the object described */ 987c478bd9Sstevel@tonic-gate } ddi_dma_obj_t; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* 1017c478bd9Sstevel@tonic-gate * DMA addressing limits. 1027c478bd9Sstevel@tonic-gate * 1037c478bd9Sstevel@tonic-gate * This structure describes the constraints that a particular device's 1047c478bd9Sstevel@tonic-gate * DMA engine has to its parent so that the parent may correctly set 1057c478bd9Sstevel@tonic-gate * things up for a DMA mapping. Each parent may in turn modify the 1067c478bd9Sstevel@tonic-gate * constraints listed in a DMA request structure in order to describe 1077c478bd9Sstevel@tonic-gate * to its parent any changed or additional constraints. The rules 1087c478bd9Sstevel@tonic-gate * are that each parent may modify a constraint in order to further 1097c478bd9Sstevel@tonic-gate * constrain things (e.g., picking a more limited address range than 1107c478bd9Sstevel@tonic-gate * that permitted by the child), but that the parent may not ignore 1117c478bd9Sstevel@tonic-gate * a child's constraints. 1127c478bd9Sstevel@tonic-gate * 1137c478bd9Sstevel@tonic-gate * A particular constraint that we do *not* address is whether or not 1147c478bd9Sstevel@tonic-gate * a requested mapping is too large for a DMA engine's counter to 1157c478bd9Sstevel@tonic-gate * correctly track. It is still up to each driver to explicitly handle 1167c478bd9Sstevel@tonic-gate * transfers that are too large for its own hardware to deal with directly. 1177c478bd9Sstevel@tonic-gate * 1187c478bd9Sstevel@tonic-gate * The mapping routines that are cognizant of this structure will 1197c478bd9Sstevel@tonic-gate * copy any user defined limits structure if they need to modify 1207c478bd9Sstevel@tonic-gate * the fields (as alluded to above). 1217c478bd9Sstevel@tonic-gate * 1227c478bd9Sstevel@tonic-gate * A note as to how to define constraints: 1237c478bd9Sstevel@tonic-gate * 1247c478bd9Sstevel@tonic-gate * How you define the constraints for your device depends on how you 1257c478bd9Sstevel@tonic-gate * define your device. For example, you may have an SBus card with a 1267c478bd9Sstevel@tonic-gate * device on it that address only the bottom 16mb of virtual DMA space. 1277c478bd9Sstevel@tonic-gate * However, if the card also has ancillary circuitry that pulls the high 8 1287c478bd9Sstevel@tonic-gate * bits of address lines high, the more correct expression for your device 1297c478bd9Sstevel@tonic-gate * is that it address [0xff000000..0xffffffff] rather than [0..0x00ffffff]. 1307c478bd9Sstevel@tonic-gate */ 1317c478bd9Sstevel@tonic-gate #if defined(__sparc) 1327c478bd9Sstevel@tonic-gate typedef struct ddi_dma_lim { 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * Low range of 32 bit addressing capability. 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate uint_t dlim_addr_lo; 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate /* 1407c478bd9Sstevel@tonic-gate * Upper inclusive bound of addressing capability. It is an 1417c478bd9Sstevel@tonic-gate * inclusive boundary limit to allow for the addressing range 1427c478bd9Sstevel@tonic-gate * [0..0xffffffff] to be specified in preference to [0..0]. 1437c478bd9Sstevel@tonic-gate */ 1447c478bd9Sstevel@tonic-gate uint_t dlim_addr_hi; 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate /* 1477c478bd9Sstevel@tonic-gate * Inclusive upper bound with which The DMA engine's counter acts as 1487c478bd9Sstevel@tonic-gate * a register. 1497c478bd9Sstevel@tonic-gate * 1507c478bd9Sstevel@tonic-gate * This handles the case where an upper portion of a DMA address 1517c478bd9Sstevel@tonic-gate * register is a latch instead of being a full 32 bit register 1527c478bd9Sstevel@tonic-gate * (e.g., the upper 8 bits may remain constant while the lower 1537c478bd9Sstevel@tonic-gate * 24 bits are the real address register). 1547c478bd9Sstevel@tonic-gate * 1557c478bd9Sstevel@tonic-gate * This essentially gives a hint about segment limitations 1567c478bd9Sstevel@tonic-gate * to the mapping routines. 1577c478bd9Sstevel@tonic-gate */ 1587c478bd9Sstevel@tonic-gate uint_t dlim_cntr_max; 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* 1617c478bd9Sstevel@tonic-gate * DMA burst sizes. 1627c478bd9Sstevel@tonic-gate * 1637c478bd9Sstevel@tonic-gate * At the time of a mapping request, this tag defines the possible 1647c478bd9Sstevel@tonic-gate * DMA burst cycle sizes that the requestor's DMA engine can 1657c478bd9Sstevel@tonic-gate * emit. The format of the data is binary encoding of burst sizes 1667c478bd9Sstevel@tonic-gate * assumed to be powers of two. That is, if a DMA engine is capable 1677c478bd9Sstevel@tonic-gate * of doing 1, 2, 4 and 16 byte transfers, the encoding would be 0x17. 1687c478bd9Sstevel@tonic-gate * 1697c478bd9Sstevel@tonic-gate * As the mapping request is handled by intervening nexi, the 1707c478bd9Sstevel@tonic-gate * burstsizes value may be modified. Prior to enabling DMA for 1717c478bd9Sstevel@tonic-gate * the specific device, the driver that owns the DMA engine should 1727c478bd9Sstevel@tonic-gate * check (via ddi_dma_burstsizes(9F)) what the allowed burstsizes 1737c478bd9Sstevel@tonic-gate * have become and program their DMA engine appropriately. 1747c478bd9Sstevel@tonic-gate */ 1757c478bd9Sstevel@tonic-gate uint_t dlim_burstsizes; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate /* 1787c478bd9Sstevel@tonic-gate * Minimum effective DMA transfer size, in units of bytes. 1797c478bd9Sstevel@tonic-gate * 1807c478bd9Sstevel@tonic-gate * This value specifies the minimum effective granularity of the 1817c478bd9Sstevel@tonic-gate * DMA engine. It is distinct from dlim_burtsizes in that it 1827c478bd9Sstevel@tonic-gate * describes the minimum amount of access a DMA transfer will 1837c478bd9Sstevel@tonic-gate * effect. dlim_burtsizes describes in what electrical fashion 1847c478bd9Sstevel@tonic-gate * the DMA engine might perform its accesses, while dlim_minxfer 1857c478bd9Sstevel@tonic-gate * describes the minimum amount of memory that can be touched by 1867c478bd9Sstevel@tonic-gate * the DMA transfer. 1877c478bd9Sstevel@tonic-gate * 1887c478bd9Sstevel@tonic-gate * As the mapping request is handled by intervening nexi, the 1897c478bd9Sstevel@tonic-gate * dlim_minxfer value may be modifed contingent upon the presence 1907c478bd9Sstevel@tonic-gate * (and use) of I/O caches and DMA write buffers in between the 1917c478bd9Sstevel@tonic-gate * DMA engine and the object that DMA is being performed on. 1927c478bd9Sstevel@tonic-gate * 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate uint_t dlim_minxfer; 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* 1977c478bd9Sstevel@tonic-gate * Expected average data rate for this DMA engine 1987c478bd9Sstevel@tonic-gate * while transferring data. 1997c478bd9Sstevel@tonic-gate * 2007c478bd9Sstevel@tonic-gate * This is used as a hint for a number of operations that might 2017c478bd9Sstevel@tonic-gate * want to know the possible optimal latency requirements of this 2027c478bd9Sstevel@tonic-gate * device. A value of zero will be interpreted as a 'do not care'. 2037c478bd9Sstevel@tonic-gate */ 2047c478bd9Sstevel@tonic-gate uint_t dlim_dmaspeed; 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate } ddi_dma_lim_t; 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate #elif defined(__x86) 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * values for dlim_minxfer 2127c478bd9Sstevel@tonic-gate */ 2137c478bd9Sstevel@tonic-gate #define DMA_UNIT_8 1 2147c478bd9Sstevel@tonic-gate #define DMA_UNIT_16 2 2157c478bd9Sstevel@tonic-gate #define DMA_UNIT_32 4 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate /* 2187c478bd9Sstevel@tonic-gate * Version number 2197c478bd9Sstevel@tonic-gate */ 2207c478bd9Sstevel@tonic-gate #define DMALIM_VER0 ((0x86000000) + 0) 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate typedef struct ddi_dma_lim { 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate /* 2257c478bd9Sstevel@tonic-gate * Low range of 32 bit addressing capability. 2267c478bd9Sstevel@tonic-gate */ 2277c478bd9Sstevel@tonic-gate uint_t dlim_addr_lo; 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate /* 2307c478bd9Sstevel@tonic-gate * Upper Inclusive bound of 32 bit addressing capability. 2317c478bd9Sstevel@tonic-gate * 2327c478bd9Sstevel@tonic-gate * The ISA nexus restricts this to 0x00ffffff, since this bus has 2337c478bd9Sstevel@tonic-gate * only 24 address lines. This enforces the 16 Mb address limitation. 2347c478bd9Sstevel@tonic-gate * The EISA nexus restricts this to 0xffffffff. 2357c478bd9Sstevel@tonic-gate */ 2367c478bd9Sstevel@tonic-gate uint_t dlim_addr_hi; 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate /* 2397c478bd9Sstevel@tonic-gate * DMA engine counter not used; set to 0 2407c478bd9Sstevel@tonic-gate */ 2417c478bd9Sstevel@tonic-gate uint_t dlim_cntr_max; 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate /* 2447c478bd9Sstevel@tonic-gate * DMA burst sizes not used; set to 1 2457c478bd9Sstevel@tonic-gate */ 2467c478bd9Sstevel@tonic-gate uint_t dlim_burstsizes; 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate /* 2497c478bd9Sstevel@tonic-gate * Minimum effective DMA transfer size. 2507c478bd9Sstevel@tonic-gate * 2517c478bd9Sstevel@tonic-gate * This value specifies the minimum effective granularity of the 2527c478bd9Sstevel@tonic-gate * DMA engine. It is distinct from dlim_burstsizes in that it 2537c478bd9Sstevel@tonic-gate * describes the minimum amount of access a DMA transfer will 2547c478bd9Sstevel@tonic-gate * effect. dlim_burstsizes describes in what electrical fashion 2557c478bd9Sstevel@tonic-gate * the DMA engine might perform its accesses, while dlim_minxfer 2567c478bd9Sstevel@tonic-gate * describes the minimum amount of memory that can be touched by 2577c478bd9Sstevel@tonic-gate * the DMA transfer. 2587c478bd9Sstevel@tonic-gate * 2597c478bd9Sstevel@tonic-gate * This value also implies the required address alignment. 2607c478bd9Sstevel@tonic-gate * The number of bytes transferred is assumed to be 2617c478bd9Sstevel@tonic-gate * dlim_minxfer * (DMA engine count) 2627c478bd9Sstevel@tonic-gate * 2637c478bd9Sstevel@tonic-gate * It should be set to DMA_UNIT_8, DMA_UNIT_16, or DMA_UNIT_32. 2647c478bd9Sstevel@tonic-gate */ 2657c478bd9Sstevel@tonic-gate uint_t dlim_minxfer; 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate /* 2687c478bd9Sstevel@tonic-gate * Expected average data rate for this DMA engine 2697c478bd9Sstevel@tonic-gate * while transferring data. 2707c478bd9Sstevel@tonic-gate * 2717c478bd9Sstevel@tonic-gate * This is used as a hint for a number of operations that might 2727c478bd9Sstevel@tonic-gate * want to know the possible optimal latency requirements of this 2737c478bd9Sstevel@tonic-gate * device. A value of zero will be interpreted as a 'do not care'. 2747c478bd9Sstevel@tonic-gate */ 2757c478bd9Sstevel@tonic-gate uint_t dlim_dmaspeed; 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate /* 2797c478bd9Sstevel@tonic-gate * Version number of this structure 2807c478bd9Sstevel@tonic-gate */ 2817c478bd9Sstevel@tonic-gate uint_t dlim_version; /* = 0x86 << 24 + 0 */ 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate /* 2847c478bd9Sstevel@tonic-gate * Inclusive upper bound with which the DMA engine's Address acts as 2857c478bd9Sstevel@tonic-gate * a register. 2867c478bd9Sstevel@tonic-gate * This handles the case where an upper portion of a DMA address 2877c478bd9Sstevel@tonic-gate * register is a latch instead of being a full 32 bit register 2887c478bd9Sstevel@tonic-gate * (e.g., the upper 16 bits remain constant while the lower 16 bits 2897c478bd9Sstevel@tonic-gate * are incremented for each DMA transfer). 2907c478bd9Sstevel@tonic-gate * 2917c478bd9Sstevel@tonic-gate * The ISA nexus restricts only 3rd-party DMA requests to 0x0000ffff, 2927c478bd9Sstevel@tonic-gate * since the ISA DMA engine has a 16-bit register for low address and 2937c478bd9Sstevel@tonic-gate * an 8-bit latch for high address. This enforces the first 64 Kb 2947c478bd9Sstevel@tonic-gate * limitation (address boundary). 2957c478bd9Sstevel@tonic-gate * The EISA nexus restricts only 3rd-party DMA requests to 0xffffffff. 2967c478bd9Sstevel@tonic-gate */ 2977c478bd9Sstevel@tonic-gate uint_t dlim_adreg_max; 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate /* 3007c478bd9Sstevel@tonic-gate * Maximum transfer count that the DMA engine can handle. 3017c478bd9Sstevel@tonic-gate * 3027c478bd9Sstevel@tonic-gate * The ISA nexus restricts only 3rd-party DMA requests to 0x0000ffff, 3037c478bd9Sstevel@tonic-gate * since the ISA DMA engine has a 16-bit register for counting. 3047c478bd9Sstevel@tonic-gate * This enforces the other 64 Kb limitation (count size). 3057c478bd9Sstevel@tonic-gate * The EISA nexus restricts only 3rd-party DMA requests to 0x00ffffff, 3067c478bd9Sstevel@tonic-gate * since the EISA DMA engine has a 24-bit register for counting. 3077c478bd9Sstevel@tonic-gate * 3087c478bd9Sstevel@tonic-gate * This transfer count limitation is a per segment limitation. 3097c478bd9Sstevel@tonic-gate * It can also be used to restrict the size of segments. 3107c478bd9Sstevel@tonic-gate * 3117c478bd9Sstevel@tonic-gate * This is used as a bit mask, so it must be a power of 2, minus 1. 3127c478bd9Sstevel@tonic-gate */ 3137c478bd9Sstevel@tonic-gate uint_t dlim_ctreg_max; 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate /* 3167c478bd9Sstevel@tonic-gate * Granularity of DMA transfer, in units of bytes. 3177c478bd9Sstevel@tonic-gate * 3187c478bd9Sstevel@tonic-gate * Breakup sizes must be multiples of this value. 3197c478bd9Sstevel@tonic-gate * If no scatter/gather capabilty is specified, then the size of 3207c478bd9Sstevel@tonic-gate * each DMA transfer must be a multiple of this value. 3217c478bd9Sstevel@tonic-gate * 3227c478bd9Sstevel@tonic-gate * If there is scatter/gather capability, then a single cookie cannot 3237c478bd9Sstevel@tonic-gate * be smaller in size than the minimum xfer value, and may be less 3247c478bd9Sstevel@tonic-gate * than the granularity value. The total transfer length of the 3257c478bd9Sstevel@tonic-gate * scatter/gather list should be a multiple of the granularity value; 3267c478bd9Sstevel@tonic-gate * use dlim_sgllen to specify the length of the scatter/gather list. 3277c478bd9Sstevel@tonic-gate * 3287c478bd9Sstevel@tonic-gate * This value should be equal to the sector size of the device. 3297c478bd9Sstevel@tonic-gate */ 3307c478bd9Sstevel@tonic-gate uint_t dlim_granular; 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate /* 3337c478bd9Sstevel@tonic-gate * Length of scatter/gather list 3347c478bd9Sstevel@tonic-gate * 3357c478bd9Sstevel@tonic-gate * This value specifies the number of segments or cookies that a DMA 3367c478bd9Sstevel@tonic-gate * engine can consume in one i/o request to the device. For 3rd-party 3377c478bd9Sstevel@tonic-gate * DMA that uses the bus nexus this should be set to 1. Devices with 3387c478bd9Sstevel@tonic-gate * 1st-party DMA capability should specify the number of entries in 3397c478bd9Sstevel@tonic-gate * its scatter/gather list. The breakup routine will ensure that each 3407c478bd9Sstevel@tonic-gate * group of dlim_sgllen cookies (within a DMA window) will have a 3417c478bd9Sstevel@tonic-gate * total transfer length that is a multiple of dlim_granular. 3427c478bd9Sstevel@tonic-gate * 3437c478bd9Sstevel@tonic-gate * < 0 : tbd 3447c478bd9Sstevel@tonic-gate * = 0 : breakup is for PIO. 3457c478bd9Sstevel@tonic-gate * = 1 : breakup is for DMA engine with no scatter/gather 3467c478bd9Sstevel@tonic-gate * capability. 3477c478bd9Sstevel@tonic-gate * >= 2 : breakup is for DMA engine with scatter/gather 3487c478bd9Sstevel@tonic-gate * capability; value is max number of entries in list. 3497c478bd9Sstevel@tonic-gate * 3507c478bd9Sstevel@tonic-gate * Note that this list length is not dependent on the DMA window 3517c478bd9Sstevel@tonic-gate * size. The size of the DMA window is based on resources consumed, 3527c478bd9Sstevel@tonic-gate * such as intermediate buffers. Several s/g lists may exist within 3537c478bd9Sstevel@tonic-gate * a window. But the end of a window does imply the end of the s/g 3547c478bd9Sstevel@tonic-gate * list. 3557c478bd9Sstevel@tonic-gate */ 3567c478bd9Sstevel@tonic-gate short dlim_sgllen; 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate /* 3597c478bd9Sstevel@tonic-gate * Size of device i/o request 3607c478bd9Sstevel@tonic-gate * 3617c478bd9Sstevel@tonic-gate * This value indicates the maximum number of bytes the device 3627c478bd9Sstevel@tonic-gate * can transmit/receive for one i/o command. This limitation is 3637c478bd9Sstevel@tonic-gate * significant ony if it is less than (dlim_ctreg_max * dlim_sgllen). 3647c478bd9Sstevel@tonic-gate */ 3657c478bd9Sstevel@tonic-gate uint_t dlim_reqsize; 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate } ddi_dma_lim_t; 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate #else 3707c478bd9Sstevel@tonic-gate #error "struct ddi_dma_lim not defined for this architecture" 3717c478bd9Sstevel@tonic-gate #endif /* defined(__sparc) */ 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate /* 3747c478bd9Sstevel@tonic-gate * Flags definition for dma_attr_flags 3757c478bd9Sstevel@tonic-gate */ 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate /* 3787c478bd9Sstevel@tonic-gate * return physical DMA address on platforms 3797c478bd9Sstevel@tonic-gate * which support DVMA 3807c478bd9Sstevel@tonic-gate */ 3817c478bd9Sstevel@tonic-gate #define DDI_DMA_FORCE_PHYSICAL 0x0100 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate /* 3847c478bd9Sstevel@tonic-gate * An error will be flagged for DMA data path errors 3857c478bd9Sstevel@tonic-gate */ 3867c478bd9Sstevel@tonic-gate #define DDI_DMA_FLAGERR 0x200 3877c478bd9Sstevel@tonic-gate 38825cf1a30Sjl139090 /* 38925cf1a30Sjl139090 * Enable relaxed ordering 39025cf1a30Sjl139090 */ 39125cf1a30Sjl139090 #define DDI_DMA_RELAXED_ORDERING 0x400 39225cf1a30Sjl139090 393*07c6692fSMark Johnson 394*07c6692fSMark Johnson /* 395*07c6692fSMark Johnson * Consolidation private x86 only flag which will cause a bounce buffer 396*07c6692fSMark Johnson * (paddr < dma_attr_seg) to be used if the buffer passed to the bind 397*07c6692fSMark Johnson * operation contains pages both above and below dma_attr_seg. If this flag 398*07c6692fSMark Johnson * is set, dma_attr_seg must be <= dma_attr_addr_hi. 399*07c6692fSMark Johnson */ 400*07c6692fSMark Johnson #define _DDI_DMA_BOUNCE_ON_SEG 0x8000 401*07c6692fSMark Johnson 4027c478bd9Sstevel@tonic-gate #define DMA_ATTR_V0 0 4037c478bd9Sstevel@tonic-gate #define DMA_ATTR_VERSION DMA_ATTR_V0 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate typedef struct ddi_dma_attr { 4067c478bd9Sstevel@tonic-gate uint_t dma_attr_version; /* version number */ 4077c478bd9Sstevel@tonic-gate uint64_t dma_attr_addr_lo; /* low DMA address range */ 4087c478bd9Sstevel@tonic-gate uint64_t dma_attr_addr_hi; /* high DMA address range */ 4097c478bd9Sstevel@tonic-gate uint64_t dma_attr_count_max; /* DMA counter register */ 4107c478bd9Sstevel@tonic-gate uint64_t dma_attr_align; /* DMA address alignment */ 4117c478bd9Sstevel@tonic-gate uint_t dma_attr_burstsizes; /* DMA burstsizes */ 4127c478bd9Sstevel@tonic-gate uint32_t dma_attr_minxfer; /* min effective DMA size */ 4137c478bd9Sstevel@tonic-gate uint64_t dma_attr_maxxfer; /* max DMA xfer size */ 4147c478bd9Sstevel@tonic-gate uint64_t dma_attr_seg; /* segment boundary */ 4157c478bd9Sstevel@tonic-gate int dma_attr_sgllen; /* s/g length */ 4167c478bd9Sstevel@tonic-gate uint32_t dma_attr_granular; /* granularity of device */ 4177c478bd9Sstevel@tonic-gate uint_t dma_attr_flags; /* Bus specific DMA flags */ 4187c478bd9Sstevel@tonic-gate } ddi_dma_attr_t; 4197c478bd9Sstevel@tonic-gate 4207c478bd9Sstevel@tonic-gate /* 4217c478bd9Sstevel@tonic-gate * Handy macro to set a maximum bit value (should be elsewhere) 4227c478bd9Sstevel@tonic-gate * 4237c478bd9Sstevel@tonic-gate * Clear off all bits lower then 'mybit' in val; if there are no 4247c478bd9Sstevel@tonic-gate * bits higher than or equal to mybit in val then set mybit. Assumes 4257c478bd9Sstevel@tonic-gate * mybit equals some power of 2 and is not zero. 4267c478bd9Sstevel@tonic-gate */ 4277c478bd9Sstevel@tonic-gate #define maxbit(val, mybit) \ 4287c478bd9Sstevel@tonic-gate ((val) & ~((mybit)-1)) | ((((val) & ~((mybit)-1)) == 0) ? (mybit) : 0) 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate /* 4317c478bd9Sstevel@tonic-gate * Handy macro to set a minimum bit value (should be elsewhere) 4327c478bd9Sstevel@tonic-gate * 4337c478bd9Sstevel@tonic-gate * Clear off all bits higher then 'mybit' in val; if there are no 4347c478bd9Sstevel@tonic-gate * bits lower than or equal to mybit in val then set mybit. Assumes 4357c478bd9Sstevel@tonic-gate * mybit equals some pow2 and is not zero. 4367c478bd9Sstevel@tonic-gate */ 4377c478bd9Sstevel@tonic-gate #define minbit(val, mybit) \ 4387c478bd9Sstevel@tonic-gate (((val)&((mybit)|((mybit)-1))) | \ 4397c478bd9Sstevel@tonic-gate ((((val) & ((mybit)-1)) == 0) ? (mybit) : 0)) 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate /* 4427c478bd9Sstevel@tonic-gate * Structure of a request to map an object for DMA. 4437c478bd9Sstevel@tonic-gate */ 4447c478bd9Sstevel@tonic-gate typedef struct ddi_dma_req { 4457c478bd9Sstevel@tonic-gate /* 4467c478bd9Sstevel@tonic-gate * Caller's DMA engine constraints. 4477c478bd9Sstevel@tonic-gate * 4487c478bd9Sstevel@tonic-gate * If there are no particular constraints to the caller's DMA 4497c478bd9Sstevel@tonic-gate * engine, this field may be set to NULL. The implementation DMA 4507c478bd9Sstevel@tonic-gate * setup functions will then select a set of standard beginning 4517c478bd9Sstevel@tonic-gate * constraints. 4527c478bd9Sstevel@tonic-gate * 4537c478bd9Sstevel@tonic-gate * In either case, as the mapping proceeds, the initial DMA 4547c478bd9Sstevel@tonic-gate * constraints may become more restrictive as each intervening 4557c478bd9Sstevel@tonic-gate * nexus might add further restrictions. 4567c478bd9Sstevel@tonic-gate */ 4577c478bd9Sstevel@tonic-gate ddi_dma_lim_t *dmar_limits; 4587c478bd9Sstevel@tonic-gate 4597c478bd9Sstevel@tonic-gate /* 4607c478bd9Sstevel@tonic-gate * Contains the information passed to the DMA mapping allocation 4617c478bd9Sstevel@tonic-gate * routine(s). 4627c478bd9Sstevel@tonic-gate */ 4637c478bd9Sstevel@tonic-gate uint_t dmar_flags; 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate /* 4667c478bd9Sstevel@tonic-gate * Callback function. A caller of the DMA mapping functions must 4677c478bd9Sstevel@tonic-gate * specify by filling in this field whether the allocation routines 4687c478bd9Sstevel@tonic-gate * can sleep awaiting mapping resources, must *not* sleep awaiting 4697c478bd9Sstevel@tonic-gate * resources, or may *not* sleep awaiting any resources and must 4707c478bd9Sstevel@tonic-gate * call the function specified by dmar_fp with the the argument 4717c478bd9Sstevel@tonic-gate * dmar_arg when resources might have become available at a future 4727c478bd9Sstevel@tonic-gate * time. 4737c478bd9Sstevel@tonic-gate */ 4747c478bd9Sstevel@tonic-gate int (*dmar_fp)(); 4757c478bd9Sstevel@tonic-gate 4767c478bd9Sstevel@tonic-gate caddr_t dmar_arg; /* Callback function argument */ 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate /* 4797c478bd9Sstevel@tonic-gate * Description of the object to be mapped for DMA. 4807c478bd9Sstevel@tonic-gate * Must be last in this structure in case that the 4817c478bd9Sstevel@tonic-gate * union ddi_dma_obj_t changes in the future. 4827c478bd9Sstevel@tonic-gate */ 4837c478bd9Sstevel@tonic-gate ddi_dma_obj_t dmar_object; 4847c478bd9Sstevel@tonic-gate 4857c478bd9Sstevel@tonic-gate } ddi_dma_req_t; 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate /* 4887c478bd9Sstevel@tonic-gate * Defines for the DMA mapping allocation functions 4897c478bd9Sstevel@tonic-gate * 4907c478bd9Sstevel@tonic-gate * If a DMA callback funtion is set to anything other than the following 4917c478bd9Sstevel@tonic-gate * defines then it is assumed that one wishes a callback and is providing 4927c478bd9Sstevel@tonic-gate * a function address. 4937c478bd9Sstevel@tonic-gate */ 4947c478bd9Sstevel@tonic-gate #ifdef __STDC__ 4957c478bd9Sstevel@tonic-gate #define DDI_DMA_DONTWAIT ((int (*)(caddr_t))0) 4967c478bd9Sstevel@tonic-gate #define DDI_DMA_SLEEP ((int (*)(caddr_t))1) 4977c478bd9Sstevel@tonic-gate #else 4987c478bd9Sstevel@tonic-gate #define DDI_DMA_DONTWAIT ((int (*)())0) 4997c478bd9Sstevel@tonic-gate #define DDI_DMA_SLEEP ((int (*)())1) 5007c478bd9Sstevel@tonic-gate #endif 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate /* 5037c478bd9Sstevel@tonic-gate * Return values from callback functions. 5047c478bd9Sstevel@tonic-gate */ 5057c478bd9Sstevel@tonic-gate #define DDI_DMA_CALLBACK_RUNOUT 0 5067c478bd9Sstevel@tonic-gate #define DDI_DMA_CALLBACK_DONE 1 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate /* 5097c478bd9Sstevel@tonic-gate * Flag definitions for the allocation functions. 5107c478bd9Sstevel@tonic-gate */ 5117c478bd9Sstevel@tonic-gate #define DDI_DMA_WRITE 0x0001 /* Direction memory --> IO */ 5127c478bd9Sstevel@tonic-gate #define DDI_DMA_READ 0x0002 /* Direction IO --> memory */ 5137c478bd9Sstevel@tonic-gate #define DDI_DMA_RDWR (DDI_DMA_READ | DDI_DMA_WRITE) 5147c478bd9Sstevel@tonic-gate 5157c478bd9Sstevel@tonic-gate /* 5167c478bd9Sstevel@tonic-gate * If possible, establish a MMU redzone after the mapping (to protect 5177c478bd9Sstevel@tonic-gate * against cheap DMA hardware that might get out of control). 5187c478bd9Sstevel@tonic-gate */ 5197c478bd9Sstevel@tonic-gate #define DDI_DMA_REDZONE 0x0004 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate /* 5227c478bd9Sstevel@tonic-gate * A partial allocation is allowed. That is, if the size of the object 5237c478bd9Sstevel@tonic-gate * exceeds the mapping resources available, only map a portion of the 5247c478bd9Sstevel@tonic-gate * object and return status indicating that this took place. The caller 5257c478bd9Sstevel@tonic-gate * can use the functions ddi_dma_numwin(9F) and ddi_dma_getwin(9F) to 5267c478bd9Sstevel@tonic-gate * change, at a later point, the actual mapped portion of the object. 5277c478bd9Sstevel@tonic-gate * 5287c478bd9Sstevel@tonic-gate * The mapped portion begins at offset 0 of the object. 5297c478bd9Sstevel@tonic-gate * 5307c478bd9Sstevel@tonic-gate */ 5317c478bd9Sstevel@tonic-gate #define DDI_DMA_PARTIAL 0x0008 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate /* 5347c478bd9Sstevel@tonic-gate * Map the object for byte consistent access. Note that explicit 5357c478bd9Sstevel@tonic-gate * synchronization (via ddi_dma_sync(9F)) will still be required. 5367c478bd9Sstevel@tonic-gate * Consider this flag to be a hint to the mapping routines as to 5377c478bd9Sstevel@tonic-gate * the intended use of the mapping. 5387c478bd9Sstevel@tonic-gate * 5397c478bd9Sstevel@tonic-gate * Normal data transfers can be usually consider to use 'streaming' 5407c478bd9Sstevel@tonic-gate * modes of operations. They start at a specific point, transfer a 5417c478bd9Sstevel@tonic-gate * fairly large amount of data sequentially, and then stop (usually 5427c478bd9Sstevel@tonic-gate * on a well aligned boundary). 5437c478bd9Sstevel@tonic-gate * 5447c478bd9Sstevel@tonic-gate * Control mode data transfers (for memory resident device control blocks, 5457c478bd9Sstevel@tonic-gate * e.g., ethernet message descriptors) do not access memory in such 5467c478bd9Sstevel@tonic-gate * a streaming sequential fashion. Instead, they tend to modify a few 5477c478bd9Sstevel@tonic-gate * words or bytes, move around and maybe modify a few more. 5487c478bd9Sstevel@tonic-gate * 5497c478bd9Sstevel@tonic-gate * There are many machine implementations that make this difficult to 5507c478bd9Sstevel@tonic-gate * control in a generic and seamless fashion. Therefore, explicit synch- 5517c478bd9Sstevel@tonic-gate * ronization steps (via ddi_dma_sync(9F)) are still required (even if you 5527c478bd9Sstevel@tonic-gate * ask for a byte-consistent mapping) in order to make the view of the 5537c478bd9Sstevel@tonic-gate * memory object shared between a CPU and a DMA master in consistent. 5547c478bd9Sstevel@tonic-gate * However, judicious use of this flag can give sufficient hints to 5557c478bd9Sstevel@tonic-gate * the mapping routines to attempt to pick the most efficacious mapping 5567c478bd9Sstevel@tonic-gate * such that the synchronization steps are as efficient as possible. 5577c478bd9Sstevel@tonic-gate * 5587c478bd9Sstevel@tonic-gate */ 5597c478bd9Sstevel@tonic-gate #define DDI_DMA_CONSISTENT 0x0010 5607c478bd9Sstevel@tonic-gate 5617c478bd9Sstevel@tonic-gate /* 5627c478bd9Sstevel@tonic-gate * Some DMA mappings have to be 'exclusive' access. 5637c478bd9Sstevel@tonic-gate */ 5647c478bd9Sstevel@tonic-gate #define DDI_DMA_EXCLUSIVE 0x0020 5657c478bd9Sstevel@tonic-gate 5667c478bd9Sstevel@tonic-gate /* 5677c478bd9Sstevel@tonic-gate * Sequential, unidirectional, block-sized and block aligned transfers 5687c478bd9Sstevel@tonic-gate */ 5697c478bd9Sstevel@tonic-gate #define DDI_DMA_STREAMING 0x0040 5707c478bd9Sstevel@tonic-gate 5717c478bd9Sstevel@tonic-gate /* 5727c478bd9Sstevel@tonic-gate * Support for 64-bit SBus devices 5737c478bd9Sstevel@tonic-gate */ 5747c478bd9Sstevel@tonic-gate #define DDI_DMA_SBUS_64BIT 0x2000 5757c478bd9Sstevel@tonic-gate 5767c478bd9Sstevel@tonic-gate /* 5777c478bd9Sstevel@tonic-gate * Return values from the mapping allocation functions. 5787c478bd9Sstevel@tonic-gate */ 5797c478bd9Sstevel@tonic-gate 5807c478bd9Sstevel@tonic-gate /* 5817c478bd9Sstevel@tonic-gate * succeeded in satisfying request 5827c478bd9Sstevel@tonic-gate */ 5837c478bd9Sstevel@tonic-gate #define DDI_DMA_MAPPED 0 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate /* 5867c478bd9Sstevel@tonic-gate * Mapping is legitimate (for advisory calls). 5877c478bd9Sstevel@tonic-gate */ 5887c478bd9Sstevel@tonic-gate #define DDI_DMA_MAPOK 0 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate /* 5917c478bd9Sstevel@tonic-gate * Succeeded in mapping a portion of the request. 5927c478bd9Sstevel@tonic-gate */ 5937c478bd9Sstevel@tonic-gate #define DDI_DMA_PARTIAL_MAP 1 5947c478bd9Sstevel@tonic-gate 5957c478bd9Sstevel@tonic-gate /* 5967c478bd9Sstevel@tonic-gate * indicates end of window/segment list 5977c478bd9Sstevel@tonic-gate */ 5987c478bd9Sstevel@tonic-gate #define DDI_DMA_DONE 2 5997c478bd9Sstevel@tonic-gate 6007c478bd9Sstevel@tonic-gate /* 6017c478bd9Sstevel@tonic-gate * No resources to map request. 6027c478bd9Sstevel@tonic-gate */ 6037c478bd9Sstevel@tonic-gate #define DDI_DMA_NORESOURCES -1 6047c478bd9Sstevel@tonic-gate 6057c478bd9Sstevel@tonic-gate /* 6067c478bd9Sstevel@tonic-gate * Can't establish a mapping to the specified object 6077c478bd9Sstevel@tonic-gate * (no specific reason). 6087c478bd9Sstevel@tonic-gate */ 6097c478bd9Sstevel@tonic-gate #define DDI_DMA_NOMAPPING -2 6107c478bd9Sstevel@tonic-gate 6117c478bd9Sstevel@tonic-gate /* 6127c478bd9Sstevel@tonic-gate * The request is too big to be mapped. 6137c478bd9Sstevel@tonic-gate */ 6147c478bd9Sstevel@tonic-gate #define DDI_DMA_TOOBIG -3 6157c478bd9Sstevel@tonic-gate 6167c478bd9Sstevel@tonic-gate /* 6177c478bd9Sstevel@tonic-gate * The request is too small to be mapped. 6187c478bd9Sstevel@tonic-gate */ 6197c478bd9Sstevel@tonic-gate #define DDI_DMA_TOOSMALL -4 6207c478bd9Sstevel@tonic-gate 6217c478bd9Sstevel@tonic-gate /* 6227c478bd9Sstevel@tonic-gate * The request cannot be mapped because the object 6237c478bd9Sstevel@tonic-gate * is locked against mapping by another DMA master. 6247c478bd9Sstevel@tonic-gate */ 6257c478bd9Sstevel@tonic-gate #define DDI_DMA_LOCKED -5 6267c478bd9Sstevel@tonic-gate 6277c478bd9Sstevel@tonic-gate /* 6287c478bd9Sstevel@tonic-gate * The request cannot be mapped because the limits 6297c478bd9Sstevel@tonic-gate * structure has bogus values. 6307c478bd9Sstevel@tonic-gate */ 6317c478bd9Sstevel@tonic-gate #define DDI_DMA_BADLIMITS -6 6327c478bd9Sstevel@tonic-gate 6337c478bd9Sstevel@tonic-gate /* 6347c478bd9Sstevel@tonic-gate * the segment/window pointer is stale 6357c478bd9Sstevel@tonic-gate */ 6367c478bd9Sstevel@tonic-gate #define DDI_DMA_STALE -7 6377c478bd9Sstevel@tonic-gate 6387c478bd9Sstevel@tonic-gate /* 6397c478bd9Sstevel@tonic-gate * The system can't allocate DMA resources using 6407c478bd9Sstevel@tonic-gate * the given DMA attributes 6417c478bd9Sstevel@tonic-gate */ 6427c478bd9Sstevel@tonic-gate #define DDI_DMA_BADATTR -8 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate /* 6457c478bd9Sstevel@tonic-gate * A DMA handle is already used for a DMA 6467c478bd9Sstevel@tonic-gate */ 6477c478bd9Sstevel@tonic-gate #define DDI_DMA_INUSE -9 6487c478bd9Sstevel@tonic-gate 6493a634bfcSVikram Hegde 6503a634bfcSVikram Hegde /* 6513a634bfcSVikram Hegde * DVMA disabled or not supported. use physical DMA 6523a634bfcSVikram Hegde */ 6533a634bfcSVikram Hegde #define DDI_DMA_USE_PHYSICAL -10 6543a634bfcSVikram Hegde 6553a634bfcSVikram Hegde 6567c478bd9Sstevel@tonic-gate /* 6577c478bd9Sstevel@tonic-gate * In order for the access to a memory object to be consistent 6587c478bd9Sstevel@tonic-gate * between a device and a CPU, the function ddi_dma_sync(9F) 6597c478bd9Sstevel@tonic-gate * must be called upon the DMA handle. The following flags 6607c478bd9Sstevel@tonic-gate * define whose view of the object should be made consistent. 6617c478bd9Sstevel@tonic-gate * There are different flags here because on different machines 6627c478bd9Sstevel@tonic-gate * there are definite performance implications of how long 6637c478bd9Sstevel@tonic-gate * such synchronization takes. 6647c478bd9Sstevel@tonic-gate * 6657c478bd9Sstevel@tonic-gate * DDI_DMA_SYNC_FORDEV makes all device references to the object 6667c478bd9Sstevel@tonic-gate * mapped by the DMA handle up to date. It should be used by a 6677c478bd9Sstevel@tonic-gate * driver after a cpu modifies the memory object (over the range 6687c478bd9Sstevel@tonic-gate * specified by the other arguments to the ddi_dma_sync(9F) call). 6697c478bd9Sstevel@tonic-gate * 6707c478bd9Sstevel@tonic-gate * DDI_DMA_SYNC_FORCPU makes all cpu references to the object 6717c478bd9Sstevel@tonic-gate * mapped by the DMA handle up to date. It should be used 6727c478bd9Sstevel@tonic-gate * by a driver after the receipt of data from the device to 6737c478bd9Sstevel@tonic-gate * the memory object is done (over the range specified by 6747c478bd9Sstevel@tonic-gate * the other arguments to the ddi_dma_sync(9F) call). 6757c478bd9Sstevel@tonic-gate * 6767c478bd9Sstevel@tonic-gate * If the only mapping that concerns the driver is one for the 6777c478bd9Sstevel@tonic-gate * kernel (such as memory allocated by ddi_iopb_alloc(9F)), the 6787c478bd9Sstevel@tonic-gate * flag DDI_DMA_SYNC_FORKERNEL can be used. This is a hint to the 6797c478bd9Sstevel@tonic-gate * system that if it can synchronize the kernel's view faster 6807c478bd9Sstevel@tonic-gate * that the CPU's view, it can do so, otherwise it acts the 6817c478bd9Sstevel@tonic-gate * same as DDI_DMA_SYNC_FORCPU. DDI_DMA_SYNC_FORKERNEL might 6827c478bd9Sstevel@tonic-gate * speed up the synchronization of kernel mappings in case of 6837c478bd9Sstevel@tonic-gate * non IO-coherent CPU caches. 6847c478bd9Sstevel@tonic-gate */ 6857c478bd9Sstevel@tonic-gate #define DDI_DMA_SYNC_FORDEV 0x0 6867c478bd9Sstevel@tonic-gate #define DDI_DMA_SYNC_FORCPU 0x1 6877c478bd9Sstevel@tonic-gate #define DDI_DMA_SYNC_FORKERNEL 0x2 6887c478bd9Sstevel@tonic-gate 6897c478bd9Sstevel@tonic-gate /* 6907c478bd9Sstevel@tonic-gate * Bus nexus control functions for DMA 6917c478bd9Sstevel@tonic-gate */ 6927c478bd9Sstevel@tonic-gate 6937c478bd9Sstevel@tonic-gate /* 6947c478bd9Sstevel@tonic-gate * Control operations, defined here so that devops.h can be included 6957c478bd9Sstevel@tonic-gate * by drivers without having to include a specific SYSDDI implementation 6967c478bd9Sstevel@tonic-gate * header file. 6977c478bd9Sstevel@tonic-gate */ 6987c478bd9Sstevel@tonic-gate 6997c478bd9Sstevel@tonic-gate enum ddi_dma_ctlops { 7007c478bd9Sstevel@tonic-gate DDI_DMA_FREE, /* free reference to object */ 7017c478bd9Sstevel@tonic-gate DDI_DMA_SYNC, /* synchronize cache references */ 7027c478bd9Sstevel@tonic-gate DDI_DMA_HTOC, /* return DMA cookie for handle */ 7037c478bd9Sstevel@tonic-gate DDI_DMA_KVADDR, /* return kernel virtual address */ 7047c478bd9Sstevel@tonic-gate DDI_DMA_MOVWIN, /* change mapped DMA window on object */ 7057c478bd9Sstevel@tonic-gate DDI_DMA_REPWIN, /* report current window on DMA object */ 7067c478bd9Sstevel@tonic-gate DDI_DMA_GETERR, /* report any post-transfer DMA errors */ 7077c478bd9Sstevel@tonic-gate DDI_DMA_COFF, /* convert a DMA cookie to an offset */ 7087c478bd9Sstevel@tonic-gate DDI_DMA_NEXTWIN, /* get next window within object */ 7097c478bd9Sstevel@tonic-gate DDI_DMA_NEXTSEG, /* get next segment within window */ 7107c478bd9Sstevel@tonic-gate DDI_DMA_SEGTOC, /* return segment DMA cookie */ 7117c478bd9Sstevel@tonic-gate DDI_DMA_RESERVE, /* reserve some DVMA range */ 7127c478bd9Sstevel@tonic-gate DDI_DMA_RELEASE, /* free preallocated DVMA range */ 7137c478bd9Sstevel@tonic-gate DDI_DMA_RESETH, /* reset next cookie ptr in handle */ 7147c478bd9Sstevel@tonic-gate DDI_DMA_CKSYNC, /* sync intermediate buffer to cookies */ 7157c478bd9Sstevel@tonic-gate DDI_DMA_IOPB_ALLOC, /* get contiguous DMA-able memory */ 7167c478bd9Sstevel@tonic-gate DDI_DMA_IOPB_FREE, /* return contiguous DMA-able memory */ 7177c478bd9Sstevel@tonic-gate DDI_DMA_SMEM_ALLOC, /* get contiguous DMA-able memory */ 7187c478bd9Sstevel@tonic-gate DDI_DMA_SMEM_FREE, /* return contiguous DMA-able memory */ 7197c478bd9Sstevel@tonic-gate DDI_DMA_SET_SBUS64, /* 64 bit SBus support */ 7207c478bd9Sstevel@tonic-gate DDI_DMA_REMAP, /* remap DMA buffers after relocation */ 7217c478bd9Sstevel@tonic-gate 7227c478bd9Sstevel@tonic-gate /* 7237c478bd9Sstevel@tonic-gate * control ops for DMA engine on motherboard 7247c478bd9Sstevel@tonic-gate */ 7257c478bd9Sstevel@tonic-gate DDI_DMA_E_ACQUIRE, /* get channel for exclusive use */ 7267c478bd9Sstevel@tonic-gate DDI_DMA_E_FREE, /* release channel */ 7277c478bd9Sstevel@tonic-gate DDI_DMA_E_1STPTY, /* setup channel for 1st party DMA */ 7287c478bd9Sstevel@tonic-gate DDI_DMA_E_GETCB, /* get control block for DMA engine */ 7297c478bd9Sstevel@tonic-gate DDI_DMA_E_FREECB, /* free control blk for DMA engine */ 7307c478bd9Sstevel@tonic-gate DDI_DMA_E_PROG, /* program channel of DMA engine */ 7317c478bd9Sstevel@tonic-gate DDI_DMA_E_SWSETUP, /* setup channel for software control */ 7327c478bd9Sstevel@tonic-gate DDI_DMA_E_SWSTART, /* software operation of DMA channel */ 7337c478bd9Sstevel@tonic-gate DDI_DMA_E_ENABLE, /* enable channel of DMA engine */ 7347c478bd9Sstevel@tonic-gate DDI_DMA_E_STOP, /* stop a channel of DMA engine */ 7357c478bd9Sstevel@tonic-gate DDI_DMA_E_DISABLE, /* disable channel of DMA engine */ 7367c478bd9Sstevel@tonic-gate DDI_DMA_E_GETCNT, /* get remaining xfer count */ 7377c478bd9Sstevel@tonic-gate DDI_DMA_E_GETLIM, /* get DMA engine limits */ 7387c478bd9Sstevel@tonic-gate DDI_DMA_E_GETATTR /* get DMA engine attributes */ 7397c478bd9Sstevel@tonic-gate }; 7407c478bd9Sstevel@tonic-gate 7417b93957cSeota /* 7427b93957cSeota * Cache attribute flags: 7437b93957cSeota * 7447b93957cSeota * IOMEM_DATA_CACHED 7457b93957cSeota * The CPU can cache the data it fetches and push it to memory at a later 7467b93957cSeota * time. This is the default attribute and used if no cache attributes is 7477b93957cSeota * specified. 7487b93957cSeota * 7497b93957cSeota * IOMEM_DATA_UC_WR_COMBINE 7507b93957cSeota * The CPU never caches the data but writes may occur out of order or be 7517b93957cSeota * combined. It implies re-ordering. 7527b93957cSeota * 7537b93957cSeota * IOMEM_DATA_UNCACHED 7547b93957cSeota * The CPU never caches the data and has uncacheable access to memory. 7557b93957cSeota * It also implies strict ordering. 7567b93957cSeota * 7577b93957cSeota * The cache attributes are mutually exclusive, and any combination of the 7587b93957cSeota * values leads to a failure. On the sparc architecture, only IOMEM_DATA_CACHED 7597b93957cSeota * is meaningful, but others lead to a failure. 7607b93957cSeota */ 7617b93957cSeota #define IOMEM_DATA_CACHED 0x10000 /* data is cached */ 7627b93957cSeota #define IOMEM_DATA_UC_WR_COMBINE 0x20000 /* data is not cached, but */ 7637b93957cSeota /* writes might be combined */ 7647b93957cSeota #define IOMEM_DATA_UNCACHED 0x40000 /* data is not cached. */ 7657b93957cSeota #define IOMEM_DATA_MASK 0xF0000 /* cache attrs mask */ 7667b93957cSeota 7677b93957cSeota /* 7687b93957cSeota * Check if either uncacheable or write-combining specified. (those flags are 7697b93957cSeota * mutually exclusive) This macro is used to override hat attributes if either 7707b93957cSeota * one is set. 7717b93957cSeota */ 7727b93957cSeota #define OVERRIDE_CACHE_ATTR(attr) \ 7737b93957cSeota (attr & (IOMEM_DATA_UNCACHED | IOMEM_DATA_UC_WR_COMBINE)) 7747b93957cSeota 7757b93957cSeota /* 7767b93957cSeota * Get the cache attribute from flags. If there is no attributes, 7777b93957cSeota * return IOMEM_DATA_CACHED (default attribute). 7787b93957cSeota */ 7797b93957cSeota #define IOMEM_CACHE_ATTR(flags) \ 7807b93957cSeota ((flags & IOMEM_DATA_MASK) ? (flags & IOMEM_DATA_MASK) : \ 7817b93957cSeota IOMEM_DATA_CACHED) 7827b93957cSeota 7837c478bd9Sstevel@tonic-gate #ifdef __cplusplus 7847c478bd9Sstevel@tonic-gate } 7857c478bd9Sstevel@tonic-gate #endif 7867c478bd9Sstevel@tonic-gate 7877c478bd9Sstevel@tonic-gate #endif /* _SYS_DDIDMAREQ_H */ 788