]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOEventSource.cpp
3393993e0a286123748daf7a2e514cafb39f13d9
2 * Copyright (c) 1998-2000, 2009 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
32 1998-7-13 Godfrey van der Linden(gvdl)
35 #include <IOKit/IOLib.h>
37 #include <IOKit/IOEventSource.h>
38 #include <IOKit/IOWorkLoop.h>
40 #define super OSObject
42 OSDefineMetaClassAndAbstractStructors(IOEventSource
, OSObject
)
44 OSMetaClassDefineReservedUnused(IOEventSource
, 0);
45 OSMetaClassDefineReservedUnused(IOEventSource
, 1);
46 OSMetaClassDefineReservedUnused(IOEventSource
, 2);
47 OSMetaClassDefineReservedUnused(IOEventSource
, 3);
48 OSMetaClassDefineReservedUnused(IOEventSource
, 4);
49 OSMetaClassDefineReservedUnused(IOEventSource
, 5);
50 OSMetaClassDefineReservedUnused(IOEventSource
, 6);
51 OSMetaClassDefineReservedUnused(IOEventSource
, 7);
53 bool IOEventSource::checkForWork() { return false; }
55 /* inline function implementations */
59 #define IOStatisticsRegisterCounter() \
61 reserved->counter = IOStatistics::registerEventSource(inOwner); \
64 #define IOStatisticsUnregisterCounter() \
67 IOStatistics::unregisterEventSource(reserved->counter); \
70 #define IOStatisticsOpenGate() \
72 IOStatistics::countOpenGate(reserved->counter); \
75 #define IOStatisticsCloseGate() \
77 IOStatistics::countCloseGate(reserved->counter); \
82 #define IOStatisticsRegisterCounter()
83 #define IOStatisticsUnregisterCounter()
84 #define IOStatisticsOpenGate()
85 #define IOStatisticsCloseGate()
87 #endif /* IOKITSTATS */
89 void IOEventSource::signalWorkAvailable()
91 workLoop
->signalWorkAvailable();
94 void IOEventSource::openGate()
96 IOStatisticsOpenGate();
100 void IOEventSource::closeGate()
102 workLoop
->closeGate();
103 IOStatisticsCloseGate();
106 bool IOEventSource::tryCloseGate()
109 if ((res
= workLoop
->tryCloseGate())) {
110 IOStatisticsCloseGate();
115 int IOEventSource::sleepGate(void *event
, UInt32 type
)
118 IOStatisticsOpenGate();
119 res
= workLoop
->sleepGate(event
, type
);
120 IOStatisticsCloseGate();
124 int IOEventSource::sleepGate(void *event
, AbsoluteTime deadline
, UInt32 type
)
127 IOStatisticsOpenGate();
128 res
= workLoop
->sleepGate(event
, deadline
, type
);
129 IOStatisticsCloseGate();
133 void IOEventSource::wakeupGate(void *event
, bool oneThread
) { workLoop
->wakeupGate(event
, oneThread
); }
136 bool IOEventSource::init(OSObject
*inOwner
,
144 if ( !super::init() )
147 (void) setAction(inAction
);
151 reserved
= IONew(ExpansionData
, 1);
157 IOStatisticsRegisterCounter();
162 void IOEventSource::free( void )
164 IOStatisticsUnregisterCounter();
167 IODelete(reserved
, ExpansionData
, 1);
172 IOEventSource::Action
IOEventSource::getAction () const { return action
; };
174 void IOEventSource::setAction(Action inAction
)
179 IOEventSource
*IOEventSource::getNext() const { return eventChainNext
; };
181 void IOEventSource::setNext(IOEventSource
*inNext
)
183 eventChainNext
= inNext
;
186 void IOEventSource::enable()
190 return signalWorkAvailable();
193 void IOEventSource::disable()
198 bool IOEventSource::isEnabled() const
203 void IOEventSource::setWorkLoop(IOWorkLoop
*inWorkLoop
)
207 workLoop
= inWorkLoop
;
210 IOWorkLoop
*IOEventSource::getWorkLoop() const
215 bool IOEventSource::onThread() const
217 return (workLoop
!= 0) && workLoop
->onThread();