]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IOFilterInterruptEventSource.h
xnu-517.12.7.tar.gz
[apple/xnu.git] / iokit / IOKit / IOFilterInterruptEventSource.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
e5568f75
A
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.
1c79356b 11 *
e5568f75
A
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
e5568f75
A
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.
1c79356b
A
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#ifndef _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H
30#define _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H
31
32#include <IOKit/IOInterruptEventSource.h>
33
34class 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 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.
43*/
44class IOFilterInterruptEventSource : public IOInterruptEventSource
45{
46 OSDeclareDefaultStructors(IOFilterInterruptEventSource)
47
48public:
49/*!
50 @typedef Filter
51 @discussion C Function pointer to a routine to call when an interrupt occurs.
52 @param owner Pointer to the owning/client instance.
53 @param sender Where is the interrupt comming from.
54 @result false if this interrupt can be ignored. */
55 typedef bool (*Filter)(OSObject *, IOFilterInterruptEventSource *);
56
57/*! @defined IOFilterInterruptAction
58 @discussion Backward compatibilty define for the old non-class scoped type definition. See $link IOFilterInterruptSource::Filter */
59#define IOFilterInterruptAction IOFilterInterruptEventSource::Filter
60
61private:
62 // Hide the superclass initializers
63 virtual bool init(OSObject *inOwner,
64 IOInterruptEventSource::Action inAction = 0,
65 IOService *inProvider = 0,
66 int inIntIndex = 0);
67
68 static IOInterruptEventSource *
69 interruptEventSource(OSObject *inOwner,
70 IOInterruptEventSource::Action inAction = 0,
71 IOService *inProvider = 0,
72 int inIntIndex = 0);
73
74protected:
75/*! @var filterAction Filter callout */
76 Filter filterAction;
77
78/*! @struct ExpansionData
79 @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
80 */
81 struct ExpansionData { };
82
83/*! @var reserved
84 Reserved for future use. (Internal use only) */
85 ExpansionData *reserved;
86
87public:
88/*! @function filterInterruptEventSource
89 @abstract Factor method to create and initialise an IOFilterInterruptEventSource. See $link init.
90 @param owner Owner/client of this event source.
91 @param action 'C' Function to call when something happens.
92 @param filter 'C' Function to call when interrupt occurs.
93 @param provider Service that provides interrupts.
94 @param intIndex Defaults to 0.
95 @result a new event source if succesful, 0 otherwise. */
96 static IOFilterInterruptEventSource *
97 filterInterruptEventSource(OSObject *owner,
98 IOInterruptEventSource::Action action,
99 Filter filter,
100 IOService *provider,
101 int intIndex = 0);
102
103/*! @function init
104 @abstract Primary initialiser for the IOFilterInterruptEventSource class.
105 @param owner Owner/client of this event source.
106 @param action 'C' Function to call when something happens.
107 @param filter 'C' Function to call in primary interrupt context.
108 @param provider Service that provides interrupts.
109 @param intIndex Interrupt source within provider. Defaults to 0.
110 @result true if the inherited classes and this instance initialise
111successfully. */
112 virtual bool init(OSObject *owner,
113 IOInterruptEventSource::Action action,
114 Filter filter,
115 IOService *provider,
116 int intIndex = 0);
117
118
119/*! @function signalInterrupt
120 @abstract Cause the work loop to schedule the action.
121 @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 */
122 virtual void signalInterrupt();
123
124/*! @function getFilterAction
125 @abstract Get'ter for filterAction variable.
126 @result value of filterAction. */
127 virtual Filter getFilterAction() const;
128
129/*! @function normalInterruptOccurred
130 @abstract Override $link IOInterruptEventSource::normalInterruptOccured to make a filter callout. */
131 virtual void normalInterruptOccurred(void *self, IOService *prov, int ind);
132
133/*! @function disableInterruptOccurred
134 @abstract Override $link IOInterruptEventSource::disableInterruptOccurred to make a filter callout. */
135 virtual void disableInterruptOccurred(void *self, IOService *prov, int ind);
136
137private:
138 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 0);
139 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 1);
140 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 2);
141 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 3);
142 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 4);
143 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 5);
144 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 6);
145 OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 7);
146};
147
148#endif /* !_IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H */