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