]>
Commit | Line | Data |
---|---|---|
cb323159 A |
1 | /* |
2 | * Copyright (c) 1998-2012 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 | #ifndef __IOKIT_IOTYPES_H | |
29 | #define __IOKIT_IOTYPES_H | |
30 | ||
31 | #ifndef PLATFORM_DriverKit | |
32 | ||
33 | #ifndef IOKIT | |
34 | #define IOKIT 1 | |
35 | #endif /* !IOKIT */ | |
36 | ||
37 | #if KERNEL | |
38 | #include <IOKit/system.h> | |
39 | #else | |
40 | #include <mach/message.h> | |
41 | #include <mach/vm_types.h> | |
42 | #endif | |
43 | ||
44 | #include <IOKit/IOReturn.h> | |
45 | ||
46 | #ifdef __cplusplus | |
47 | extern "C" { | |
48 | #endif | |
49 | ||
50 | #ifndef NULL | |
51 | #if defined (__cplusplus) | |
52 | #ifdef XNU_KERNEL_PRIVATE | |
53 | #define NULL nullptr | |
54 | #else | |
55 | #if __cplusplus >= 201103L && (defined(__arm__) || defined(__arm64__)) | |
56 | #define NULL nullptr | |
57 | #else | |
58 | #define NULL 0 | |
59 | #endif | |
60 | #endif | |
61 | #else | |
62 | #define NULL ((void *)0) | |
63 | #endif | |
64 | #endif | |
65 | ||
66 | /* | |
67 | * Simple data types. | |
68 | */ | |
69 | #include <stdbool.h> | |
70 | #include <libkern/OSTypes.h> | |
71 | ||
72 | #if KERNEL | |
73 | #include <libkern/OSBase.h> | |
74 | #endif | |
75 | ||
76 | typedef UInt32 IOOptionBits; | |
77 | typedef SInt32 IOFixed; | |
78 | typedef UInt32 IOVersion; | |
79 | typedef UInt32 IOItemCount; | |
80 | typedef UInt32 IOCacheMode; | |
81 | ||
82 | typedef UInt32 IOByteCount32; | |
83 | typedef UInt64 IOByteCount64; | |
84 | ||
85 | typedef UInt32 IOPhysicalAddress32; | |
86 | typedef UInt64 IOPhysicalAddress64; | |
87 | typedef UInt32 IOPhysicalLength32; | |
88 | typedef UInt64 IOPhysicalLength64; | |
89 | ||
90 | #if !defined(__arm__) && !defined(__i386__) | |
91 | typedef mach_vm_address_t IOVirtualAddress; | |
92 | #else | |
93 | typedef vm_address_t IOVirtualAddress; | |
94 | #endif | |
95 | ||
96 | #if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL)) && !(defined(__arm64__) && !defined(__LP64__)) | |
97 | typedef IOByteCount64 IOByteCount; | |
f427ee49 | 98 | #define PRIIOByteCount PRIu64 |
cb323159 A |
99 | #else |
100 | typedef IOByteCount32 IOByteCount; | |
f427ee49 | 101 | #define PRIIOByteCount PRIu32 |
cb323159 A |
102 | #endif |
103 | ||
104 | typedef IOVirtualAddress IOLogicalAddress; | |
105 | ||
106 | #if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL)) | |
107 | ||
108 | typedef IOPhysicalAddress64 IOPhysicalAddress; | |
109 | typedef IOPhysicalLength64 IOPhysicalLength; | |
110 | #define IOPhysical32( hi, lo ) ((UInt64) lo + ((UInt64)(hi) << 32)) | |
111 | #define IOPhysSize 64 | |
112 | ||
113 | #else | |
114 | ||
115 | typedef IOPhysicalAddress32 IOPhysicalAddress; | |
116 | typedef IOPhysicalLength32 IOPhysicalLength; | |
117 | #define IOPhysical32( hi, lo ) (lo) | |
118 | #define IOPhysSize 32 | |
119 | ||
120 | #endif | |
121 | ||
122 | ||
123 | typedef struct{ | |
124 | IOPhysicalAddress address; | |
125 | IOByteCount length; | |
126 | } IOPhysicalRange; | |
127 | ||
128 | typedef struct{ | |
129 | IOVirtualAddress address; | |
130 | IOByteCount length; | |
131 | } IOVirtualRange; | |
132 | ||
133 | #if !defined(__arm__) && !defined(__i386__) | |
134 | typedef IOVirtualRange IOAddressRange; | |
135 | #else | |
136 | typedef struct{ | |
137 | mach_vm_address_t address; | |
138 | mach_vm_size_t length; | |
139 | } IOAddressRange; | |
140 | #endif | |
141 | ||
142 | /* | |
143 | * Map between #defined or enum'd constants and text description. | |
144 | */ | |
145 | typedef struct { | |
146 | int value; | |
147 | const char *name; | |
148 | } IONamedValue; | |
149 | ||
150 | ||
151 | /* | |
152 | * Memory alignment -- specified as a power of two. | |
153 | */ | |
154 | typedef unsigned int IOAlignment; | |
155 | ||
156 | #define IO_NULL_VM_TASK ((vm_task_t)0) | |
157 | ||
158 | ||
159 | /* | |
160 | * Pull in machine specific stuff. | |
161 | */ | |
162 | ||
163 | //#include <IOKit/machine/IOTypes.h> | |
164 | ||
165 | #ifndef MACH_KERNEL | |
166 | ||
167 | #ifndef __IOKIT_PORTS_DEFINED__ | |
168 | #define __IOKIT_PORTS_DEFINED__ | |
169 | #ifdef KERNEL | |
170 | #ifdef __cplusplus | |
171 | class OSObject; | |
172 | typedef OSObject * io_object_t; | |
173 | #else | |
174 | typedef struct OSObject * io_object_t; | |
175 | #endif | |
176 | #else /* KERNEL */ | |
177 | typedef mach_port_t io_object_t; | |
178 | #endif /* KERNEL */ | |
179 | #endif /* __IOKIT_PORTS_DEFINED__ */ | |
180 | ||
181 | #include <device/device_types.h> | |
182 | ||
183 | typedef io_object_t io_connect_t; | |
184 | typedef io_object_t io_enumerator_t; | |
185 | typedef io_object_t io_iterator_t; | |
186 | typedef io_object_t io_registry_entry_t; | |
187 | typedef io_object_t io_service_t; | |
188 | typedef io_object_t uext_object_t; | |
189 | ||
190 | #define IO_OBJECT_NULL ((io_object_t) 0) | |
191 | ||
192 | #endif /* MACH_KERNEL */ | |
193 | ||
194 | // IOConnectMapMemory memoryTypes | |
195 | enum { | |
196 | kIODefaultMemoryType = 0 | |
197 | }; | |
198 | ||
199 | enum { | |
200 | kIODefaultCache = 0, | |
201 | kIOInhibitCache = 1, | |
202 | kIOWriteThruCache = 2, | |
203 | kIOCopybackCache = 3, | |
204 | kIOWriteCombineCache = 4, | |
205 | kIOCopybackInnerCache = 5, | |
206 | kIOPostedWrite = 6, | |
207 | kIORealTimeCache = 7, | |
208 | kIOPostedReordered = 8, | |
f427ee49 | 209 | kIOPostedCombinedReordered = 9, |
cb323159 A |
210 | }; |
211 | ||
212 | // IOMemory mapping options | |
213 | enum { | |
f427ee49 A |
214 | kIOMapAnywhere = 0x00000001, |
215 | ||
216 | kIOMapCacheMask = 0x00000f00, | |
217 | kIOMapCacheShift = 8, | |
218 | kIOMapDefaultCache = kIODefaultCache << kIOMapCacheShift, | |
219 | kIOMapInhibitCache = kIOInhibitCache << kIOMapCacheShift, | |
220 | kIOMapWriteThruCache = kIOWriteThruCache << kIOMapCacheShift, | |
221 | kIOMapCopybackCache = kIOCopybackCache << kIOMapCacheShift, | |
222 | kIOMapWriteCombineCache = kIOWriteCombineCache << kIOMapCacheShift, | |
223 | kIOMapCopybackInnerCache = kIOCopybackInnerCache << kIOMapCacheShift, | |
224 | kIOMapPostedWrite = kIOPostedWrite << kIOMapCacheShift, | |
225 | kIOMapRealTimeCache = kIORealTimeCache << kIOMapCacheShift, | |
226 | kIOMapPostedReordered = kIOPostedReordered << kIOMapCacheShift, | |
227 | kIOMapPostedCombinedReordered = kIOPostedCombinedReordered << kIOMapCacheShift, | |
228 | ||
229 | kIOMapUserOptionsMask = 0x00000fff, | |
230 | ||
231 | kIOMapReadOnly = 0x00001000, | |
232 | ||
233 | kIOMapStatic = 0x01000000, | |
234 | kIOMapReference = 0x02000000, | |
235 | kIOMapUnique = 0x04000000, | |
cb323159 | 236 | #ifdef XNU_KERNEL_PRIVATE |
f427ee49 | 237 | kIOMap64Bit = 0x08000000, |
cb323159 | 238 | #endif |
f427ee49 A |
239 | kIOMapPrefault = 0x10000000, |
240 | kIOMapOverwrite = 0x20000000 | |
cb323159 A |
241 | }; |
242 | ||
243 | /*! @enum Scale Factors | |
244 | * @discussion Used when a scale_factor parameter is required to define a unit of time. | |
245 | * @constant kNanosecondScale Scale factor for nanosecond based times. | |
246 | * @constant kMicrosecondScale Scale factor for microsecond based times. | |
247 | * @constant kMillisecondScale Scale factor for millisecond based times. | |
248 | * @constant kTickScale Scale factor for the standard (100Hz) tick. | |
249 | * @constant kSecondScale Scale factor for second based times. */ | |
250 | ||
251 | enum { | |
252 | kNanosecondScale = 1, | |
253 | kMicrosecondScale = 1000, | |
254 | kMillisecondScale = 1000 * 1000, | |
255 | kSecondScale = 1000 * 1000 * 1000, | |
256 | kTickScale = (kSecondScale / 100) | |
257 | }; | |
258 | ||
259 | enum { | |
260 | kIOConnectMethodVarOutputSize = -3 | |
261 | }; | |
262 | ||
263 | /* compatibility types */ | |
264 | ||
265 | #ifndef KERNEL | |
266 | ||
267 | typedef unsigned int IODeviceNumber; | |
268 | ||
269 | #endif | |
270 | ||
271 | #ifdef __cplusplus | |
272 | } | |
273 | #endif | |
274 | ||
275 | #else /* !PLATFORM_DriverKit */ | |
276 | ||
277 | #include <stdint.h> | |
278 | ||
279 | typedef uint32_t IOOptionBits; | |
280 | typedef int32_t IOFixed; | |
281 | typedef uint32_t IOVersion; | |
282 | typedef uint32_t IOItemCount; | |
283 | typedef uint32_t IOCacheMode; | |
284 | ||
285 | typedef uint32_t IOByteCount32; | |
286 | typedef uint64_t IOByteCount64; | |
287 | typedef IOByteCount64 IOByteCount; | |
288 | ||
289 | typedef uint32_t IOPhysicalAddress32; | |
290 | typedef uint64_t IOPhysicalAddress64; | |
291 | typedef uint32_t IOPhysicalLength32; | |
292 | typedef uint64_t IOPhysicalLength64; | |
293 | ||
294 | typedef IOPhysicalAddress64 IOPhysicalAddress; | |
295 | typedef IOPhysicalLength64 IOPhysicalLength; | |
296 | ||
297 | typedef uint64_t IOVirtualAddress; | |
298 | ||
299 | #endif /* PLATFORM_DriverKit */ | |
300 | ||
f427ee49 A |
301 | enum { |
302 | kIOMaxBusStall40usec = 40000, | |
303 | kIOMaxBusStall30usec = 30000, | |
304 | kIOMaxBusStall25usec = 25000, | |
305 | kIOMaxBusStall20usec = 20000, | |
306 | kIOMaxBusStall10usec = 10000, | |
307 | kIOMaxBusStall5usec = 5000, | |
308 | kIOMaxBusStallNone = 0, | |
309 | }; | |
310 | ||
cb323159 | 311 | #endif /* ! __IOKIT_IOTYPES_H */ |