1*bbb1b6f9SApple OSS Distributions /*
2*bbb1b6f9SApple OSS Distributions * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3*bbb1b6f9SApple OSS Distributions *
4*bbb1b6f9SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*bbb1b6f9SApple OSS Distributions *
6*bbb1b6f9SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*bbb1b6f9SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*bbb1b6f9SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*bbb1b6f9SApple OSS Distributions * compliance with the License. The rights granted to you under the License
10*bbb1b6f9SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of,
11*bbb1b6f9SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to
12*bbb1b6f9SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any
13*bbb1b6f9SApple OSS Distributions * terms of an Apple operating system software license agreement.
14*bbb1b6f9SApple OSS Distributions *
15*bbb1b6f9SApple OSS Distributions * Please obtain a copy of the License at
16*bbb1b6f9SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*bbb1b6f9SApple OSS Distributions *
18*bbb1b6f9SApple OSS Distributions * The Original Code and all software distributed under the License are
19*bbb1b6f9SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*bbb1b6f9SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*bbb1b6f9SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*bbb1b6f9SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*bbb1b6f9SApple OSS Distributions * Please see the License for the specific language governing rights and
24*bbb1b6f9SApple OSS Distributions * limitations under the License.
25*bbb1b6f9SApple OSS Distributions *
26*bbb1b6f9SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*bbb1b6f9SApple OSS Distributions */
28*bbb1b6f9SApple OSS Distributions
29*bbb1b6f9SApple OSS Distributions #define IOKIT_ENABLE_SHARED_PTR
30*bbb1b6f9SApple OSS Distributions
31*bbb1b6f9SApple OSS Distributions #define DISABLE_DATAQUEUE_WARNING
32*bbb1b6f9SApple OSS Distributions
33*bbb1b6f9SApple OSS Distributions #include <IOKit/IODataQueue.h>
34*bbb1b6f9SApple OSS Distributions
35*bbb1b6f9SApple OSS Distributions #undef DISABLE_DATAQUEUE_WARNING
36*bbb1b6f9SApple OSS Distributions #include <vm/vm_kern_xnu.h>
37*bbb1b6f9SApple OSS Distributions
38*bbb1b6f9SApple OSS Distributions #include <IOKit/IODataQueueShared.h>
39*bbb1b6f9SApple OSS Distributions #include <IOKit/IOLib.h>
40*bbb1b6f9SApple OSS Distributions #include <IOKit/IOMemoryDescriptor.h>
41*bbb1b6f9SApple OSS Distributions #include <libkern/OSAtomic.h>
42*bbb1b6f9SApple OSS Distributions #include <libkern/c++/OSSharedPtr.h>
43*bbb1b6f9SApple OSS Distributions
44*bbb1b6f9SApple OSS Distributions struct IODataQueueInternal {
45*bbb1b6f9SApple OSS Distributions mach_msg_header_t msg;
46*bbb1b6f9SApple OSS Distributions UInt32 queueSize;
47*bbb1b6f9SApple OSS Distributions };
48*bbb1b6f9SApple OSS Distributions
49*bbb1b6f9SApple OSS Distributions #ifdef enqueue
50*bbb1b6f9SApple OSS Distributions #undef enqueue
51*bbb1b6f9SApple OSS Distributions #endif
52*bbb1b6f9SApple OSS Distributions
53*bbb1b6f9SApple OSS Distributions #ifdef dequeue
54*bbb1b6f9SApple OSS Distributions #undef dequeue
55*bbb1b6f9SApple OSS Distributions #endif
56*bbb1b6f9SApple OSS Distributions
57*bbb1b6f9SApple OSS Distributions #define super OSObject
58*bbb1b6f9SApple OSS Distributions
OSDefineMetaClassAndStructors(IODataQueue,OSObject)59*bbb1b6f9SApple OSS Distributions OSDefineMetaClassAndStructors(IODataQueue, OSObject)
60*bbb1b6f9SApple OSS Distributions
61*bbb1b6f9SApple OSS Distributions OSSharedPtr<IODataQueue>
62*bbb1b6f9SApple OSS Distributions IODataQueue::withCapacity(UInt32 size)
63*bbb1b6f9SApple OSS Distributions {
64*bbb1b6f9SApple OSS Distributions OSSharedPtr<IODataQueue> dataQueue = OSMakeShared<IODataQueue>();
65*bbb1b6f9SApple OSS Distributions
66*bbb1b6f9SApple OSS Distributions if (dataQueue) {
67*bbb1b6f9SApple OSS Distributions if (!dataQueue->initWithCapacity(size)) {
68*bbb1b6f9SApple OSS Distributions return nullptr;
69*bbb1b6f9SApple OSS Distributions }
70*bbb1b6f9SApple OSS Distributions }
71*bbb1b6f9SApple OSS Distributions
72*bbb1b6f9SApple OSS Distributions return dataQueue;
73*bbb1b6f9SApple OSS Distributions }
74*bbb1b6f9SApple OSS Distributions
75*bbb1b6f9SApple OSS Distributions OSSharedPtr<IODataQueue>
withEntries(UInt32 numEntries,UInt32 entrySize)76*bbb1b6f9SApple OSS Distributions IODataQueue::withEntries(UInt32 numEntries, UInt32 entrySize)
77*bbb1b6f9SApple OSS Distributions {
78*bbb1b6f9SApple OSS Distributions OSSharedPtr<IODataQueue> dataQueue = OSMakeShared<IODataQueue>();
79*bbb1b6f9SApple OSS Distributions
80*bbb1b6f9SApple OSS Distributions if (dataQueue) {
81*bbb1b6f9SApple OSS Distributions if (!dataQueue->initWithEntries(numEntries, entrySize)) {
82*bbb1b6f9SApple OSS Distributions return nullptr;
83*bbb1b6f9SApple OSS Distributions }
84*bbb1b6f9SApple OSS Distributions }
85*bbb1b6f9SApple OSS Distributions
86*bbb1b6f9SApple OSS Distributions return dataQueue;
87*bbb1b6f9SApple OSS Distributions }
88*bbb1b6f9SApple OSS Distributions
89*bbb1b6f9SApple OSS Distributions Boolean
initWithCapacity(UInt32 size)90*bbb1b6f9SApple OSS Distributions IODataQueue::initWithCapacity(UInt32 size)
91*bbb1b6f9SApple OSS Distributions {
92*bbb1b6f9SApple OSS Distributions vm_size_t allocSize = 0;
93*bbb1b6f9SApple OSS Distributions kern_return_t kr;
94*bbb1b6f9SApple OSS Distributions
95*bbb1b6f9SApple OSS Distributions if (!super::init()) {
96*bbb1b6f9SApple OSS Distributions return false;
97*bbb1b6f9SApple OSS Distributions }
98*bbb1b6f9SApple OSS Distributions
99*bbb1b6f9SApple OSS Distributions if (size > UINT32_MAX - DATA_QUEUE_MEMORY_HEADER_SIZE) {
100*bbb1b6f9SApple OSS Distributions return false;
101*bbb1b6f9SApple OSS Distributions }
102*bbb1b6f9SApple OSS Distributions
103*bbb1b6f9SApple OSS Distributions allocSize = round_page(size + DATA_QUEUE_MEMORY_HEADER_SIZE);
104*bbb1b6f9SApple OSS Distributions
105*bbb1b6f9SApple OSS Distributions if (allocSize < size) {
106*bbb1b6f9SApple OSS Distributions return false;
107*bbb1b6f9SApple OSS Distributions }
108*bbb1b6f9SApple OSS Distributions
109*bbb1b6f9SApple OSS Distributions assert(!notifyMsg);
110*bbb1b6f9SApple OSS Distributions notifyMsg = IOMallocType(IODataQueueInternal);
111*bbb1b6f9SApple OSS Distributions ((IODataQueueInternal *)notifyMsg)->queueSize = size;
112*bbb1b6f9SApple OSS Distributions
113*bbb1b6f9SApple OSS Distributions kr = kmem_alloc(kernel_map, (vm_offset_t *)&dataQueue, allocSize,
114*bbb1b6f9SApple OSS Distributions (kma_flags_t)(KMA_DATA | KMA_ZERO), IOMemoryTag(kernel_map));
115*bbb1b6f9SApple OSS Distributions if (kr != KERN_SUCCESS) {
116*bbb1b6f9SApple OSS Distributions return false;
117*bbb1b6f9SApple OSS Distributions }
118*bbb1b6f9SApple OSS Distributions
119*bbb1b6f9SApple OSS Distributions dataQueue->queueSize = size;
120*bbb1b6f9SApple OSS Distributions // dataQueue->head = 0;
121*bbb1b6f9SApple OSS Distributions // dataQueue->tail = 0;
122*bbb1b6f9SApple OSS Distributions
123*bbb1b6f9SApple OSS Distributions return true;
124*bbb1b6f9SApple OSS Distributions }
125*bbb1b6f9SApple OSS Distributions
126*bbb1b6f9SApple OSS Distributions Boolean
initWithEntries(UInt32 numEntries,UInt32 entrySize)127*bbb1b6f9SApple OSS Distributions IODataQueue::initWithEntries(UInt32 numEntries, UInt32 entrySize)
128*bbb1b6f9SApple OSS Distributions {
129*bbb1b6f9SApple OSS Distributions // Checking overflow for (numEntries + 1)*(entrySize + DATA_QUEUE_ENTRY_HEADER_SIZE):
130*bbb1b6f9SApple OSS Distributions // check (entrySize + DATA_QUEUE_ENTRY_HEADER_SIZE)
131*bbb1b6f9SApple OSS Distributions if ((entrySize > UINT32_MAX - DATA_QUEUE_ENTRY_HEADER_SIZE) ||
132*bbb1b6f9SApple OSS Distributions // check (numEntries + 1)
133*bbb1b6f9SApple OSS Distributions (numEntries > UINT32_MAX - 1) ||
134*bbb1b6f9SApple OSS Distributions // check (numEntries + 1)*(entrySize + DATA_QUEUE_ENTRY_HEADER_SIZE)
135*bbb1b6f9SApple OSS Distributions (entrySize + DATA_QUEUE_ENTRY_HEADER_SIZE > UINT32_MAX / (numEntries + 1))) {
136*bbb1b6f9SApple OSS Distributions return false;
137*bbb1b6f9SApple OSS Distributions }
138*bbb1b6f9SApple OSS Distributions
139*bbb1b6f9SApple OSS Distributions return initWithCapacity((numEntries + 1) * (DATA_QUEUE_ENTRY_HEADER_SIZE + entrySize));
140*bbb1b6f9SApple OSS Distributions }
141*bbb1b6f9SApple OSS Distributions
142*bbb1b6f9SApple OSS Distributions void
free()143*bbb1b6f9SApple OSS Distributions IODataQueue::free()
144*bbb1b6f9SApple OSS Distributions {
145*bbb1b6f9SApple OSS Distributions if (notifyMsg) {
146*bbb1b6f9SApple OSS Distributions if (dataQueue) {
147*bbb1b6f9SApple OSS Distributions kmem_free(kernel_map, (vm_offset_t)dataQueue,
148*bbb1b6f9SApple OSS Distributions round_page(((IODataQueueInternal *)notifyMsg)->queueSize +
149*bbb1b6f9SApple OSS Distributions DATA_QUEUE_MEMORY_HEADER_SIZE));
150*bbb1b6f9SApple OSS Distributions dataQueue = NULL;
151*bbb1b6f9SApple OSS Distributions }
152*bbb1b6f9SApple OSS Distributions
153*bbb1b6f9SApple OSS Distributions IOFreeType(notifyMsg, IODataQueueInternal);
154*bbb1b6f9SApple OSS Distributions notifyMsg = NULL;
155*bbb1b6f9SApple OSS Distributions }
156*bbb1b6f9SApple OSS Distributions
157*bbb1b6f9SApple OSS Distributions super::free();
158*bbb1b6f9SApple OSS Distributions
159*bbb1b6f9SApple OSS Distributions return;
160*bbb1b6f9SApple OSS Distributions }
161*bbb1b6f9SApple OSS Distributions
162*bbb1b6f9SApple OSS Distributions Boolean
enqueue(void * data,UInt32 dataSize)163*bbb1b6f9SApple OSS Distributions IODataQueue::enqueue(void * data, UInt32 dataSize)
164*bbb1b6f9SApple OSS Distributions {
165*bbb1b6f9SApple OSS Distributions UInt32 head;
166*bbb1b6f9SApple OSS Distributions UInt32 tail;
167*bbb1b6f9SApple OSS Distributions UInt32 newTail;
168*bbb1b6f9SApple OSS Distributions const UInt32 entrySize = dataSize + DATA_QUEUE_ENTRY_HEADER_SIZE;
169*bbb1b6f9SApple OSS Distributions UInt32 queueSize;
170*bbb1b6f9SApple OSS Distributions IODataQueueEntry * entry;
171*bbb1b6f9SApple OSS Distributions
172*bbb1b6f9SApple OSS Distributions // Check for overflow of entrySize
173*bbb1b6f9SApple OSS Distributions if (dataSize > UINT32_MAX - DATA_QUEUE_ENTRY_HEADER_SIZE) {
174*bbb1b6f9SApple OSS Distributions return false;
175*bbb1b6f9SApple OSS Distributions }
176*bbb1b6f9SApple OSS Distributions
177*bbb1b6f9SApple OSS Distributions // Force a single read of head and tail
178*bbb1b6f9SApple OSS Distributions // See rdar://problem/40780584 for an explanation of relaxed/acquire barriers
179*bbb1b6f9SApple OSS Distributions tail = __c11_atomic_load((_Atomic UInt32 *)&dataQueue->tail, __ATOMIC_RELAXED);
180*bbb1b6f9SApple OSS Distributions head = __c11_atomic_load((_Atomic UInt32 *)&dataQueue->head, __ATOMIC_ACQUIRE);
181*bbb1b6f9SApple OSS Distributions
182*bbb1b6f9SApple OSS Distributions // Check for underflow of (dataQueue->queueSize - tail)
183*bbb1b6f9SApple OSS Distributions queueSize = ((IODataQueueInternal *) notifyMsg)->queueSize;
184*bbb1b6f9SApple OSS Distributions if ((queueSize < tail) || (queueSize < head)) {
185*bbb1b6f9SApple OSS Distributions return false;
186*bbb1b6f9SApple OSS Distributions }
187*bbb1b6f9SApple OSS Distributions
188*bbb1b6f9SApple OSS Distributions if (tail >= head) {
189*bbb1b6f9SApple OSS Distributions // Is there enough room at the end for the entry?
190*bbb1b6f9SApple OSS Distributions if ((entrySize <= UINT32_MAX - tail) &&
191*bbb1b6f9SApple OSS Distributions ((tail + entrySize) <= queueSize)) {
192*bbb1b6f9SApple OSS Distributions entry = (IODataQueueEntry *)((UInt8 *)dataQueue->queue + tail);
193*bbb1b6f9SApple OSS Distributions
194*bbb1b6f9SApple OSS Distributions entry->size = dataSize;
195*bbb1b6f9SApple OSS Distributions __nochk_memcpy(&entry->data, data, dataSize);
196*bbb1b6f9SApple OSS Distributions
197*bbb1b6f9SApple OSS Distributions // The tail can be out of bound when the size of the new entry
198*bbb1b6f9SApple OSS Distributions // exactly matches the available space at the end of the queue.
199*bbb1b6f9SApple OSS Distributions // The tail can range from 0 to dataQueue->queueSize inclusive.
200*bbb1b6f9SApple OSS Distributions
201*bbb1b6f9SApple OSS Distributions newTail = tail + entrySize;
202*bbb1b6f9SApple OSS Distributions } else if (head > entrySize) { // Is there enough room at the beginning?
203*bbb1b6f9SApple OSS Distributions // Wrap around to the beginning, but do not allow the tail to catch
204*bbb1b6f9SApple OSS Distributions // up to the head.
205*bbb1b6f9SApple OSS Distributions
206*bbb1b6f9SApple OSS Distributions dataQueue->queue->size = dataSize;
207*bbb1b6f9SApple OSS Distributions
208*bbb1b6f9SApple OSS Distributions // We need to make sure that there is enough room to set the size before
209*bbb1b6f9SApple OSS Distributions // doing this. The user client checks for this and will look for the size
210*bbb1b6f9SApple OSS Distributions // at the beginning if there isn't room for it at the end.
211*bbb1b6f9SApple OSS Distributions
212*bbb1b6f9SApple OSS Distributions if ((queueSize - tail) >= DATA_QUEUE_ENTRY_HEADER_SIZE) {
213*bbb1b6f9SApple OSS Distributions ((IODataQueueEntry *)((UInt8 *)dataQueue->queue + tail))->size = dataSize;
214*bbb1b6f9SApple OSS Distributions }
215*bbb1b6f9SApple OSS Distributions
216*bbb1b6f9SApple OSS Distributions __nochk_memcpy(&dataQueue->queue->data, data, dataSize);
217*bbb1b6f9SApple OSS Distributions newTail = entrySize;
218*bbb1b6f9SApple OSS Distributions } else {
219*bbb1b6f9SApple OSS Distributions return false; // queue is full
220*bbb1b6f9SApple OSS Distributions }
221*bbb1b6f9SApple OSS Distributions } else {
222*bbb1b6f9SApple OSS Distributions // Do not allow the tail to catch up to the head when the queue is full.
223*bbb1b6f9SApple OSS Distributions // That's why the comparison uses a '>' rather than '>='.
224*bbb1b6f9SApple OSS Distributions
225*bbb1b6f9SApple OSS Distributions if ((head - tail) > entrySize) {
226*bbb1b6f9SApple OSS Distributions entry = (IODataQueueEntry *)((UInt8 *)dataQueue->queue + tail);
227*bbb1b6f9SApple OSS Distributions
228*bbb1b6f9SApple OSS Distributions entry->size = dataSize;
229*bbb1b6f9SApple OSS Distributions __nochk_memcpy(&entry->data, data, dataSize);
230*bbb1b6f9SApple OSS Distributions newTail = tail + entrySize;
231*bbb1b6f9SApple OSS Distributions } else {
232*bbb1b6f9SApple OSS Distributions return false; // queue is full
233*bbb1b6f9SApple OSS Distributions }
234*bbb1b6f9SApple OSS Distributions }
235*bbb1b6f9SApple OSS Distributions
236*bbb1b6f9SApple OSS Distributions // Publish the data we just enqueued
237*bbb1b6f9SApple OSS Distributions __c11_atomic_store((_Atomic UInt32 *)&dataQueue->tail, newTail, __ATOMIC_RELEASE);
238*bbb1b6f9SApple OSS Distributions
239*bbb1b6f9SApple OSS Distributions if (tail != head) {
240*bbb1b6f9SApple OSS Distributions //
241*bbb1b6f9SApple OSS Distributions // The memory barrier below paris with the one in ::dequeue
242*bbb1b6f9SApple OSS Distributions // so that either our store to the tail cannot be missed by
243*bbb1b6f9SApple OSS Distributions // the next dequeue attempt, or we will observe the dequeuer
244*bbb1b6f9SApple OSS Distributions // making the queue empty.
245*bbb1b6f9SApple OSS Distributions //
246*bbb1b6f9SApple OSS Distributions // Of course, if we already think the queue is empty,
247*bbb1b6f9SApple OSS Distributions // there's no point paying this extra cost.
248*bbb1b6f9SApple OSS Distributions //
249*bbb1b6f9SApple OSS Distributions __c11_atomic_thread_fence(__ATOMIC_SEQ_CST);
250*bbb1b6f9SApple OSS Distributions head = __c11_atomic_load((_Atomic UInt32 *)&dataQueue->head, __ATOMIC_RELAXED);
251*bbb1b6f9SApple OSS Distributions }
252*bbb1b6f9SApple OSS Distributions
253*bbb1b6f9SApple OSS Distributions if (tail == head) {
254*bbb1b6f9SApple OSS Distributions // Send notification (via mach message) that data is now available.
255*bbb1b6f9SApple OSS Distributions sendDataAvailableNotification();
256*bbb1b6f9SApple OSS Distributions }
257*bbb1b6f9SApple OSS Distributions return true;
258*bbb1b6f9SApple OSS Distributions }
259*bbb1b6f9SApple OSS Distributions
260*bbb1b6f9SApple OSS Distributions void
setNotificationPort(mach_port_t port)261*bbb1b6f9SApple OSS Distributions IODataQueue::setNotificationPort(mach_port_t port)
262*bbb1b6f9SApple OSS Distributions {
263*bbb1b6f9SApple OSS Distributions mach_msg_header_t * msgh;
264*bbb1b6f9SApple OSS Distributions
265*bbb1b6f9SApple OSS Distributions msgh = &((IODataQueueInternal *) notifyMsg)->msg;
266*bbb1b6f9SApple OSS Distributions bzero(msgh, sizeof(mach_msg_header_t));
267*bbb1b6f9SApple OSS Distributions msgh->msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0);
268*bbb1b6f9SApple OSS Distributions msgh->msgh_size = sizeof(mach_msg_header_t);
269*bbb1b6f9SApple OSS Distributions msgh->msgh_remote_port = port;
270*bbb1b6f9SApple OSS Distributions }
271*bbb1b6f9SApple OSS Distributions
272*bbb1b6f9SApple OSS Distributions void
sendDataAvailableNotification()273*bbb1b6f9SApple OSS Distributions IODataQueue::sendDataAvailableNotification()
274*bbb1b6f9SApple OSS Distributions {
275*bbb1b6f9SApple OSS Distributions kern_return_t kr;
276*bbb1b6f9SApple OSS Distributions mach_msg_header_t * msgh;
277*bbb1b6f9SApple OSS Distributions
278*bbb1b6f9SApple OSS Distributions msgh = &((IODataQueueInternal *) notifyMsg)->msg;
279*bbb1b6f9SApple OSS Distributions if (msgh->msgh_remote_port) {
280*bbb1b6f9SApple OSS Distributions kr = mach_msg_send_from_kernel_with_options(msgh, msgh->msgh_size,
281*bbb1b6f9SApple OSS Distributions MACH64_SEND_TIMEOUT, MACH_MSG_TIMEOUT_NONE);
282*bbb1b6f9SApple OSS Distributions switch (kr) {
283*bbb1b6f9SApple OSS Distributions case MACH_SEND_TIMED_OUT: // Notification already sent
284*bbb1b6f9SApple OSS Distributions case MACH_MSG_SUCCESS:
285*bbb1b6f9SApple OSS Distributions case MACH_SEND_NO_BUFFER:
286*bbb1b6f9SApple OSS Distributions break;
287*bbb1b6f9SApple OSS Distributions default:
288*bbb1b6f9SApple OSS Distributions IOLog("%s: dataAvailableNotification failed - msg_send returned: %d\n", /*getName()*/ "IODataQueue", kr);
289*bbb1b6f9SApple OSS Distributions break;
290*bbb1b6f9SApple OSS Distributions }
291*bbb1b6f9SApple OSS Distributions }
292*bbb1b6f9SApple OSS Distributions }
293*bbb1b6f9SApple OSS Distributions
294*bbb1b6f9SApple OSS Distributions OSSharedPtr<IOMemoryDescriptor>
getMemoryDescriptor()295*bbb1b6f9SApple OSS Distributions IODataQueue::getMemoryDescriptor()
296*bbb1b6f9SApple OSS Distributions {
297*bbb1b6f9SApple OSS Distributions OSSharedPtr<IOMemoryDescriptor> descriptor;
298*bbb1b6f9SApple OSS Distributions UInt32 queueSize;
299*bbb1b6f9SApple OSS Distributions
300*bbb1b6f9SApple OSS Distributions queueSize = ((IODataQueueInternal *) notifyMsg)->queueSize;
301*bbb1b6f9SApple OSS Distributions if (dataQueue != NULL) {
302*bbb1b6f9SApple OSS Distributions descriptor = IOMemoryDescriptor::withAddress(dataQueue, queueSize + DATA_QUEUE_MEMORY_HEADER_SIZE, kIODirectionOutIn);
303*bbb1b6f9SApple OSS Distributions }
304*bbb1b6f9SApple OSS Distributions
305*bbb1b6f9SApple OSS Distributions return descriptor;
306*bbb1b6f9SApple OSS Distributions }
307