xref: /xnu-8796.141.3/iokit/IOKit/IOTypes.h (revision 1b191cb58250d0705d8a51287127505aa4bc0789)
1*1b191cb5SApple OSS Distributions /*
2*1b191cb5SApple OSS Distributions  * Copyright (c) 1998-2012 Apple Computer, Inc. All rights reserved.
3*1b191cb5SApple OSS Distributions  *
4*1b191cb5SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*1b191cb5SApple OSS Distributions  *
6*1b191cb5SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*1b191cb5SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*1b191cb5SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*1b191cb5SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*1b191cb5SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*1b191cb5SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*1b191cb5SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*1b191cb5SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*1b191cb5SApple OSS Distributions  *
15*1b191cb5SApple OSS Distributions  * Please obtain a copy of the License at
16*1b191cb5SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*1b191cb5SApple OSS Distributions  *
18*1b191cb5SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*1b191cb5SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*1b191cb5SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*1b191cb5SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*1b191cb5SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*1b191cb5SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*1b191cb5SApple OSS Distributions  * limitations under the License.
25*1b191cb5SApple OSS Distributions  *
26*1b191cb5SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*1b191cb5SApple OSS Distributions  */
28*1b191cb5SApple OSS Distributions #ifndef __IOKIT_IOTYPES_H
29*1b191cb5SApple OSS Distributions #define __IOKIT_IOTYPES_H
30*1b191cb5SApple OSS Distributions 
31*1b191cb5SApple OSS Distributions #ifndef XNU_PLATFORM_DriverKit
32*1b191cb5SApple OSS Distributions 
33*1b191cb5SApple OSS Distributions #ifndef IOKIT
34*1b191cb5SApple OSS Distributions #define IOKIT 1
35*1b191cb5SApple OSS Distributions #endif /* !IOKIT */
36*1b191cb5SApple OSS Distributions 
37*1b191cb5SApple OSS Distributions #include <sys/cdefs.h>
38*1b191cb5SApple OSS Distributions 
39*1b191cb5SApple OSS Distributions #if KERNEL
40*1b191cb5SApple OSS Distributions #include <IOKit/system.h>
41*1b191cb5SApple OSS Distributions #else
42*1b191cb5SApple OSS Distributions #include <mach/message.h>
43*1b191cb5SApple OSS Distributions #include <mach/vm_types.h>
44*1b191cb5SApple OSS Distributions #endif
45*1b191cb5SApple OSS Distributions 
46*1b191cb5SApple OSS Distributions #include <IOKit/IOReturn.h>
47*1b191cb5SApple OSS Distributions 
48*1b191cb5SApple OSS Distributions #ifdef __cplusplus
49*1b191cb5SApple OSS Distributions extern "C" {
50*1b191cb5SApple OSS Distributions #endif
51*1b191cb5SApple OSS Distributions 
52*1b191cb5SApple OSS Distributions #ifndef NULL
53*1b191cb5SApple OSS Distributions #if defined (__cplusplus)
54*1b191cb5SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE
55*1b191cb5SApple OSS Distributions #define NULL nullptr
56*1b191cb5SApple OSS Distributions #else
57*1b191cb5SApple OSS Distributions #if __cplusplus >= 201103L && (defined(__arm__) || defined(__arm64__))
58*1b191cb5SApple OSS Distributions #define NULL nullptr
59*1b191cb5SApple OSS Distributions #else
60*1b191cb5SApple OSS Distributions #define NULL    0
61*1b191cb5SApple OSS Distributions #endif
62*1b191cb5SApple OSS Distributions #endif
63*1b191cb5SApple OSS Distributions #else
64*1b191cb5SApple OSS Distributions #define NULL ((void *)0)
65*1b191cb5SApple OSS Distributions #endif
66*1b191cb5SApple OSS Distributions #endif
67*1b191cb5SApple OSS Distributions 
68*1b191cb5SApple OSS Distributions /*
69*1b191cb5SApple OSS Distributions  * Simple data types.
70*1b191cb5SApple OSS Distributions  */
71*1b191cb5SApple OSS Distributions #include <stdbool.h>
72*1b191cb5SApple OSS Distributions #include <libkern/OSTypes.h>
73*1b191cb5SApple OSS Distributions 
74*1b191cb5SApple OSS Distributions #if KERNEL
75*1b191cb5SApple OSS Distributions #include <libkern/OSBase.h>
76*1b191cb5SApple OSS Distributions #endif
77*1b191cb5SApple OSS Distributions 
78*1b191cb5SApple OSS Distributions typedef UInt32          IOOptionBits;
79*1b191cb5SApple OSS Distributions typedef SInt32          IOFixed;
80*1b191cb5SApple OSS Distributions typedef UInt32          IOVersion;
81*1b191cb5SApple OSS Distributions typedef UInt32          IOItemCount;
82*1b191cb5SApple OSS Distributions typedef UInt32          IOCacheMode;
83*1b191cb5SApple OSS Distributions 
84*1b191cb5SApple OSS Distributions typedef UInt32          IOByteCount32;
85*1b191cb5SApple OSS Distributions typedef UInt64          IOByteCount64;
86*1b191cb5SApple OSS Distributions 
87*1b191cb5SApple OSS Distributions typedef UInt32  IOPhysicalAddress32;
88*1b191cb5SApple OSS Distributions typedef UInt64  IOPhysicalAddress64;
89*1b191cb5SApple OSS Distributions typedef UInt32  IOPhysicalLength32;
90*1b191cb5SApple OSS Distributions typedef UInt64  IOPhysicalLength64;
91*1b191cb5SApple OSS Distributions 
92*1b191cb5SApple OSS Distributions #if !defined(__arm__) && !defined(__i386__)
93*1b191cb5SApple OSS Distributions typedef mach_vm_address_t       IOVirtualAddress __kernel_ptr_semantics;
94*1b191cb5SApple OSS Distributions #else
95*1b191cb5SApple OSS Distributions typedef vm_address_t            IOVirtualAddress __kernel_ptr_semantics;
96*1b191cb5SApple OSS Distributions #endif
97*1b191cb5SApple OSS Distributions 
98*1b191cb5SApple OSS Distributions #if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL)) && !(defined(__arm64__) && !defined(__LP64__))
99*1b191cb5SApple OSS Distributions typedef IOByteCount64           IOByteCount;
100*1b191cb5SApple OSS Distributions #define PRIIOByteCount                  PRIu64
101*1b191cb5SApple OSS Distributions #else
102*1b191cb5SApple OSS Distributions typedef IOByteCount32           IOByteCount;
103*1b191cb5SApple OSS Distributions #define PRIIOByteCount                  PRIu32
104*1b191cb5SApple OSS Distributions #endif
105*1b191cb5SApple OSS Distributions 
106*1b191cb5SApple OSS Distributions typedef IOVirtualAddress    IOLogicalAddress;
107*1b191cb5SApple OSS Distributions 
108*1b191cb5SApple OSS Distributions #if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL))
109*1b191cb5SApple OSS Distributions 
110*1b191cb5SApple OSS Distributions typedef IOPhysicalAddress64      IOPhysicalAddress;
111*1b191cb5SApple OSS Distributions typedef IOPhysicalLength64       IOPhysicalLength;
112*1b191cb5SApple OSS Distributions #define IOPhysical32( hi, lo )          ((UInt64) lo + ((UInt64)(hi) << 32))
113*1b191cb5SApple OSS Distributions #define IOPhysSize      64
114*1b191cb5SApple OSS Distributions 
115*1b191cb5SApple OSS Distributions #else
116*1b191cb5SApple OSS Distributions 
117*1b191cb5SApple OSS Distributions typedef IOPhysicalAddress32      IOPhysicalAddress;
118*1b191cb5SApple OSS Distributions typedef IOPhysicalLength32       IOPhysicalLength;
119*1b191cb5SApple OSS Distributions #define IOPhysical32( hi, lo )          (lo)
120*1b191cb5SApple OSS Distributions #define IOPhysSize      32
121*1b191cb5SApple OSS Distributions 
122*1b191cb5SApple OSS Distributions #endif
123*1b191cb5SApple OSS Distributions 
124*1b191cb5SApple OSS Distributions 
125*1b191cb5SApple OSS Distributions typedef struct{
126*1b191cb5SApple OSS Distributions 	IOPhysicalAddress   address;
127*1b191cb5SApple OSS Distributions 	IOByteCount         length;
128*1b191cb5SApple OSS Distributions } IOPhysicalRange;
129*1b191cb5SApple OSS Distributions 
130*1b191cb5SApple OSS Distributions typedef struct{
131*1b191cb5SApple OSS Distributions 	IOVirtualAddress    address;
132*1b191cb5SApple OSS Distributions 	IOByteCount         length;
133*1b191cb5SApple OSS Distributions } IOVirtualRange;
134*1b191cb5SApple OSS Distributions 
135*1b191cb5SApple OSS Distributions #if !defined(__arm__) && !defined(__i386__)
136*1b191cb5SApple OSS Distributions typedef IOVirtualRange  IOAddressRange;
137*1b191cb5SApple OSS Distributions #else
138*1b191cb5SApple OSS Distributions typedef struct{
139*1b191cb5SApple OSS Distributions 	mach_vm_address_t   address;
140*1b191cb5SApple OSS Distributions 	mach_vm_size_t      length;
141*1b191cb5SApple OSS Distributions } IOAddressRange;
142*1b191cb5SApple OSS Distributions #endif
143*1b191cb5SApple OSS Distributions 
144*1b191cb5SApple OSS Distributions /*
145*1b191cb5SApple OSS Distributions  * Map between #defined or enum'd constants and text description.
146*1b191cb5SApple OSS Distributions  */
147*1b191cb5SApple OSS Distributions typedef struct {
148*1b191cb5SApple OSS Distributions 	int value;
149*1b191cb5SApple OSS Distributions 	const char *name;
150*1b191cb5SApple OSS Distributions } IONamedValue;
151*1b191cb5SApple OSS Distributions 
152*1b191cb5SApple OSS Distributions 
153*1b191cb5SApple OSS Distributions /*
154*1b191cb5SApple OSS Distributions  * Memory alignment -- specified as a power of two.
155*1b191cb5SApple OSS Distributions  */
156*1b191cb5SApple OSS Distributions typedef unsigned int    IOAlignment;
157*1b191cb5SApple OSS Distributions 
158*1b191cb5SApple OSS Distributions #define IO_NULL_VM_TASK         ((vm_task_t)0)
159*1b191cb5SApple OSS Distributions 
160*1b191cb5SApple OSS Distributions 
161*1b191cb5SApple OSS Distributions /*
162*1b191cb5SApple OSS Distributions  * Pull in machine specific stuff.
163*1b191cb5SApple OSS Distributions  */
164*1b191cb5SApple OSS Distributions 
165*1b191cb5SApple OSS Distributions //#include <IOKit/machine/IOTypes.h>
166*1b191cb5SApple OSS Distributions 
167*1b191cb5SApple OSS Distributions #ifndef MACH_KERNEL
168*1b191cb5SApple OSS Distributions 
169*1b191cb5SApple OSS Distributions #ifndef __IOKIT_PORTS_DEFINED__
170*1b191cb5SApple OSS Distributions #define __IOKIT_PORTS_DEFINED__
171*1b191cb5SApple OSS Distributions #ifdef KERNEL
172*1b191cb5SApple OSS Distributions #ifdef __cplusplus
173*1b191cb5SApple OSS Distributions class OSObject;
174*1b191cb5SApple OSS Distributions typedef OSObject * io_object_t;
175*1b191cb5SApple OSS Distributions #else
176*1b191cb5SApple OSS Distributions typedef struct OSObject * io_object_t;
177*1b191cb5SApple OSS Distributions #endif
178*1b191cb5SApple OSS Distributions #else /* KERNEL */
179*1b191cb5SApple OSS Distributions typedef mach_port_t     io_object_t;
180*1b191cb5SApple OSS Distributions #endif /* KERNEL */
181*1b191cb5SApple OSS Distributions #endif /* __IOKIT_PORTS_DEFINED__ */
182*1b191cb5SApple OSS Distributions 
183*1b191cb5SApple OSS Distributions #include <device/device_types.h>
184*1b191cb5SApple OSS Distributions 
185*1b191cb5SApple OSS Distributions typedef io_object_t     io_connect_t;
186*1b191cb5SApple OSS Distributions typedef io_object_t     io_enumerator_t;
187*1b191cb5SApple OSS Distributions typedef io_object_t     io_ident_t;
188*1b191cb5SApple OSS Distributions typedef io_object_t     io_iterator_t;
189*1b191cb5SApple OSS Distributions typedef io_object_t     io_registry_entry_t;
190*1b191cb5SApple OSS Distributions typedef io_object_t     io_service_t;
191*1b191cb5SApple OSS Distributions typedef io_object_t     uext_object_t;
192*1b191cb5SApple OSS Distributions 
193*1b191cb5SApple OSS Distributions #define IO_OBJECT_NULL  ((io_object_t) 0)
194*1b191cb5SApple OSS Distributions 
195*1b191cb5SApple OSS Distributions #endif /* MACH_KERNEL */
196*1b191cb5SApple OSS Distributions 
197*1b191cb5SApple OSS Distributions #include <IOKit/IOMapTypes.h>
198*1b191cb5SApple OSS Distributions 
199*1b191cb5SApple OSS Distributions /*! @enum Scale Factors
200*1b191cb5SApple OSS Distributions  *   @discussion Used when a scale_factor parameter is required to define a unit of time.
201*1b191cb5SApple OSS Distributions  *   @constant kNanosecondScale Scale factor for nanosecond based times.
202*1b191cb5SApple OSS Distributions  *   @constant kMicrosecondScale Scale factor for microsecond based times.
203*1b191cb5SApple OSS Distributions  *   @constant kMillisecondScale Scale factor for millisecond based times.
204*1b191cb5SApple OSS Distributions  *   @constant kTickScale Scale factor for the standard (100Hz) tick.
205*1b191cb5SApple OSS Distributions  *   @constant kSecondScale Scale factor for second based times. */
206*1b191cb5SApple OSS Distributions 
207*1b191cb5SApple OSS Distributions enum {
208*1b191cb5SApple OSS Distributions 	kNanosecondScale  = 1,
209*1b191cb5SApple OSS Distributions 	kMicrosecondScale = 1000,
210*1b191cb5SApple OSS Distributions 	kMillisecondScale = 1000 * 1000,
211*1b191cb5SApple OSS Distributions 	kSecondScale      = 1000 * 1000 * 1000,
212*1b191cb5SApple OSS Distributions 	kTickScale        = (kSecondScale / 100)
213*1b191cb5SApple OSS Distributions };
214*1b191cb5SApple OSS Distributions 
215*1b191cb5SApple OSS Distributions enum {
216*1b191cb5SApple OSS Distributions 	kIOConnectMethodVarOutputSize = -3
217*1b191cb5SApple OSS Distributions };
218*1b191cb5SApple OSS Distributions 
219*1b191cb5SApple OSS Distributions /* compatibility types */
220*1b191cb5SApple OSS Distributions 
221*1b191cb5SApple OSS Distributions #ifndef KERNEL
222*1b191cb5SApple OSS Distributions 
223*1b191cb5SApple OSS Distributions typedef unsigned int IODeviceNumber;
224*1b191cb5SApple OSS Distributions 
225*1b191cb5SApple OSS Distributions #endif
226*1b191cb5SApple OSS Distributions 
227*1b191cb5SApple OSS Distributions #ifdef __cplusplus
228*1b191cb5SApple OSS Distributions }
229*1b191cb5SApple OSS Distributions #endif
230*1b191cb5SApple OSS Distributions 
231*1b191cb5SApple OSS Distributions #else /* !XNU_PLATFORM_DriverKit */
232*1b191cb5SApple OSS Distributions 
233*1b191cb5SApple OSS Distributions #include <stdint.h>
234*1b191cb5SApple OSS Distributions 
235*1b191cb5SApple OSS Distributions typedef uint32_t          IOOptionBits;
236*1b191cb5SApple OSS Distributions typedef int32_t           IOFixed;
237*1b191cb5SApple OSS Distributions typedef uint32_t          IOVersion;
238*1b191cb5SApple OSS Distributions typedef uint32_t          IOItemCount;
239*1b191cb5SApple OSS Distributions typedef uint32_t          IOCacheMode;
240*1b191cb5SApple OSS Distributions 
241*1b191cb5SApple OSS Distributions typedef uint32_t          IOByteCount32;
242*1b191cb5SApple OSS Distributions typedef uint64_t          IOByteCount64;
243*1b191cb5SApple OSS Distributions typedef IOByteCount64     IOByteCount;
244*1b191cb5SApple OSS Distributions 
245*1b191cb5SApple OSS Distributions typedef uint32_t  IOPhysicalAddress32;
246*1b191cb5SApple OSS Distributions typedef uint64_t  IOPhysicalAddress64;
247*1b191cb5SApple OSS Distributions typedef uint32_t  IOPhysicalLength32;
248*1b191cb5SApple OSS Distributions typedef uint64_t  IOPhysicalLength64;
249*1b191cb5SApple OSS Distributions 
250*1b191cb5SApple OSS Distributions typedef IOPhysicalAddress64      IOPhysicalAddress;
251*1b191cb5SApple OSS Distributions typedef IOPhysicalLength64       IOPhysicalLength;
252*1b191cb5SApple OSS Distributions 
253*1b191cb5SApple OSS Distributions typedef uint64_t       IOVirtualAddress;
254*1b191cb5SApple OSS Distributions 
255*1b191cb5SApple OSS Distributions #endif /* XNU_PLATFORM_DriverKit */
256*1b191cb5SApple OSS Distributions 
257*1b191cb5SApple OSS Distributions enum {
258*1b191cb5SApple OSS Distributions 	kIOMaxBusStall40usec = 40000,
259*1b191cb5SApple OSS Distributions 	kIOMaxBusStall30usec = 30000,
260*1b191cb5SApple OSS Distributions 	kIOMaxBusStall25usec = 25000,
261*1b191cb5SApple OSS Distributions 	kIOMaxBusStall20usec = 20000,
262*1b191cb5SApple OSS Distributions 	kIOMaxBusStall10usec = 10000,
263*1b191cb5SApple OSS Distributions 	kIOMaxBusStall5usec  = 5000,
264*1b191cb5SApple OSS Distributions 	kIOMaxBusStallNone   = 0,
265*1b191cb5SApple OSS Distributions };
266*1b191cb5SApple OSS Distributions 
267*1b191cb5SApple OSS Distributions #if PRIVATE
268*1b191cb5SApple OSS Distributions #define LIBKERN_OSNUMBER_FLOAT_SUPPORT          1
269*1b191cb5SApple OSS Distributions #endif /* PRIVATE */
270*1b191cb5SApple OSS Distributions 
271*1b191cb5SApple OSS Distributions #endif /* ! __IOKIT_IOTYPES_H */
272