]> git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IONDRVSupport/IONDRV.h
xnu-123.5.tar.gz
[apple/xnu.git] / iokit / Families / IONDRVSupport / IONDRV.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) 1997 Apple Computer, Inc.
24 *
25 *
26 * HISTORY
27 *
28 * sdouglas 22 Oct 97 - first checked in.
29 * sdouglas 21 July 98 - start IOKit
30 */
31
32
33 #ifndef __IONDRV__
34 #define __IONDRV__
35
36 #include <IOKit/IORegistryEntry.h>
37 #include <IOKit/IOInterruptEventSource.h>
38
39 #include <IOKit/ndrvsupport/IOMacOSTypes.h>
40 #include <IOKit/ndrvsupport/IONDRVSupport.h>
41
42 #pragma options align=mac68k
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 typedef void * RegEntryID[4];
49
50 struct DriverInitInfo {
51 UInt16 refNum;
52 RegEntryID deviceEntry;
53 };
54
55 #define MAKE_REG_ENTRY(regEntryID,obj) \
56 regEntryID[ 0 ] = (void *) obj; \
57 regEntryID[ 1 ] = (void *) ~(UInt32)obj; \
58 regEntryID[ 2 ] = (void *) 0x53696d65; \
59 regEntryID[ 3 ] = (void *) 0x52756c7a;
60
61 #define REG_ENTRY_TO_OBJ(regEntryID,obj) \
62 if( (UInt32)((obj = ((IORegistryEntry **)regEntryID)[ 0 ])) \
63 != ~((UInt32 *)regEntryID)[ 1 ] ) \
64 return( -2538);
65
66 #define REG_ENTRY_TO_OBJ_RET(regEntryID,obj,ret) \
67 if( (UInt32)((obj = ((IORegistryEntry **)regEntryID)[ 0 ])) \
68 != ~((UInt32 *)regEntryID)[ 1 ] ) \
69 return( ret);
70
71 #define REG_ENTRY_TO_PT(regEntryID,obj) \
72 IORegistryEntry * obj; \
73 if( (UInt32)((obj = ((IORegistryEntry **)regEntryID)[ 0 ])) \
74 != ~((UInt32 *)regEntryID)[ 1 ] ) \
75 return( -2538);
76
77 #define REG_ENTRY_TO_SERVICE(regEntryID,type,obj) \
78 IORegistryEntry * regEntry; \
79 type * obj; \
80 if( (UInt32)((regEntry = ((IORegistryEntry **)regEntryID)[ 0 ])) \
81 != ~((UInt32 *)regEntryID)[ 1 ] ) \
82 return( -2538); \
83 if( 0 == (obj = OSDynamicCast( type, regEntry))) \
84 return( -2542);
85
86 struct CntrlParam {
87 void * qLink;
88 short qType;
89 short ioTrap;
90 void * ioCmdAddr;
91 void * ioCompletion;
92 short ioResult;
93 char * ioNamePtr;
94 short ioVRefNum;
95 short ioCRefNum;
96 short csCode;
97 void * csParams;
98 short csParam[9];
99 };
100 typedef struct CntrlParam CntrlParam, *CntrlParamPtr;
101
102 #pragma options align=reset
103
104 enum {
105 kOpenCommand = 0,
106 kCloseCommand = 1,
107 kReadCommand = 2,
108 kWriteCommand = 3,
109 kControlCommand = 4,
110 kStatusCommand = 5,
111 kKillIOCommand = 6,
112 kInitializeCommand = 7, /* init driver and device*/
113 kFinalizeCommand = 8, /* shutdown driver and device*/
114 kReplaceCommand = 9, /* replace an old driver*/
115 kSupersededCommand = 10 /* prepare to be replaced by a new driver*/
116 };
117 enum {
118 kSynchronousIOCommandKind = 0x00000001,
119 kAsynchronousIOCommandKind = 0x00000002,
120 kImmediateIOCommandKind = 0x00000004
121 };
122
123
124 extern OSStatus CallTVector(
125 void * p1, void * p2, void * p3, void * p4, void * p5, void * p6,
126 struct IOTVector * entry );
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 class IONDRV : public OSObject
133 {
134 OSDeclareDefaultStructors(IONDRV)
135
136 private:
137 void * pcInst;
138 struct IOTVector * fDoDriverIO;
139 struct DriverDescription * theDriverDesc;
140
141 public:
142 static IONDRV * instantiate( IORegistryEntry * regEntry,
143 IOLogicalAddress container,
144 IOByteCount containerSize,
145 IONDRVUndefinedSymbolHandler handler,
146 void * self );
147
148 static IONDRV * fromRegistryEntry( IORegistryEntry * regEntry,
149 IONDRVUndefinedSymbolHandler handler,
150 void * self);
151
152 virtual void free( void );
153
154 virtual IOReturn getSymbol( const char * symbolName,
155 IOLogicalAddress * address );
156
157 virtual const char * driverName( void );
158
159 virtual IOReturn doDriverIO( UInt32 commandID, void * contents,
160 UInt32 commandCode, UInt32 commandKind );
161
162 };
163
164 struct IONDRVInterruptSource {
165 void * refCon;
166 struct IOTVector * handler;
167 struct IOTVector * enabler;
168 struct IOTVector * disabler;
169 bool registered;
170 bool enabled;
171 };
172
173 class IONDRVInterruptSet : public OSObject {
174
175 OSDeclareDefaultStructors(IONDRVInterruptSet)
176
177 public:
178 IOService * provider;
179 IOOptionBits options;
180 UInt32 count;
181 IONDRVInterruptSource * sources;
182 IONDRVInterruptSet * child;
183
184 static IONDRVInterruptSet * with(IOService * provider,
185 IOOptionBits options, SInt32 count);
186 void free();
187 };
188
189 #endif /* __IONDRV__ */
190