]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IOTypes.h
xnu-2050.48.11.tar.gz
[apple/xnu.git] / iokit / IOKit / IOTypes.h
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 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.
8f6c56a5 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.
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
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b 27 */
1c79356b
A
28#ifndef __IOKIT_IOTYPES_H
29#define __IOKIT_IOTYPES_H
30
31#ifndef IOKIT
32#define IOKIT 1
33#endif /* !IOKIT */
34
35#if KERNEL
36#include <IOKit/system.h>
37#else
38#include <mach/message.h>
39#include <mach/vm_types.h>
40#endif
41
42#include <IOKit/IOReturn.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#ifndef NULL
2d21ac55 49#if defined (__cplusplus)
1c79356b 50#define NULL 0
2d21ac55
A
51#else
52#define NULL ((void *)0)
53#endif
1c79356b
A
54#endif
55
56/*
57 * Simple data types.
58 */
59#ifndef __MACTYPES__ /* CF MacTypes.h */
60#ifndef __TYPES__ /* guess... Mac Types.h */
61
0c530ab8 62#include <stdbool.h>
1c79356b
A
63#include <libkern/OSTypes.h>
64
1c79356b
A
65#endif /* __TYPES__ */
66#endif /* __MACTYPES__ */
67
2d21ac55
A
68#if KERNEL
69#include <libkern/OSBase.h>
70#endif
71
1c79356b
A
72typedef UInt32 IOOptionBits;
73typedef SInt32 IOFixed;
74typedef UInt32 IOVersion;
75typedef UInt32 IOItemCount;
76typedef UInt32 IOCacheMode;
77
b0d623f7
A
78typedef UInt32 IOByteCount32;
79typedef UInt64 IOByteCount64;
1c79356b 80
b0d623f7
A
81typedef UInt32 IOPhysicalAddress32;
82typedef UInt64 IOPhysicalAddress64;
83typedef UInt32 IOPhysicalLength32;
84typedef UInt64 IOPhysicalLength64;
1c79356b 85
b0d623f7
A
86#ifdef __LP64__
87typedef mach_vm_address_t IOVirtualAddress;
88#else
89typedef vm_address_t IOVirtualAddress;
90#endif
91
92#if defined(__LP64__) && defined(KERNEL)
93typedef IOByteCount64 IOByteCount;
94#else
95typedef IOByteCount32 IOByteCount;
96#endif
1c79356b 97
b0d623f7
A
98typedef IOVirtualAddress IOLogicalAddress;
99
100#if defined(__LP64__) && defined(KERNEL)
101
102typedef IOPhysicalAddress64 IOPhysicalAddress;
103typedef IOPhysicalLength64 IOPhysicalLength;
1c79356b
A
104#define IOPhysical32( hi, lo ) ((UInt64) lo + ((UInt64)(hi) << 32))
105#define IOPhysSize 64
106
107#else
108
b0d623f7
A
109typedef IOPhysicalAddress32 IOPhysicalAddress;
110typedef IOPhysicalLength32 IOPhysicalLength;
1c79356b
A
111#define IOPhysical32( hi, lo ) (lo)
112#define IOPhysSize 32
113
114#endif
115
2d21ac55 116
b0d623f7 117typedef struct
1c79356b 118{
b0d623f7 119 IOPhysicalAddress address;
1c79356b 120 IOByteCount length;
b0d623f7
A
121} IOPhysicalRange;
122
1c79356b
A
123typedef struct
124{
125 IOVirtualAddress address;
126 IOByteCount length;
127} IOVirtualRange;
0c530ab8 128
b0d623f7
A
129#ifdef __LP64__
130typedef IOVirtualRange IOAddressRange;
131#else /* !__LP64__ */
2d21ac55 132typedef struct
0c530ab8
A
133{
134 mach_vm_address_t address;
135 mach_vm_size_t length;
2d21ac55 136} IOAddressRange;
b0d623f7 137#endif /* !__LP64__ */
1c79356b
A
138
139/*
140 * Map between #defined or enum'd constants and text description.
141 */
142typedef struct {
143 int value;
144 const char *name;
145} IONamedValue;
146
147
148/*
149 * Memory alignment -- specified as a power of two.
150 */
151typedef unsigned int IOAlignment;
152
153#define IO_NULL_VM_TASK ((vm_task_t)0)
154
155
156/*
157 * Pull in machine specific stuff.
158 */
159
160//#include <IOKit/machine/IOTypes.h>
161
162#ifndef MACH_KERNEL
163
164#ifndef __IOKIT_PORTS_DEFINED__
165#define __IOKIT_PORTS_DEFINED__
166#ifdef KERNEL
6d2010ae
A
167#ifdef __cplusplus
168class OSObject;
169typedef OSObject * io_object_t;
170#else
1c79356b 171typedef struct OSObject * io_object_t;
6d2010ae 172#endif
1c79356b
A
173#else /* KERNEL */
174typedef mach_port_t io_object_t;
175#endif /* KERNEL */
176#endif /* __IOKIT_PORTS_DEFINED__ */
177
178#include <device/device_types.h>
179
180typedef io_object_t io_connect_t;
91447636 181typedef io_object_t io_enumerator_t;
1c79356b
A
182typedef io_object_t io_iterator_t;
183typedef io_object_t io_registry_entry_t;
184typedef io_object_t io_service_t;
185
91447636 186#define IO_OBJECT_NULL ((io_object_t) 0)
1c79356b
A
187
188#endif /* MACH_KERNEL */
189
190// IOConnectMapMemory memoryTypes
191enum {
192 kIODefaultMemoryType = 0
193};
194
195enum {
196 kIODefaultCache = 0,
197 kIOInhibitCache = 1,
198 kIOWriteThruCache = 2,
55e303ae 199 kIOCopybackCache = 3,
316670eb
A
200 kIOWriteCombineCache = 4,
201 kIOCopybackInnerCache = 5
1c79356b
A
202};
203
204// IOMemory mapping options
205enum {
206 kIOMapAnywhere = 0x00000001,
207
55e303ae 208 kIOMapCacheMask = 0x00000700,
1c79356b 209 kIOMapCacheShift = 8,
316670eb
A
210 kIOMapDefaultCache = kIODefaultCache << kIOMapCacheShift,
211 kIOMapInhibitCache = kIOInhibitCache << kIOMapCacheShift,
212 kIOMapWriteThruCache = kIOWriteThruCache << kIOMapCacheShift,
213 kIOMapCopybackCache = kIOCopybackCache << kIOMapCacheShift,
214 kIOMapWriteCombineCache = kIOWriteCombineCache << kIOMapCacheShift,
215 kIOMapCopybackInnerCache = kIOCopybackInnerCache << kIOMapCacheShift,
1c79356b
A
216
217 kIOMapUserOptionsMask = 0x00000fff,
218
219 kIOMapReadOnly = 0x00001000,
220
221 kIOMapStatic = 0x01000000,
91447636 222 kIOMapReference = 0x02000000,
b0d623f7
A
223 kIOMapUnique = 0x04000000
224#ifdef XNU_KERNEL_PRIVATE
225 , kIOMap64Bit = 0x08000000
226#endif
1c79356b
A
227};
228
229/*! @enum Scale Factors
230 @discussion Used when a scale_factor parameter is required to define a unit of time.
231 @constant kNanosecondScale Scale factor for nanosecond based times.
232 @constant kMicrosecondScale Scale factor for microsecond based times.
233 @constant kMillisecondScale Scale factor for millisecond based times.
91447636 234 @constant kTickScale Scale factor for the standard (100Hz) tick.
1c79356b
A
235 @constant kSecondScale Scale factor for second based times. */
236
237enum {
238 kNanosecondScale = 1,
239 kMicrosecondScale = 1000,
240 kMillisecondScale = 1000 * 1000,
91447636
A
241 kSecondScale = 1000 * 1000 * 1000,
242 kTickScale = (kSecondScale / 100)
1c79356b
A
243};
244
ebb1b9f4
A
245enum {
246 kIOConnectMethodVarOutputSize = -3
247};
248
1c79356b
A
249/* compatibility types */
250
251#ifndef KERNEL
1c79356b 252
1c79356b 253typedef unsigned int IODeviceNumber;
1c79356b
A
254
255#endif
256
257#ifdef __cplusplus
258}
259#endif
260
261#endif /* ! __IOKIT_IOTYPES_H */