]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOCommandGate.cpp
53a99baa9e2929cf8bbd53730d732cb16cc22de6
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #include <IOKit/IOCommandGate.h>
23 #include <IOKit/IOWorkLoop.h>
24 #include <IOKit/IOReturn.h>
25 #include <IOKit/IOTimeStamp.h>
27 #define super IOEventSource
29 OSDefineMetaClassAndStructors(IOCommandGate
, IOEventSource
)
30 OSMetaClassDefineReservedUnused(IOCommandGate
, 0);
31 OSMetaClassDefineReservedUnused(IOCommandGate
, 1);
32 OSMetaClassDefineReservedUnused(IOCommandGate
, 2);
33 OSMetaClassDefineReservedUnused(IOCommandGate
, 3);
34 OSMetaClassDefineReservedUnused(IOCommandGate
, 4);
35 OSMetaClassDefineReservedUnused(IOCommandGate
, 5);
36 OSMetaClassDefineReservedUnused(IOCommandGate
, 6);
37 OSMetaClassDefineReservedUnused(IOCommandGate
, 7);
39 bool IOCommandGate::checkForWork() { return false; }
41 bool IOCommandGate::init(OSObject
*inOwner
, Action inAction
= 0)
43 return super::init(inOwner
, (IOEventSource::Action
) inAction
);
47 IOCommandGate::commandGate(OSObject
*inOwner
, Action inAction
= 0)
49 IOCommandGate
*me
= new IOCommandGate
;
51 if (me
&& !me
->init(inOwner
, inAction
)) {
59 IOReturn
IOCommandGate::runCommand(void *arg0
= 0, void *arg1
= 0,
60 void *arg2
= 0, void *arg3
= 0)
65 return kIOReturnNotPermitted
;
68 return kIOReturnNoResources
;
70 // closeGate is recursive so don't worry if we already hold the lock.
71 IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION
),
72 (unsigned int) action
, (unsigned int) owner
);
75 res
= (*(Action
) action
)(owner
, arg0
, arg1
, arg2
, arg3
);
81 IOReturn
IOCommandGate::runAction(Action inAction
,
82 void *arg0
= 0, void *arg1
= 0,
83 void *arg2
= 0, void *arg3
= 0)
88 return kIOReturnNotPermitted
;
91 return kIOReturnBadArgument
;
93 IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION
),
94 (unsigned int) inAction
, (unsigned int) owner
);
96 // closeGate is recursive so don't worry if we already hold the lock.
98 res
= (*inAction
)(owner
, arg0
, arg1
, arg2
, arg3
);
104 IOReturn
IOCommandGate::attemptCommand(void *arg0
= 0, void *arg1
= 0,
105 void *arg2
= 0, void *arg3
= 0)
110 return kIOReturnNotPermitted
;
113 return kIOReturnNoResources
;
115 // Try to hold the lock if can't get return immediately.
117 return kIOReturnCannotLock
;
119 // closeGate is recursive so don't worry if we already hold the lock.
120 IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION
),
121 (unsigned int) action
, (unsigned int) owner
);
123 res
= (*(Action
) action
)(owner
, arg0
, arg1
, arg2
, arg3
);
129 IOReturn
IOCommandGate::attemptAction(Action inAction
,
130 void *arg0
= 0, void *arg1
= 0,
131 void *arg2
= 0, void *arg3
= 0)
136 return kIOReturnNotPermitted
;
139 return kIOReturnBadArgument
;
141 // Try to close the gate if can't get return immediately.
143 return kIOReturnCannotLock
;
145 IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION
),
146 (unsigned int) inAction
, (unsigned int) owner
);
148 res
= (*inAction
)(owner
, arg0
, arg1
, arg2
, arg3
);
154 IOReturn
IOCommandGate::commandSleep(void *event
, UInt32 interruptible
)
158 if (!workLoop
->inGate())
159 return kIOReturnNotPermitted
;
161 return sleepGate(event
, interruptible
);
164 void IOCommandGate::commandWakeup(void *event
, bool oneThread
)
166 wakeupGate(event
, oneThread
);