]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOCommandGate.cpp
73a7cc98e5f2aa651e2f05a7e234228291a15316
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
25 #include <IOKit/IOCommandGate.h>
26 #include <IOKit/IOWorkLoop.h>
27 #include <IOKit/IOReturn.h>
28 #include <IOKit/IOTimeStamp.h>
30 #define super IOEventSource
32 OSDefineMetaClassAndStructors(IOCommandGate
, IOEventSource
)
33 OSMetaClassDefineReservedUnused(IOCommandGate
, 0);
34 OSMetaClassDefineReservedUnused(IOCommandGate
, 1);
35 OSMetaClassDefineReservedUnused(IOCommandGate
, 2);
36 OSMetaClassDefineReservedUnused(IOCommandGate
, 3);
37 OSMetaClassDefineReservedUnused(IOCommandGate
, 4);
38 OSMetaClassDefineReservedUnused(IOCommandGate
, 5);
39 OSMetaClassDefineReservedUnused(IOCommandGate
, 6);
40 OSMetaClassDefineReservedUnused(IOCommandGate
, 7);
42 bool IOCommandGate::checkForWork() { return false; }
44 bool IOCommandGate::init(OSObject
*inOwner
, Action inAction
= 0)
46 return super::init(inOwner
, (IOEventSource::Action
) inAction
);
50 IOCommandGate::commandGate(OSObject
*inOwner
, Action inAction
= 0)
52 IOCommandGate
*me
= new IOCommandGate
;
54 if (me
&& !me
->init(inOwner
, inAction
)) {
62 IOReturn
IOCommandGate::runCommand(void *arg0
= 0, void *arg1
= 0,
63 void *arg2
= 0, void *arg3
= 0)
68 return kIOReturnNotPermitted
;
71 return kIOReturnNoResources
;
73 // closeGate is recursive so don't worry if we already hold the lock.
74 IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION
),
75 (unsigned int) action
, (unsigned int) owner
);
78 res
= (*(Action
) action
)(owner
, arg0
, arg1
, arg2
, arg3
);
84 IOReturn
IOCommandGate::runAction(Action inAction
,
85 void *arg0
= 0, void *arg1
= 0,
86 void *arg2
= 0, void *arg3
= 0)
91 return kIOReturnNotPermitted
;
94 return kIOReturnBadArgument
;
96 IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION
),
97 (unsigned int) inAction
, (unsigned int) owner
);
99 // closeGate is recursive so don't worry if we already hold the lock.
101 res
= (*inAction
)(owner
, arg0
, arg1
, arg2
, arg3
);
107 IOReturn
IOCommandGate::attemptCommand(void *arg0
= 0, void *arg1
= 0,
108 void *arg2
= 0, void *arg3
= 0)
113 return kIOReturnNotPermitted
;
116 return kIOReturnNoResources
;
118 // Try to hold the lock if can't get return immediately.
120 return kIOReturnCannotLock
;
122 // closeGate is recursive so don't worry if we already hold the lock.
123 IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION
),
124 (unsigned int) action
, (unsigned int) owner
);
126 res
= (*(Action
) action
)(owner
, arg0
, arg1
, arg2
, arg3
);
132 IOReturn
IOCommandGate::attemptAction(Action inAction
,
133 void *arg0
= 0, void *arg1
= 0,
134 void *arg2
= 0, void *arg3
= 0)
139 return kIOReturnNotPermitted
;
142 return kIOReturnBadArgument
;
144 // Try to close the gate if can't get return immediately.
146 return kIOReturnCannotLock
;
148 IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION
),
149 (unsigned int) inAction
, (unsigned int) owner
);
151 res
= (*inAction
)(owner
, arg0
, arg1
, arg2
, arg3
);
157 IOReturn
IOCommandGate::commandSleep(void *event
, UInt32 interruptible
)
161 if (!workLoop
->inGate())
162 return kIOReturnNotPermitted
;
164 return sleepGate(event
, interruptible
);
167 void IOCommandGate::commandWakeup(void *event
, bool oneThread
)
169 wakeupGate(event
, oneThread
);