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