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