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