xref: /xnu-8020.140.41/iokit/IOKit/IOInterruptController.h (revision 27b03b360a988dfd3dfdf34262bb0042026747cc)
1*27b03b36SApple OSS Distributions /*
2*27b03b36SApple OSS Distributions  * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3*27b03b36SApple OSS Distributions  *
4*27b03b36SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*27b03b36SApple OSS Distributions  *
6*27b03b36SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*27b03b36SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*27b03b36SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*27b03b36SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*27b03b36SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*27b03b36SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*27b03b36SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*27b03b36SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*27b03b36SApple OSS Distributions  *
15*27b03b36SApple OSS Distributions  * Please obtain a copy of the License at
16*27b03b36SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*27b03b36SApple OSS Distributions  *
18*27b03b36SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*27b03b36SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*27b03b36SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*27b03b36SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*27b03b36SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*27b03b36SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*27b03b36SApple OSS Distributions  * limitations under the License.
25*27b03b36SApple OSS Distributions  *
26*27b03b36SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*27b03b36SApple OSS Distributions  */
28*27b03b36SApple OSS Distributions /*
29*27b03b36SApple OSS Distributions  * Copyright (c) 1999 Apple Computer, Inc.  All rights reserved.
30*27b03b36SApple OSS Distributions  *
31*27b03b36SApple OSS Distributions  *  DRI: Josh de Cesare
32*27b03b36SApple OSS Distributions  *
33*27b03b36SApple OSS Distributions  */
34*27b03b36SApple OSS Distributions 
35*27b03b36SApple OSS Distributions 
36*27b03b36SApple OSS Distributions #ifndef _IOKIT_IOINTERRUPTCONTROLLER_H
37*27b03b36SApple OSS Distributions #define _IOKIT_IOINTERRUPTCONTROLLER_H
38*27b03b36SApple OSS Distributions 
39*27b03b36SApple OSS Distributions #include <IOKit/IOLocks.h>
40*27b03b36SApple OSS Distributions #include <IOKit/IOService.h>
41*27b03b36SApple OSS Distributions #include <IOKit/IOInterrupts.h>
42*27b03b36SApple OSS Distributions 
43*27b03b36SApple OSS Distributions 
44*27b03b36SApple OSS Distributions class IOSharedInterruptController;
45*27b03b36SApple OSS Distributions 
46*27b03b36SApple OSS Distributions struct IOInterruptVector {
47*27b03b36SApple OSS Distributions 	volatile char               interruptActive;
48*27b03b36SApple OSS Distributions 	volatile char               interruptDisabledSoft;
49*27b03b36SApple OSS Distributions 	volatile char               interruptDisabledHard;
50*27b03b36SApple OSS Distributions 	volatile char               interruptRegistered;
51*27b03b36SApple OSS Distributions 	IOLock *                    interruptLock;
52*27b03b36SApple OSS Distributions 	IOService *                 nub;
53*27b03b36SApple OSS Distributions 	int                         source;
54*27b03b36SApple OSS Distributions 	void *                      target;
55*27b03b36SApple OSS Distributions 	IOInterruptHandler          handler;
56*27b03b36SApple OSS Distributions 	void *                      refCon;
57*27b03b36SApple OSS Distributions 	IOSharedInterruptController *sharedController;
58*27b03b36SApple OSS Distributions };
59*27b03b36SApple OSS Distributions 
60*27b03b36SApple OSS Distributions typedef struct IOInterruptVector IOInterruptVector;
61*27b03b36SApple OSS Distributions 
62*27b03b36SApple OSS Distributions #if __LP64__
63*27b03b36SApple OSS Distributions typedef int32_t IOInterruptVectorNumber;
64*27b03b36SApple OSS Distributions #else
65*27b03b36SApple OSS Distributions typedef long IOInterruptVectorNumber;
66*27b03b36SApple OSS Distributions #endif
67*27b03b36SApple OSS Distributions 
68*27b03b36SApple OSS Distributions class IOInterruptController : public IOService
69*27b03b36SApple OSS Distributions {
70*27b03b36SApple OSS Distributions 	OSDeclareAbstractStructors(IOInterruptController);
71*27b03b36SApple OSS Distributions 
72*27b03b36SApple OSS Distributions protected:
73*27b03b36SApple OSS Distributions 	IOInterruptVector *vectors;
74*27b03b36SApple OSS Distributions 	IOSimpleLock      *controllerLock;
75*27b03b36SApple OSS Distributions 
76*27b03b36SApple OSS Distributions 	struct ExpansionData { };
77*27b03b36SApple OSS Distributions 	ExpansionData *ioic_reserved;
78*27b03b36SApple OSS Distributions 
79*27b03b36SApple OSS Distributions public:
80*27b03b36SApple OSS Distributions 	virtual IOReturn registerInterrupt(IOService *nub, int source,
81*27b03b36SApple OSS Distributions 	    void *target,
82*27b03b36SApple OSS Distributions 	    IOInterruptHandler handler,
83*27b03b36SApple OSS Distributions 	    void *refCon);
84*27b03b36SApple OSS Distributions 	virtual IOReturn unregisterInterrupt(IOService *nub, int source);
85*27b03b36SApple OSS Distributions 
86*27b03b36SApple OSS Distributions 	virtual IOReturn getInterruptType(IOService *nub, int source,
87*27b03b36SApple OSS Distributions 	    int *interruptType);
88*27b03b36SApple OSS Distributions 
89*27b03b36SApple OSS Distributions 	virtual IOReturn enableInterrupt(IOService *nub, int source);
90*27b03b36SApple OSS Distributions 	virtual IOReturn disableInterrupt(IOService *nub, int source);
91*27b03b36SApple OSS Distributions 	virtual IOReturn causeInterrupt(IOService *nub, int source);
92*27b03b36SApple OSS Distributions 
93*27b03b36SApple OSS Distributions 	virtual IOInterruptAction getInterruptHandlerAddress(void);
94*27b03b36SApple OSS Distributions 	virtual IOReturn handleInterrupt(void *refCon, IOService *nub,
95*27b03b36SApple OSS Distributions 	    int source);
96*27b03b36SApple OSS Distributions 
97*27b03b36SApple OSS Distributions // Methods to be overridden for simplifed interrupt controller subclasses.
98*27b03b36SApple OSS Distributions 
99*27b03b36SApple OSS Distributions 	virtual bool vectorCanBeShared(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
100*27b03b36SApple OSS Distributions 	virtual void initVector(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
101*27b03b36SApple OSS Distributions 	virtual int  getVectorType(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
102*27b03b36SApple OSS Distributions 	virtual void disableVectorHard(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
103*27b03b36SApple OSS Distributions 	virtual void enableVector(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
104*27b03b36SApple OSS Distributions 	virtual void causeVector(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
105*27b03b36SApple OSS Distributions 	virtual void setCPUInterruptProperties(IOService *service);
106*27b03b36SApple OSS Distributions 
107*27b03b36SApple OSS Distributions 	virtual void sendIPI(unsigned int cpu_id, bool deferred);
108*27b03b36SApple OSS Distributions 	virtual void cancelDeferredIPI(unsigned int cpu_id);
109*27b03b36SApple OSS Distributions 
110*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUsedX86(IOInterruptController, 0);
111*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUsedX86(IOInterruptController, 1);
112*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUsedX86(IOInterruptController, 2);
113*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUnused(IOInterruptController, 3);
114*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUnused(IOInterruptController, 4);
115*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUnused(IOInterruptController, 5);
116*27b03b36SApple OSS Distributions 
117*27b03b36SApple OSS Distributions public:
118*27b03b36SApple OSS Distributions // Generic methods (not to be overriden).
119*27b03b36SApple OSS Distributions 
120*27b03b36SApple OSS Distributions 	void timeStampSpuriousInterrupt(void);
121*27b03b36SApple OSS Distributions 	void timeStampInterruptHandlerStart(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
122*27b03b36SApple OSS Distributions 	void timeStampInterruptHandlerEnd(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
123*27b03b36SApple OSS Distributions 
124*27b03b36SApple OSS Distributions private:
125*27b03b36SApple OSS Distributions 	void timeStampInterruptHandlerInternal(bool isStart, IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
126*27b03b36SApple OSS Distributions };
127*27b03b36SApple OSS Distributions 
128*27b03b36SApple OSS Distributions 
129*27b03b36SApple OSS Distributions class IOSharedInterruptController : public IOInterruptController
130*27b03b36SApple OSS Distributions {
131*27b03b36SApple OSS Distributions 	OSDeclareDefaultStructors(IOSharedInterruptController);
132*27b03b36SApple OSS Distributions 
133*27b03b36SApple OSS Distributions private:
134*27b03b36SApple OSS Distributions 	IOService         *provider;
135*27b03b36SApple OSS Distributions 	int               numVectors;
136*27b03b36SApple OSS Distributions 	int               vectorsRegistered;
137*27b03b36SApple OSS Distributions 	int               vectorsEnabled;
138*27b03b36SApple OSS Distributions 	volatile int      controllerDisabled;
139*27b03b36SApple OSS Distributions 	bool              sourceIsLevel;
140*27b03b36SApple OSS Distributions 
141*27b03b36SApple OSS Distributions 	struct ExpansionData { };
142*27b03b36SApple OSS Distributions 	ExpansionData *iosic_reserved __unused;
143*27b03b36SApple OSS Distributions 
144*27b03b36SApple OSS Distributions public:
145*27b03b36SApple OSS Distributions 	virtual IOReturn initInterruptController(IOInterruptController *parentController, OSData *parentSource);
146*27b03b36SApple OSS Distributions 
147*27b03b36SApple OSS Distributions 	virtual IOReturn registerInterrupt(IOService *nub, int source,
148*27b03b36SApple OSS Distributions 	    void *target,
149*27b03b36SApple OSS Distributions 	    IOInterruptHandler handler,
150*27b03b36SApple OSS Distributions 	    void *refCon) APPLE_KEXT_OVERRIDE;
151*27b03b36SApple OSS Distributions 	virtual IOReturn unregisterInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
152*27b03b36SApple OSS Distributions 
153*27b03b36SApple OSS Distributions 	virtual IOReturn getInterruptType(IOService *nub, int source,
154*27b03b36SApple OSS Distributions 	    int *interruptType) APPLE_KEXT_OVERRIDE;
155*27b03b36SApple OSS Distributions 
156*27b03b36SApple OSS Distributions 	virtual IOReturn enableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
157*27b03b36SApple OSS Distributions 	virtual IOReturn disableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
158*27b03b36SApple OSS Distributions 
159*27b03b36SApple OSS Distributions 	virtual IOInterruptAction getInterruptHandlerAddress(void) APPLE_KEXT_OVERRIDE;
160*27b03b36SApple OSS Distributions 	virtual IOReturn handleInterrupt(void *refCon, IOService *nub, int source) APPLE_KEXT_OVERRIDE;
161*27b03b36SApple OSS Distributions 
162*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 0);
163*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 1);
164*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 2);
165*27b03b36SApple OSS Distributions 	OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 3);
166*27b03b36SApple OSS Distributions };
167*27b03b36SApple OSS Distributions 
168*27b03b36SApple OSS Distributions 
169*27b03b36SApple OSS Distributions #endif /* ! _IOKIT_IOINTERRUPTCONTROLLER_H */
170