1258945Sroberto/*
2258945Sroberto * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
3258945Sroberto *
4258945Sroberto * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5258945Sroberto *
6258945Sroberto * This file contains Original Code and/or Modifications of Original Code
7258945Sroberto * as defined in and that are subject to the Apple Public Source License
8258945Sroberto * Version 2.0 (the 'License'). You may not use this file except in
9258945Sroberto * compliance with the License. The rights granted to you under the License
10258945Sroberto * may not be used to create, or enable the creation or redistribution of,
11258945Sroberto * unlawful or unlicensed copies of an Apple operating system, or to
12258945Sroberto * circumvent, violate, or enable the circumvention or violation of, any
13258945Sroberto * terms of an Apple operating system software license agreement.
14258945Sroberto *
15258945Sroberto * Please obtain a copy of the License at
16258945Sroberto * http://www.opensource.apple.com/apsl/ and read it before using this file.
17258945Sroberto *
18258945Sroberto * The Original Code and all software distributed under the License are
19258945Sroberto * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20258945Sroberto * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21258945Sroberto * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22258945Sroberto * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23258945Sroberto * Please see the License for the specific language governing rights and
24258945Sroberto * limitations under the License.
25258945Sroberto *
26258945Sroberto * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27258945Sroberto */
28258945Sroberto#ifndef	__IOKIT_IOTYPES_H
29258945Sroberto#define __IOKIT_IOTYPES_H
30258945Sroberto
31258945Sroberto#ifndef IOKIT
32293423Sdelphij#define IOKIT 1
33258945Sroberto#endif /* !IOKIT */
34258945Sroberto
35258945Sroberto#if KERNEL
36258945Sroberto#include <IOKit/system.h>
37258945Sroberto#else
38258945Sroberto#include <mach/message.h>
39258945Sroberto#include <mach/vm_types.h>
40289764Sglebius#endif
41258945Sroberto
42258945Sroberto#include <IOKit/IOReturn.h>
43258945Sroberto
44258945Sroberto#ifdef __cplusplus
45258945Srobertoextern "C" {
46258945Sroberto#endif
47258945Sroberto
48258945Sroberto#ifndef	NULL
49258945Sroberto#if defined (__cplusplus)
50258945Sroberto#define	NULL	0
51258945Sroberto#else
52258945Sroberto#define NULL ((void *)0)
53258945Sroberto#endif
54258945Sroberto#endif
55258945Sroberto
56258945Sroberto/*
57258945Sroberto * Simple data types.
58258945Sroberto */
59258945Sroberto#ifndef __MACTYPES__	/* CF MacTypes.h */
60258945Sroberto#ifndef __TYPES__	/* guess... Mac Types.h */
61258945Sroberto
62258945Sroberto#include <stdbool.h>
63258945Sroberto#include <libkern/OSTypes.h>
64258945Sroberto
65258945Sroberto#endif /* __TYPES__ */
66258945Sroberto#endif /* __MACTYPES__ */
67258945Sroberto
68258945Sroberto#if KERNEL
69258945Sroberto#include <libkern/OSBase.h>
70258945Sroberto#endif
71258945Sroberto
72258945Srobertotypedef UInt32		IOOptionBits;
73258945Srobertotypedef SInt32		IOFixed;
74258945Srobertotypedef UInt32		IOVersion;
75258945Srobertotypedef UInt32		IOItemCount;
76258945Srobertotypedef UInt32  	IOCacheMode;
77258945Sroberto
78258945Srobertotypedef UInt32	 	IOByteCount32;
79258945Srobertotypedef UInt64	 	IOByteCount64;
80258945Sroberto
81258945Srobertotypedef UInt32	IOPhysicalAddress32;
82258945Srobertotypedef UInt64	IOPhysicalAddress64;
83258945Srobertotypedef UInt32	IOPhysicalLength32;
84258945Srobertotypedef UInt64	IOPhysicalLength64;
85258945Sroberto
86258945Sroberto#ifdef __LP64__
87258945Srobertotypedef mach_vm_address_t	IOVirtualAddress;
88258945Sroberto#else
89258945Srobertotypedef vm_address_t		IOVirtualAddress;
90258945Sroberto#endif
91258945Sroberto
92258945Sroberto#if defined(__LP64__) && defined(KERNEL)
93258945Srobertotypedef IOByteCount64		IOByteCount;
94258945Sroberto#else
95258945Srobertotypedef IOByteCount32	 	IOByteCount;
96258945Sroberto#endif
97280849Scy
98258945Srobertotypedef IOVirtualAddress    IOLogicalAddress;
99258945Sroberto
100258945Sroberto#if defined(__LP64__) && defined(KERNEL)
101258945Sroberto
102258945Srobertotypedef IOPhysicalAddress64	 IOPhysicalAddress;
103258945Srobertotypedef IOPhysicalLength64	 IOPhysicalLength;
104258945Sroberto#define IOPhysical32( hi, lo )		((UInt64) lo + ((UInt64)(hi) << 32))
105258945Sroberto#define IOPhysSize	64
106280849Scy
107258945Sroberto#else
108258945Sroberto
109258945Srobertotypedef IOPhysicalAddress32	 IOPhysicalAddress;
110258945Srobertotypedef IOPhysicalLength32	 IOPhysicalLength;
111258945Sroberto#define IOPhysical32( hi, lo )		(lo)
112258945Sroberto#define IOPhysSize	32
113258945Sroberto
114258945Sroberto#endif
115258945Sroberto
116258945Sroberto
117258945Srobertotypedef struct
118258945Sroberto{
119258945Sroberto    IOPhysicalAddress	address;
120258945Sroberto    IOByteCount		length;
121258945Sroberto} IOPhysicalRange;
122258945Sroberto
123258945Srobertotypedef struct
124258945Sroberto{
125258945Sroberto    IOVirtualAddress	address;
126258945Sroberto    IOByteCount		length;
127258945Sroberto} IOVirtualRange;
128258945Sroberto
129258945Sroberto#ifdef __LP64__
130258945Srobertotypedef IOVirtualRange	IOAddressRange;
131258945Sroberto#else /* !__LP64__ */
132258945Srobertotypedef struct
133258945Sroberto{
134258945Sroberto    mach_vm_address_t	address;
135258945Sroberto    mach_vm_size_t	length;
136258945Sroberto} IOAddressRange;
137258945Sroberto#endif /* !__LP64__ */
138258945Sroberto
139258945Sroberto/*
140258945Sroberto * Map between #defined or enum'd constants and text description.
141258945Sroberto */
142258945Srobertotypedef struct {
143258945Sroberto	int value;
144258945Sroberto	const char *name;
145258945Sroberto} IONamedValue;
146258945Sroberto
147258945Sroberto
148258945Sroberto/*
149258945Sroberto * Memory alignment -- specified as a power of two.
150258945Sroberto */
151258945Srobertotypedef unsigned int	IOAlignment;
152258945Sroberto
153258945Sroberto#define IO_NULL_VM_TASK		((vm_task_t)0)
154258945Sroberto
155258945Sroberto
156258945Sroberto/*
157258945Sroberto * Pull in machine specific stuff.
158258945Sroberto */
159258945Sroberto
160258945Sroberto//#include <IOKit/machine/IOTypes.h>
161258945Sroberto
162258945Sroberto#ifndef MACH_KERNEL
163258945Sroberto
164258945Sroberto#ifndef __IOKIT_PORTS_DEFINED__
165258945Sroberto#define __IOKIT_PORTS_DEFINED__
166258945Sroberto#ifdef KERNEL
167258945Sroberto#ifdef __cplusplus
168258945Srobertoclass OSObject;
169258945Srobertotypedef OSObject * io_object_t;
170258945Sroberto#else
171258945Srobertotypedef struct OSObject * io_object_t;
172258945Sroberto#endif
173258945Sroberto#else /* KERNEL */
174258945Srobertotypedef mach_port_t	io_object_t;
175258945Sroberto#endif /* KERNEL */
176258945Sroberto#endif /* __IOKIT_PORTS_DEFINED__ */
177258945Sroberto
178258945Sroberto#include <device/device_types.h>
179258945Sroberto
180258945Srobertotypedef io_object_t	io_connect_t;
181258945Srobertotypedef io_object_t	io_enumerator_t;
182258945Srobertotypedef io_object_t	io_iterator_t;
183280849Scytypedef io_object_t	io_registry_entry_t;
184258945Srobertotypedef io_object_t	io_service_t;
185258945Sroberto
186258945Sroberto#define	IO_OBJECT_NULL	((io_object_t) 0)
187258945Sroberto
188258945Sroberto#endif /* MACH_KERNEL */
189258945Sroberto
190280849Scy// IOConnectMapMemory memoryTypes
191258945Srobertoenum {
192258945Sroberto    kIODefaultMemoryType	= 0
193280849Scy};
194258945Sroberto
195280849Scyenum {
196280849Scy    kIODefaultCache		= 0,
197280849Scy    kIOInhibitCache		= 1,
198258945Sroberto    kIOWriteThruCache		= 2,
199258945Sroberto    kIOCopybackCache		= 3,
200258945Sroberto    kIOWriteCombineCache	= 4,
201258945Sroberto    kIOCopybackInnerCache	= 5
202258945Sroberto};
203258945Sroberto
204258945Sroberto// IOMemory mapping options
205258945Srobertoenum {
206258945Sroberto    kIOMapAnywhere		= 0x00000001,
207258945Sroberto
208258945Sroberto    kIOMapCacheMask		= 0x00000700,
209258945Sroberto    kIOMapCacheShift		= 8,
210258945Sroberto    kIOMapDefaultCache		= kIODefaultCache       << kIOMapCacheShift,
211258945Sroberto    kIOMapInhibitCache		= kIOInhibitCache       << kIOMapCacheShift,
212258945Sroberto    kIOMapWriteThruCache	= kIOWriteThruCache     << kIOMapCacheShift,
213258945Sroberto    kIOMapCopybackCache		= kIOCopybackCache      << kIOMapCacheShift,
214258945Sroberto    kIOMapWriteCombineCache	= kIOWriteCombineCache  << kIOMapCacheShift,
215258945Sroberto    kIOMapCopybackInnerCache	= kIOCopybackInnerCache << kIOMapCacheShift,
216258945Sroberto
217293423Sdelphij    kIOMapUserOptionsMask	= 0x00000fff,
218258945Sroberto
219258945Sroberto    kIOMapReadOnly		= 0x00001000,
220258945Sroberto
221258945Sroberto    kIOMapStatic		= 0x01000000,
222258945Sroberto    kIOMapReference		= 0x02000000,
223258945Sroberto    kIOMapUnique		= 0x04000000
224258945Sroberto#ifdef XNU_KERNEL_PRIVATE
225258945Sroberto    , kIOMap64Bit		= 0x08000000
226258945Sroberto#endif
227258945Sroberto};
228258945Sroberto
229258945Sroberto/*! @enum Scale Factors
230258945Sroberto    @discussion Used when a scale_factor parameter is required to define a unit of time.
231258945Sroberto    @constant kNanosecondScale Scale factor for nanosecond based times.
232258945Sroberto    @constant kMicrosecondScale Scale factor for microsecond based times.
233258945Sroberto    @constant kMillisecondScale Scale factor for millisecond based times.
234258945Sroberto    @constant kTickScale Scale factor for the standard (100Hz) tick.
235258945Sroberto    @constant kSecondScale Scale factor for second based times. */
236258945Sroberto
237258945Srobertoenum {
238258945Sroberto    kNanosecondScale  = 1,
239258945Sroberto    kMicrosecondScale = 1000,
240258945Sroberto    kMillisecondScale = 1000 * 1000,
241258945Sroberto    kSecondScale      = 1000 * 1000 * 1000,
242258945Sroberto    kTickScale        = (kSecondScale / 100)
243258945Sroberto};
244258945Sroberto
245258945Srobertoenum {
246258945Sroberto    kIOConnectMethodVarOutputSize = -3
247};
248
249/* compatibility types */
250
251#ifndef KERNEL
252
253typedef unsigned int IODeviceNumber;
254
255#endif
256
257#ifdef __cplusplus
258}
259#endif
260
261#endif /* ! __IOKIT_IOTYPES_H */
262