xref: /xnu-10002.81.5/iokit/IOKit/IOTypes.h (revision 5e3eaea39dcf651e66cb99ba7d70e32cc4a99587)
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 XNU_PLATFORM_DriverKit
32 
33 #ifndef IOKIT
34 #define IOKIT 1
35 #endif /* !IOKIT */
36 
37 #include <sys/cdefs.h>
38 
39 #if KERNEL
40 #include <IOKit/system.h>
41 #else
42 #include <mach/message.h>
43 #include <mach/vm_types.h>
44 #endif
45 
46 #include <IOKit/IOReturn.h>
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 #ifndef NULL
53 #if defined (__cplusplus)
54 #ifdef XNU_KERNEL_PRIVATE
55 #define NULL nullptr
56 #else
57 #if __cplusplus >= 201103L && (defined(__arm__) || defined(__arm64__))
58 #define NULL nullptr
59 #else
60 #define NULL    0
61 #endif
62 #endif
63 #else
64 #define NULL ((void *)0)
65 #endif
66 #endif
67 
68 /*
69  * Simple data types.
70  */
71 #include <stdbool.h>
72 #include <libkern/OSTypes.h>
73 
74 #if KERNEL
75 #include <libkern/OSBase.h>
76 #endif
77 
78 typedef UInt32          IOOptionBits;
79 typedef SInt32          IOFixed;
80 typedef UInt32          IOVersion;
81 typedef UInt32          IOItemCount;
82 typedef UInt32          IOCacheMode;
83 
84 typedef UInt32          IOByteCount32;
85 typedef UInt64          IOByteCount64;
86 
87 typedef UInt32  IOPhysicalAddress32;
88 typedef UInt64  IOPhysicalAddress64;
89 typedef UInt32  IOPhysicalLength32;
90 typedef UInt64  IOPhysicalLength64;
91 
92 #if !defined(__arm__) && !defined(__i386__)
93 typedef mach_vm_address_t       IOVirtualAddress __kernel_ptr_semantics;
94 #else
95 typedef vm_address_t            IOVirtualAddress __kernel_ptr_semantics;
96 #endif
97 
98 #if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL)) && !(defined(__arm64__) && !defined(__LP64__))
99 typedef IOByteCount64           IOByteCount;
100 #define PRIIOByteCount                  PRIu64
101 #else
102 typedef IOByteCount32           IOByteCount;
103 #define PRIIOByteCount                  PRIu32
104 #endif
105 
106 typedef IOVirtualAddress    IOLogicalAddress;
107 
108 #if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL))
109 
110 typedef IOPhysicalAddress64      IOPhysicalAddress;
111 typedef IOPhysicalLength64       IOPhysicalLength;
112 #define IOPhysical32( hi, lo )          ((UInt64) lo + ((UInt64)(hi) << 32))
113 #define IOPhysSize      64
114 
115 #else
116 
117 typedef IOPhysicalAddress32      IOPhysicalAddress;
118 typedef IOPhysicalLength32       IOPhysicalLength;
119 #define IOPhysical32( hi, lo )          (lo)
120 #define IOPhysSize      32
121 
122 #endif
123 
124 
125 typedef struct{
126 	IOPhysicalAddress   address;
127 	IOByteCount         length;
128 } IOPhysicalRange;
129 
130 typedef struct{
131 	IOVirtualAddress    address;
132 	IOByteCount         length;
133 } IOVirtualRange;
134 
135 #if !defined(__arm__) && !defined(__i386__)
136 typedef IOVirtualRange  IOAddressRange;
137 #else
138 typedef struct{
139 	mach_vm_address_t   address;
140 	mach_vm_size_t      length;
141 } IOAddressRange;
142 #endif
143 
144 /*
145  * Map between #defined or enum'd constants and text description.
146  */
147 typedef struct {
148 	int value;
149 	const char *name;
150 } IONamedValue;
151 
152 
153 /*
154  * Memory alignment -- specified as a power of two.
155  */
156 typedef unsigned int    IOAlignment;
157 
158 #define IO_NULL_VM_TASK         ((vm_task_t)0)
159 
160 
161 /*
162  * Pull in machine specific stuff.
163  */
164 
165 //#include <IOKit/machine/IOTypes.h>
166 
167 #ifndef MACH_KERNEL
168 
169 #ifndef __IOKIT_PORTS_DEFINED__
170 #define __IOKIT_PORTS_DEFINED__
171 #ifdef KERNEL
172 #ifdef __cplusplus
173 class OSObject;
174 typedef OSObject * io_object_t;
175 #else
176 typedef struct OSObject * io_object_t;
177 #endif
178 #else /* KERNEL */
179 typedef mach_port_t     io_object_t;
180 #endif /* KERNEL */
181 #endif /* __IOKIT_PORTS_DEFINED__ */
182 
183 #include <device/device_types.h>
184 
185 typedef io_object_t     io_connect_t;
186 typedef io_object_t     io_enumerator_t;
187 typedef io_object_t     io_ident_t;
188 typedef io_object_t     io_iterator_t;
189 typedef io_object_t     io_registry_entry_t;
190 typedef io_object_t     io_service_t;
191 typedef io_object_t     uext_object_t;
192 
193 #define IO_OBJECT_NULL  ((io_object_t) 0)
194 
195 #endif /* MACH_KERNEL */
196 
197 #include <IOKit/IOMapTypes.h>
198 
199 /*! @enum Scale Factors
200  *   @discussion Used when a scale_factor parameter is required to define a unit of time.
201  *   @constant kNanosecondScale Scale factor for nanosecond based times.
202  *   @constant kMicrosecondScale Scale factor for microsecond based times.
203  *   @constant kMillisecondScale Scale factor for millisecond based times.
204  *   @constant kTickScale Scale factor for the standard (100Hz) tick.
205  *   @constant kSecondScale Scale factor for second based times. */
206 
207 enum {
208 	kNanosecondScale  = 1,
209 	kMicrosecondScale = 1000,
210 	kMillisecondScale = 1000 * 1000,
211 	kSecondScale      = 1000 * 1000 * 1000,
212 	kTickScale        = (kSecondScale / 100)
213 };
214 
215 enum {
216 	kIOConnectMethodVarOutputSize = -3
217 };
218 
219 /* compatibility types */
220 
221 #ifndef KERNEL
222 
223 typedef unsigned int IODeviceNumber;
224 
225 #endif
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 
231 #else /* !XNU_PLATFORM_DriverKit */
232 
233 #include <stdint.h>
234 
235 typedef uint32_t          IOOptionBits;
236 typedef int32_t           IOFixed;
237 typedef uint32_t          IOVersion;
238 typedef uint32_t          IOItemCount;
239 typedef uint32_t          IOCacheMode;
240 
241 typedef uint32_t          IOByteCount32;
242 typedef uint64_t          IOByteCount64;
243 typedef IOByteCount64     IOByteCount;
244 
245 typedef uint32_t  IOPhysicalAddress32;
246 typedef uint64_t  IOPhysicalAddress64;
247 typedef uint32_t  IOPhysicalLength32;
248 typedef uint64_t  IOPhysicalLength64;
249 
250 typedef IOPhysicalAddress64      IOPhysicalAddress;
251 typedef IOPhysicalLength64       IOPhysicalLength;
252 
253 typedef uint64_t       IOVirtualAddress;
254 
255 #endif /* XNU_PLATFORM_DriverKit */
256 
257 enum {
258 	kIOMaxBusStall40usec = 40000,
259 	kIOMaxBusStall30usec = 30000,
260 	kIOMaxBusStall25usec = 25000,
261 	kIOMaxBusStall20usec = 20000,
262 	kIOMaxBusStall10usec = 10000,
263 	kIOMaxBusStall5usec  = 5000,
264 	kIOMaxBusStallNone   = 0,
265 };
266 
267 #if PRIVATE
268 #define LIBKERN_OSNUMBER_FLOAT_SUPPORT          1
269 #endif /* PRIVATE */
270 
271 #endif /* ! __IOKIT_IOTYPES_H */
272