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