]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IODataQueueShared.h
xnu-344.34.tar.gz
[apple/xnu.git] / iokit / IOKit / IODataQueueShared.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
de355530
A
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
1c79356b 11 *
de355530
A
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
de355530
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#ifndef _IOKIT_IODATAQUEUESHARED_H
24#define _IOKIT_IODATAQUEUESHARED_H
25
26#include <libkern/OSTypes.h>
27
28/*!
29 * @typedef IODataQueueEntry
30 * @abstract Represents an entry within the data queue
31 * @discussion This is a variable sized struct. The data field simply represents the start of the data region. The size of the data region is stored in the size field. The whole size of the specific entry is the size of a UInt32 plus the size of the data region.
32 * @field size The size of the following data region.
33 * @field data Represents the beginning of the data region. The address of the data field is a pointer to the start of the data region.
34 */
35typedef struct _IODataQueueEntry{
36 UInt32 size;
37 void * data;
38} IODataQueueEntry;
39
40/*!
41 * @typedef IODataQueueMemory
42 * @abstract A struct mapping to the header region of a data queue.
43 * @discussion This struct is variable sized. The struct represents the data queue header information plus a pointer to the actual data queue itself. The size of the struct is the combined size of the header fields (3 * sizeof(UInt32)) plus the actual size of the queue region. This size is stored in the queueSize field.
44 * @field queueSize The size of the queue region pointed to by the queue field.
45 * @field head The location of the queue head. This field is represented as a byte offset from the beginning of the queue memory region.
46 * @field tail The location of the queue tail. This field is represented as a byte offset from the beginning of the queue memory region.
47 * @field queue Represents the beginning of the queue memory region. The size of the region pointed to by queue is stored in the queueSize field.
48 */
49typedef struct _IODataQueueMemory {
50 UInt32 queueSize;
51 volatile UInt32 head;
52 volatile UInt32 tail;
53 IODataQueueEntry queue[1];
54} IODataQueueMemory;
55
56/*!
57 * @defined DATA_QUEUE_ENTRY_HEADER_SIZE Represents the size of the data queue entry header independent of the actual size of the data in the entry. This is the overhead of each entry in the queue. The total size of an entry is equal to this value plus the size stored in the entry's size field (in IODataQueueEntry).
58 */
59#define DATA_QUEUE_ENTRY_HEADER_SIZE (sizeof(IODataQueueEntry) - sizeof(void *))
60
61/*!
62 * @defined DATA_QUEUE_MEMORY_HEADER_SIZE Represents the size of the data queue memory header independent of the actual size of the queue data itself. The total size of the queue memory is equal to this value plus the size of the queue data region which is stored in the queueSize field of IODataQueueMeory.
63 */
64#define DATA_QUEUE_MEMORY_HEADER_SIZE (sizeof(IODataQueueMemory) - sizeof(IODataQueueEntry))
65
66#endif /* _IOKIT_IODATAQUEUESHARED_H */
67