#include <IOKit/IOMemoryDescriptor.h>

IOKit/IOMemoryDescriptor.h Kernel.framework

includes: sys/cdefs.h, IOKit/IOTypes.h, IOKit/IOLocks.h, libkern/c++/OSPtr.h, libkern/c++/OSContainers.h, Kernel/DriverKit/IOMemoryDescriptor.h, Kernel/DriverKit/IOMemoryMap.h, mach/memory_object_types.h
9 enums · 7 macros · 3 classs · 2 structs · 1 typedef · 1 variable

enum(anonymous)

Direction of transfer, with respect to the described memory.
underlying type unsigned int
kIODirectionNone0same as VM_PROT_NONE
kIODirectionIn1User land 'read', same as VM_PROT_READ
kIODirectionOut2User land 'write', same as VM_PROT_WRITE
kIODirectionOutIn3
kIODirectionInOut3
kIODirectionPrepareToPhys324these flags are valid for the prepare() method only
kIODirectionPrepareNoFault8
kIODirectionPrepareReserved116
kIODirectionPrepareNonCoherent32
kIODirectionCompleteWithError64
kIODirectionCompleteWithDataValid128

macroIODIRECTIONPREPARENONCOHERENTDEFINED

#define IODIRECTIONPREPARENONCOHERENTDEFINED 1

macroIODIRECTIONCOMPLETEWITHERRORDEFINED

these flags are valid for the complete() method only
#define IODIRECTIONCOMPLETEWITHERRORDEFINED 1

macroIODIRECTIONCOMPLETEWITHDATAVALIDDEFINED

#define IODIRECTIONCOMPLETEWITHDATAVALIDDEFINED 1

typedefIODirection

typedef IOOptionBits IODirection

enum(anonymous)

IOOptionBits used in the withOptions variant
underlying type unsigned int
kIOMemoryDirectionMask7
kIOMemoryTypeVirtual16
kIOMemoryTypePhysical32
kIOMemoryTypeUPL48
kIOMemoryTypePersistentMD64Persistent Memory Descriptor
kIOMemoryTypeUIO80
kIOMemoryTypeVirtual6416
kIOMemoryTypePhysical6432
kIOMemoryTypeVnode96
kIOMemoryTypeMask240
kIOMemoryAsReference256
kIOMemoryBufferPageable1024
kIOMemoryMapperNone2048Shared with Buffer MD
kIOMemoryHostOnly4096Never DMA accessible
kIOMemoryPersistent65536
kIOMemoryMapCopyOnWrite131072
kIOMemoryRemote262144
kIOMemoryThreadSafe1048576Shared with Buffer MD
kIOMemoryClearEncrypt2097152Shared with Buffer MD
kIOMemoryUseReserve8388608Shared with Buffer MD

macroIOMEMORYUSERESERVEDEFINED

#define IOMEMORYUSERESERVEDEFINED 1

macrokIOMapperSystem

#define kIOMapperSystem ((IOMapper *) NULL)

enum(anonymous)

underlying type unsigned int
kIOMemoryLedgerTagDefault1
kIOmemoryLedgerTagNetwork2
kIOMemoryLedgerTagMedia3
kIOMemoryLedgerTagGraphics4
kIOMemoryLedgerTagNeural5

enum(anonymous)

underlying type unsigned int
kIOMemoryLedgerFlagNoFootprint1

enum(anonymous)

underlying type unsigned int
kIOMemoryPurgeableKeepCurrent1
kIOMemoryPurgeableNonVolatile2
kIOMemoryPurgeableVolatile3
kIOMemoryPurgeableEmpty4
kIOMemoryPurgeableVolatileGroup00modifiers for kIOMemoryPurgeableVolatile behavior
kIOMemoryPurgeableVolatileGroup1256
kIOMemoryPurgeableVolatileGroup2512
kIOMemoryPurgeableVolatileGroup3768
kIOMemoryPurgeableVolatileGroup41024
kIOMemoryPurgeableVolatileGroup51280
kIOMemoryPurgeableVolatileGroup61536
kIOMemoryPurgeableVolatileGroup71792
kIOMemoryPurgeableVolatileBehaviorFifo0
kIOMemoryPurgeableVolatileBehaviorLifo64
kIOMemoryPurgeableVolatileOrderingObsolete32
kIOMemoryPurgeableVolatileOrderingNormal0
kIOMemoryPurgeableFaultOnAccess8192

