-/*
- * getPhysicalSegment:
- *
- * Get the physical address of the buffer, relative to the current position.
- * If the current position is at the end of the buffer, a zero is returned.
- */
-IOPhysicalAddress
-IOBufferMemoryDescriptor::getPhysicalSegment(IOByteCount offset,
- IOByteCount * lengthOfSegment)
-{
- IOPhysicalAddress physAddr;
-
- if( offset != _position)
- setPosition( offset );
-
- assert(_position <= _length);
-
- /* Fail gracefully if the position is at (or past) the end-of-buffer. */
- if (_position >= _length) {
- *lengthOfSegment = 0;
- return 0;
- }
-
- if (_options & kIOMemoryPageable) {
- physAddr = super::getPhysicalSegment(offset, lengthOfSegment);
-
- } else {
- /* Compute the largest contiguous physical length possible. */
- vm_address_t actualPos = _singleRange.v.address + _position;
- vm_address_t actualPage = trunc_page(actualPos);
- unsigned physInd = atop(actualPage-trunc_page(_singleRange.v.address));
-
- vm_size_t physicalLength = actualPage + page_size - actualPos;
- for (unsigned index = physInd + 1; index < _physSegCount &&
- _physAddrs[index] == _physAddrs[index-1] + page_size; index++) {
- physicalLength += page_size;
- }
-
- /* Clip contiguous physical length at the end-of-buffer. */
- if (physicalLength > _length - _position)
- physicalLength = _length - _position;
-
- *lengthOfSegment = physicalLength;
- physAddr = _physAddrs[physInd] + (actualPos - actualPage);
- }
-
- return physAddr;
-}
-
-OSMetaClassDefineReservedUnused(IOBufferMemoryDescriptor, 0);