Loading...
iokit/Kernel/IODataQueue.cpp xnu-12377.121.6 xnu-7195.141.2
--- xnu/xnu-12377.121.6/iokit/Kernel/IODataQueue.cpp
+++ xnu/xnu-7195.141.2/iokit/Kernel/IODataQueue.cpp
@@ -33,7 +33,6 @@
 #include <IOKit/IODataQueue.h>
 
 #undef DISABLE_DATAQUEUE_WARNING
-#include <vm/vm_kern_xnu.h>
 
 #include <IOKit/IODataQueueShared.h>
 #include <IOKit/IOLib.h>
@@ -90,7 +89,6 @@
 IODataQueue::initWithCapacity(UInt32 size)
 {
 	vm_size_t allocSize = 0;
-	kern_return_t kr;
 
 	if (!super::init()) {
 		return false;
@@ -107,14 +105,18 @@
 	}
 
 	assert(!notifyMsg);
-	notifyMsg = IOMallocType(IODataQueueInternal);
+	notifyMsg = IONew(IODataQueueInternal, 1);
+	if (!notifyMsg) {
+		return false;
+	}
+	bzero(notifyMsg, sizeof(IODataQueueInternal));
 	((IODataQueueInternal *)notifyMsg)->queueSize = size;
 
-	kr = kmem_alloc(kernel_map, (vm_offset_t *)&dataQueue, allocSize,
-	    (kma_flags_t)(KMA_DATA_SHARED | KMA_ZERO), IOMemoryTag(kernel_map));
-	if (kr != KERN_SUCCESS) {
-		return false;
-	}
+	dataQueue = (IODataQueueMemory *)IOMallocAligned(allocSize, PAGE_SIZE);
+	if (dataQueue == NULL) {
+		return false;
+	}
+	bzero(dataQueue, allocSize);
 
 	dataQueue->queueSize    = size;
 //  dataQueue->head         = 0;
@@ -144,13 +146,11 @@
 {
 	if (notifyMsg) {
 		if (dataQueue) {
-			kmem_free(kernel_map, (vm_offset_t)dataQueue,
-			    round_page(((IODataQueueInternal *)notifyMsg)->queueSize +
-			    DATA_QUEUE_MEMORY_HEADER_SIZE));
+			IOFreeAligned(dataQueue, round_page(((IODataQueueInternal *)notifyMsg)->queueSize + DATA_QUEUE_MEMORY_HEADER_SIZE));
 			dataQueue = NULL;
 		}
 
-		IOFreeType(notifyMsg, IODataQueueInternal);
+		IODelete(notifyMsg, IODataQueueInternal, 1);
 		notifyMsg = NULL;
 	}
 
@@ -277,8 +277,7 @@
 
 	msgh = &((IODataQueueInternal *) notifyMsg)->msg;
 	if (msgh->msgh_remote_port) {
-		kr = mach_msg_send_from_kernel_with_options(msgh, msgh->msgh_size,
-		    MACH64_SEND_TIMEOUT, MACH_MSG_TIMEOUT_NONE);
+		kr = mach_msg_send_from_kernel_with_options(msgh, msgh->msgh_size, MACH_SEND_TIMEOUT, MACH_MSG_TIMEOUT_NONE);
 		switch (kr) {
 		case MACH_SEND_TIMED_OUT: // Notification already sent
 		case MACH_MSG_SUCCESS: