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