enum(anonymous)

underlying type unsigned int
kIOMemoryIncoherentIOFlush1
kIOMemoryIncoherentIOStore2
kIOMemoryClearEncrypted50
kIOMemorySetEncrypted51

macroIOMEMORYDESCRIPTOR_SUPPORTS_DMACOMMAND

#define IOMEMORYDESCRIPTOR_SUPPORTS_DMACOMMAND 1

structIODMAMapSpecification

size 40, align 8
uint64_talignment
IOService *device
uint32_toptions
uint8_tnumAddressBits
uint8_t[3]resvA
uint32_t[4]resvB

structIODMAMapPageList

size 16, align 8
uint32_tpageOffset
uint32_tpageListCount
const upl_page_info_t *pageList

enum(anonymous)

mapOptions for iovmMapMemory
underlying type unsigned int
kIODMAMapReadAccess1
kIODMAMapWriteAccess2
kIODMAMapPhysicallyContiguous16
kIODMAMapDeviceMemory32
kIODMAMapPagingPath64
kIODMAMapIdentityMap128
kIODMAMapPageListFullyOccupied256
kIODMAMapFixedAddress512

enum(anonymous)

Options used by IOMapper. example IOMappers are DART and VT-d
underlying type unsigned int
kIOMapperUncached1

enum(anonymous)

underlying type unsigned int
kIOPreparationIDUnprepared0
kIOPreparationIDUnsupported1
kIOPreparationIDAlwaysPrepared2

classIOMemoryDescriptor

