+ kIODirectionOutIn = kIODirectionOut | kIODirectionIn,
+ kIODirectionInOut = kIODirectionIn | kIODirectionOut,
+
+ // these flags are valid for the prepare() method only
+ kIODirectionPrepareToPhys32 = 0x00000004,
+ kIODirectionPrepareNoFault = 0x00000008,
+ kIODirectionPrepareReserved1 = 0x00000010,
+#define IODIRECTIONPREPARENONCOHERENTDEFINED 1
+ kIODirectionPrepareNonCoherent = 0x00000020,
+
+ // these flags are valid for the complete() method only
+#define IODIRECTIONCOMPLETEWITHERRORDEFINED 1
+ kIODirectionCompleteWithError = 0x00000040,
+#define IODIRECTIONCOMPLETEWITHDATAVALIDDEFINED 1
+ kIODirectionCompleteWithDataValid = 0x00000080,
+};
+
+#ifdef __LP64__
+typedef IOOptionBits IODirection;
+#endif /* __LP64__ */
+
+/*
+ * IOOptionBits used in the withOptions variant
+ */
+enum {
+ kIOMemoryDirectionMask = 0x00000007,
+#ifdef XNU_KERNEL_PRIVATE
+ kIOMemoryAutoPrepare = 0x00000008, // Shared with Buffer MD
+#endif
+
+ kIOMemoryTypeVirtual = 0x00000010,
+ kIOMemoryTypePhysical = 0x00000020,
+ kIOMemoryTypeUPL = 0x00000030,
+ kIOMemoryTypePersistentMD = 0x00000040, // Persistent Memory Descriptor
+ kIOMemoryTypeUIO = 0x00000050,
+#ifdef __LP64__
+ kIOMemoryTypeVirtual64 = kIOMemoryTypeVirtual,
+ kIOMemoryTypePhysical64 = kIOMemoryTypePhysical,
+#else /* !__LP64__ */
+ kIOMemoryTypeVirtual64 = 0x00000060,
+ kIOMemoryTypePhysical64 = 0x00000070,
+#endif /* !__LP64__ */
+ kIOMemoryTypeMask = 0x000000f0,
+
+ kIOMemoryAsReference = 0x00000100,
+ kIOMemoryBufferPageable = 0x00000400,
+ kIOMemoryMapperNone = 0x00000800, // Shared with Buffer MD
+ kIOMemoryHostOnly = 0x00001000, // Never DMA accessible
+#ifdef XNU_KERNEL_PRIVATE
+ kIOMemoryRedirected = 0x00004000,
+ kIOMemoryPreparedReadOnly = 0x00008000,
+#endif
+ kIOMemoryPersistent = 0x00010000,
+#ifdef XNU_KERNEL_PRIVATE
+ kIOMemoryMapCopyOnWrite = 0x00020000,
+#endif
+ kIOMemoryRemote = 0x00040000,
+ kIOMemoryThreadSafe = 0x00100000, // Shared with Buffer MD
+ kIOMemoryClearEncrypt = 0x00200000, // Shared with Buffer MD
+ kIOMemoryUseReserve = 0x00800000, // Shared with Buffer MD
+#define IOMEMORYUSERESERVEDEFINED 1
+
+#ifdef XNU_KERNEL_PRIVATE
+ kIOMemoryBufferPurgeable = 0x00400000,
+ kIOMemoryBufferCacheMask = 0x70000000,
+ kIOMemoryBufferCacheShift = 28,
+#endif
+};
+
+#define kIOMapperSystem ((IOMapper *) 0)
+
+enum
+{
+ kIOMemoryPurgeableKeepCurrent = 1,
+
+ kIOMemoryPurgeableNonVolatile = 2,
+ kIOMemoryPurgeableVolatile = 3,
+ kIOMemoryPurgeableEmpty = 4,
+
+ // modifiers for kIOMemoryPurgeableVolatile behavior
+ kIOMemoryPurgeableVolatileGroup0 = VM_VOLATILE_GROUP_0,
+ kIOMemoryPurgeableVolatileGroup1 = VM_VOLATILE_GROUP_1,
+ kIOMemoryPurgeableVolatileGroup2 = VM_VOLATILE_GROUP_2,
+ kIOMemoryPurgeableVolatileGroup3 = VM_VOLATILE_GROUP_3,
+ kIOMemoryPurgeableVolatileGroup4 = VM_VOLATILE_GROUP_4,
+ kIOMemoryPurgeableVolatileGroup5 = VM_VOLATILE_GROUP_5,
+ kIOMemoryPurgeableVolatileGroup6 = VM_VOLATILE_GROUP_6,
+ kIOMemoryPurgeableVolatileGroup7 = VM_VOLATILE_GROUP_7,
+ kIOMemoryPurgeableVolatileBehaviorFifo = VM_PURGABLE_BEHAVIOR_FIFO,
+ kIOMemoryPurgeableVolatileBehaviorLifo = VM_PURGABLE_BEHAVIOR_LIFO,
+ kIOMemoryPurgeableVolatileOrderingObsolete = VM_PURGABLE_ORDERING_OBSOLETE,
+ kIOMemoryPurgeableVolatileOrderingNormal = VM_PURGABLE_ORDERING_NORMAL,
+ kIOMemoryPurgeableFaultOnAccess = VM_PURGABLE_DEBUG_FAULT,
+};
+enum
+{
+ kIOMemoryIncoherentIOFlush = 1,
+ kIOMemoryIncoherentIOStore = 2,
+
+ kIOMemoryClearEncrypted = 50,
+ kIOMemorySetEncrypted = 51,
+};
+
+#define IOMEMORYDESCRIPTOR_SUPPORTS_DMACOMMAND 1
+
+struct IODMAMapSpecification
+{
+ uint64_t alignment;
+ IOService * device;
+ uint32_t options;
+ uint8_t numAddressBits;
+ uint8_t resvA[3];
+ uint32_t resvB[4];
+};
+
+struct IODMAMapPageList
+{
+ uint32_t pageOffset;
+ uint32_t pageListCount;
+ const upl_page_info_t * pageList;
+};
+
+// mapOptions for iovmMapMemory
+enum
+{
+ kIODMAMapReadAccess = 0x00000001,
+ kIODMAMapWriteAccess = 0x00000002,
+ kIODMAMapPhysicallyContiguous = 0x00000010,
+ kIODMAMapDeviceMemory = 0x00000020,
+ kIODMAMapPagingPath = 0x00000040,
+ kIODMAMapIdentityMap = 0x00000080,
+
+ kIODMAMapPageListFullyOccupied = 0x00000100,
+ kIODMAMapFixedAddress = 0x00000200,
+};
+
+#ifdef KERNEL_PRIVATE
+
+// Used for dmaCommandOperation communications for IODMACommand and mappers
+
+enum {
+ kIOMDWalkSegments = 0x01000000,
+ kIOMDFirstSegment = 1 | kIOMDWalkSegments,
+ kIOMDGetCharacteristics = 0x02000000,
+ kIOMDGetCharacteristicsMapped = 1 | kIOMDGetCharacteristics,
+ kIOMDDMAActive = 0x03000000,
+ kIOMDSetDMAActive = 1 | kIOMDDMAActive,
+ kIOMDSetDMAInactive = kIOMDDMAActive,
+ kIOMDAddDMAMapSpec = 0x04000000,
+ kIOMDDMAMap = 0x05000000,
+ kIOMDDMAUnmap = 0x06000000,
+ kIOMDDMACommandOperationMask = 0xFF000000,
+};
+struct IOMDDMACharacteristics {
+ UInt64 fLength;
+ UInt32 fSGCount;
+ UInt32 fPages;
+ UInt32 fPageAlign;
+ ppnum_t fHighestPage;
+ IODirection fDirection;
+ UInt8 fIsPrepared;
+};
+
+struct IOMDDMAMapArgs {
+ IOMapper * fMapper;
+ IODMACommand * fCommand;
+ IODMAMapSpecification fMapSpec;
+ uint64_t fOffset;
+ uint64_t fLength;
+ uint64_t fAlloc;
+ uint64_t fAllocLength;
+ uint8_t fMapContig;