-
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-void * IOMultiMemoryDescriptor::getVirtualSegment( IOByteCount /* offset */ ,
- IOByteCount * /* length */ )
-{
- return 0;
-}
-
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-IOByteCount IOMultiMemoryDescriptor::readBytes( IOByteCount offset,
- void * bytes,
- IOByteCount withLength )
-{
- //
- // Copies data from the memory descriptor's buffer at the given offset, to
- // the specified buffer. Returns the number of bytes copied.
- //
-
- IOByteCount bytesCopied = 0;
- unsigned index;
-
- for ( index = 0; index < _descriptorsCount; index++ )
- {
- if ( offset < _descriptors[index]->getLength() ) break;
- offset -= _descriptors[index]->getLength();
- }
-
- for ( ; index < _descriptorsCount && withLength; index++)
- {
- IOByteCount copy = min(_descriptors[index]->getLength(), withLength);
- IOByteCount copied = _descriptors[index]->readBytes(offset,bytes,copy);
-
- bytesCopied += copied;
- if ( copied != copy ) break;
-
- bytes = ((UInt8 *) bytes) + copied;
- withLength -= copied;
- offset = 0;
- }
-
- return bytesCopied;
-}
-
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-IOByteCount IOMultiMemoryDescriptor::writeBytes( IOByteCount offset,
- const void * bytes,
- IOByteCount withLength )
-{
- //
- // Copies data to the memory descriptor's buffer at the given offset, from
- // the specified buffer. Returns the number of bytes copied.
- //
-
- IOByteCount bytesCopied = 0;
- unsigned index;
-
- for ( index = 0; index < _descriptorsCount; index++ )
- {
- if ( offset < _descriptors[index]->getLength() ) break;
- offset -= _descriptors[index]->getLength();
- }
-
- for ( ; index < _descriptorsCount && withLength; index++)
- {
- IOByteCount copy = min(_descriptors[index]->getLength(), withLength);
- IOByteCount copied = _descriptors[index]->writeBytes(offset,bytes,copy);
-
- bytesCopied += copied;
- if ( copied != copy ) break;
-
- bytes = ((UInt8 *) bytes) + copied;
- withLength -= copied;
- offset = 0;
- }
-
- return bytesCopied;
-}