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