: public OSObject
struct IOMemoryDescriptorReserved *reserved
OSPtr<OSSet>_mappings
IOOptionBits_flags
void *__iomd_reserved5
uint16_t[4]__iomd_reserved1
uintptr_t__iomd_reserved2
uint16_t_iomapperOptions
uint16_t[3]__iomd_reserved3
uintptr_t__iomd_reserved4
IOByteCount_lengthlength of all ranges
IOOptionBits_tag
virtual bool initWithOptions(
	void * buffers,
	UInt32 count,
	UInt32 offset,
	task_t task,
	IOOptionBits options,
	IOMapper * mapper = kIOMapperSystem
)
virtual
@function initWithOptions @abstract Master initialiser for all variants of memory descriptors. For a more complete description see IOMemoryDescriptor::withOptions. @discussion Note this function can be used to re-init a previously created memory descriptor. @result true on success, false on failure.
virtual IOReturn setPurgeable(IOOptionBits newState, IOOptionBits * oldState)virtual
IOReturn setOwnership(task_t newOwner, int newLedgerTag, IOOptionBits newLedgerOptions)
IOReturn getPageCounts(IOByteCount * residentPageCount, IOByteCount * dirtyPageCount)
IOReturn getPageCounts(
	IOByteCount * residentPageCount,
	IOByteCount * dirtyPageCount,
	IOByteCount * swappedPageCount
)
virtual IOReturn performOperation(
	IOOptionBits options,
	IOByteCount offset,
	IOByteCount length
)
virtual
virtual IOReturn dmaCommandOperation(DMACommandOps op, void *vData, UInt dataSize) constvirtual
Used for dedicated communications for IODMACommand
virtual addr64_t getPhysicalSegment(
	IOByteCount offset,
	IOByteCount * length,
	IOOptionBits options = 0
) = 0
pure virtual
virtual uint64_t getPreparationID(void)virtual
void setPreparationID(void)
void setVMTags(uint32_t kernelTag, uint32_t userTag)
uint32_t getVMTag(vm_map_t map)
APPLE_KEXT_OVERRIDE
virtual void free(void)
virtual protected
static void initialize(void)static
static OSPtr<IOMemoryDescriptor> withAddress(
	void * address,
	IOByteCount withLength,
	IODirection withDirection
)
static
static OSPtr<IOMemoryDescriptor> withPhysicalAddress(
	IOPhysicalAddress address,
	IOByteCount withLength,
	IODirection withDirection
)
static
static OSPtr<IOMemoryDescriptor> withAddressRange(
	mach_vm_address_t address,
	mach_vm_size_t length,
	IOOptionBits options,
	task_t task
)
static
static OSPtr<IOMemoryDescriptor> withAddressRanges(
	IOAddressRange * ranges,
	UInt32 rangeCount,
	IOOptionBits options,
	task_t task
)
static
static OSPtr<IOMemoryDescriptor> withOptions(
	void * buffers,
	UInt32 count,
	UInt32 offset,
	task_t task,
	IOOptionBits options,
	IOMapper * mapper = kIOMapperSystem
)
static
static OSPtr<IOMemoryDescriptor> withPersistentMemoryDescriptor(
	IOMemoryDescriptor *originalMD
)
static
@function withPersistentMemoryDescriptor @abstract Copy constructor that generates a new memory descriptor if the backing memory for the same task's virtual address and length has changed. @discussion If the original memory descriptor's address and length is still backed by the same real memory, i.e. the user hasn't deallocated and the reallocated memory at the same address then the original memory descriptor is returned with a additional reference. Otherwise we build a totally new memory descriptor with the same characteristics as the previous one but with a new view of the vm. Note not legal to call this function with anything except an IOGeneralMemoryDescriptor that was created with the kIOMemoryPersistent option. @param originalMD The memory descriptor to be duplicated. @result Either the original memory descriptor with an additional retain or a new memory descriptor, 0 for a bad original memory descriptor or some other resource shortage.
virtual IODirection getDirection() constvirtual
virtual IOByteCount getLength() constvirtual
uint64_t getDMAMapLength(uint64_t * offset = NULL)
virtual void setTag(IOOptionBits tag)virtual
virtual IOOptionBits getTag(void)virtual
uint64_t getFlags(void)
virtual IOByteCount readBytes(IOByteCount offset, void * bytes, IOByteCount withLength)virtual
virtual IOByteCount writeBytes(
	IOByteCount offset,
	const void * bytes,
	IOByteCount withLength
)
virtual
IOPhysicalAddress getPhysicalAddress()
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) = 0pure virtual
virtual IOReturn complete(IODirection forDirection = kIODirectionNone) = 0pure virtual
OSPtr<IOMemoryMap> createMappingInTask(
	task_t intoTask,
	mach_vm_address_t atAddress,
	IOOptionBits options,
	mach_vm_size_t offset = 0,
	mach_vm_size_t length = 0
)
virtual OSPtr<IOMemoryMap> map(IOOptionBits options = 0)virtual
virtual OSPtr<IOMemoryMap> setMapping(
	task_t task,
	IOVirtualAddress mapAddress,
	IOOptionBits options = 0
)
virtual
void setMapperOptions(uint16_t options)
uint16_t getMapperOptions(void)
virtual IOReturn redirect(task_t safeTask, bool redirect)virtual
IOReturn handleFault(void * _pager, mach_vm_size_t sourceOffset, mach_vm_size_t length)
IOReturn populateDevicePager(
	void * pager,
	vm_map_t addressMap,
	mach_vm_address_t address,
	mach_vm_size_t sourceOffset,
	mach_vm_size_t length,
	IOOptionBits options
)
virtual LIBKERN_RETURNS_NOT_RETAINED IOMemoryMap * makeMapping(
	IOMemoryDescriptor * owner,
	task_t intoTask,
	IOVirtualAddress atAddress,
	IOOptionBits options,
	IOByteCount offset,
	IOByteCount length
)
virtual
virtual void addMapping(IOMemoryMap * mapping)virtual protected
virtual void removeMapping(IOMemoryMap * mapping)virtual protected
virtual IOReturn doMap(
	vm_map_t addressMap,
	IOVirtualAddress * atAddress,
	IOOptionBits options,
	IOByteCount sourceOffset = 0,
	IOByteCount length = 0
)
virtual protected
virtual IOReturn doUnmap(
	vm_map_t addressMap,
	IOVirtualAddress logical,
	IOByteCount length
)
virtual protected

macroIOMEMORYDESCRIPTOR_SUPPORTS_GETDMAMAPLENGTH

#define IOMEMORYDESCRIPTOR_SUPPORTS_GETDMAMAPLENGTH 

classIOMemoryMap

