+
+ if (IS_NONCOHERENT(mappingOptions) && flushCache)
+ {
+ if (state->fCopyMD)
+ {
+ state->fCopyMD->performOperation(kIOMemoryIncoherentIOStore, 0, length);
+ }
+ else
+ {
+ IOMemoryDescriptor * md = const_cast<IOMemoryDescriptor *>(fMemory);
+ md->performOperation(kIOMemoryIncoherentIOStore, offset, length);
+ }
+ }
+
+ if (fMapper)
+ {
+ IOMDDMAMapArgs mapArgs;
+ bzero(&mapArgs, sizeof(mapArgs));
+ mapArgs.fMapper = fMapper;
+ mapArgs.fCommand = this;
+ mapArgs.fMapSpec.device = state->fDevice;
+ mapArgs.fMapSpec.alignment = fAlignMask + 1;
+ mapArgs.fMapSpec.numAddressBits = fNumAddressBits ? fNumAddressBits : 64;
+ mapArgs.fLength = state->fPreparedLength;
+ const IOMemoryDescriptor * md = state->fCopyMD;
+ if (md) { mapArgs.fOffset = 0; } else
+ {
+ md = fMemory;
+ mapArgs.fOffset = state->fPreparedOffset;
+ }
+ ret = md->dmaCommandOperation(kIOMDDMAMap | state->fIterateOnly, &mapArgs, sizeof(mapArgs));
+//IOLog("dma %p 0x%x 0x%qx-0x%qx 0x%qx-0x%qx\n", this, ret, state->fPreparedOffset, state->fPreparedLength, mapArgs.fAlloc, mapArgs.fAllocLength);
+
+ if (kIOReturnSuccess == ret)
+ {
+ state->fLocalMapperAlloc = mapArgs.fAlloc;
+ state->fLocalMapperAllocValid = true;
+ state->fLocalMapperAllocLength = mapArgs.fAllocLength;
+ state->fMapContig = mapArgs.fMapContig;
+ }
+ if (NULL != IOMapper::gSystem) ret = kIOReturnSuccess;
+ }
+ if (kIOReturnSuccess == ret) state->fPrepared = true;