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