Loading...
--- xnu/xnu-4570.61.1/iokit/Kernel/IOBufferMemoryDescriptor.cpp
+++ xnu/xnu-2782.1.97/iokit/Kernel/IOBufferMemoryDescriptor.cpp
@@ -66,8 +66,7 @@
{
kInternalFlagPhysical = 0x00000001,
kInternalFlagPageSized = 0x00000002,
- kInternalFlagPageAllocated = 0x00000004,
- kInternalFlagInit = 0x00000008
+ kInternalFlagPageAllocated = 0x00000004
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -85,7 +84,7 @@
int options = 0; // KMA_LOMEM;
kr = kernel_memory_allocate(kernel_map, &vmaddr,
- page_size, 0, options, VM_KERN_MEMORY_IOKIT);
+ page_size, 0, options);
if (KERN_SUCCESS != kr) vmaddr = 0;
else bzero((void *) vmaddr, page_size);
@@ -167,8 +166,6 @@
options |= kIOMemoryPhysicallyContiguous;
_alignment = alignment;
-
- if ((capacity + alignment) < _capacity) return (false);
if ((inTask != kernel_task) && !(options & kIOMemoryPageable))
return false;
@@ -235,7 +232,7 @@
{
IOStatisticsAlloc(kIOStatisticsMallocAligned, capacity);
#if IOALLOCDEBUG
- OSAddAtomic(capacity, &debug_iomalloc_size);
+ debug_iomalloc_size += capacity;
#endif
}
}
@@ -262,7 +259,7 @@
if( options & kIOMemoryPageable) {
#if IOALLOCDEBUG
- OSAddAtomicLong(size, &debug_iomallocpageable_size);
+ debug_iomallocpageable_size += size;
#endif
mapTask = inTask;
if (NULL == inTask)
@@ -289,11 +286,6 @@
if (!super::initWithOptions(_ranges.v64, 1, 0,
inTask, iomdOptions, /* System mapper */ 0))
return false;
-
- _internalFlags |= kInternalFlagInit;
-#if IOTRACKING
- if (!(options & kIOMemoryPageable)) trackingAccumSize(capacity);
-#endif /* IOTRACKING */
// give any system mapper the allocation params
if (kIOReturnSuccess != dmaCommandOperation(kIOMDAddDMAMapSpec,
@@ -494,26 +486,19 @@
map->release();
}
- if ((options & kIOMemoryPageable)
- || (kInternalFlagPageSized & internalFlags)) size = round_page(size);
-
-#if IOTRACKING
- if (!(options & kIOMemoryPageable)
- && buffer
- && (kInternalFlagInit & _internalFlags)) trackingAccumSize(-size);
-#endif /* IOTRACKING */
-
/* super::free may unwire - deallocate buffer afterwards */
super::free();
if (options & kIOMemoryPageable)
{
#if IOALLOCDEBUG
- OSAddAtomicLong(-size, &debug_iomallocpageable_size);
+ debug_iomallocpageable_size -= round_page(size);
#endif
}
else if (buffer)
{
+ if (kInternalFlagPageSized & internalFlags) size = round_page(size);
+
if (kInternalFlagPhysical & internalFlags)
{
IOKernelFreePhysical((mach_vm_address_t) buffer, size);
@@ -527,7 +512,7 @@
kmem_free(kernel_map, page, page_size);
}
#if IOALLOCDEBUG
- OSAddAtomic(-size, &debug_iomalloc_size);
+ debug_iomalloc_size -= size;
#endif
IOStatisticsAlloc(kIOStatisticsFreeAligned, size);
}
@@ -567,7 +552,6 @@
void IOBufferMemoryDescriptor::setLength(vm_size_t length)
{
assert(length <= _capacity);
- if (length > _capacity) return;
_length = length;
_ranges.v64->length = length;
@@ -639,9 +623,6 @@
IOBufferMemoryDescriptor::getBytesNoCopy(vm_size_t start, vm_size_t withLength)
{
IOVirtualAddress address;
-
- if ((start + withLength) < start) return 0;
-
if (kIOMemoryTypePhysical64 == (_flags & kIOMemoryTypeMask))
address = (IOVirtualAddress) _buffer;
else