1/* 2 * Copyright (c) 1998-2006 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 IOKIT 32#define IOKIT 1 33#endif /* !IOKIT */ 34 35#if KERNEL 36#include <IOKit/system.h> 37#else 38#include <mach/message.h> 39#include <mach/vm_types.h> 40#endif 41 42#include <IOKit/IOReturn.h> 43 44#ifdef __cplusplus 45extern "C" { 46#endif 47 48#ifndef NULL 49#if defined (__cplusplus) 50#define NULL 0 51#else 52#define NULL ((void *)0) 53#endif 54#endif 55 56/* 57 * Simple data types. 58 */ 59#ifndef __MACTYPES__ /* CF MacTypes.h */ 60#ifndef __TYPES__ /* guess... Mac Types.h */ 61 62#include <stdbool.h> 63#include <libkern/OSTypes.h> 64 65#endif /* __TYPES__ */ 66#endif /* __MACTYPES__ */ 67 68#if KERNEL 69#include <libkern/OSBase.h> 70#endif 71 72typedef UInt32 IOOptionBits; 73typedef SInt32 IOFixed; 74typedef UInt32 IOVersion; 75typedef UInt32 IOItemCount; 76typedef UInt32 IOCacheMode; 77 78typedef UInt32 IOByteCount; 79 80 /* LP64todo - these will need to expand to mach_vm_address_t */ 81typedef vm_address_t IOVirtualAddress; 82typedef IOVirtualAddress IOLogicalAddress; 83 84#if 0 85 86typedef UInt64 IOPhysicalAddress; 87typedef UInt64 IOPhysicalLength; 88#define IOPhysical32( hi, lo ) ((UInt64) lo + ((UInt64)(hi) << 32)) 89#define IOPhysSize 64 90 91#else 92 93typedef UInt32 IOPhysicalAddress; 94typedef UInt32 IOPhysicalLength; 95#define IOPhysical32( hi, lo ) (lo) 96#define IOPhysSize 32 97 98#endif 99 100 101#if __cplusplus 102struct IOVirtualRange 103{ 104 IOVirtualAddress address; 105 IOByteCount length; 106}; 107struct IOAddressRange 108{ 109 mach_vm_address_t address; 110 mach_vm_size_t length; 111}; 112#else 113typedef struct 114{ 115 IOVirtualAddress address; 116 IOByteCount length; 117} IOVirtualRange; 118 119typedef struct 120{ 121 mach_vm_address_t address; 122 mach_vm_size_t length; 123} IOAddressRange; 124#endif 125 126/* 127 * Map between #defined or enum'd constants and text description. 128 */ 129typedef struct { 130 int value; 131 const char *name; 132} IONamedValue; 133 134 135/* 136 * Memory alignment -- specified as a power of two. 137 */ 138typedef 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 154typedef struct OSObject * io_object_t; 155#else /* KERNEL */ 156typedef mach_port_t io_object_t; 157#endif /* KERNEL */ 158#endif /* __IOKIT_PORTS_DEFINED__ */ 159 160#include <device/device_types.h> 161 162typedef io_object_t io_connect_t; 163typedef io_object_t io_enumerator_t; 164typedef io_object_t io_iterator_t; 165typedef io_object_t io_registry_entry_t; 166typedef 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 173enum { 174 kIODefaultMemoryType = 0 175}; 176 177enum { 178 kIODefaultCache = 0, 179 kIOInhibitCache = 1, 180 kIOWriteThruCache = 2, 181 kIOCopybackCache = 3, 182 kIOWriteCombineCache = 4 183}; 184 185// IOMemory mapping options 186enum { 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 kIOMap64Bit = 0x08000000 205}; 206 207/*! @enum Scale Factors 208 @discussion Used when a scale_factor parameter is required to define a unit of time. 209 @constant kNanosecondScale Scale factor for nanosecond based times. 210 @constant kMicrosecondScale Scale factor for microsecond based times. 211 @constant kMillisecondScale Scale factor for millisecond based times. 212 @constant kTickScale Scale factor for the standard (100Hz) tick. 213 @constant kSecondScale Scale factor for second based times. */ 214 215enum { 216 kNanosecondScale = 1, 217 kMicrosecondScale = 1000, 218 kMillisecondScale = 1000 * 1000, 219 kSecondScale = 1000 * 1000 * 1000, 220 kTickScale = (kSecondScale / 100) 221}; 222 223/* compatibility types */ 224 225#ifndef KERNEL 226/* 227 * Machine-independent caching specification. 228 */ 229typedef enum { 230 IO_CacheOff, // cache inhibit 231 IO_WriteThrough, 232 IO_CopyBack 233} IOCache; 234 235//typedef char OSString[64]; 236typedef unsigned int IODeviceNumber; 237typedef unsigned int IOObjectNumber; 238 239#endif 240 241#ifdef __cplusplus 242} 243#endif 244 245#endif /* ! __IOKIT_IOTYPES_H */ 246