: public OSObject
APPLE_KEXT_OVERRIDE
virtual void taggedRelease(const void *tag = NULL) const
virtual protected
APPLE_KEXT_OVERRIDE
virtual void free(void)
virtual protected
virtual IOVirtualAddress getVirtualAddress(void)virtual
virtual IOPhysicalAddress getPhysicalSegment(
	IOByteCount offset,
	IOByteCount * length,
	IOOptionBits options = 0
)
virtual
IOPhysicalAddress getPhysicalAddress(void)
virtual IOByteCount getLength(void)virtual
virtual task_t getAddressTask()virtual
virtual IOMemoryDescriptor * getMemoryDescriptor()virtual
virtual IOOptionBits getMapOptions()virtual
virtual IOReturn unmap()virtual
virtual void taskDied()virtual
virtual IOReturn redirect(
	IOMemoryDescriptor * newBackingMemory,
	IOOptionBits options,
	mach_vm_size_t offset = 0
)
virtual
__attribute__((always_inline))
inline mach_vm_address_t getAddress()
@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.
__attribute__((always_inline))
inline mach_vm_size_t getSize()
@function getSize @abstract Accessor to the length of the mapping. @discussion This method returns the length of the mapping. @result A byte count.
IOReturn wireRange(uint32_t options, mach_vm_size_t offset, mach_vm_size_t length)

classIOGeneralMemoryDescriptor

Ranges_ranges
unsigned int_rangesCountnumber of address ranges in list
task_t_tasktask where all ranges are mapped to
unnamed union at Kernel/IOKit/IOMemoryDescriptor.h:928:2_singleRangestorage space for a single range
unsigned int_wireCountnumber of outstanding wires
bool_initializedhas superclass been initialized?
APPLE_KEXT_OVERRIDE
virtual void free()
virtual
APPLE_KEXT_OVERRIDE
virtual IOReturn dmaCommandOperation(DMACommandOps op, void *vData, UInt dataSize) const
virtual
APPLE_KEXT_OVERRIDE
virtual uint64_t getPreparationID(void)
virtual
APPLE_KEXT_OVERRIDE
virtual bool initWithOptions(
	void * buffers,
	UInt32 count,
	UInt32 offset,
	task_t task,
	IOOptionBits options,
	IOMapper * mapper = kIOMapperSystem
)
virtual
Master initaliser
APPLE_KEXT_OVERRIDE
virtual IOReturn setPurgeable(IOOptionBits newState, IOOptionBits * oldState)
virtual
IOReturn setOwnership(task_t newOwner, int newLedgerTag, IOOptionBits newLedgerOptions)
APPLE_KEXT_OVERRIDE
virtual addr64_t getPhysicalSegment(
	IOByteCount offset,
	IOByteCount * length,
	IOOptionBits options = 0
)
virtual
APPLE_KEXT_OVERRIDE
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone)
virtual
APPLE_KEXT_OVERRIDE
virtual IOReturn complete(IODirection forDirection = kIODirectionNone)
virtual
APPLE_KEXT_OVERRIDE
virtual LIBKERN_RETURNS_NOT_RETAINED IOMemoryMap * makeMapping(
	IOMemoryDescriptor * owner,
	task_t intoTask,
	IOVirtualAddress atAddress,
	IOOptionBits options,
	IOByteCount offset,
	IOByteCount length
)
virtual
APPLE_KEXT_OVERRIDE
virtual IOReturn doMap(
	vm_map_t addressMap,
	IOVirtualAddress * atAddress,
	IOOptionBits options,
	IOByteCount sourceOffset = 0,
	IOByteCount length = 0
)
virtual
APPLE_KEXT_OVERRIDE
virtual IOReturn doUnmap(
	vm_map_t addressMap,
	IOVirtualAddress logical,
	IOByteCount length
)
virtual
APPLE_KEXT_OVERRIDE
virtual bool serialize(OSSerialize *s) const
virtual
static OSPtr<IOMemoryDescriptor> withPersistentMemoryDescriptor(
	IOGeneralMemoryDescriptor *originalMD
)
static
Factory method for cloning a persistent IOMD, see IOMemoryDescriptor
IOOptionBits memoryReferenceCreateOptions(IOOptionBits options, IOMemoryMap * map)

variableiokit_iomd_setownership_enabled

extern bool iokit_iomd_setownership_enabled