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