]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOCommandQueue.h
2a2a781957a3e1f446c19ccd2011ad35703d678f
[apple/xnu.git] / iokit / IOKit / IOCommandQueue.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
32
33 HISTORY
34 1998-7-13 Godfrey van der Linden(gvdl)
35 Created.
36 1998-10-30 Godfrey van der Linden(gvdl)
37 Converted to C++
38 1999-9-22 Godfrey van der Linden(gvdl)
39 Deprecated
40 ]*/
41 #ifndef _IOKIT_IOCOMMANDQUEUE_H
42 #define _IOKIT_IOCOMMANDQUEUE_H
43
44 #include <IOKit/IOEventSource.h>
45
46
47
48
49 #warning IOCommandQueue has been deprecated in favour of IOCommandGate and will be going away before too long.
50
51
52
53
54
55 class IOCommandQueue;
56
57 typedef void (*IOCommandQueueAction)
58 (OSObject *, void *field0, void *field1, void *field2, void *field3);
59
60 class IOCommandQueue : public IOEventSource
61 {
62 OSDeclareDefaultStructors(IOCommandQueue)
63
64 protected:
65 static const int kIOCQDefaultSize = 128;
66
67 void *queue;
68 IOLock *producerLock;
69 semaphore_port_t producerSema;
70 int producerIndex, consumerIndex;
71 int size;
72
73 virtual void free();
74
75 virtual bool checkForWork();
76
77 public:
78 static IOCommandQueue *commandQueue(OSObject *inOwner,
79 IOCommandQueueAction inAction = 0,
80 int inSize = kIOCQDefaultSize);
81 virtual bool init(OSObject *inOwner,
82 IOCommandQueueAction inAction = 0,
83 int inSize = kIOCQDefaultSize);
84
85 virtual kern_return_t enqueueCommand(bool gotoSleep = true,
86 void *field0 = 0, void *field1 = 0,
87 void *field2 = 0, void *field3 = 0);
88
89 // WARNING: This function can only be safely called from the appropriate
90 // work loop context. You should check IOWorkLoop::onThread is true.
91 //
92 // For each entry in the commandQueue call the target/action.
93 // Lockout all new entries to the queue while iterating.
94 // If the input fields are zero then the queue's owner/action will be used.
95 virtual int performAndFlush(OSObject *target = 0,
96 IOCommandQueueAction inAction = 0);
97 };
98
99 #endif /* !_IOKIT_IOCOMMANDQUEUE_H */