]> git.saurik.com Git - apple/xnu.git/blame - iokit/Kernel/IOFilterInterruptEventSource.cpp
xnu-201.19.tar.gz
[apple/xnu.git] / iokit / Kernel / IOFilterInterruptEventSource.cpp
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
24
25HISTORY
26 1999-4-15 Godfrey van der Linden(gvdl)
27 Created.
28*/
29#include <IOKit/IOFilterInterruptEventSource.h>
30#include <IOKit/IOService.h>
31#include <IOKit/IOTimeStamp.h>
32#include <IOKit/IOWorkLoop.h>
33
34#if KDEBUG
35
36#define IOTimeTypeStampS(t) \
37do { \
38 IOTimeStampStart(IODBG_INTES(t), \
39 (unsigned int) this, (unsigned int) owner); \
40} while(0)
41
42#define IOTimeTypeStampE(t) \
43do { \
44 IOTimeStampEnd(IODBG_INTES(t), \
45 (unsigned int) this, (unsigned int) owner); \
46} while(0)
47
48#define IOTimeStampLatency() \
49do { \
50 IOTimeStampEnd(IODBG_INTES(IOINTES_LAT), \
51 (unsigned int) this, (unsigned int) owner); \
52} while(0)
53
54#else /* !KDEBUG */
55#define IOTimeTypeStampS(t)
56#define IOTimeTypeStampE(t)
57#define IOTimeStampLatency()
58#endif /* KDEBUG */
59
60#define super IOInterruptEventSource
61
62OSDefineMetaClassAndStructors
63 (IOFilterInterruptEventSource, IOInterruptEventSource)
64OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 0);
65OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 1);
66OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 2);
67OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 3);
68OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 4);
69OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 5);
70OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 6);
71OSMetaClassDefineReservedUnused(IOFilterInterruptEventSource, 7);
72
73/*
74 * Implement the call throughs for the private protection conversion
75 */
76bool IOFilterInterruptEventSource::init(OSObject *inOwner,
77 Action inAction = 0,
78 IOService *inProvider = 0,
79 int inIntIndex = 0)
80{
81 return false;
82}
83
84IOInterruptEventSource *
85IOFilterInterruptEventSource::interruptEventSource(OSObject *inOwner,
86 Action inAction,
87 IOService *inProvider,
88 int inIntIndex)
89{
90 return 0;
91}
92
93bool
94IOFilterInterruptEventSource::init(OSObject *inOwner,
95 Action inAction,
96 Filter inFilterAction,
97 IOService *inProvider,
98 int inIntIndex = 0)
99{
100 if ( !super::init(inOwner, inAction, inProvider, inIntIndex) )
101 return false;
102
103 if (!inFilterAction)
104 return false;
105
106 filterAction = inFilterAction;
107 return true;
108}
109
110IOFilterInterruptEventSource *IOFilterInterruptEventSource
111::filterInterruptEventSource(OSObject *inOwner,
112 Action inAction,
113 Filter inFilterAction,
114 IOService *inProvider,
115 int inIntIndex = 0)
116{
117 IOFilterInterruptEventSource *me = new IOFilterInterruptEventSource;
118
119 if (me
120 && !me->init(inOwner, inAction, inFilterAction, inProvider, inIntIndex)) {
121 me->free();
122 return 0;
123 }
124
125 return me;
126}
127
128void IOFilterInterruptEventSource::signalInterrupt()
129{
130IOTimeStampLatency();
131
132 producerCount++;
133
134IOTimeTypeStampS(IOINTES_SEMA);
135 signalWorkAvailable();
136IOTimeTypeStampE(IOINTES_SEMA);
137}
138
139
140IOFilterInterruptEventSource::Filter
141IOFilterInterruptEventSource::getFilterAction() const
142{
143 return filterAction;
144}
145
146
147
148
149void IOFilterInterruptEventSource::normalInterruptOccurred
150 (void */*refcon*/, IOService */*prov*/, int /*source*/)
151{
152 bool filterRes;
153
154IOTimeTypeStampS(IOINTES_INTCTXT);
155
156IOTimeTypeStampS(IOINTES_INTFLTR);
157 IOTimeStampConstant(IODBG_INTES(IOINTES_FILTER),
158 (unsigned int) filterAction, (unsigned int) owner);
159 filterRes = (*filterAction)(owner, this);
160IOTimeTypeStampE(IOINTES_INTFLTR);
161
162 if (filterRes)
163 signalInterrupt();
164
165IOTimeTypeStampE(IOINTES_INTCTXT);
166}
167
168void IOFilterInterruptEventSource::disableInterruptOccurred
169 (void */*refcon*/, IOService *prov, int source)
170{
171 bool filterRes;
172
173IOTimeTypeStampS(IOINTES_INTCTXT);
174
175IOTimeTypeStampS(IOINTES_INTFLTR);
176 IOTimeStampConstant(IODBG_INTES(IOINTES_FILTER),
177 (unsigned int) filterAction, (unsigned int) owner);
178 filterRes = (*filterAction)(owner, this);
179IOTimeTypeStampE(IOINTES_INTFLTR);
180
181 if (filterRes) {
182 prov->disableInterrupt(source); /* disable the interrupt */
183
184 signalInterrupt();
185 }
186IOTimeTypeStampE(IOINTES_INTCTXT);
187}