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