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