2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #ifndef _IOKIT_KERNELINTERNAL_H
31 #define _IOKIT_KERNELINTERNAL_H
33 #include <sys/cdefs.h>
37 #include <vm/vm_pageout.h>
38 #include <mach/memory_object_types.h>
39 #include <device/device_port.h>
40 #include <IOKit/IODMACommand.h>
42 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
44 #if (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD)
46 #define IOServiceTrace(csc, a, b, c, d) do { \
47 if(kIOTraceIOService & gIOKitDebug) { \
48 KERNEL_DEBUG_CONSTANT(IODBG_IOSERVICE(csc), a, b, c, d, 0); \
52 #else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
54 #define IOServiceTrace(csc, a, b, c, d) do { \
61 #endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
63 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
65 typedef kern_return_t (*IOIteratePageableMapsCallback
)(vm_map_t map
, void * ref
);
68 kern_return_t
IOIteratePageableMaps(vm_size_t size
,
69 IOIteratePageableMapsCallback callback
, void * ref
);
70 vm_map_t
IOPageableMapForAddress(uintptr_t address
);
72 struct IOMemoryDescriptorMapAllocRef
75 mach_vm_address_t mapped
;
83 IOMemoryDescriptorMapAlloc(vm_map_t map
, void * ref
);
87 IOKernelAllocateWithPhysicalRestrict(mach_vm_size_t size
, mach_vm_address_t maxPhys
,
88 mach_vm_size_t alignment
, bool contiguous
);
90 IOKernelFreePhysical(mach_vm_address_t address
, mach_vm_size_t size
);
94 IOMemoryMapTracking(IOTrackingUser
* tracking
, task_t
* task
,
95 mach_vm_address_t
* address
, mach_vm_size_t
* size
);
96 #endif /* IOTRACKING */
98 extern vm_size_t debug_iomallocpageable_size
;
100 // osfmk/device/iokit_rpc.c
101 extern kern_return_t
IOMapPages(vm_map_t map
, mach_vm_address_t va
, mach_vm_address_t pa
,
102 mach_vm_size_t length
, unsigned int mapFlags
);
103 extern kern_return_t
IOUnmapPages(vm_map_t map
, mach_vm_address_t va
, mach_vm_size_t length
);
105 extern kern_return_t
IOProtectCacheMode(vm_map_t map
, mach_vm_address_t va
,
106 mach_vm_size_t length
, unsigned int mapFlags
);
108 extern ppnum_t
IOGetLastPageNumber(void);
110 extern ppnum_t gIOLastPage
;
112 extern IOSimpleLock
* gIOPageAllocLock
;
113 extern queue_head_t gIOPageAllocList
;
115 /* Physical to physical copy (ints must be disabled) */
116 extern void bcopy_phys(addr64_t from
, addr64_t to
, vm_size_t size
);
120 #define __IODEQUALIFY(type, expr) \
121 ({ typeof(expr) expr_ = (type)(uintptr_t)(expr); \
122 (type)(uintptr_t)(expr_); })
125 struct IODMACommandInternal
127 IOMDDMAWalkSegmentState fState
;
128 IOMDDMACharacteristics fMDSummary
;
130 UInt64 fPreparedOffset
;
131 UInt64 fPreparedLength
;
133 UInt32 fSourceAlignMask
;
136 UInt8 fCheckAddressing
;
147 IOTracking fWireTracking
;
148 #endif /* IOTRACKING */
150 vm_page_t fCopyPageAlloc
;
152 vm_page_t fNextRemapPage
;
154 ppnum_t fCopyPageCount
;
156 uint64_t fLocalMapperAlloc
;
157 uint64_t fLocalMapperAllocLength
;
159 class IOBufferMemoryDescriptor
* fCopyMD
;
163 // IODMAEventSource use
165 UInt64 fActualByteCount
;
166 AbsoluteTime fTimeStamp
;
169 struct IOMemoryDescriptorDevicePager
{
171 unsigned int pagerContig
:1;
172 unsigned int unused
:31;
173 IOMemoryDescriptor
* memory
;
176 struct IOMemoryDescriptorReserved
{
177 IOMemoryDescriptorDevicePager dp
;
178 uint64_t preparationID
;
179 // for kernel IOMD subclasses... they have no expansion
180 uint64_t kernReserved
[4];
199 typedef struct iopa_page_t iopa_page_t
;
201 typedef uintptr_t (*iopa_proc_t
)(iopa_t
* a
);
205 kIOPageAllocSignature
= 'iopa'
208 extern "C" void iopa_init(iopa_t
* a
);
209 extern "C" uintptr_t iopa_alloc(iopa_t
* a
, iopa_proc_t alloc
, vm_size_t bytes
, uint32_t balign
);
210 extern "C" uintptr_t iopa_free(iopa_t
* a
, uintptr_t addr
, vm_size_t bytes
);
211 extern "C" uint32_t gIOPageAllocChunkBytes
;
213 extern "C" iopa_t gIOBMDPageAllocator
;
215 extern "C" struct timeval gIOLastSleepTime
;
216 extern "C" struct timeval gIOLastWakeTime
;
218 extern clock_sec_t gIOConsoleLockTime
;
220 extern OSSet
* gIORemoveOnReadProperties
;
222 extern "C" void IOKitInitializeTime( void );
224 extern "C" OSString
* IOCopyLogNameForPID(int pid
);
226 #if defined(__i386__) || defined(__x86_64__)
231 extern const OSSymbol
* gIOCreateEFIDevicePathSymbol
;
232 extern "C" void IOSetKeyStoreData(IOMemoryDescriptor
* data
);
234 extern const OSSymbol
* gAKSGetKey
;
236 void IOScreenLockTimeUpdate(clock_sec_t secs
);
238 void IOCPUInitialize(void);
239 IOReturn
IOInstallServicePlatformActions(IOService
* service
);
240 IOReturn
IORemoveServicePlatformActions(IOService
* service
);
242 #endif /* ! _IOKIT_KERNELINTERNAL_H */