class IOMemoryMap;
class IOMapper;
+class IOService;
/*
* Direction of transfer, with respect to the described memory.
kIOMemoryAsReference = 0x00000100,
kIOMemoryBufferPageable = 0x00000400,
- kIOMemoryMapperNone = 0x00000800,
+ kIOMemoryMapperNone = 0x00000800, // Shared with Buffer MD
+ kIOMemoryHostOnly = 0x00001000, // Never DMA accessible
#ifdef XNU_KERNEL_PRIVATE
kIOMemoryRedirected = 0x00004000,
kIOMemoryPreparedReadOnly = 0x00008000,
kIOMemoryReserved6156215 = 0x00020000,
#endif
kIOMemoryThreadSafe = 0x00100000, // Shared with Buffer MD
+ kIOMemoryClearEncrypt = 0x00200000, // Shared with Buffer MD
};
#define kIOMapperSystem ((IOMapper *) 0)
{
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];
+};
+
+enum
+{
+ kIODMAMapWriteAccess = 0x00000002,
+ kIODMAMapPhysicallyContiguous = 0x00000010,
+ kIODMAMapDeviceMemory = 0x00000020,
+ kIODMAMapPagingPath = 0x00000040,
+ kIODMAMapIdentityMap = 0x00000080,
+};
+
+
enum
{
kIOPreparationIDUnprepared = 0,
kIOPreparationIDUnsupported = 1,
+ kIOPreparationIDAlwaysPrepared = 2,
};
/*! @class IOMemoryDescriptor : public OSObject
OSDeclareDefaultStructors(IOMemoryDescriptor);
protected:
-/*! @struct ExpansionData
- @discussion This structure will be used to expand the capablilties of this class in the future.
- */
- struct ExpansionData {
- void * devicePager;
- unsigned int pagerContig:1;
- unsigned int unused:31;
- IOMemoryDescriptor * memory;
- };
/*! @var reserved
Reserved for future use. (Internal use only) */
- ExpansionData * reserved;
+ struct IOMemoryDescriptorReserved * reserved;
protected:
OSSet * _mappings;
#endif /* !__LP64__ */
virtual uint64_t getPreparationID( void );
+ void setPreparationID( void );
+
+#ifdef XNU_KERNEL_PRIVATE
+ IOMemoryDescriptorReserved * getKernelReserved( void );
+ IOReturn dmaMap(
+ IOMapper * mapper,
+ const IODMAMapSpecification * mapSpec,
+ uint64_t offset,
+ uint64_t length,
+ uint64_t * address,
+ ppnum_t * mapPages);
+#endif
private:
OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 0);
@param withLength The length of memory.
@param options
kIOMemoryDirectionMask (options:direction) This nibble indicates the I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
- @param task The task the virtual ranges are mapped into. Note that unlike IOMemoryDescriptor::withAddress(), kernel_task memory must be explicitly prepared when passed to this api.
+ @param task The task the virtual ranges are mapped into. Note that unlike IOMemoryDescriptor::withAddress(), kernel_task memory must be explicitly prepared when passed to this api. The task argument may be NULL to specify memory by physical address.
@result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static IOMemoryDescriptor * withAddressRange(
@param options
kIOMemoryDirectionMask (options:direction) This nibble indicates the I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
kIOMemoryAsReference For options:type = Virtual or Physical this indicate that the memory descriptor need not copy the ranges array into local memory. This is an optimisation to try to minimise unnecessary allocations.
- @param task The task each of the virtual ranges are mapped into. Note that unlike IOMemoryDescriptor::withAddress(), kernel_task memory must be explicitly prepared when passed to this api.
+ @param task The task each of the virtual ranges are mapped into. Note that unlike IOMemoryDescriptor::withAddress(), kernel_task memory must be explicitly prepared when passed to this api. The task argument may be NULL to specify memory by physical address.
@result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static IOMemoryDescriptor * withAddressRanges(
public:
/*! @function getVirtualAddress
@abstract Accessor to the virtual address of the first byte in the mapping.
- @discussion This method returns the virtual address of the first byte in the mapping.
+ @discussion This method returns the virtual address of the first byte in the mapping. Since the IOVirtualAddress is only 32bit in 32bit kernels, the getAddress() method should be used for compatibility with 64bit task mappings.
@result A virtual address. */
virtual IOVirtualAddress getVirtualAddress();
mach_vm_size_t offset = 0);
#ifdef __LP64__
+/*! @function getAddress
+ @abstract Accessor to the virtual address of the first byte in the mapping.
+ @discussion This method returns the virtual address of the first byte in the mapping.
+ @result A virtual address. */
+/*! @function getSize
+ @abstract Accessor to the length of the mapping.
+ @discussion This method returns the length of the mapping.
+ @result A byte count. */
inline mach_vm_address_t getAddress() __attribute__((always_inline));
inline mach_vm_size_t getSize() __attribute__((always_inline));
#else /* !__LP64__ */
+/*! @function getAddress
+ @abstract Accessor to the virtual address of the first byte in the mapping.
+ @discussion This method returns the virtual address of the first byte in the mapping.
+ @result A virtual address. */
+/*! @function getSize
+ @abstract Accessor to the length of the mapping.
+ @discussion This method returns the length of the mapping.
+ @result A byte count. */
virtual mach_vm_address_t getAddress();
virtual mach_vm_size_t getSize();
#endif /* !__LP64__ */
IOReturn userClientUnmap();
#endif /* XNU_KERNEL_PRIVATE */
+ IOReturn wireRange(
+ uint32_t options,
+ mach_vm_size_t offset,
+ mach_vm_size_t length);
+
OSMetaClassDeclareReservedUnused(IOMemoryMap, 0);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 1);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 2);
};
#endif /* XNU_KERNEL_PRIVATE */
-#if !defined(__LP64) || defined(_IOMEMORYDESCRIPTOR_INTERNAL_)
-
// The following classes are private implementation of IOMemoryDescriptor - they
// should not be referenced directly, just through the public API's in the
// IOMemoryDescriptor class. For example, an IOGeneralMemoryDescriptor instance
virtual uint64_t getPreparationID( void );
+#ifdef XNU_KERNEL_PRIVATE
+ // Internal APIs may be made virtual at some time in the future.
+ IOReturn wireVirtual(IODirection forDirection);
+ IOReturn dmaMap(
+ IOMapper * mapper,
+ const IODMAMapSpecification * mapSpec,
+ uint64_t offset,
+ uint64_t length,
+ uint64_t * address,
+ ppnum_t * mapPages);
+ bool initMemoryEntries(size_t size, IOMapper * mapper);
+#endif
+
private:
#ifndef __LP64__
virtual void unmapFromKernel();
#endif /* !__LP64__ */
- // Internal APIs may be made virtual at some time in the future.
- IOReturn wireVirtual(IODirection forDirection);
void *createNamedEntry();
// Internal
};
-#endif /* !defined(__LP64) || defined(_IOMEMORYDESCRIPTOR_INTERNAL_) */
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifdef __LP64__