2 * Copyright (c) 1998-2010 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 #include <IOKit/IOFilterInterruptEventSource.h>
30 #include <IOKit/IOService.h>
31 #include <IOKit/IOKitDebug.h>
32 #include <IOKit/IOTimeStamp.h>
33 #include <IOKit/IOWorkLoop.h>
37 #define IOStatisticsInitializeCounter() \
39 IOStatistics::setCounterType(IOEventSource::reserved->counter, kIOStatisticsFilterInterruptEventSourceCounter); \
42 #define IOStatisticsInterrupt() \
44 IOStatistics::countInterrupt(IOEventSource::reserved->counter); \
49 #define IOStatisticsInitializeCounter()
50 #define IOStatisticsInterrupt()
52 #endif /* IOKITSTATS */
54 #define super IOInterruptEventSource
56 OSDefineMetaClassAndStructors
57 (IOFilterInterruptEventSource
, IOInterruptEventSource
)
58 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource
, 0);
59 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource
, 1);
60 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource
, 2);
61 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource
, 3);
62 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource
, 4);
63 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource
, 5);
64 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource
, 6);
65 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource
, 7);
68 * Implement the call throughs for the private protection conversion
70 bool IOFilterInterruptEventSource::init(OSObject
*inOwner
,
72 IOService
*inProvider
,
78 IOInterruptEventSource
*
79 IOFilterInterruptEventSource::interruptEventSource(OSObject
*inOwner
,
81 IOService
*inProvider
,
88 IOFilterInterruptEventSource::init(OSObject
*inOwner
,
90 Filter inFilterAction
,
91 IOService
*inProvider
,
94 if ( !super::init(inOwner
, inAction
, inProvider
, inIntIndex
) )
100 filterAction
= inFilterAction
;
102 IOStatisticsInitializeCounter();
107 IOFilterInterruptEventSource
*IOFilterInterruptEventSource
108 ::filterInterruptEventSource(OSObject
*inOwner
,
110 Filter inFilterAction
,
111 IOService
*inProvider
,
114 IOFilterInterruptEventSource
*me
= new IOFilterInterruptEventSource
;
117 && !me
->init(inOwner
, inAction
, inFilterAction
, inProvider
, inIntIndex
)) {
125 void IOFilterInterruptEventSource::signalInterrupt()
127 bool trace
= (gIOKitTrace
& kIOTraceIntEventSource
) ? true : false;
129 IOStatisticsInterrupt();
133 IOTimeStampStartConstant(IODBG_INTES(IOINTES_SEMA
), (uintptr_t) this, (uintptr_t) owner
);
135 signalWorkAvailable();
138 IOTimeStampEndConstant(IODBG_INTES(IOINTES_SEMA
), (uintptr_t) this, (uintptr_t) owner
);
143 IOFilterInterruptEventSource::Filter
144 IOFilterInterruptEventSource::getFilterAction() const
152 void IOFilterInterruptEventSource::normalInterruptOccurred
153 (void */
*refcon*/
, IOService */
*prov*/
, int /*source*/)
156 bool trace
= (gIOKitTrace
& kIOTraceIntEventSource
) ? true : false;
159 IOTimeStampStartConstant(IODBG_INTES(IOINTES_FILTER
),
160 (uintptr_t) filterAction
, (uintptr_t) owner
, (uintptr_t) this, (uintptr_t) workLoop
);
163 filterRes
= (*filterAction
)(owner
, this);
166 IOTimeStampEndConstant(IODBG_INTES(IOINTES_FILTER
),
167 (uintptr_t) filterAction
, (uintptr_t) owner
, (uintptr_t) this, (uintptr_t) workLoop
);
173 void IOFilterInterruptEventSource::disableInterruptOccurred
174 (void */
*refcon*/
, IOService
*prov
, int source
)
177 bool trace
= (gIOKitTrace
& kIOTraceIntEventSource
) ? true : false;
180 IOTimeStampStartConstant(IODBG_INTES(IOINTES_FILTER
),
181 (uintptr_t) filterAction
, (uintptr_t) owner
, (uintptr_t) this, (uintptr_t) workLoop
);
184 filterRes
= (*filterAction
)(owner
, this);
187 IOTimeStampEndConstant(IODBG_INTES(IOINTES_FILTER
),
188 (uintptr_t) filterAction
, (uintptr_t) owner
, (uintptr_t) this, (uintptr_t) workLoop
);
191 prov
->disableInterrupt(source
); /* disable the interrupt */