]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/IOMemoryDescriptor.h
xnu-6153.11.26.tar.gz
[apple/xnu.git] / iokit / IOKit / IOMemoryDescriptor.h
index b9deeaa4ad656435887ba3f1778782546b3f02bb..0c19f496484f0343fc823b4411ca5d9056752d76 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998-2016 Apple Inc. All rights reserved.
+ * Copyright (c) 1998-2019 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
@@ -33,6 +33,8 @@
 #include <IOKit/IOTypes.h>
 #include <IOKit/IOLocks.h>
 #include <libkern/c++/OSContainers.h>
+#include <DriverKit/IOMemoryDescriptor.h>
+#include <DriverKit/IOMemoryMap.h>
 #ifdef XNU_KERNEL_PRIVATE
 #include <IOKit/IOKitDebug.h>
 #endif
@@ -123,7 +125,18 @@ enum {
 #endif
 };
 
-#define kIOMapperSystem ((IOMapper *) 0)
+#define kIOMapperSystem ((IOMapper *) NULL)
+
+enum{
+       kIOMemoryLedgerTagDefault       = VM_LEDGER_TAG_DEFAULT,
+       kIOmemoryLedgerTagNetwork       = VM_LEDGER_TAG_NETWORK,
+       kIOMemoryLedgerTagMedia         = VM_LEDGER_TAG_MEDIA,
+       kIOMemoryLedgerTagGraphics      = VM_LEDGER_TAG_GRAPHICS,
+       kIOMemoryLedgerTagNeural        = VM_LEDGER_TAG_NEURAL,
+};
+enum{
+       kIOMemoryLedgerFlagNoFootprint  = VM_LEDGER_FLAG_NO_FOOTPRINT,
+};
 
 enum{
        kIOMemoryPurgeableKeepCurrent = 1,
@@ -257,7 +270,7 @@ class IOMemoryDescriptor : public OSObject
        friend class IOMemoryMap;
        friend class IOMultiMemoryDescriptor;
 
-       OSDeclareDefaultStructors(IOMemoryDescriptor);
+       OSDeclareDefaultStructorsWithDispatch(IOMemoryDescriptor);
 
 protected:
 
@@ -334,6 +347,17 @@ public:
        virtual IOReturn setPurgeable( IOOptionBits newState,
            IOOptionBits * oldState );
 
+/*! @function setOwnership
+ *   @abstract Control the ownership of a memory descriptors memory.
+ *   @discussion IOBufferMemoryDescriptor are owned by a specific task. The ownership of such a buffer may be controlled with setOwnership().
+ *   @param newOwner - the task to be the new owner of the memory.
+ *   @param newLedgerTag - the ledger this memory should be accounted in.
+ *   @param newLedgerOptions - accounting options
+ *   @result An IOReturn code. */
+
+       IOReturn setOwnership( task_t newOwner,
+           int newLedgerTag,
+           IOOptionBits newLedgerOptions );
 
 /*! @function getPageCounts
  *   @abstract Retrieve the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
@@ -381,8 +405,12 @@ public:
        virtual uint64_t getPreparationID( void );
        void             setPreparationID( void );
 
+       void     setVMTags(uint32_t kernelTag, uint32_t userTag);
+       uint32_t getVMTag(vm_map_t map);
+
 #ifdef XNU_KERNEL_PRIVATE
        IOMemoryDescriptorReserved * getKernelReserved( void );
+       void                         cleanKernelReserved(IOMemoryDescriptorReserved * reserved);
        IOReturn dmaMap(
                IOMapper                    * mapper,
                IODMACommand                * command,
@@ -401,9 +429,6 @@ public:
                IOMapper                    * mapper,
                IODMACommand                * command,
                uint64_t                      mapLength);
-
-       void     setVMTags(vm_tag_t kernelTag, vm_tag_t userTag);
-       vm_tag_t getVMTag(vm_map_t map);
 #endif
 
 private:
@@ -435,7 +460,7 @@ private:
        OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 15);
 
 protected:
-       virtual void free() APPLE_KEXT_OVERRIDE;
+       virtual void free(void) APPLE_KEXT_OVERRIDE;
 public:
        static void initialize( void );
 
@@ -796,7 +821,7 @@ protected:
 
 class IOMemoryMap : public OSObject
 {
-       OSDeclareDefaultStructors(IOMemoryMap)
+       OSDeclareDefaultStructorsWithDispatch(IOMemoryMap);
 #ifdef XNU_KERNEL_PRIVATE
 public:
        IOMemoryDescriptor * fMemory;
@@ -817,8 +842,8 @@ public:
 #endif /* XNU_KERNEL_PRIVATE */
 
 protected:
-       virtual void taggedRelease(const void *tag = 0) const APPLE_KEXT_OVERRIDE;
-       virtual void free() APPLE_KEXT_OVERRIDE;
+       virtual void taggedRelease(const void *tag = NULL) const APPLE_KEXT_OVERRIDE;
+       virtual void free(void) APPLE_KEXT_OVERRIDE;
 
 public:
 /*! @function getVirtualAddress
@@ -826,7 +851,7 @@ public:
  *   @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();
+       virtual IOVirtualAddress    getVirtualAddress(void);
 
 /*! @function getPhysicalSegment
  *   @abstract Break a mapping into its physically contiguous segments.
@@ -849,14 +874,14 @@ public:
  *   @discussion This method returns the physical address of the  first byte in the mapping. It is most useful on mappings known to be physically contiguous.
  *   @result A physical address. */
 
-       IOPhysicalAddress getPhysicalAddress();
+       IOPhysicalAddress getPhysicalAddress(void);
 
 /*! @function getLength
  *   @abstract Accessor to the length of the mapping.
  *   @discussion This method returns the length of the mapping.
  *   @result A byte count. */
 
-       virtual IOByteCount         getLength();
+       virtual IOByteCount         getLength(void);
 
 /*! @function getAddressTask
  *   @abstract Accessor to the task of the mapping.
@@ -1055,6 +1080,11 @@ public:
                IOMemoryReference * ref,
                IOOptionBits newState,
                IOOptionBits * oldState);
+       static IOReturn memoryReferenceSetOwnership(
+               IOMemoryReference * ref,
+               task_t newOwner,
+               int newLedgerTag,
+               IOOptionBits newLedgerOptions);
        static IOReturn memoryReferenceGetPageCounts(
                IOMemoryReference * ref,
                IOByteCount       * residentPageCount,
@@ -1134,6 +1164,10 @@ public:
        virtual IOReturn setPurgeable( IOOptionBits newState,
            IOOptionBits * oldState ) APPLE_KEXT_OVERRIDE;
 
+       IOReturn setOwnership( task_t newOwner,
+           int newLedgerTag,
+           IOOptionBits newLedgerOptions );
+
        virtual addr64_t getPhysicalSegment( IOByteCount   offset,
            IOByteCount * length,
 #ifdef __LP64__
@@ -1185,4 +1219,6 @@ IOMemoryMap::getSize()
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
+extern boolean_t iokit_iomd_setownership_enabled;
+
 #endif /* !_IOMEMORYDESCRIPTOR_H */