]> git.saurik.com Git - apple/xnu.git/blame - iokit/DriverKit/IOTypes.h
xnu-7195.101.1.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;
f427ee49 98#define PRIIOByteCount PRIu64
cb323159
A
99#else
100typedef IOByteCount32 IOByteCount;
f427ee49 101#define PRIIOByteCount PRIu32
cb323159
A
102#endif
103
104typedef IOVirtualAddress IOLogicalAddress;
105
106#if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL))
107
108typedef IOPhysicalAddress64 IOPhysicalAddress;
109typedef IOPhysicalLength64 IOPhysicalLength;
110#define IOPhysical32( hi, lo ) ((UInt64) lo + ((UInt64)(hi) << 32))
111#define IOPhysSize 64
112
113#else
114
115typedef IOPhysicalAddress32 IOPhysicalAddress;
116typedef IOPhysicalLength32 IOPhysicalLength;
117#define IOPhysical32( hi, lo ) (lo)
118#define IOPhysSize 32
119
120#endif
121
122
123typedef struct{
124 IOPhysicalAddress address;
125 IOByteCount length;
126} IOPhysicalRange;
127
128typedef struct{
129 IOVirtualAddress address;
130 IOByteCount length;
131} IOVirtualRange;
132
133#if !defined(__arm__) && !defined(__i386__)
134typedef IOVirtualRange IOAddressRange;
135#else
136typedef struct{
137 mach_vm_address_t address;
138 mach_vm_size_t length;
139} IOAddressRange;
140#endif
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 */
154typedef unsigned int IOAlignment;
155
156#define IO_NULL_VM_TASK ((vm_task_t)0)
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
170#ifdef __cplusplus
171class OSObject;
172typedef OSObject * io_object_t;
173#else
174typedef struct OSObject * io_object_t;
175#endif
176#else /* KERNEL */
177typedef mach_port_t io_object_t;
178#endif /* KERNEL */
179#endif /* __IOKIT_PORTS_DEFINED__ */
180
181#include <device/device_types.h>
182
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;
188typedef io_object_t uext_object_t;
189
190#define IO_OBJECT_NULL ((io_object_t) 0)
191
192#endif /* MACH_KERNEL */
193
194// IOConnectMapMemory memoryTypes
195enum {
196 kIODefaultMemoryType = 0
197};
198
199enum {
200 kIODefaultCache = 0,
201 kIOInhibitCache = 1,
202 kIOWriteThruCache = 2,
203 kIOCopybackCache = 3,
204 kIOWriteCombineCache = 4,
205 kIOCopybackInnerCache = 5,
206 kIOPostedWrite = 6,
207 kIORealTimeCache = 7,
208 kIOPostedReordered = 8,
f427ee49 209 kIOPostedCombinedReordered = 9,
cb323159
A
210};
211
212// IOMemory mapping options
213enum {
f427ee49
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,
cb323159 236#ifdef XNU_KERNEL_PRIVATE
f427ee49 237 kIOMap64Bit = 0x08000000,
cb323159 238#endif
f427ee49
A
239 kIOMapPrefault = 0x10000000,
240 kIOMapOverwrite = 0x20000000
cb323159
A
241};
242
243/*! @enum Scale Factors
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. */
250
251enum {
252 kNanosecondScale = 1,
253 kMicrosecondScale = 1000,
254 kMillisecondScale = 1000 * 1000,
255 kSecondScale = 1000 * 1000 * 1000,
256 kTickScale = (kSecondScale / 100)
257};
258
259enum {
260 kIOConnectMethodVarOutputSize = -3
261};
262
263/* compatibility types */
264
265#ifndef KERNEL
266
267typedef unsigned int IODeviceNumber;
268
269#endif
270
271#ifdef __cplusplus
272}
273#endif
274
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
cb323159 311#endif /* ! __IOKIT_IOTYPES_H */