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