]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/IOMemoryDescriptor.h
xnu-344.23.tar.gz
[apple/xnu.git] / iokit / IOKit / IOMemoryDescriptor.h
index bb3b5d54e6d35f26976543436b870dbe0d95f105..0212d39477ca19ecfd488c43f0ebb9c28ce03d7b 100644 (file)
@@ -59,7 +59,12 @@ protected:
 /*! @struct ExpansionData
     @discussion This structure will be used to expand the capablilties of this class in the future.
     */    
-    struct ExpansionData { };
+    struct ExpansionData {
+        void *                         devicePager;
+        unsigned int                   pagerContig:1;
+        unsigned int                   unused:31;
+       IOMemoryDescriptor *            memory;
+    };
 
 /*! @var reserved
     Reserved for future use.  (Internal use only)  */
@@ -74,8 +79,13 @@ protected:
     IOByteCount         _length;           /* length of all ranges */
     IOOptionBits       _tag;
 
+public:
+
+    virtual IOPhysicalAddress getSourceSegment( IOByteCount offset,
+                                               IOByteCount * length );
+
 private:
-    OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 0);
+    OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 0);
     OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 1);
     OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 2);
     OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 3);
@@ -288,7 +298,7 @@ public:
     @result The number of bytes copied, zero will be returned if the specified offset is beyond the length of the descriptor. */
 
     virtual IOByteCount readBytes(IOByteCount offset,
-                               void * bytes, IOByteCount withLength) = 0;
+                               void * bytes, IOByteCount withLength);
 
 /*! @function writeBytes
     @abstract Copy data to the memory descriptor's buffer from the specified buffer.
@@ -299,7 +309,7 @@ public:
     @result The number of bytes copied, zero will be returned if the specified offset is beyond the length of the descriptor. */
 
     virtual IOByteCount writeBytes(IOByteCount offset,
-                               const void * bytes, IOByteCount withLength) = 0;
+                               const void * bytes, IOByteCount withLength);
 
 /*! @function getPhysicalSegment
     @abstract Break a memory descriptor into its physically contiguous segments.
@@ -316,19 +326,13 @@ public:
     @discussion This method returns the physical address of the  first byte in the memory. It is most useful on memory known to be physically contiguous.
     @result A physical address. */
 
-    inline IOPhysicalAddress   getPhysicalAddress()
-                               { return( getPhysicalSegment( 0, 0 )); }
+    /* inline */ IOPhysicalAddress getPhysicalAddress();
+        /* { return( getPhysicalSegment( 0, 0 )); } */
 
-    /*
-     * getVirtualSegment:
-     *
-     * Get the virtual address of the buffer, relative to the given offset.
-     * If the memory wasn't mapped into the caller's address space, it will be
-     * mapped in now.   If the current position is at the end of the buffer, a
-     * null is returned.
-     */
-    virtual void * getVirtualSegment(IOByteCount offset,
-                                       IOByteCount * length) = 0;
+    /* DEPRECATED */ /* USE INSTEAD: map(), readBytes(), writeBytes() */
+    /* DEPRECATED */ virtual void * getVirtualSegment(IOByteCount offset,
+    /* DEPRECATED */                                   IOByteCount * length) = 0;
+    /* DEPRECATED */ /* USE INSTEAD: map(), readBytes(), writeBytes() */
 
 /*! @function prepare
     @abstract Prepare the memory for an I/O transfer.
@@ -394,6 +398,19 @@ public:
        IOVirtualAddress        mapAddress,
        IOOptionBits            options = 0 );
 
+    // Following methods are private implementation
+
+    // make virtual
+    IOReturn redirect( task_t safeTask, bool redirect );
+
+    IOReturn handleFault(
+        void *                 pager,
+       vm_map_t                addressMap,
+       IOVirtualAddress        address,
+       IOByteCount             sourceOffset,
+       IOByteCount             length,
+        IOOptionBits           options );
+
 protected:
     virtual IOMemoryMap *      makeMapping(
        IOMemoryDescriptor *    owner,
@@ -455,8 +472,8 @@ 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. */
 
