1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_DDIDMAREQ_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_DDIDMAREQ_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate /* 37*7c478bd9Sstevel@tonic-gate * Memory Objects 38*7c478bd9Sstevel@tonic-gate * 39*7c478bd9Sstevel@tonic-gate * Definitions of structures that can describe 40*7c478bd9Sstevel@tonic-gate * an object that can be mapped for DMA. 41*7c478bd9Sstevel@tonic-gate */ 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate /* 44*7c478bd9Sstevel@tonic-gate * Structure describing a virtual address 45*7c478bd9Sstevel@tonic-gate */ 46*7c478bd9Sstevel@tonic-gate struct v_address { 47*7c478bd9Sstevel@tonic-gate caddr_t v_addr; /* base virtual address */ 48*7c478bd9Sstevel@tonic-gate struct as *v_as; /* pointer to address space */ 49*7c478bd9Sstevel@tonic-gate void *v_priv; /* priv data for shadow I/O */ 50*7c478bd9Sstevel@tonic-gate }; 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate /* 53*7c478bd9Sstevel@tonic-gate * Structure describing a page-based address 54*7c478bd9Sstevel@tonic-gate */ 55*7c478bd9Sstevel@tonic-gate struct pp_address { 56*7c478bd9Sstevel@tonic-gate /* 57*7c478bd9Sstevel@tonic-gate * A pointer to a circularly linked list of page structures. 58*7c478bd9Sstevel@tonic-gate */ 59*7c478bd9Sstevel@tonic-gate struct page *pp_pp; 60*7c478bd9Sstevel@tonic-gate uint_t pp_offset; /* offset within first page */ 61*7c478bd9Sstevel@tonic-gate }; 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate /* 64*7c478bd9Sstevel@tonic-gate * Structure to describe a physical memory address. 65*7c478bd9Sstevel@tonic-gate */ 66*7c478bd9Sstevel@tonic-gate struct phy_address { 67*7c478bd9Sstevel@tonic-gate ulong_t p_addr; /* base physical address */ 68*7c478bd9Sstevel@tonic-gate ulong_t p_memtype; /* memory type */ 69*7c478bd9Sstevel@tonic-gate }; 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* 72*7c478bd9Sstevel@tonic-gate * A union of all of the above structures. 73*7c478bd9Sstevel@tonic-gate * 74*7c478bd9Sstevel@tonic-gate * This union describes the relationship between 75*7c478bd9Sstevel@tonic-gate * the kind of an address description and an object. 76*7c478bd9Sstevel@tonic-gate */ 77*7c478bd9Sstevel@tonic-gate typedef union { 78*7c478bd9Sstevel@tonic-gate struct v_address virt_obj; /* Some virtual address */ 79*7c478bd9Sstevel@tonic-gate struct pp_address pp_obj; /* Some page-based address */ 80*7c478bd9Sstevel@tonic-gate struct phy_address phys_obj; /* Some physical address */ 81*7c478bd9Sstevel@tonic-gate } ddi_dma_aobj_t; 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate /* 84*7c478bd9Sstevel@tonic-gate * DMA object types - used to select how the object 85*7c478bd9Sstevel@tonic-gate * being mapped is being addressed by the IU. 86*7c478bd9Sstevel@tonic-gate */ 87*7c478bd9Sstevel@tonic-gate typedef enum { 88*7c478bd9Sstevel@tonic-gate DMA_OTYP_VADDR = 0, /* enforce starting value of zero */ 89*7c478bd9Sstevel@tonic-gate DMA_OTYP_PAGES, 90*7c478bd9Sstevel@tonic-gate DMA_OTYP_PADDR, 91*7c478bd9Sstevel@tonic-gate DMA_OTYP_BUFVADDR 92*7c478bd9Sstevel@tonic-gate } ddi_dma_atyp_t; 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate /* 95*7c478bd9Sstevel@tonic-gate * A compact package to describe an object that is to be mapped for DMA. 96*7c478bd9Sstevel@tonic-gate */ 97*7c478bd9Sstevel@tonic-gate typedef struct { 98*7c478bd9Sstevel@tonic-gate uint_t dmao_size; /* size, in bytes, of the object */ 99*7c478bd9Sstevel@tonic-gate ddi_dma_atyp_t dmao_type; /* type of object */ 100*7c478bd9Sstevel@tonic-gate ddi_dma_aobj_t dmao_obj; /* the object described */ 101*7c478bd9Sstevel@tonic-gate } ddi_dma_obj_t; 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate /* 104*7c478bd9Sstevel@tonic-gate * DMA addressing limits. 105*7c478bd9Sstevel@tonic-gate * 106*7c478bd9Sstevel@tonic-gate * This structure describes the constraints that a particular device's 107*7c478bd9Sstevel@tonic-gate * DMA engine has to its parent so that the parent may correctly set 108*7c478bd9Sstevel@tonic-gate * things up for a DMA mapping. Each parent may in turn modify the 109*7c478bd9Sstevel@tonic-gate * constraints listed in a DMA request structure in order to describe 110*7c478bd9Sstevel@tonic-gate * to its parent any changed or additional constraints. The rules 111*7c478bd9Sstevel@tonic-gate * are that each parent may modify a constraint in order to further 112*7c478bd9Sstevel@tonic-gate * constrain things (e.g., picking a more limited address range than 113*7c478bd9Sstevel@tonic-gate * that permitted by the child), but that the parent may not ignore 114*7c478bd9Sstevel@tonic-gate * a child's constraints. 115*7c478bd9Sstevel@tonic-gate * 116*7c478bd9Sstevel@tonic-gate * A particular constraint that we do *not* address is whether or not 117*7c478bd9Sstevel@tonic-gate * a requested mapping is too large for a DMA engine's counter to 118*7c478bd9Sstevel@tonic-gate * correctly track. It is still up to each driver to explicitly handle 119*7c478bd9Sstevel@tonic-gate * transfers that are too large for its own hardware to deal with directly. 120*7c478bd9Sstevel@tonic-gate * 121*7c478bd9Sstevel@tonic-gate * The mapping routines that are cognizant of this structure will 122*7c478bd9Sstevel@tonic-gate * copy any user defined limits structure if they need to modify 123*7c478bd9Sstevel@tonic-gate * the fields (as alluded to above). 124*7c478bd9Sstevel@tonic-gate * 125*7c478bd9Sstevel@tonic-gate * A note as to how to define constraints: 126*7c478bd9Sstevel@tonic-gate * 127*7c478bd9Sstevel@tonic-gate * How you define the constraints for your device depends on how you 128*7c478bd9Sstevel@tonic-gate * define your device. For example, you may have an SBus card with a 129*7c478bd9Sstevel@tonic-gate * device on it that address only the bottom 16mb of virtual DMA space. 130*7c478bd9Sstevel@tonic-gate * However, if the card also has ancillary circuitry that pulls the high 8 131*7c478bd9Sstevel@tonic-gate * bits of address lines high, the more correct expression for your device 132*7c478bd9Sstevel@tonic-gate * is that it address [0xff000000..0xffffffff] rather than [0..0x00ffffff]. 133*7c478bd9Sstevel@tonic-gate */ 134*7c478bd9Sstevel@tonic-gate #if defined(__sparc) 135*7c478bd9Sstevel@tonic-gate typedef struct ddi_dma_lim { 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate /* 138*7c478bd9Sstevel@tonic-gate * Low range of 32 bit addressing capability. 139*7c478bd9Sstevel@tonic-gate */ 140*7c478bd9Sstevel@tonic-gate uint_t dlim_addr_lo; 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate /* 143*7c478bd9Sstevel@tonic-gate * Upper inclusive bound of addressing capability. It is an 144*7c478bd9Sstevel@tonic-gate * inclusive boundary limit to allow for the addressing range 145*7c478bd9Sstevel@tonic-gate * [0..0xffffffff] to be specified in preference to [0..0]. 146*7c478bd9Sstevel@tonic-gate */ 147*7c478bd9Sstevel@tonic-gate uint_t dlim_addr_hi; 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate /* 150*7c478bd9Sstevel@tonic-gate * Inclusive upper bound with which The DMA engine's counter acts as 151*7c478bd9Sstevel@tonic-gate * a register. 152*7c478bd9Sstevel@tonic-gate * 153*7c478bd9Sstevel@tonic-gate * This handles the case where an upper portion of a DMA address 154*7c478bd9Sstevel@tonic-gate * register is a latch instead of being a full 32 bit register 155*7c478bd9Sstevel@tonic-gate * (e.g., the upper 8 bits may remain constant while the lower 156*7c478bd9Sstevel@tonic-gate * 24 bits are the real address register). 157*7c478bd9Sstevel@tonic-gate * 158*7c478bd9Sstevel@tonic-gate * This essentially gives a hint about segment limitations 159*7c478bd9Sstevel@tonic-gate * to the mapping routines. 160*7c478bd9Sstevel@tonic-gate */ 161*7c478bd9Sstevel@tonic-gate uint_t dlim_cntr_max; 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate /* 164*7c478bd9Sstevel@tonic-gate * DMA burst sizes. 165*7c478bd9Sstevel@tonic-gate * 166*7c478bd9Sstevel@tonic-gate * At the time of a mapping request, this tag defines the possible 167*7c478bd9Sstevel@tonic-gate * DMA burst cycle sizes that the requestor's DMA engine can 168*7c478bd9Sstevel@tonic-gate * emit. The format of the data is binary encoding of burst sizes 169*7c478bd9Sstevel@tonic-gate * assumed to be powers of two. That is, if a DMA engine is capable 170*7c478bd9Sstevel@tonic-gate * of doing 1, 2, 4 and 16 byte transfers, the encoding would be 0x17. 171*7c478bd9Sstevel@tonic-gate * 172*7c478bd9Sstevel@tonic-gate * As the mapping request is handled by intervening nexi, the 173*7c478bd9Sstevel@tonic-gate * burstsizes value may be modified. Prior to enabling DMA for 174*7c478bd9Sstevel@tonic-gate * the specific device, the driver that owns the DMA engine should 175*7c478bd9Sstevel@tonic-gate * check (via ddi_dma_burstsizes(9F)) what the allowed burstsizes 176*7c478bd9Sstevel@tonic-gate * have become and program their DMA engine appropriately. 177*7c478bd9Sstevel@tonic-gate */ 178*7c478bd9Sstevel@tonic-gate uint_t dlim_burstsizes; 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate /* 181*7c478bd9Sstevel@tonic-gate * Minimum effective DMA transfer size, in units of bytes. 182*7c478bd9Sstevel@tonic-gate * 183*7c478bd9Sstevel@tonic-gate * This value specifies the minimum effective granularity of the 184*7c478bd9Sstevel@tonic-gate * DMA engine. It is distinct from dlim_burtsizes in that it 185*7c478bd9Sstevel@tonic-gate * describes the minimum amount of access a DMA transfer will 186*7c478bd9Sstevel@tonic-gate * effect. dlim_burtsizes describes in what electrical fashion 187*7c478bd9Sstevel@tonic-gate * the DMA engine might perform its accesses, while dlim_minxfer 188*7c478bd9Sstevel@tonic-gate * describes the minimum amount of memory that can be touched by 189*7c478bd9Sstevel@tonic-gate * the DMA transfer. 190*7c478bd9Sstevel@tonic-gate * 191*7c478bd9Sstevel@tonic-gate * As the mapping request is handled by intervening nexi, the 192*7c478bd9Sstevel@tonic-gate * dlim_minxfer value may be modifed contingent upon the presence 193*7c478bd9Sstevel@tonic-gate * (and use) of I/O caches and DMA write buffers in between the 194*7c478bd9Sstevel@tonic-gate * DMA engine and the object that DMA is being performed on. 195*7c478bd9Sstevel@tonic-gate * 196*7c478bd9Sstevel@tonic-gate */ 197*7c478bd9Sstevel@tonic-gate uint_t dlim_minxfer; 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate /* 200*7c478bd9Sstevel@tonic-gate * Expected average data rate for this DMA engine 201*7c478bd9Sstevel@tonic-gate * while transferring data. 202*7c478bd9Sstevel@tonic-gate * 203*7c478bd9Sstevel@tonic-gate * This is used as a hint for a number of operations that might 204*7c478bd9Sstevel@tonic-gate * want to know the possible optimal latency requirements of this 205*7c478bd9Sstevel@tonic-gate * device. A value of zero will be interpreted as a 'do not care'. 206*7c478bd9Sstevel@tonic-gate */ 207*7c478bd9Sstevel@tonic-gate uint_t dlim_dmaspeed; 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate } ddi_dma_lim_t; 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate #elif defined(__x86) 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate /* 214*7c478bd9Sstevel@tonic-gate * values for dlim_minxfer 215*7c478bd9Sstevel@tonic-gate */ 216*7c478bd9Sstevel@tonic-gate #define DMA_UNIT_8 1 217*7c478bd9Sstevel@tonic-gate #define DMA_UNIT_16 2 218*7c478bd9Sstevel@tonic-gate #define DMA_UNIT_32 4 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate /* 221*7c478bd9Sstevel@tonic-gate * Version number 222*7c478bd9Sstevel@tonic-gate */ 223*7c478bd9Sstevel@tonic-gate #define DMALIM_VER0 ((0x86000000) + 0) 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate typedef struct ddi_dma_lim { 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate /* 228*7c478bd9Sstevel@tonic-gate * Low range of 32 bit addressing capability. 229*7c478bd9Sstevel@tonic-gate */ 230*7c478bd9Sstevel@tonic-gate uint_t dlim_addr_lo; 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate /* 233*7c478bd9Sstevel@tonic-gate * Upper Inclusive bound of 32 bit addressing capability. 234*7c478bd9Sstevel@tonic-gate * 235*7c478bd9Sstevel@tonic-gate * The ISA nexus restricts this to 0x00ffffff, since this bus has 236*7c478bd9Sstevel@tonic-gate * only 24 address lines. This enforces the 16 Mb address limitation. 237*7c478bd9Sstevel@tonic-gate * The EISA nexus restricts this to 0xffffffff. 238*7c478bd9Sstevel@tonic-gate */ 239*7c478bd9Sstevel@tonic-gate uint_t dlim_addr_hi; 240*7c478bd9Sstevel@tonic-gate 241*7c478bd9Sstevel@tonic-gate /* 242*7c478bd9Sstevel@tonic-gate * DMA engine counter not used; set to 0 243*7c478bd9Sstevel@tonic-gate */ 244*7c478bd9Sstevel@tonic-gate uint_t dlim_cntr_max; 245*7c478bd9Sstevel@tonic-gate 246*7c478bd9Sstevel@tonic-gate /* 247*7c478bd9Sstevel@tonic-gate * DMA burst sizes not used; set to 1 248*7c478bd9Sstevel@tonic-gate */ 249*7c478bd9Sstevel@tonic-gate uint_t dlim_burstsizes; 250*7c478bd9Sstevel@tonic-gate 251*7c478bd9Sstevel@tonic-gate /* 252*7c478bd9Sstevel@tonic-gate * Minimum effective DMA transfer size. 253*7c478bd9Sstevel@tonic-gate * 254*7c478bd9Sstevel@tonic-gate * This value specifies the minimum effective granularity of the 255*7c478bd9Sstevel@tonic-gate * DMA engine. It is distinct from dlim_burstsizes in that it 256*7c478bd9Sstevel@tonic-gate * describes the minimum amount of access a DMA transfer will 257*7c478bd9Sstevel@tonic-gate * effect. dlim_burstsizes describes in what electrical fashion 258*7c478bd9Sstevel@tonic-gate * the DMA engine might perform its accesses, while dlim_minxfer 259*7c478bd9Sstevel@tonic-gate * describes the minimum amount of memory that can be touched by 260*7c478bd9Sstevel@tonic-gate * the DMA transfer. 261*7c478bd9Sstevel@tonic-gate * 262*7c478bd9Sstevel@tonic-gate * This value also implies the required address alignment. 263*7c478bd9Sstevel@tonic-gate * The number of bytes transferred is assumed to be 264*7c478bd9Sstevel@tonic-gate * dlim_minxfer * (DMA engine count) 265*7c478bd9Sstevel@tonic-gate * 266*7c478bd9Sstevel@tonic-gate * It should be set to DMA_UNIT_8, DMA_UNIT_16, or DMA_UNIT_32. 267*7c478bd9Sstevel@tonic-gate */ 268*7c478bd9Sstevel@tonic-gate uint_t dlim_minxfer; 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate /* 271*7c478bd9Sstevel@tonic-gate * Expected average data rate for this DMA engine 272*7c478bd9Sstevel@tonic-gate * while transferring data. 273*7c478bd9Sstevel@tonic-gate * 274*7c478bd9Sstevel@tonic-gate * This is used as a hint for a number of operations that might 275*7c478bd9Sstevel@tonic-gate * want to know the possible optimal latency requirements of this 276*7c478bd9Sstevel@tonic-gate * device. A value of zero will be interpreted as a 'do not care'. 277*7c478bd9Sstevel@tonic-gate */ 278*7c478bd9Sstevel@tonic-gate uint_t dlim_dmaspeed; 279*7c478bd9Sstevel@tonic-gate 280*7c478bd9Sstevel@tonic-gate 281*7c478bd9Sstevel@tonic-gate /* 282*7c478bd9Sstevel@tonic-gate * Version number of this structure 283*7c478bd9Sstevel@tonic-gate */ 284*7c478bd9Sstevel@tonic-gate uint_t dlim_version; /* = 0x86 << 24 + 0 */ 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate /* 287*7c478bd9Sstevel@tonic-gate * Inclusive upper bound with which the DMA engine's Address acts as 288*7c478bd9Sstevel@tonic-gate * a register. 289*7c478bd9Sstevel@tonic-gate * This handles the case where an upper portion of a DMA address 290*7c478bd9Sstevel@tonic-gate * register is a latch instead of being a full 32 bit register 291*7c478bd9Sstevel@tonic-gate * (e.g., the upper 16 bits remain constant while the lower 16 bits 292*7c478bd9Sstevel@tonic-gate * are incremented for each DMA transfer). 293*7c478bd9Sstevel@tonic-gate * 294*7c478bd9Sstevel@tonic-gate * The ISA nexus restricts only 3rd-party DMA requests to 0x0000ffff, 295*7c478bd9Sstevel@tonic-gate * since the ISA DMA engine has a 16-bit register for low address and 296*7c478bd9Sstevel@tonic-gate * an 8-bit latch for high address. This enforces the first 64 Kb 297*7c478bd9Sstevel@tonic-gate * limitation (address boundary). 298*7c478bd9Sstevel@tonic-gate * The EISA nexus restricts only 3rd-party DMA requests to 0xffffffff. 299*7c478bd9Sstevel@tonic-gate */ 300*7c478bd9Sstevel@tonic-gate uint_t dlim_adreg_max; 301*7c478bd9Sstevel@tonic-gate 302*7c478bd9Sstevel@tonic-gate /* 303*7c478bd9Sstevel@tonic-gate * Maximum transfer count that the DMA engine can handle. 304*7c478bd9Sstevel@tonic-gate * 305*7c478bd9Sstevel@tonic-gate * The ISA nexus restricts only 3rd-party DMA requests to 0x0000ffff, 306*7c478bd9Sstevel@tonic-gate * since the ISA DMA engine has a 16-bit register for counting. 307*7c478bd9Sstevel@tonic-gate * This enforces the other 64 Kb limitation (count size). 308*7c478bd9Sstevel@tonic-gate * The EISA nexus restricts only 3rd-party DMA requests to 0x00ffffff, 309*7c478bd9Sstevel@tonic-gate * since the EISA DMA engine has a 24-bit register for counting. 310*7c478bd9Sstevel@tonic-gate * 311*7c478bd9Sstevel@tonic-gate * This transfer count limitation is a per segment limitation. 312*7c478bd9Sstevel@tonic-gate * It can also be used to restrict the size of segments. 313*7c478bd9Sstevel@tonic-gate * 314*7c478bd9Sstevel@tonic-gate * This is used as a bit mask, so it must be a power of 2, minus 1. 315*7c478bd9Sstevel@tonic-gate */ 316*7c478bd9Sstevel@tonic-gate uint_t dlim_ctreg_max; 317*7c478bd9Sstevel@tonic-gate 318*7c478bd9Sstevel@tonic-gate /* 319*7c478bd9Sstevel@tonic-gate * Granularity of DMA transfer, in units of bytes. 320*7c478bd9Sstevel@tonic-gate * 321*7c478bd9Sstevel@tonic-gate * Breakup sizes must be multiples of this value. 322*7c478bd9Sstevel@tonic-gate * If no scatter/gather capabilty is specified, then the size of 323*7c478bd9Sstevel@tonic-gate * each DMA transfer must be a multiple of this value. 324*7c478bd9Sstevel@tonic-gate * 325*7c478bd9Sstevel@tonic-gate * If there is scatter/gather capability, then a single cookie cannot 326*7c478bd9Sstevel@tonic-gate * be smaller in size than the minimum xfer value, and may be less 327*7c478bd9Sstevel@tonic-gate * than the granularity value. The total transfer length of the 328*7c478bd9Sstevel@tonic-gate * scatter/gather list should be a multiple of the granularity value; 329*7c478bd9Sstevel@tonic-gate * use dlim_sgllen to specify the length of the scatter/gather list. 330*7c478bd9Sstevel@tonic-gate * 331*7c478bd9Sstevel@tonic-gate * This value should be equal to the sector size of the device. 332*7c478bd9Sstevel@tonic-gate */ 333*7c478bd9Sstevel@tonic-gate uint_t dlim_granular; 334*7c478bd9Sstevel@tonic-gate 335*7c478bd9Sstevel@tonic-gate /* 336*7c478bd9Sstevel@tonic-gate * Length of scatter/gather list 337*7c478bd9Sstevel@tonic-gate * 338*7c478bd9Sstevel@tonic-gate * This value specifies the number of segments or cookies that a DMA 339*7c478bd9Sstevel@tonic-gate * engine can consume in one i/o request to the device. For 3rd-party 340*7c478bd9Sstevel@tonic-gate * DMA that uses the bus nexus this should be set to 1. Devices with 341*7c478bd9Sstevel@tonic-gate * 1st-party DMA capability should specify the number of entries in 342*7c478bd9Sstevel@tonic-gate * its scatter/gather list. The breakup routine will ensure that each 343*7c478bd9Sstevel@tonic-gate * group of dlim_sgllen cookies (within a DMA window) will have a 344*7c478bd9Sstevel@tonic-gate * total transfer length that is a multiple of dlim_granular. 345*7c478bd9Sstevel@tonic-gate * 346*7c478bd9Sstevel@tonic-gate * < 0 : tbd 347*7c478bd9Sstevel@tonic-gate * = 0 : breakup is for PIO. 348*7c478bd9Sstevel@tonic-gate * = 1 : breakup is for DMA engine with no scatter/gather 349*7c478bd9Sstevel@tonic-gate * capability. 350*7c478bd9Sstevel@tonic-gate * >= 2 : breakup is for DMA engine with scatter/gather 351*7c478bd9Sstevel@tonic-gate * capability; value is max number of entries in list. 352*7c478bd9Sstevel@tonic-gate * 353*7c478bd9Sstevel@tonic-gate * Note that this list length is not dependent on the DMA window 354*7c478bd9Sstevel@tonic-gate * size. The size of the DMA window is based on resources consumed, 355*7c478bd9Sstevel@tonic-gate * such as intermediate buffers. Several s/g lists may exist within 356*7c478bd9Sstevel@tonic-gate * a window. But the end of a window does imply the end of the s/g 357*7c478bd9Sstevel@tonic-gate * list. 358*7c478bd9Sstevel@tonic-gate */ 359*7c478bd9Sstevel@tonic-gate short dlim_sgllen; 360*7c478bd9Sstevel@tonic-gate 361*7c478bd9Sstevel@tonic-gate /* 362*7c478bd9Sstevel@tonic-gate * Size of device i/o request 363*7c478bd9Sstevel@tonic-gate * 364*7c478bd9Sstevel@tonic-gate * This value indicates the maximum number of bytes the device 365*7c478bd9Sstevel@tonic-gate * can transmit/receive for one i/o command. This limitation is 366*7c478bd9Sstevel@tonic-gate * significant ony if it is less than (dlim_ctreg_max * dlim_sgllen). 367*7c478bd9Sstevel@tonic-gate */ 368*7c478bd9Sstevel@tonic-gate uint_t dlim_reqsize; 369*7c478bd9Sstevel@tonic-gate 370*7c478bd9Sstevel@tonic-gate } ddi_dma_lim_t; 371*7c478bd9Sstevel@tonic-gate 372*7c478bd9Sstevel@tonic-gate #else 373*7c478bd9Sstevel@tonic-gate #error "struct ddi_dma_lim not defined for this architecture" 374*7c478bd9Sstevel@tonic-gate #endif /* defined(__sparc) */ 375*7c478bd9Sstevel@tonic-gate 376*7c478bd9Sstevel@tonic-gate /* 377*7c478bd9Sstevel@tonic-gate * Flags definition for dma_attr_flags 378*7c478bd9Sstevel@tonic-gate */ 379*7c478bd9Sstevel@tonic-gate 380*7c478bd9Sstevel@tonic-gate /* 381*7c478bd9Sstevel@tonic-gate * return physical DMA address on platforms 382*7c478bd9Sstevel@tonic-gate * which support DVMA 383*7c478bd9Sstevel@tonic-gate */ 384*7c478bd9Sstevel@tonic-gate #define DDI_DMA_FORCE_PHYSICAL 0x0100 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate /* 387*7c478bd9Sstevel@tonic-gate * An error will be flagged for DMA data path errors 388*7c478bd9Sstevel@tonic-gate */ 389*7c478bd9Sstevel@tonic-gate #define DDI_DMA_FLAGERR 0x200 390*7c478bd9Sstevel@tonic-gate 391*7c478bd9Sstevel@tonic-gate #define DMA_ATTR_V0 0 392*7c478bd9Sstevel@tonic-gate #define DMA_ATTR_VERSION DMA_ATTR_V0 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate typedef struct ddi_dma_attr { 395*7c478bd9Sstevel@tonic-gate uint_t dma_attr_version; /* version number */ 396*7c478bd9Sstevel@tonic-gate uint64_t dma_attr_addr_lo; /* low DMA address range */ 397*7c478bd9Sstevel@tonic-gate uint64_t dma_attr_addr_hi; /* high DMA address range */ 398*7c478bd9Sstevel@tonic-gate uint64_t dma_attr_count_max; /* DMA counter register */ 399*7c478bd9Sstevel@tonic-gate uint64_t dma_attr_align; /* DMA address alignment */ 400*7c478bd9Sstevel@tonic-gate uint_t dma_attr_burstsizes; /* DMA burstsizes */ 401*7c478bd9Sstevel@tonic-gate uint32_t dma_attr_minxfer; /* min effective DMA size */ 402*7c478bd9Sstevel@tonic-gate uint64_t dma_attr_maxxfer; /* max DMA xfer size */ 403*7c478bd9Sstevel@tonic-gate uint64_t dma_attr_seg; /* segment boundary */ 404*7c478bd9Sstevel@tonic-gate int dma_attr_sgllen; /* s/g length */ 405*7c478bd9Sstevel@tonic-gate uint32_t dma_attr_granular; /* granularity of device */ 406*7c478bd9Sstevel@tonic-gate uint_t dma_attr_flags; /* Bus specific DMA flags */ 407*7c478bd9Sstevel@tonic-gate } ddi_dma_attr_t; 408*7c478bd9Sstevel@tonic-gate 409*7c478bd9Sstevel@tonic-gate /* 410*7c478bd9Sstevel@tonic-gate * Handy macro to set a maximum bit value (should be elsewhere) 411*7c478bd9Sstevel@tonic-gate * 412*7c478bd9Sstevel@tonic-gate * Clear off all bits lower then 'mybit' in val; if there are no 413*7c478bd9Sstevel@tonic-gate * bits higher than or equal to mybit in val then set mybit. Assumes 414*7c478bd9Sstevel@tonic-gate * mybit equals some power of 2 and is not zero. 415*7c478bd9Sstevel@tonic-gate */ 416*7c478bd9Sstevel@tonic-gate #define maxbit(val, mybit) \ 417*7c478bd9Sstevel@tonic-gate ((val) & ~((mybit)-1)) | ((((val) & ~((mybit)-1)) == 0) ? (mybit) : 0) 418*7c478bd9Sstevel@tonic-gate 419*7c478bd9Sstevel@tonic-gate /* 420*7c478bd9Sstevel@tonic-gate * Handy macro to set a minimum bit value (should be elsewhere) 421*7c478bd9Sstevel@tonic-gate * 422*7c478bd9Sstevel@tonic-gate * Clear off all bits higher then 'mybit' in val; if there are no 423*7c478bd9Sstevel@tonic-gate * bits lower than or equal to mybit in val then set mybit. Assumes 424*7c478bd9Sstevel@tonic-gate * mybit equals some pow2 and is not zero. 425*7c478bd9Sstevel@tonic-gate */ 426*7c478bd9Sstevel@tonic-gate #define minbit(val, mybit) \ 427*7c478bd9Sstevel@tonic-gate (((val)&((mybit)|((mybit)-1))) | \ 428*7c478bd9Sstevel@tonic-gate ((((val) & ((mybit)-1)) == 0) ? (mybit) : 0)) 429*7c478bd9Sstevel@tonic-gate 430*7c478bd9Sstevel@tonic-gate /* 431*7c478bd9Sstevel@tonic-gate * Structure of a request to map an object for DMA. 432*7c478bd9Sstevel@tonic-gate */ 433*7c478bd9Sstevel@tonic-gate typedef struct ddi_dma_req { 434*7c478bd9Sstevel@tonic-gate /* 435*7c478bd9Sstevel@tonic-gate * Caller's DMA engine constraints. 436*7c478bd9Sstevel@tonic-gate * 437*7c478bd9Sstevel@tonic-gate * If there are no particular constraints to the caller's DMA 438*7c478bd9Sstevel@tonic-gate * engine, this field may be set to NULL. The implementation DMA 439*7c478bd9Sstevel@tonic-gate * setup functions will then select a set of standard beginning 440*7c478bd9Sstevel@tonic-gate * constraints. 441*7c478bd9Sstevel@tonic-gate * 442*7c478bd9Sstevel@tonic-gate * In either case, as the mapping proceeds, the initial DMA 443*7c478bd9Sstevel@tonic-gate * constraints may become more restrictive as each intervening 444*7c478bd9Sstevel@tonic-gate * nexus might add further restrictions. 445*7c478bd9Sstevel@tonic-gate */ 446*7c478bd9Sstevel@tonic-gate ddi_dma_lim_t *dmar_limits; 447*7c478bd9Sstevel@tonic-gate 448*7c478bd9Sstevel@tonic-gate /* 449*7c478bd9Sstevel@tonic-gate * Contains the information passed to the DMA mapping allocation 450*7c478bd9Sstevel@tonic-gate * routine(s). 451*7c478bd9Sstevel@tonic-gate */ 452*7c478bd9Sstevel@tonic-gate uint_t dmar_flags; 453*7c478bd9Sstevel@tonic-gate 454*7c478bd9Sstevel@tonic-gate /* 455*7c478bd9Sstevel@tonic-gate * Callback function. A caller of the DMA mapping functions must 456*7c478bd9Sstevel@tonic-gate * specify by filling in this field whether the allocation routines 457*7c478bd9Sstevel@tonic-gate * can sleep awaiting mapping resources, must *not* sleep awaiting 458*7c478bd9Sstevel@tonic-gate * resources, or may *not* sleep awaiting any resources and must 459*7c478bd9Sstevel@tonic-gate * call the function specified by dmar_fp with the the argument 460*7c478bd9Sstevel@tonic-gate * dmar_arg when resources might have become available at a future 461*7c478bd9Sstevel@tonic-gate * time. 462*7c478bd9Sstevel@tonic-gate */ 463*7c478bd9Sstevel@tonic-gate int (*dmar_fp)(); 464*7c478bd9Sstevel@tonic-gate 465*7c478bd9Sstevel@tonic-gate caddr_t dmar_arg; /* Callback function argument */ 466*7c478bd9Sstevel@tonic-gate 467*7c478bd9Sstevel@tonic-gate /* 468*7c478bd9Sstevel@tonic-gate * Description of the object to be mapped for DMA. 469*7c478bd9Sstevel@tonic-gate * Must be last in this structure in case that the 470*7c478bd9Sstevel@tonic-gate * union ddi_dma_obj_t changes in the future. 471*7c478bd9Sstevel@tonic-gate */ 472*7c478bd9Sstevel@tonic-gate ddi_dma_obj_t dmar_object; 473*7c478bd9Sstevel@tonic-gate 474*7c478bd9Sstevel@tonic-gate } ddi_dma_req_t; 475*7c478bd9Sstevel@tonic-gate 476*7c478bd9Sstevel@tonic-gate /* 477*7c478bd9Sstevel@tonic-gate * Defines for the DMA mapping allocation functions 478*7c478bd9Sstevel@tonic-gate * 479*7c478bd9Sstevel@tonic-gate * If a DMA callback funtion is set to anything other than the following 480*7c478bd9Sstevel@tonic-gate * defines then it is assumed that one wishes a callback and is providing 481*7c478bd9Sstevel@tonic-gate * a function address. 482*7c478bd9Sstevel@tonic-gate */ 483*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 484*7c478bd9Sstevel@tonic-gate #define DDI_DMA_DONTWAIT ((int (*)(caddr_t))0) 485*7c478bd9Sstevel@tonic-gate #define DDI_DMA_SLEEP ((int (*)(caddr_t))1) 486*7c478bd9Sstevel@tonic-gate #else 487*7c478bd9Sstevel@tonic-gate #define DDI_DMA_DONTWAIT ((int (*)())0) 488*7c478bd9Sstevel@tonic-gate #define DDI_DMA_SLEEP ((int (*)())1) 489*7c478bd9Sstevel@tonic-gate #endif 490*7c478bd9Sstevel@tonic-gate 491*7c478bd9Sstevel@tonic-gate /* 492*7c478bd9Sstevel@tonic-gate * Return values from callback functions. 493*7c478bd9Sstevel@tonic-gate */ 494*7c478bd9Sstevel@tonic-gate #define DDI_DMA_CALLBACK_RUNOUT 0 495*7c478bd9Sstevel@tonic-gate #define DDI_DMA_CALLBACK_DONE 1 496*7c478bd9Sstevel@tonic-gate 497*7c478bd9Sstevel@tonic-gate /* 498*7c478bd9Sstevel@tonic-gate * Flag definitions for the allocation functions. 499*7c478bd9Sstevel@tonic-gate */ 500*7c478bd9Sstevel@tonic-gate #define DDI_DMA_WRITE 0x0001 /* Direction memory --> IO */ 501*7c478bd9Sstevel@tonic-gate #define DDI_DMA_READ 0x0002 /* Direction IO --> memory */ 502*7c478bd9Sstevel@tonic-gate #define DDI_DMA_RDWR (DDI_DMA_READ | DDI_DMA_WRITE) 503*7c478bd9Sstevel@tonic-gate 504*7c478bd9Sstevel@tonic-gate /* 505*7c478bd9Sstevel@tonic-gate * If possible, establish a MMU redzone after the mapping (to protect 506*7c478bd9Sstevel@tonic-gate * against cheap DMA hardware that might get out of control). 507*7c478bd9Sstevel@tonic-gate */ 508*7c478bd9Sstevel@tonic-gate #define DDI_DMA_REDZONE 0x0004 509*7c478bd9Sstevel@tonic-gate 510*7c478bd9Sstevel@tonic-gate /* 511*7c478bd9Sstevel@tonic-gate * A partial allocation is allowed. That is, if the size of the object 512*7c478bd9Sstevel@tonic-gate * exceeds the mapping resources available, only map a portion of the 513*7c478bd9Sstevel@tonic-gate * object and return status indicating that this took place. The caller 514*7c478bd9Sstevel@tonic-gate * can use the functions ddi_dma_numwin(9F) and ddi_dma_getwin(9F) to 515*7c478bd9Sstevel@tonic-gate * change, at a later point, the actual mapped portion of the object. 516*7c478bd9Sstevel@tonic-gate * 517*7c478bd9Sstevel@tonic-gate * The mapped portion begins at offset 0 of the object. 518*7c478bd9Sstevel@tonic-gate * 519*7c478bd9Sstevel@tonic-gate */ 520*7c478bd9Sstevel@tonic-gate #define DDI_DMA_PARTIAL 0x0008 521*7c478bd9Sstevel@tonic-gate 522*7c478bd9Sstevel@tonic-gate /* 523*7c478bd9Sstevel@tonic-gate * Map the object for byte consistent access. Note that explicit 524*7c478bd9Sstevel@tonic-gate * synchronization (via ddi_dma_sync(9F)) will still be required. 525*7c478bd9Sstevel@tonic-gate * Consider this flag to be a hint to the mapping routines as to 526*7c478bd9Sstevel@tonic-gate * the intended use of the mapping. 527*7c478bd9Sstevel@tonic-gate * 528*7c478bd9Sstevel@tonic-gate * Normal data transfers can be usually consider to use 'streaming' 529*7c478bd9Sstevel@tonic-gate * modes of operations. They start at a specific point, transfer a 530*7c478bd9Sstevel@tonic-gate * fairly large amount of data sequentially, and then stop (usually 531*7c478bd9Sstevel@tonic-gate * on a well aligned boundary). 532*7c478bd9Sstevel@tonic-gate * 533*7c478bd9Sstevel@tonic-gate * Control mode data transfers (for memory resident device control blocks, 534*7c478bd9Sstevel@tonic-gate * e.g., ethernet message descriptors) do not access memory in such 535*7c478bd9Sstevel@tonic-gate * a streaming sequential fashion. Instead, they tend to modify a few 536*7c478bd9Sstevel@tonic-gate * words or bytes, move around and maybe modify a few more. 537*7c478bd9Sstevel@tonic-gate * 538*7c478bd9Sstevel@tonic-gate * There are many machine implementations that make this difficult to 539*7c478bd9Sstevel@tonic-gate * control in a generic and seamless fashion. Therefore, explicit synch- 540*7c478bd9Sstevel@tonic-gate * ronization steps (via ddi_dma_sync(9F)) are still required (even if you 541*7c478bd9Sstevel@tonic-gate * ask for a byte-consistent mapping) in order to make the view of the 542*7c478bd9Sstevel@tonic-gate * memory object shared between a CPU and a DMA master in consistent. 543*7c478bd9Sstevel@tonic-gate * However, judicious use of this flag can give sufficient hints to 544*7c478bd9Sstevel@tonic-gate * the mapping routines to attempt to pick the most efficacious mapping 545*7c478bd9Sstevel@tonic-gate * such that the synchronization steps are as efficient as possible. 546*7c478bd9Sstevel@tonic-gate * 547*7c478bd9Sstevel@tonic-gate */ 548*7c478bd9Sstevel@tonic-gate #define DDI_DMA_CONSISTENT 0x0010 549*7c478bd9Sstevel@tonic-gate 550*7c478bd9Sstevel@tonic-gate /* 551*7c478bd9Sstevel@tonic-gate * Some DMA mappings have to be 'exclusive' access. 552*7c478bd9Sstevel@tonic-gate */ 553*7c478bd9Sstevel@tonic-gate #define DDI_DMA_EXCLUSIVE 0x0020 554*7c478bd9Sstevel@tonic-gate 555*7c478bd9Sstevel@tonic-gate /* 556*7c478bd9Sstevel@tonic-gate * Sequential, unidirectional, block-sized and block aligned transfers 557*7c478bd9Sstevel@tonic-gate */ 558*7c478bd9Sstevel@tonic-gate #define DDI_DMA_STREAMING 0x0040 559*7c478bd9Sstevel@tonic-gate 560*7c478bd9Sstevel@tonic-gate /* 561*7c478bd9Sstevel@tonic-gate * Support for 64-bit SBus devices 562*7c478bd9Sstevel@tonic-gate */ 563*7c478bd9Sstevel@tonic-gate #define DDI_DMA_SBUS_64BIT 0x2000 564*7c478bd9Sstevel@tonic-gate 565*7c478bd9Sstevel@tonic-gate /* 566*7c478bd9Sstevel@tonic-gate * Return values from the mapping allocation functions. 567*7c478bd9Sstevel@tonic-gate */ 568*7c478bd9Sstevel@tonic-gate 569*7c478bd9Sstevel@tonic-gate /* 570*7c478bd9Sstevel@tonic-gate * succeeded in satisfying request 571*7c478bd9Sstevel@tonic-gate */ 572*7c478bd9Sstevel@tonic-gate #define DDI_DMA_MAPPED 0 573*7c478bd9Sstevel@tonic-gate 574*7c478bd9Sstevel@tonic-gate /* 575*7c478bd9Sstevel@tonic-gate * Mapping is legitimate (for advisory calls). 576*7c478bd9Sstevel@tonic-gate */ 577*7c478bd9Sstevel@tonic-gate #define DDI_DMA_MAPOK 0 578*7c478bd9Sstevel@tonic-gate 579*7c478bd9Sstevel@tonic-gate /* 580*7c478bd9Sstevel@tonic-gate * Succeeded in mapping a portion of the request. 581*7c478bd9Sstevel@tonic-gate */ 582*7c478bd9Sstevel@tonic-gate #define DDI_DMA_PARTIAL_MAP 1 583*7c478bd9Sstevel@tonic-gate 584*7c478bd9Sstevel@tonic-gate /* 585*7c478bd9Sstevel@tonic-gate * indicates end of window/segment list 586*7c478bd9Sstevel@tonic-gate */ 587*7c478bd9Sstevel@tonic-gate #define DDI_DMA_DONE 2 588*7c478bd9Sstevel@tonic-gate 589*7c478bd9Sstevel@tonic-gate /* 590*7c478bd9Sstevel@tonic-gate * No resources to map request. 591*7c478bd9Sstevel@tonic-gate */ 592*7c478bd9Sstevel@tonic-gate #define DDI_DMA_NORESOURCES -1 593*7c478bd9Sstevel@tonic-gate 594*7c478bd9Sstevel@tonic-gate /* 595*7c478bd9Sstevel@tonic-gate * Can't establish a mapping to the specified object 596*7c478bd9Sstevel@tonic-gate * (no specific reason). 597*7c478bd9Sstevel@tonic-gate */ 598*7c478bd9Sstevel@tonic-gate #define DDI_DMA_NOMAPPING -2 599*7c478bd9Sstevel@tonic-gate 600*7c478bd9Sstevel@tonic-gate /* 601*7c478bd9Sstevel@tonic-gate * The request is too big to be mapped. 602*7c478bd9Sstevel@tonic-gate */ 603*7c478bd9Sstevel@tonic-gate #define DDI_DMA_TOOBIG -3 604*7c478bd9Sstevel@tonic-gate 605*7c478bd9Sstevel@tonic-gate /* 606*7c478bd9Sstevel@tonic-gate * The request is too small to be mapped. 607*7c478bd9Sstevel@tonic-gate */ 608*7c478bd9Sstevel@tonic-gate #define DDI_DMA_TOOSMALL -4 609*7c478bd9Sstevel@tonic-gate 610*7c478bd9Sstevel@tonic-gate /* 611*7c478bd9Sstevel@tonic-gate * The request cannot be mapped because the object 612*7c478bd9Sstevel@tonic-gate * is locked against mapping by another DMA master. 613*7c478bd9Sstevel@tonic-gate */ 614*7c478bd9Sstevel@tonic-gate #define DDI_DMA_LOCKED -5 615*7c478bd9Sstevel@tonic-gate 616*7c478bd9Sstevel@tonic-gate /* 617*7c478bd9Sstevel@tonic-gate * The request cannot be mapped because the limits 618*7c478bd9Sstevel@tonic-gate * structure has bogus values. 619*7c478bd9Sstevel@tonic-gate */ 620*7c478bd9Sstevel@tonic-gate #define DDI_DMA_BADLIMITS -6 621*7c478bd9Sstevel@tonic-gate 622*7c478bd9Sstevel@tonic-gate /* 623*7c478bd9Sstevel@tonic-gate * the segment/window pointer is stale 624*7c478bd9Sstevel@tonic-gate */ 625*7c478bd9Sstevel@tonic-gate #define DDI_DMA_STALE -7 626*7c478bd9Sstevel@tonic-gate 627*7c478bd9Sstevel@tonic-gate /* 628*7c478bd9Sstevel@tonic-gate * The system can't allocate DMA resources using 629*7c478bd9Sstevel@tonic-gate * the given DMA attributes 630*7c478bd9Sstevel@tonic-gate */ 631*7c478bd9Sstevel@tonic-gate #define DDI_DMA_BADATTR -8 632*7c478bd9Sstevel@tonic-gate 633*7c478bd9Sstevel@tonic-gate /* 634*7c478bd9Sstevel@tonic-gate * A DMA handle is already used for a DMA 635*7c478bd9Sstevel@tonic-gate */ 636*7c478bd9Sstevel@tonic-gate #define DDI_DMA_INUSE -9 637*7c478bd9Sstevel@tonic-gate 638*7c478bd9Sstevel@tonic-gate /* 639*7c478bd9Sstevel@tonic-gate * In order for the access to a memory object to be consistent 640*7c478bd9Sstevel@tonic-gate * between a device and a CPU, the function ddi_dma_sync(9F) 641*7c478bd9Sstevel@tonic-gate * must be called upon the DMA handle. The following flags 642*7c478bd9Sstevel@tonic-gate * define whose view of the object should be made consistent. 643*7c478bd9Sstevel@tonic-gate * There are different flags here because on different machines 644*7c478bd9Sstevel@tonic-gate * there are definite performance implications of how long 645*7c478bd9Sstevel@tonic-gate * such synchronization takes. 646*7c478bd9Sstevel@tonic-gate * 647*7c478bd9Sstevel@tonic-gate * DDI_DMA_SYNC_FORDEV makes all device references to the object 648*7c478bd9Sstevel@tonic-gate * mapped by the DMA handle up to date. It should be used by a 649*7c478bd9Sstevel@tonic-gate * driver after a cpu modifies the memory object (over the range 650*7c478bd9Sstevel@tonic-gate * specified by the other arguments to the ddi_dma_sync(9F) call). 651*7c478bd9Sstevel@tonic-gate * 652*7c478bd9Sstevel@tonic-gate * DDI_DMA_SYNC_FORCPU makes all cpu references to the object 653*7c478bd9Sstevel@tonic-gate * mapped by the DMA handle up to date. It should be used 654*7c478bd9Sstevel@tonic-gate * by a driver after the receipt of data from the device to 655*7c478bd9Sstevel@tonic-gate * the memory object is done (over the range specified by 656*7c478bd9Sstevel@tonic-gate * the other arguments to the ddi_dma_sync(9F) call). 657*7c478bd9Sstevel@tonic-gate * 658*7c478bd9Sstevel@tonic-gate * If the only mapping that concerns the driver is one for the 659*7c478bd9Sstevel@tonic-gate * kernel (such as memory allocated by ddi_iopb_alloc(9F)), the 660*7c478bd9Sstevel@tonic-gate * flag DDI_DMA_SYNC_FORKERNEL can be used. This is a hint to the 661*7c478bd9Sstevel@tonic-gate * system that if it can synchronize the kernel's view faster 662*7c478bd9Sstevel@tonic-gate * that the CPU's view, it can do so, otherwise it acts the 663*7c478bd9Sstevel@tonic-gate * same as DDI_DMA_SYNC_FORCPU. DDI_DMA_SYNC_FORKERNEL might 664*7c478bd9Sstevel@tonic-gate * speed up the synchronization of kernel mappings in case of 665*7c478bd9Sstevel@tonic-gate * non IO-coherent CPU caches. 666*7c478bd9Sstevel@tonic-gate */ 667*7c478bd9Sstevel@tonic-gate #define DDI_DMA_SYNC_FORDEV 0x0 668*7c478bd9Sstevel@tonic-gate #define DDI_DMA_SYNC_FORCPU 0x1 669*7c478bd9Sstevel@tonic-gate #define DDI_DMA_SYNC_FORKERNEL 0x2 670*7c478bd9Sstevel@tonic-gate 671*7c478bd9Sstevel@tonic-gate /* 672*7c478bd9Sstevel@tonic-gate * Bus nexus control functions for DMA 673*7c478bd9Sstevel@tonic-gate */ 674*7c478bd9Sstevel@tonic-gate 675*7c478bd9Sstevel@tonic-gate /* 676*7c478bd9Sstevel@tonic-gate * Control operations, defined here so that devops.h can be included 677*7c478bd9Sstevel@tonic-gate * by drivers without having to include a specific SYSDDI implementation 678*7c478bd9Sstevel@tonic-gate * header file. 679*7c478bd9Sstevel@tonic-gate */ 680*7c478bd9Sstevel@tonic-gate 681*7c478bd9Sstevel@tonic-gate enum ddi_dma_ctlops { 682*7c478bd9Sstevel@tonic-gate DDI_DMA_FREE, /* free reference to object */ 683*7c478bd9Sstevel@tonic-gate DDI_DMA_SYNC, /* synchronize cache references */ 684*7c478bd9Sstevel@tonic-gate DDI_DMA_HTOC, /* return DMA cookie for handle */ 685*7c478bd9Sstevel@tonic-gate DDI_DMA_KVADDR, /* return kernel virtual address */ 686*7c478bd9Sstevel@tonic-gate DDI_DMA_MOVWIN, /* change mapped DMA window on object */ 687*7c478bd9Sstevel@tonic-gate DDI_DMA_REPWIN, /* report current window on DMA object */ 688*7c478bd9Sstevel@tonic-gate DDI_DMA_GETERR, /* report any post-transfer DMA errors */ 689*7c478bd9Sstevel@tonic-gate DDI_DMA_COFF, /* convert a DMA cookie to an offset */ 690*7c478bd9Sstevel@tonic-gate DDI_DMA_NEXTWIN, /* get next window within object */ 691*7c478bd9Sstevel@tonic-gate DDI_DMA_NEXTSEG, /* get next segment within window */ 692*7c478bd9Sstevel@tonic-gate DDI_DMA_SEGTOC, /* return segment DMA cookie */ 693*7c478bd9Sstevel@tonic-gate DDI_DMA_RESERVE, /* reserve some DVMA range */ 694*7c478bd9Sstevel@tonic-gate DDI_DMA_RELEASE, /* free preallocated DVMA range */ 695*7c478bd9Sstevel@tonic-gate DDI_DMA_RESETH, /* reset next cookie ptr in handle */ 696*7c478bd9Sstevel@tonic-gate DDI_DMA_CKSYNC, /* sync intermediate buffer to cookies */ 697*7c478bd9Sstevel@tonic-gate DDI_DMA_IOPB_ALLOC, /* get contiguous DMA-able memory */ 698*7c478bd9Sstevel@tonic-gate DDI_DMA_IOPB_FREE, /* return contiguous DMA-able memory */ 699*7c478bd9Sstevel@tonic-gate DDI_DMA_SMEM_ALLOC, /* get contiguous DMA-able memory */ 700*7c478bd9Sstevel@tonic-gate DDI_DMA_SMEM_FREE, /* return contiguous DMA-able memory */ 701*7c478bd9Sstevel@tonic-gate DDI_DMA_SET_SBUS64, /* 64 bit SBus support */ 702*7c478bd9Sstevel@tonic-gate DDI_DMA_REMAP, /* remap DMA buffers after relocation */ 703*7c478bd9Sstevel@tonic-gate 704*7c478bd9Sstevel@tonic-gate /* 705*7c478bd9Sstevel@tonic-gate * control ops for DMA engine on motherboard 706*7c478bd9Sstevel@tonic-gate */ 707*7c478bd9Sstevel@tonic-gate DDI_DMA_E_ACQUIRE, /* get channel for exclusive use */ 708*7c478bd9Sstevel@tonic-gate DDI_DMA_E_FREE, /* release channel */ 709*7c478bd9Sstevel@tonic-gate DDI_DMA_E_1STPTY, /* setup channel for 1st party DMA */ 710*7c478bd9Sstevel@tonic-gate DDI_DMA_E_GETCB, /* get control block for DMA engine */ 711*7c478bd9Sstevel@tonic-gate DDI_DMA_E_FREECB, /* free control blk for DMA engine */ 712*7c478bd9Sstevel@tonic-gate DDI_DMA_E_PROG, /* program channel of DMA engine */ 713*7c478bd9Sstevel@tonic-gate DDI_DMA_E_SWSETUP, /* setup channel for software control */ 714*7c478bd9Sstevel@tonic-gate DDI_DMA_E_SWSTART, /* software operation of DMA channel */ 715*7c478bd9Sstevel@tonic-gate DDI_DMA_E_ENABLE, /* enable channel of DMA engine */ 716*7c478bd9Sstevel@tonic-gate DDI_DMA_E_STOP, /* stop a channel of DMA engine */ 717*7c478bd9Sstevel@tonic-gate DDI_DMA_E_DISABLE, /* disable channel of DMA engine */ 718*7c478bd9Sstevel@tonic-gate DDI_DMA_E_GETCNT, /* get remaining xfer count */ 719*7c478bd9Sstevel@tonic-gate DDI_DMA_E_GETLIM, /* get DMA engine limits */ 720*7c478bd9Sstevel@tonic-gate DDI_DMA_E_GETATTR /* get DMA engine attributes */ 721*7c478bd9Sstevel@tonic-gate }; 722*7c478bd9Sstevel@tonic-gate 723*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 724*7c478bd9Sstevel@tonic-gate } 725*7c478bd9Sstevel@tonic-gate #endif 726*7c478bd9Sstevel@tonic-gate 727*7c478bd9Sstevel@tonic-gate #endif /* _SYS_DDIDMAREQ_H */ 728