]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IODMACommand.h
xnu-792.18.15.tar.gz
[apple/xnu.git] / iokit / IOKit / IODMACommand.h
CommitLineData
89b3af67
A
1/*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28#ifndef _IODMACOMMAND_H
29#define _IODMACOMMAND_H
30
31#include <IOKit/IOCommand.h>
32#include <IOKit/IOMemoryDescriptor.h>
33class IOMapper;
34
35/**************************** class IODMACommand ***************************/
36
37/*!
38 @class IODMACommand
39 @abstract A mechanism to convert memory references to I/O bus addresses.
40 @discussion The IODMACommand is supersedes the IOMemoryCursor and greatly enhances the functionality and power of it. The command can be specified to output 64 bit physical addresses and also allows driver writers bypass mapping hardware or get addresses suitable for non-snooped DMA.
41<br><br>
42 The command is designed to be very easily subclassable. Most driver writers need to associate some DMA operations with their memory descriptor and usually use a C structure for that purpose. This structure is often kept in a linked list. This IODMACommand has built it <kern/queue.h> linkage and can be derived and 'public:' variables added, giving the developer a structure that can associate a memory descriptor with a particular dma command but will also allow the developer to generate that command and keep the state necessary for tracking it.
43<br><br>
44 It is envisaged that a pool of IODMACommands will be created at driver initialisation and each command will be kept in an IOCommandPool while not in use. However if developers wishes to maintain their own free lists that is certainly possible. See the <kern/queue.h> and <xnu/iokit/Kernel/IOCommandPool> for sample code on manipulating the command's doubly linked list entries.
45<br><br>
46 The IODMACommand can be used in a 'weak-linked' manner. To do this you must avoid using any static member functions. Use the, much slower but safe, weakWithSpecification function. On success a dma command instance will be returned. This instance can then be used to clone as many commands as is needed. Remember deriving from this class can not be done weakly, that is no weak subclassing!
47*/
48
49class IODMACommand : public IOCommand
50{
51 OSDeclareDefaultStructors(IODMACommand);
52
53public:
54
55/*!
56 @typedef Segment32
57 @discussion A 32 bit I/O bus address/length pair
58*/
59 struct Segment32 {
60 UInt32 fIOVMAddr, fLength;
61 };
62
63/*!
64 @typedef Segment64
65 @discussion A 64 bit I/O bus address/length pair
66*/
67 struct Segment64 {
68 UInt64 fIOVMAddr, fLength;
69 };
70
71/*! @enum MappingOptions
72 @abstract Mapping types to indicate the desired mapper type for translating memory descriptors into I/O DMA Bus addresses.
73 @constant kNonCoherent Used by drivers for non-coherent transfers, implies unmapped memmory
74 @constant kMapped Allow a driver to define addressing size
75 @constant kBypassed Allow drivers to bypass any mapper
76 @constant kMaxMappingOptions Internal use only
77*/
78 enum MappingOptions {
79 kMapped = 0x00000000,
80 kBypassed = 0x00000001,
81 kNonCoherent = 0x00000002,
82 kTypeMask = 0x0000000f,
83
84 kNoCacheStore = 0x00000010, // Memory in descriptor
85 kOnChip = 0x00000020, // Indicates DMA is on South Bridge
86 kIterateOnly = 0x00000040 // DMACommand will be used as a cursor only
87 };
88
89/*! @enum SynchronizeOptions
90 @abstract Options for the synchronize method.
91 @constant kForceDoubleBuffer Copy the entire prepared range to a new page aligned buffer.
92*/
93 enum SynchronizeOptions {
94 kForceDoubleBuffer = 0x01000000
95 };
96
97/*!
98 @typedef SegmentFunction
99 @discussion Pointer to a C function that translates a 64 segment and outputs a single desired segment to the array at the requested index. There are a group of pre-implemented SegmentFunctions that may be usefull to the developer below.
100 @param segment The 64Bit I/O bus address and length.
101 @param segments Base of the output vector of DMA address length pairs.
102 @param segmentIndex Index to output 'segment' in the 'segments' array.
103 @result Returns true if segment encoding succeeded. false may be returned if the current segment does not fit in an output segment, i.e. a 38bit address wont fit into a 32 encoding.
104*/
105 typedef bool (*SegmentFunction)(IODMACommand *target,
106 Segment64 segment,
107 void *segments,
108 UInt32 segmentIndex);
109
110 // -------------- Preimplemented output functions ----------------
111
112/*! @function OutputHost32
113 @abstract Output host natural Segment32 output segment function.
114*/
115 static bool OutputHost32(IODMACommand *target,
116 Segment64 seg, void *segs, UInt32 ind);
117
118/*! @defined kIODMACommandOutputHost32
119 @abstract Output host natural Segment32 output segment function.
120 */
121#define kIODMACommandOutputHost32 (IODMACommand::OutputHost32)
122
123/*! @function OutputBig32
124 @abstract Output big-endian Segment32 output segment function.
125*/
126 static bool OutputBig32(IODMACommand *target,
127 Segment64 seg, void *segs, UInt32 ind);
128
129/*! @defined kIODMACommandOutputBig32
130 @abstract Output big-endian Segment32 output segment function.
131 */
132#define kIODMACommandOutputBig32 (IODMACommand::OutputBig32)
133
134/*! @function OutputLittle32
135 @abstract Output little-endian Segment32 output segment function.
136*/
137 static bool OutputLittle32(IODMACommand *target,
138 Segment64 seg, void *segs, UInt32 ind);
139
140/*! @defined kIODMACommandOutputLittle32
141 @abstract Output little-endian Segment32 output segment function.
142*/
143#define kIODMACommandOutputLittle32 (IODMACommand::OutputLittle32)
144
145/*! @function OutputHost64
146 @abstract Output host natural Segment64 output segment function.
147*/
148 static bool OutputHost64(IODMACommand *target,
149 Segment64 seg, void *segs, UInt32 ind);
150
151/*! @defined kIODMACommandOutputHost64
152 @abstract Output host natural Segment64 output segment function.
153*/
154#define kIODMACommandOutputHost64 (IODMACommand::OutputHost64)
155
156/*! @function OutputBig64
157 @abstract Output big-endian Segment64 output segment function.
158*/
159 static bool OutputBig64(IODMACommand *target,
160 Segment64 seg, void *segs, UInt32 ind);
161
162/*! @defined kIODMACommandOutputLittle64
163 @abstract Output little-endian Segment64 output segment function.
164*/
165#define kIODMACommandOutputBig64 (IODMACommand::OutputBig64)
166
167/*! @function OutputLittle64
168 @abstract Output little-endian Segment64 output segment function.
169*/
170 static bool OutputLittle64(IODMACommand *target,
171 Segment64 seg, void *segs, UInt32 ind);
172
173/*! @defined kIODMACommandOutputBig64
174 @abstract Output big-endian Segment64 output segment function.
175*/
176#define kIODMACommandOutputLittle64 (IODMACommand::OutputLittle64)
177
178/*! @function withSpecification
179 @abstract Creates and initializes an IODMACommand in one operation.
180 @discussion Factory function to create and initialize an IODMACommand in one operation.
181 @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
182 @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
183 @param maxSegmentSize Maximum allowable size for one segment. If 0 is passed the maximum segment size is unlimited.
184 @param mappingOptions is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below.This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transferes are into coherent memory but no mapping is required. See also prepare() for failure cases.
185 @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
186 @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
187 @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
188 @result Returns a new memory cursor if successfully created and initialized, 0 otherwise.
189*/
190 static IODMACommand *
191 withSpecification(SegmentFunction outSegFunc,
192 UInt8 numAddressBits,
193 UInt64 maxSegmentSize,
194 MappingOptions mappingOptions = kMapped,
195 UInt64 maxTransferSize = 0,
196 UInt32 alignment = 1,
197 IOMapper *mapper = 0,
198 void *refCon = 0);
199
200/*! @function weakWithSpecification
201 @abstract Creates and initialises an IODMACommand in one operation if this version of the operating system supports it.
202 @discussion Factory function to create and initialise an IODMACommand in one operation. The function allows a developer to 'weak' link with IODMACommand. This function will return kIOReturnUnsupported if the IODMACommand is unavailable. This function is actually fairly slow so it will be better to call it once then clone the successfully create command using cloneCommand (q.v.).
203 @param newCommand Output reference variable of the newly created IODMACommand.
204 @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
205 @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
206 @param maxSegmentSize Maximum allowable size for one segment. Zero is treated as an unlimited segment size.
207 @param mapType is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below. This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transfers are into coherent memory but no mapping is required. See also prepare() for failure cases.
208 @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
209 @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
210 @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
211 @result kIOReturnSuccess if everything is OK, otherwise kIOReturnBadArgument if newCommand is NULL, kIOReturnUnsupported if the kernel doesn't export IODMACommand or IOReturnError if the new command fails to init, q.v. initWithSpecification.
212*/
213 // Note that the function has the attribute always_inline.
214 // The point of this function is to make a call into the kernel
215 // without generating an undefined symbol. If the client could call
216 // the code as a function then the goal of no undefined symbols
217 // would be lost thus defeating the purpose.
218 static inline IOReturn weakWithSpecification
219 (IODMACommand **newCommand,
220 SegmentFunction outSegFunc,
221 UInt8 numAddressBits,
222 UInt64 maxSegmentSize,
223 MappingOptions mapType = kMapped,
224 UInt64 maxTransferSize = 0,
225 UInt32 alignment = 1,
226 IOMapper *mapper = 0,
227 void *refCon = 0) __attribute__((always_inline));
228
229/*!
230 @function cloneCommand
231 @abstract Creates a new command based on the specification of the current one.
232 @discussion Factory function to create and initialise an IODMACommand in one operation. The current command's specification will be duplicated in the new object, but however none of its state will be duplicated. This means that it is safe to clone a command even if it is currently active and running, however you must be certain that the command to be duplicated does have a valid reference for the duration.
233 @result Returns a new memory cursor if successfully created and initialised, 0 otherwise.
234*/
235 virtual IODMACommand *cloneCommand(void *refCon = 0);
236
237/*! @function initWithSpecification
238 @abstract Primary initializer for the IODMACommand class.
239 @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
240 @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
241 @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0 which means any size.
242 @param mappingOptions is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below.This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transferes are into coherent memory but no mapping is required. See also prepare() for failure cases.
243 @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
244 @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
245 @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
246 @result Can fail if the mapping type is not recognised, if one of the 3 mandatory parameters are set to 0, if a 32 bit output function is selected when more than 32 bits of address is required or, if kBypassed is requested on a machine that doesn't support bypassing. Returns true otherwise.
247*/
248 virtual bool initWithSpecification( SegmentFunction outSegFunc,
249 UInt8 numAddressBits,
250 UInt64 maxSegmentSize,
251 MappingOptions mappingOptions = kMapped,
252 UInt64 maxTransferSize = 0,
253 UInt32 alignment = 1,
254 IOMapper *mapper = 0,
255 void *refCon = 0);
256
257/*! @function setMemoryDescriptor
258 @abstract Sets and resets the DMACommand's current memory descriptor
259 @discussion The DMA command will configure itself based on the information that it finds in the memory descriptor. It looks for things like the direction of the memory descriptor and whether the current memory descriptor is already mapped into some IOMMU. As a programmer convenience it can also prepare the memory descriptor immediately. See prepare(). Note the IODMACommand is designed to used multiple times with a succession of memory descriptors, making the pooling of commands possible. It is an error though to attempt to reset a currently prepared() DMA command. Warning: This routine may block so never try to autoprepare an IODMACommand while in a gated context, i.e. one of the WorkLoops action call outs.
260 @param mem A pointer to the current I/Os memory descriptor.
261 @param autoPrepare An optional boolean variable that will call the prepare() function automatically after the memory descriptor is processed. Defaults to true.
262 @result Returns kIOReturnSuccess, kIOReturnBusy if currently prepared, kIOReturnNoSpace if the length(mem) >= Maximum Transfer Size or the error codes returned by prepare() (qv).
263*/
264 virtual IOReturn setMemoryDescriptor(const IOMemoryDescriptor *mem,
265 bool autoPrepare = true);
266
267/*! @function clearMemoryDescriptor
268 @abstract Clears the DMACommand's current memory descriptor
269 @discussion completes and invalidates the cache if the DMA command is currently active, copies all data from bounce buffers if necessary and releases all resources acquired during setMemoryDescriptor.
270 @param autoComplete An optional boolean variable that will call the complete() function automatically before the memory descriptor is processed. Defaults to true.
271*/
272 virtual IOReturn clearMemoryDescriptor(bool autoComplete = true);
273
274/*! @function getMemoryDescriptor
275 @abstract Get the current memory descriptor
276*/
277 virtual const IOMemoryDescriptor *getMemoryDescriptor() const;
278
279/*! @function prepare
280 @abstract Prepare the memory for an I/O transfer.
281 @discussion Allocate the mapping resources neccessary for this transfer, specifying a sub range of the IOMemoryDescriptor that will be the target of the I/O. The complete() method frees these resources. Data may be copied to buffers for kIODirectionOut memory descriptors, depending on hardware mapping resource availabilty or alignment restrictions. It should be noted that the this function may block and should only be called on the clients context, i.e never call this routine while gated; also the call itself is not thread safe though this should be an issue as each IODMACommand is independant.
282 @param offset defines the starting offset in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
283 @param length defines the ending position in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
284 @param flushCache Flush the caches for the memory descriptor and make certain that the memory cycles are complete. Defaults to true for kNonCoherent and is ignored by the other types.
285 @param synchronize Copy any buffered data back from the target IOMemoryDescriptor. Defaults to true, if synchronize() is being used to explicitly copy data, passing false may avoid an unneeded copy.
286 @result An IOReturn code. */
287
288 virtual IOReturn prepare(UInt64 offset = 0, UInt64 length = 0, bool flushCache = true, bool synchronize = true);
289
290/*! @function complete
291 @abstract Complete processing of DMA mappings after an I/O transfer is finished.
292 @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer
293 @param invalidCache Invalidate the caches for the memory descriptor. Defaults to true for kNonCoherent and is ignored by the other types.
294 @param synchronize Copy any buffered data back to the target IOMemoryDescriptor. Defaults to true, if synchronize() is being used to explicitly copy data, passing false may avoid an unneeded copy.
295 @result kIOReturnNotReady if not prepared, kIOReturnSuccess otherwise. */
296
297 virtual IOReturn complete(bool invalidateCache = true, bool synchronize = true);
298
299/*! @function synchronize
300 @abstract Bring IOMemoryDescriptor and IODMACommand buffers into sync.
301 @discussion This method should not be called unless a prepare was previously issued. If needed a caller may synchronize any IODMACommand buffers with the original IOMemoryDescriptor buffers.
302 @param options Specifies the direction of the copy:
303 kIODirectionOut copy IOMemoryDesciptor memory to any IODMACommand buffers. By default this action takes place automatically at prepare().
304 kIODirectionIn copy any IODMACommand buffers back to the IOMemoryDescriptor. By default this action takes place automatically at complete().
305 kForceDoubleBuffer copy the entire prepared range to a new page aligned buffer.
306 @result kIOReturnNotReady if not prepared, kIOReturnBadArgument if invalid options are passed, kIOReturnSuccess otherwise. */
307
308 virtual IOReturn synchronize(IOOptionBits options);
309
310/*! @function genIOVMSegments
311 @abstract Generates a physical scatter/gather for the current DMA command
312 @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor. The constraints that are set during initialisation will be respected. This function maintains the state across multiple calls for efficiency. However the state is discarded if the new offset is not the expected one.
313 @param offset input/output parameter, defines the starting and ending offset in the memory descriptor, relative to any offset passed to the prepare() method.
314 @param segments Void pointer to base of output physical scatter/gather list. Always passed directly onto the SegmentFunction.
315 @param numSegments Input/output parameter Number of segments that can fit in the segment array and returns number of segments generated.
316 @result kIOReturnSuccess on success, kIOReturnOverrun if the memory descriptor is exhausted, kIOReturnMessageTooLarge if the output segment function's address bits has insufficient resolution for a segment, kIOReturnNotReady if the DMA command has not be prepared, kIOReturnBadArgument if the DMA command doesn't have a memory descriptor yet or some of the parameters are NULL and kIOReturnNotReady if the DMA command is not prepared.
317*/
318 virtual IOReturn genIOVMSegments(UInt64 *offset,
319 void *segments,
320 UInt32 *numSegments);
321
322/*! @function gen32IOVMSegments
323 @abstract Helper function for a type checked call to genIOVMSegments(qv), for use with an IODMACommand set up with the output function kIODMACommandOutputHost32, kIODMACommandOutputBig32, or kIODMACommandOutputLittle32. If the output function of the IODMACommand is not a 32 bit function, results will be incorrect.
324*/
325 inline IOReturn gen32IOVMSegments(UInt64 *offset,
326 Segment32 *segments,
327 UInt32 *numSegments)
328 { return genIOVMSegments(offset, segments, numSegments); };
329
330/*! @function gen64IOVMSegments
331 @abstract Helper function for a type checked call to genIOVMSegments(qv), for use with an IODMACommand set up with the output function kIODMACommandOutputHost64, kIODMACommandOutputBig64, or kIODMACommandOutputLittle64. If the output function of the IODMACommand is not a 64 bit function, results will be incorrect.
332*/
333 inline IOReturn gen64IOVMSegments(UInt64 *offset,
334 Segment64 *segments,
335 UInt32 *numSegments)
336 { return genIOVMSegments(offset, segments, numSegments); };
337
338 virtual void free();
339
340private:
341
342 typedef IOReturn (*InternalSegmentFunction)(
343 void *reference,
344 IODMACommand *target,
345 Segment64 segment,
346 void *segments,
347 UInt32 segmentIndex);
348
349 IOReturn genIOVMSegments(InternalSegmentFunction outSegFunc,
350 void *reference,
351 UInt64 *offsetP,
352 void *segmentsP,
353 UInt32 *numSegmentsP);
354
355 static IOReturn clientOutputSegment(
356 void *reference, IODMACommand *target,
357 Segment64 segment, void *vSegList, UInt32 outSegIndex);
358
359 static IOReturn segmentOp(
360 void *reference,
361 IODMACommand *target,
362 Segment64 segment,
363 void *segments,
364 UInt32 segmentIndex);
365 IOReturn IODMACommand::walkAll(UInt8 op);
366
367private:
368 OSMetaClassDeclareReservedUnused(IODMACommand, 0);
369 OSMetaClassDeclareReservedUnused(IODMACommand, 1);
370 OSMetaClassDeclareReservedUnused(IODMACommand, 2);
371 OSMetaClassDeclareReservedUnused(IODMACommand, 3);
372 OSMetaClassDeclareReservedUnused(IODMACommand, 4);
373 OSMetaClassDeclareReservedUnused(IODMACommand, 5);
374 OSMetaClassDeclareReservedUnused(IODMACommand, 6);
375 OSMetaClassDeclareReservedUnused(IODMACommand, 7);
376 OSMetaClassDeclareReservedUnused(IODMACommand, 8);
377 OSMetaClassDeclareReservedUnused(IODMACommand, 9);
378 OSMetaClassDeclareReservedUnused(IODMACommand, 10);
379 OSMetaClassDeclareReservedUnused(IODMACommand, 11);
380 OSMetaClassDeclareReservedUnused(IODMACommand, 12);
381 OSMetaClassDeclareReservedUnused(IODMACommand, 13);
382 OSMetaClassDeclareReservedUnused(IODMACommand, 14);
383 OSMetaClassDeclareReservedUnused(IODMACommand, 15);
384
385public:
386/*! @var fRefCon Reference Constant, client defined publicly avialable */
387 void *fRefCon;
388
389protected:
390
391/*! @var fMaxSegmentSize Maximum size of one segment in a scatter/gather list */
392 UInt64 fMaxSegmentSize;
393
394/*! @var fMaxTransferSize
395 Maximum size of a transfer that this memory cursor is allowed to generate */
396 UInt64 fMaxTransferSize;
397
398/*! @var fBypassMask
399 Mask to be ored into the address to bypass the given iommu's mapping. */
400 UInt64 fBypassMask;
401
402/*! @var fMapper
403 Client defined mapper. */
404 IOMapper *fMapper;
405
406/*! @var fMemory
407 memory descriptor for current I/O. */
408 const IOMemoryDescriptor *fMemory;
409
410/*! @var fOutSeg The action method called when an event has been delivered */
411 SegmentFunction fOutSeg;
412
413/*! @var fAlignMask
414 Alignment restriction mask. */
415 UInt32 fAlignMask;
416
417/*! @var fNumAddressBits
418 Number of bits that the hardware can address */
419 UInt32 fNumAddressBits;
420
421/*! @var fNumSegments
422 Number of contiguous segments required for the current memory descriptor and desired mapping */
423 UInt32 fNumSegments;
424
425/*! @var fMappingOptions
426 What type of I/O virtual address mapping is required for this command */
427 MappingOptions fMappingOptions;
428
429/*! @var fActive
430 fActive indicates that this DMA command is currently prepared and ready to go */
431 UInt32 fActive;
432
433/*! @var reserved
434 Reserved for future use. (Internal use only) */
435 struct ExpansionData * reserved;
436};
437
438IOReturn IODMACommand::
439weakWithSpecification(IODMACommand **newCommand,
440 SegmentFunction outSegFunc,
441 UInt8 numAddressBits,
442 UInt64 maxSegmentSize,
443 MappingOptions mapType,
444 UInt64 maxTransferSize,
445 UInt32 alignment,
446 IOMapper *mapper,
447 void *refCon)
448{
449 if (!newCommand)
450 return kIOReturnBadArgument;
451
452 IODMACommand *self = (IODMACommand *)
453 OSMetaClass::allocClassWithName("IODMACommand");
454 if (!self)
455 return kIOReturnUnsupported;
456
457 IOReturn ret;
458 bool inited = self->
459 initWithSpecification(outSegFunc,
460 numAddressBits, maxSegmentSize, mapType,
461 maxTransferSize, alignment, mapper, refCon);
462 if (inited)
463 ret = kIOReturnSuccess;
464 else {
465 self->release();
466 self = 0;
467 ret = kIOReturnError;
468 }
469
470 *newCommand = self;
471 return ret;
472};
473#endif /* !_IODMACOMMAND_H */
474