-    inline IOPhysicalAddress   getPhysicalAddress()
-                               { return( getPhysicalSegment( 0, 0 )); }
+    /* inline */ IOPhysicalAddress getPhysicalAddress();
+        /* { return( getPhysicalSegment( 0, 0 )); } */
 
 /*! @function getLength
     @abstract Accessor to the length of the mapping.
@@ -498,6 +515,12 @@ public:
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
+// 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
+// might be created by IOMemoryDescriptor::withAddress(), but there should be 
+// no need to reference as anything but a generic IOMemoryDescriptor *.
+
 enum {
     kIOMemoryRequiresWire      = 0x00000001
 };
@@ -530,20 +553,20 @@ protected:
 
     virtual void free();
 
-protected: /* (to be deprecated) */
-    IOByteCount                _position;         /* absolute position over all ranges */
-    virtual void setPosition(IOByteCount position);
+protected:
+    /* DEPRECATED */ IOByteCount _position; /* absolute position over all ranges */
+    /* DEPRECATED */ virtual void setPosition(IOByteCount position);
 
 private:
-    unsigned           _positionAtIndex;  /* range #n in which position is now */
-    IOByteCount                _positionAtOffset; /* relative position within range #n */
+    /* DEPRECATED */ unsigned    _positionAtIndex;  /* range #n in which position is now */
+    /* DEPRECATED */ IOByteCount _positionAtOffset; /* relative position within range #n */
     OSData *_memoryEntries;
 
-    vm_offset_t _kernPtrAligned;
-    unsigned    _kernPtrAtIndex;
-    IOByteCount  _kernSize;
-    virtual void mapIntoKernel(unsigned rangeIndex);
-    virtual void unmapFromKernel();
+    /* DEPRECATED */ vm_offset_t _kernPtrAligned;
+    /* DEPRECATED */ unsigned    _kernPtrAtIndex;
+    /* DEPRECATED */ IOByteCount  _kernSize;
+    /* DEPRECATED */ virtual void mapIntoKernel(unsigned rangeIndex);
+    /* DEPRECATED */ virtual void unmapFromKernel();
     inline vm_map_t getMapForTask( task_t task, vm_address_t address );
 
 public:
@@ -576,17 +599,14 @@ public:
                                         IODirection      withDirection,
                                         bool             asReference = false);
 
-    virtual IOByteCount readBytes(IOByteCount offset,
-                               void * bytes, IOByteCount withLength);
-
-    virtual IOByteCount writeBytes(IOByteCount offset,
-                               const void * bytes, IOByteCount withLength);
-
     virtual IOPhysicalAddress getPhysicalSegment(IOByteCount offset,
                                                 IOByteCount * length);
 
-    virtual void * getVirtualSegment(IOByteCount offset,
-                                       IOByteCount * length);
+    virtual IOPhysicalAddress getSourceSegment(IOByteCount offset,
+                                               IOByteCount * length);
+
+    /* DEPRECATED */ virtual void * getVirtualSegment(IOByteCount offset,
+    /* DEPRECATED */                                   IOByteCount * length);
 
     virtual IOReturn prepare(IODirection forDirection = kIODirectionNone);
 
@@ -603,13 +623,14 @@ public:
        vm_map_t                addressMap,
        IOVirtualAddress        logical,
        IOByteCount             length );
+    virtual bool serialize(OSSerialize *s) const;
 };
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 class IOSubMemoryDescriptor : public IOMemoryDescriptor
 {
-    friend IOMemoryDescriptor;
+    friend class IOMemoryDescriptor;
 
     OSDeclareDefaultStructors(IOSubMemoryDescriptor);
 
@@ -662,6 +683,9 @@ public:
     virtual IOPhysicalAddress getPhysicalSegment(IOByteCount offset,
                                                 IOByteCount * length);
 
+    virtual IOPhysicalAddress getSourceSegment(IOByteCount offset,
+                                               IOByteCount * length);
+
     virtual IOByteCount readBytes(IOByteCount offset,
                                void * bytes, IOByteCount withLength);
 
@@ -675,6 +699,11 @@ public:
 
     virtual IOReturn complete(IODirection forDirection = kIODirectionNone);
 
+    // make virtual
+    IOReturn redirect( task_t safeTask, bool redirect );
+
+    virtual bool serialize(OSSerialize *s) const;
+
 protected:
     virtual IOMemoryMap *      makeMapping(
        IOMemoryDescriptor *    owner,