]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOInterruptController.h
xnu-792.22.5.tar.gz
[apple/xnu.git] / iokit / IOKit / IOInterruptController.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_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. 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.
14 *
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
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
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
44 class IOSharedInterruptController;
45
46 struct IOInterruptVector {
47 volatile char interruptActive;
48 volatile char interruptDisabledSoft;
49 volatile char interruptDisabledHard;
50 volatile char interruptRegistered;
51 IOLock * interruptLock;
52 IOService * nub;
53 long source;
54 void * target;
55 IOInterruptHandler handler;
56 void * refCon;
57 IOSharedInterruptController *sharedController;
58 };
59
60 typedef struct IOInterruptVector IOInterruptVector;
61
62
63 class IOInterruptController : public IOService
64 {
65 OSDeclareAbstractStructors(IOInterruptController);
66
67 protected:
68 IOInterruptVector *vectors;
69 IOSimpleLock *controllerLock;
70
71 struct ExpansionData { };
72 ExpansionData *reserved;
73
74 public:
75 virtual IOReturn registerInterrupt(IOService *nub, int source,
76 void *target,
77 IOInterruptHandler handler,
78 void *refCon);
79 virtual IOReturn unregisterInterrupt(IOService *nub, int source);
80
81 virtual IOReturn getInterruptType(IOService *nub, int source,
82 int *interruptType);
83
84 virtual IOReturn enableInterrupt(IOService *nub, int source);
85 virtual IOReturn disableInterrupt(IOService *nub, int source);
86 virtual IOReturn causeInterrupt(IOService *nub, int source);
87
88 virtual IOInterruptAction getInterruptHandlerAddress(void);
89 virtual IOReturn handleInterrupt(void *refCon, IOService *nub,
90 int source);
91
92 // Methods to be overridden for simplifed interrupt controller subclasses.
93
94 virtual bool vectorCanBeShared(long vectorNumber, IOInterruptVector *vector);
95 virtual void initVector(long vectorNumber, IOInterruptVector *vector);
96 virtual int getVectorType(long vectorNumber, IOInterruptVector *vector);
97 virtual void disableVectorHard(long vectorNumber, IOInterruptVector *vector);
98 virtual void enableVector(long vectorNumber, IOInterruptVector *vector);
99 virtual void causeVector(long vectorNumber, IOInterruptVector *vector);
100
101 OSMetaClassDeclareReservedUnused(IOInterruptController, 0);
102 OSMetaClassDeclareReservedUnused(IOInterruptController, 1);
103 OSMetaClassDeclareReservedUnused(IOInterruptController, 2);
104 OSMetaClassDeclareReservedUnused(IOInterruptController, 3);
105 OSMetaClassDeclareReservedUnused(IOInterruptController, 4);
106 OSMetaClassDeclareReservedUnused(IOInterruptController, 5);
107 };
108
109
110 class IOSharedInterruptController : public IOInterruptController
111 {
112 OSDeclareDefaultStructors(IOSharedInterruptController);
113
114 private:
115 IOService *provider;
116 int numVectors;
117 int vectorsRegistered;
118 int vectorsEnabled;
119 volatile long controllerDisabled;
120 bool sourceIsLevel;
121
122 struct ExpansionData { };
123 ExpansionData *reserved;
124
125 public:
126 virtual IOReturn initInterruptController(IOInterruptController *parentController, OSData *parentSource);
127
128 virtual IOReturn registerInterrupt(IOService *nub, int source,
129 void *target,
130 IOInterruptHandler handler,
131 void *refCon);
132 virtual IOReturn unregisterInterrupt(IOService *nub, int source);
133
134 virtual IOReturn getInterruptType(IOService *nub, int source,
135 int *interruptType);
136
137 virtual IOReturn enableInterrupt(IOService *nub, int source);
138 virtual IOReturn disableInterrupt(IOService *nub, int source);
139
140 virtual IOInterruptAction getInterruptHandlerAddress(void);
141 virtual IOReturn handleInterrupt(void *refCon, IOService *nub, int source);
142
143 OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 0);
144 OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 1);
145 OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 2);
146 OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 3);
147 };
148
149
150 #endif /* ! _IOKIT_IOINTERRUPTCONTROLLER_H */