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