]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOTypes.h
6e578358909fdbe218dd4ed00280b8023dd5e4b2
[apple/xnu.git] / iokit / IOKit / IOTypes.h
1 /*
2 * Copyright (c) 1998-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
32 *
33 * HISTORY
34 *
35 */
36
37 #ifndef __IOKIT_IOTYPES_H
38 #define __IOKIT_IOTYPES_H
39
40 #ifndef IOKIT
41 #define IOKIT 1
42 #endif /* !IOKIT */
43
44 #if KERNEL
45 #include <IOKit/system.h>
46 #else
47 #include <mach/message.h>
48 #include <mach/vm_types.h>
49 #endif
50
51 #include <IOKit/IOReturn.h>
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 #ifndef NULL
58 #define NULL 0
59 #endif
60
61 /*
62 * Simple data types.
63 */
64 #ifndef __MACTYPES__ /* CF MacTypes.h */
65 #ifndef __TYPES__ /* guess... Mac Types.h */
66
67 #include <libkern/OSTypes.h>
68
69 #ifndef __cplusplus
70 #if !TYPE_BOOL
71 #ifdef KERNEL
72 typedef int bool;
73 enum {
74 false = 0,
75 true = 1
76 };
77 #endif
78 #endif
79 #endif
80
81 #endif /* __TYPES__ */
82 #endif /* __MACTYPES__ */
83
84 typedef UInt32 IOOptionBits;
85 typedef SInt32 IOFixed;
86 typedef UInt32 IOVersion;
87 typedef UInt32 IOItemCount;
88 typedef UInt32 IOCacheMode;
89
90 typedef UInt32 IOByteCount;
91
92 /* LP64todo - these will need to expand to mach_vm_address_t */
93 typedef vm_address_t IOVirtualAddress;
94 typedef IOVirtualAddress IOLogicalAddress;
95
96 #if 0
97
98 typedef UInt64 IOPhysicalAddress;
99 typedef UInt64 IOPhysicalLength;
100 #define IOPhysical32( hi, lo ) ((UInt64) lo + ((UInt64)(hi) << 32))
101 #define IOPhysSize 64
102
103 #else
104
105 typedef UInt32 IOPhysicalAddress;
106 typedef UInt32 IOPhysicalLength;
107 #define IOPhysical32( hi, lo ) (lo)
108 #define IOPhysSize 32
109
110 #endif
111
112 #if __cplusplus
113 struct IOVirtualRange
114 {
115 IOVirtualAddress address;
116 IOByteCount length;
117 };
118 #else
119 typedef struct
120 {
121 IOVirtualAddress address;
122 IOByteCount length;
123 } IOVirtualRange;
124 #endif
125
126 /*
127 * Map between #defined or enum'd constants and text description.
128 */
129 typedef struct {
130 int value;
131 const char *name;
132 } IONamedValue;
133
134
135 /*
136 * Memory alignment -- specified as a power of two.
137 */
138 typedef unsigned int IOAlignment;
139
140 #define IO_NULL_VM_TASK ((vm_task_t)0)
141
142
143 /*
144 * Pull in machine specific stuff.
145 */
146
147 //#include <IOKit/machine/IOTypes.h>
148
149 #ifndef MACH_KERNEL
150
151 #ifndef __IOKIT_PORTS_DEFINED__
152 #define __IOKIT_PORTS_DEFINED__
153 #ifdef KERNEL
154 typedef struct OSObject * io_object_t;
155 #else /* KERNEL */
156 typedef mach_port_t io_object_t;
157 #endif /* KERNEL */
158 #endif /* __IOKIT_PORTS_DEFINED__ */
159
160 #include <device/device_types.h>
161
162 typedef io_object_t io_connect_t;
163 typedef io_object_t io_enumerator_t;
164 typedef io_object_t io_iterator_t;
165 typedef io_object_t io_registry_entry_t;
166 typedef io_object_t io_service_t;
167
168 #define IO_OBJECT_NULL ((io_object_t) 0)
169
170 #endif /* MACH_KERNEL */
171
172 // IOConnectMapMemory memoryTypes
173 enum {
174 kIODefaultMemoryType = 0
175 };
176
177 enum {
178 kIODefaultCache = 0,
179 kIOInhibitCache = 1,
180 kIOWriteThruCache = 2,
181 kIOCopybackCache = 3,
182 kIOWriteCombineCache = 4
183 };
184
185 // IOMemory mapping options
186 enum {
187 kIOMapAnywhere = 0x00000001,
188
189 kIOMapCacheMask = 0x00000700,
190 kIOMapCacheShift = 8,
191 kIOMapDefaultCache = kIODefaultCache << kIOMapCacheShift,
192 kIOMapInhibitCache = kIOInhibitCache << kIOMapCacheShift,
193 kIOMapWriteThruCache = kIOWriteThruCache << kIOMapCacheShift,
194 kIOMapCopybackCache = kIOCopybackCache << kIOMapCacheShift,
195 kIOMapWriteCombineCache = kIOWriteCombineCache << kIOMapCacheShift,
196
197 kIOMapUserOptionsMask = 0x00000fff,
198
199 kIOMapReadOnly = 0x00001000,
200
201 kIOMapStatic = 0x01000000,
202 kIOMapReference = 0x02000000,
203 kIOMapUnique = 0x04000000
204 };
205
206 /*! @enum Scale Factors
207 @discussion Used when a scale_factor parameter is required to define a unit of time.
208 @constant kNanosecondScale Scale factor for nanosecond based times.
209 @constant kMicrosecondScale Scale factor for microsecond based times.
210 @constant kMillisecondScale Scale factor for millisecond based times.
211 @constant kTickScale Scale factor for the standard (100Hz) tick.
212 @constant kSecondScale Scale factor for second based times. */
213
214 enum {
215 kNanosecondScale = 1,
216 kMicrosecondScale = 1000,
217 kMillisecondScale = 1000 * 1000,
218 kSecondScale = 1000 * 1000 * 1000,
219 kTickScale = (kSecondScale / 100)
220 };
221
222 /* compatibility types */
223
224 #ifndef KERNEL
225 /*
226 * Machine-independent caching specification.
227 */
228 typedef enum {
229 IO_CacheOff, // cache inhibit
230 IO_WriteThrough,
231 IO_CopyBack
232 } IOCache;
233
234 //typedef char OSString[64];
235 typedef unsigned int IODeviceNumber;
236 typedef unsigned int IOObjectNumber;
237
238 #endif
239
240 #ifdef __cplusplus
241 }
242 #endif
243
244 #endif /* ! __IOKIT_IOTYPES_H */