]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOFilterInterruptEventSource.h
xnu-792.10.96.tar.gz
[apple/xnu.git] / iokit / IOKit / IOFilterInterruptEventSource.h
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 /*
23 Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
24
25 HISTORY
26 1999-4-15 Godfrey van der Linden(gvdl)
27 Created.
28 */
29 #ifndef _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H
30 #define _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H
31
32 #include <IOKit/IOInterruptEventSource.h>
33
34 class IOService;
35
36 /*! @class IOFilterInterruptEventSource : public IOInterruptEventSource
37 @abstract Filtering varient of the $link IOInterruptEventSource.
38 @discussion An interrupt event source that calls the client to determine if a interrupt event needs to be scheduled on the work loop. A filter interrupt event source call's the client in the primary interrupt context, the client can then interrogate its hardware and determine if the interrupt needs to be processed yet.
39 <br><br>
40 As the routine is called in the primary interrupt context great care must be taken in the writing of this routine. In general none of the generic IOKit environment is safe to call in this context. We intend this routine to be used by hardware that can interrogate its registers without destroying state. Primarily this variant of event sources will be used by drivers that share interrupts. The filter routine will determine if the interrupt is a real interrupt or a ghost and thus optimise the work thread context switch away.
41 <br><br>
42 If you are implementing 'SoftDMA' (or pseudo-DMA), you may not want the I/O Kit to automatically start your interrupt handler routine on your work loop when your filter routine returns true. In this case, you may choose to have your filter routine schedule the work on the work loop itself and then return false. If you do this, the interrupt will not be disabled in hardware and you could receive additional primary interrupts before your work loop–level service routine completes. Because this scheme has implications for synchronization between your filter routine and your interrupt service routine, you should avoid doing this unless your driver requires SoftDMA.
43 <br><br>
44 CAUTION: Called in primary interrupt context, if you need to disable interrupt to guard you registers against an unexpected call then it is better to use a straight IOInterruptEventSource and its secondary interrupt delivery mechanism.
45 */
46 class IOFilterInterruptEventSource : public IOInterruptEventSource
47 {
48 OSDeclareDefaultStructors(IOFilterInterruptEventSource)
49
50 public:
51 /*!
52 @typedef Filter
53 @discussion C Function pointer to a routine to call when an interrupt occurs.
54 @param owner Pointer to the owning/client instance.
55 @param sender Where is the interrupt comming from.
56 @result false if this interrupt can be ignored. */
57 typedef bool (*Filter)(OSObject *, IOFilterInterruptEventSource *);
58
59 /*! @defined IOFilterInterruptAction
60 @discussion Backward compatibilty define for the old non-class scoped type definition. See $link IOFilterInterruptSource::Filter */
61 #define IOFilterInterruptAction IOFilterInterruptEventSource::Filter
62
63 private:
64 // Hide the superclass initializers
65 virtual bool init(OSObject *inOwner,
66 IOInterruptEventSource::Action inAction = 0,
67 IOService *inProvider = 0,
68 int inIntIndex = 0);
69
70 static IOInterruptEventSource *
71 interruptEventSource(OSObject *inOwner,
72 IOInterruptEventSource::Action inAction = 0,
73 IOService *inProvider = 0,
74 int inIntIndex = 0);
75
76 protected:
77 /*! @var filterAction Filter callout */
78 Filter filterAction;
79
80 /*! @struct ExpansionData
81 @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
82 */
83 struct ExpansionData { };
84
85 /*! @var reserved
86 Reserved for future use. (Internal use only) */
87 ExpansionData *reserved;
88
89 public:
90 /*! @function filterInterruptEventSource
91 @abstract Factor method to create and initialise an IOFilterInterruptEventSource. See $link init.
92 @param owner Owner/client of this event source.
93 @param action 'C' Function to call when something happens.
94 @param filter 'C' Function to call when interrupt occurs.
95 @param provider Service that provides interrupts.
96 @param intIndex Defaults to 0.
97 @result a new event source if succesful, 0 otherwise. */
98 static IOFilterInterruptEventSource *
99 filterInterruptEventSource(OSObject *owner,
100 IOInterruptEventSource::Action action,
101 Filter filter,
102 IOService *provider,
103 int intIndex = 0);
104
105 /*! @function init
106 @abstract Primary initialiser for the IOFilterInterruptEventSource class.
107 @param owner Owner/client of this event source.
108 @param action 'C' Function to call when something happens.
109 @param filter 'C' Function to call in primary interrupt context.
110 @param provider Service that provides interrupts.
111 @param intIndex Interrupt source within provider. Defaults to 0.
112 @result true if the inherited classes and this instance initialise
113 successfully. */
114 virtual bool init(OSObject *owner,
115 IOInterruptEventSource::Action action,
116 Filter filter,
117 IOService *provider,
118 int intIndex = 0);
119
120
121 /*! @function signalInterrupt
122 @abstract Cause the work loop to schedule the action.
123 @discussion Cause the work loop to schedule the interrupt action even if the filter routine returns 'false'. Note well the interrupting condition MUST be cleared from the hardware otherwise an infinite process interrupt loop will occur. Use this function when SoftDMA is desired. See $link IOFilterInterruptSource::Filter */
124 virtual void signalInterrupt();
125
126 /*! @function getFilterAction
127 @abstract Get'ter for filterAction variable.
128 @result value of filterAction. */
129 virtual Filter getFilterAction() const;
130
131 /*! @function normalInterruptOccurred
132 @abstract Override $link IOInterruptEventSource::normalInterruptOccured to make a filter callout. */
133 virtual void normalInterruptOccurred(void *self, IOService *prov, int ind);
134
135 /*! @function disableInterruptOccurred
136 @abstract Override $link IOInterruptEventSource::disableInterruptOccurred to make a filter callout. */
137 virtual void disableInterruptOccurred(void *self, IOService *prov, int ind);
138
139 private:
140 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 0);
141 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 1);
142 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 2);
143 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 3);
144 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 4);
145 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 5);
146 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 6);
147 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 7);
148 };
149
150 #endif /* !_IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H */