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