IOTypes.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * Copyright (c) 1998-2006 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. #ifndef IOKIT
  31. #define IOKIT 1
  32. #endif /* !IOKIT */
  33. #if KERNEL
  34. #include <IOKit/system.h>
  35. #else
  36. #include <mach/message.h>
  37. #include <mach/vm_types.h>
  38. #endif
  39. #include <IOKit/IOReturn.h>
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #ifndef NULL
  44. #if defined (__cplusplus)
  45. #define NULL 0
  46. #else
  47. #define NULL ((void *)0)
  48. #endif
  49. #endif
  50. /*
  51. * Simple data types.
  52. */
  53. #ifndef __MACTYPES__ /* CF MacTypes.h */
  54. #ifndef __TYPES__ /* guess... Mac Types.h */
  55. #include <stdbool.h>
  56. #include <libkern/OSTypes.h>
  57. #endif /* __TYPES__ */
  58. #endif /* __MACTYPES__ */
  59. #if KERNEL
  60. #include <libkern/OSBase.h>
  61. #endif
  62. typedef UInt32 IOOptionBits;
  63. typedef SInt32 IOFixed;
  64. typedef UInt32 IOVersion;
  65. typedef UInt32 IOItemCount;
  66. typedef UInt32 IOCacheMode;
  67. typedef UInt32 IOByteCount32;
  68. typedef UInt64 IOByteCount64;
  69. typedef UInt32 IOPhysicalAddress32;
  70. typedef UInt64 IOPhysicalAddress64;
  71. typedef UInt32 IOPhysicalLength32;
  72. typedef UInt64 IOPhysicalLength64;
  73. #ifdef __LP64__
  74. typedef mach_vm_address_t IOVirtualAddress;
  75. #else
  76. typedef vm_address_t IOVirtualAddress;
  77. #endif
  78. #if defined(__LP64__) && defined(KERNEL)
  79. typedef IOByteCount64 IOByteCount;
  80. #else
  81. typedef IOByteCount32 IOByteCount;
  82. #endif
  83. typedef IOVirtualAddress IOLogicalAddress;
  84. #if defined(__LP64__) && defined(KERNEL)
  85. typedef IOPhysicalAddress64 IOPhysicalAddress;
  86. typedef IOPhysicalLength64 IOPhysicalLength;
  87. #define IOPhysical32( hi, lo ) ((UInt64) lo + ((UInt64)(hi) << 32))
  88. #define IOPhysSize 64
  89. #else
  90. typedef IOPhysicalAddress32 IOPhysicalAddress;
  91. typedef IOPhysicalLength32 IOPhysicalLength;
  92. #define IOPhysical32( hi, lo ) (lo)
  93. #define IOPhysSize 32
  94. #endif
  95. typedef struct
  96. {
  97. IOPhysicalAddress address;
  98. IOByteCount length;
  99. } IOPhysicalRange;
  100. typedef struct
  101. {
  102. IOVirtualAddress address;
  103. IOByteCount length;
  104. } IOVirtualRange;
  105. #ifdef __LP64__
  106. typedef IOVirtualRange IOAddressRange;
  107. #else /* !__LP64__ */
  108. typedef struct
  109. {
  110. mach_vm_address_t address;
  111. mach_vm_size_t length;
  112. } IOAddressRange;
  113. #endif /* !__LP64__ */
  114. /*
  115. * Map between #defined or enum'd constants and text description.
  116. */
  117. typedef struct {
  118. int value;
  119. const char *name;
  120. } IONamedValue;
  121. /*
  122. * Memory alignment -- specified as a power of two.
  123. */
  124. typedef unsigned int IOAlignment;
  125. #define IO_NULL_VM_TASK ((vm_task_t)0)
  126. /*
  127. * Pull in machine specific stuff.
  128. */
  129. //#include <IOKit/machine/IOTypes.h>
  130. #ifndef MACH_KERNEL
  131. #ifndef __IOKIT_PORTS_DEFINED__
  132. #define __IOKIT_PORTS_DEFINED__
  133. #ifdef KERNEL
  134. typedef struct OSObject * io_object_t;
  135. #else /* KERNEL */
  136. typedef mach_port_t io_object_t;
  137. #endif /* KERNEL */
  138. #endif /* __IOKIT_PORTS_DEFINED__ */
  139. #include <device/device_types.h>
  140. typedef io_object_t io_connect_t;
  141. typedef io_object_t io_enumerator_t;
  142. typedef io_object_t io_iterator_t;
  143. typedef io_object_t io_registry_entry_t;
  144. typedef io_object_t io_service_t;
  145. #define IO_OBJECT_NULL ((io_object_t) 0)
  146. #endif /* MACH_KERNEL */
  147. // IOConnectMapMemory memoryTypes
  148. enum {
  149. kIODefaultMemoryType = 0
  150. };
  151. enum {
  152. kIODefaultCache = 0,
  153. kIOInhibitCache = 1,
  154. kIOWriteThruCache = 2,
  155. kIOCopybackCache = 3,
  156. kIOWriteCombineCache = 4
  157. };
  158. // IOMemory mapping options
  159. enum {
  160. kIOMapAnywhere = 0x00000001,
  161. kIOMapCacheMask = 0x00000700,
  162. kIOMapCacheShift = 8,
  163. kIOMapDefaultCache = kIODefaultCache << kIOMapCacheShift,
  164. kIOMapInhibitCache = kIOInhibitCache << kIOMapCacheShift,
  165. kIOMapWriteThruCache = kIOWriteThruCache << kIOMapCacheShift,
  166. kIOMapCopybackCache = kIOCopybackCache << kIOMapCacheShift,
  167. kIOMapWriteCombineCache = kIOWriteCombineCache << kIOMapCacheShift,
  168. kIOMapUserOptionsMask = 0x00000fff,
  169. kIOMapReadOnly = 0x00001000,
  170. kIOMapStatic = 0x01000000,
  171. kIOMapReference = 0x02000000,
  172. kIOMapUnique = 0x04000000
  173. #ifdef XNU_KERNEL_PRIVATE
  174. , kIOMap64Bit = 0x08000000
  175. #endif
  176. };
  177. /*! @enum Scale Factors
  178. @discussion Used when a scale_factor parameter is required to define a unit of time.
  179. @constant kNanosecondScale Scale factor for nanosecond based times.
  180. @constant kMicrosecondScale Scale factor for microsecond based times.
  181. @constant kMillisecondScale Scale factor for millisecond based times.
  182. @constant kTickScale Scale factor for the standard (100Hz) tick.
  183. @constant kSecondScale Scale factor for second based times. */
  184. enum {
  185. kNanosecondScale = 1,
  186. kMicrosecondScale = 1000,
  187. kMillisecondScale = 1000 * 1000,
  188. kSecondScale = 1000 * 1000 * 1000,
  189. kTickScale = (kSecondScale / 100)
  190. };
  191. /* compatibility types */
  192. #ifndef KERNEL
  193. typedef unsigned int IODeviceNumber;
  194. #endif
  195. #ifdef __cplusplus
  196. }
  197. #endif
  198. #endif /* ! __IOKIT_IOTYPES_H */