]> git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOFilterInterruptEventSource.cpp
xnu-792.13.8.tar.gz
[apple/xnu.git] / iokit / Kernel / IOFilterInterruptEventSource.cpp
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
32
33 HISTORY
34 1999-4-15 Godfrey van der Linden(gvdl)
35 Created.
36 */
37 #include <IOKit/IOFilterInterruptEventSource.h>
38 #include <IOKit/IOService.h>
39 #include <IOKit/IOTimeStamp.h>
40 #include <IOKit/IOWorkLoop.h>
41
42 #if KDEBUG
43
44 #define IOTimeTypeStampS(t) \
45 do { \
46 IOTimeStampStart(IODBG_INTES(t), \
47 (unsigned int) this, (unsigned int) owner); \
48 } while(0)
49
50 #define IOTimeTypeStampE(t) \
51 do { \
52 IOTimeStampEnd(IODBG_INTES(t), \
53 (unsigned int) this, (unsigned int) owner); \
54 } while(0)
55
56 #define IOTimeStampLatency() \
57 do { \
58 IOTimeStampEnd(IODBG_INTES(IOINTES_LAT), \
59 (unsigned int) this, (unsigned int) owner); \
60 } while(0)
61
62 #else /* !KDEBUG */
63 #define IOTimeTypeStampS(t)
64 #define IOTimeTypeStampE(t)
65 #define IOTimeStampLatency()
66 #endif /* KDEBUG */
67
68 #define super IOInterruptEventSource
69
70 OSDefineMetaClassAndStructors
71 (IOFilterInterruptEventSource, IOInterruptEventSource)
72 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 0);
73 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 1);
74 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 2);
75 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 3);
76 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 4);
77 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 5);
78 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 6);
79 OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 7);
80
81 /*
82 * Implement the call throughs for the private protection conversion
83 */
84 bool IOFilterInterruptEventSource::init(OSObject *inOwner,
85 Action inAction,
86 IOService *inProvider,
87 int inIntIndex)
88 {
89 return false;
90 }
91
92 IOInterruptEventSource *
93 IOFilterInterruptEventSource::interruptEventSource(OSObject *inOwner,
94 Action inAction,
95 IOService *inProvider,
96 int inIntIndex)
97 {
98 return 0;
99 }
100
101 bool
102 IOFilterInterruptEventSource::init(OSObject *inOwner,
103 Action inAction,
104 Filter inFilterAction,
105 IOService *inProvider,
106 int inIntIndex)
107 {
108 if ( !super::init(inOwner, inAction, inProvider, inIntIndex) )
109 return false;
110
111 if (!inFilterAction)
112 return false;
113
114 filterAction = inFilterAction;
115 return true;
116 }
117
118 IOFilterInterruptEventSource *IOFilterInterruptEventSource
119 ::filterInterruptEventSource(OSObject *inOwner,
120 Action inAction,
121 Filter inFilterAction,
122 IOService *inProvider,
123 int inIntIndex)
124 {
125 IOFilterInterruptEventSource *me = new IOFilterInterruptEventSource;
126
127 if (me
128 && !me->init(inOwner, inAction, inFilterAction, inProvider, inIntIndex)) {
129 me->release();
130 return 0;
131 }
132
133 return me;
134 }
135
136 void IOFilterInterruptEventSource::signalInterrupt()
137 {
138 IOTimeStampLatency();
139
140 producerCount++;
141
142 IOTimeTypeStampS(IOINTES_SEMA);
143 signalWorkAvailable();
144 IOTimeTypeStampE(IOINTES_SEMA);
145 }
146
147
148 IOFilterInterruptEventSource::Filter
149 IOFilterInterruptEventSource::getFilterAction() const
150 {
151 return filterAction;
152 }
153
154
155
156
157 void IOFilterInterruptEventSource::normalInterruptOccurred
158 (void */*refcon*/, IOService */*prov*/, int /*source*/)
159 {
160 bool filterRes;
161
162 IOTimeTypeStampS(IOINTES_INTCTXT);
163
164 IOTimeTypeStampS(IOINTES_INTFLTR);
165 IOTimeStampConstant(IODBG_INTES(IOINTES_FILTER),
166 (unsigned int) filterAction, (unsigned int) owner);
167 filterRes = (*filterAction)(owner, this);
168 IOTimeTypeStampE(IOINTES_INTFLTR);
169
170 if (filterRes)
171 signalInterrupt();
172
173 IOTimeTypeStampE(IOINTES_INTCTXT);
174 }
175
176 void IOFilterInterruptEventSource::disableInterruptOccurred
177 (void */*refcon*/, IOService *prov, int source)
178 {
179 bool filterRes;
180
181 IOTimeTypeStampS(IOINTES_INTCTXT);
182
183 IOTimeTypeStampS(IOINTES_INTFLTR);
184 IOTimeStampConstant(IODBG_INTES(IOINTES_FILTER),
185 (unsigned int) filterAction, (unsigned int) owner);
186 filterRes = (*filterAction)(owner, this);
187 IOTimeTypeStampE(IOINTES_INTFLTR);
188
189 if (filterRes) {
190 prov->disableInterrupt(source); /* disable the interrupt */
191
192 signalInterrupt();
193 }
194 IOTimeTypeStampE(IOINTES_INTCTXT);
195 }