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>
41 #include <IOKit/IOKitServer.h>
43 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
45 typedef kern_return_t (*IOIteratePageableMapsCallback
)(vm_map_t map
, void * ref
);
48 kern_return_t
IOIteratePageableMaps(vm_size_t size
,
49 IOIteratePageableMapsCallback callback
, void * ref
);
50 vm_map_t
IOPageableMapForAddress(uintptr_t address
);
52 struct IOMemoryDescriptorMapAllocRef
{
54 mach_vm_address_t mapped
;
62 IOMemoryDescriptorMapAlloc(vm_map_t map
, void * ref
);
66 IOKernelAllocateWithPhysicalRestrict(mach_vm_size_t size
, mach_vm_address_t maxPhys
,
67 mach_vm_size_t alignment
, bool contiguous
);
69 IOKernelFreePhysical(mach_vm_address_t address
, mach_vm_size_t size
);
73 IOMemoryMapTracking(IOTrackingUser
* tracking
, task_t
* task
,
74 mach_vm_address_t
* address
, mach_vm_size_t
* size
);
75 #endif /* IOTRACKING */
77 extern vm_size_t debug_iomallocpageable_size
;
79 extern ppnum_t gIOLastPage
;
81 extern IOSimpleLock
* gIOPageAllocLock
;
82 extern queue_head_t gIOPageAllocList
;
84 /* Physical to physical copy (ints must be disabled) */
85 extern void bcopy_phys(addr64_t from
, addr64_t to
, vm_size_t size
);
89 #define __IODEQUALIFY(type, expr) \
90 ({ typeof(expr) expr_ = (type)(uintptr_t)(expr); \
91 (type)(uintptr_t)(expr_); })
93 struct IODMACommandMapSegment
{
94 uint64_t fDMAOffset
; // The offset of this segment in DMA
95 uint64_t fMapOffset
; // Offset of segment in mapping
96 uint64_t fPageOffset
; // Offset within first page of segment
99 struct IODMACommandInternal
{
100 IOMDDMAWalkSegmentState fState
;
101 IOMDDMACharacteristics fMDSummary
;
103 UInt64 fPreparedOffset
;
104 UInt64 fPreparedLength
;
106 UInt32 fSourceAlignMask
;
109 UInt8 fCheckAddressing
;
115 UInt8 fLocalMapperAllocValid
;
116 UInt8 fIOVMAddrValid
;
117 UInt8 fForceDoubleBuffer
;
118 UInt8 fSetActiveNoMapper
;
120 vm_page_t fCopyPageAlloc
;
122 vm_page_t fNextRemapPage
;
124 ppnum_t fCopyPageCount
;
126 uint64_t fLocalMapperAlloc
;
127 uint64_t fLocalMapperAllocLength
;
129 OSPtr
<IOBufferMemoryDescriptor
> fCopyMD
;
133 // IODMAEventSource use
135 UInt64 fActualByteCount
;
136 AbsoluteTime fTimeStamp
;
139 IODMACommandMapSegment
* fMapSegments
;
140 uint32_t fMapSegmentsCount
;
141 uint64_t fLocalMapperAllocBase
;
142 uint64_t fOffset2Index
;
143 uint64_t fNextOffset
;
147 struct IOMemoryDescriptorDevicePager
{
149 unsigned int pagerContig
:1;
150 unsigned int unused
:31;
151 IOMemoryDescriptor
* memory
;
154 struct IOMemoryDescriptorReserved
{
155 IOMemoryDescriptorDevicePager dp
;
156 uint64_t descriptorID
;
157 uint64_t preparationID
;
158 // for kernel IOMD subclasses... they have no expansion
159 uint64_t kernReserved
[4];
177 typedef struct iopa_page_t iopa_page_t
;
179 typedef uintptr_t (*iopa_proc_t
)(iopa_t
* a
);
182 kIOPageAllocSignature
= 'iopa'
185 extern "C" void iopa_init(iopa_t
* a
);
186 extern "C" uintptr_t iopa_alloc(iopa_t
* a
, iopa_proc_t alloc
, vm_size_t bytes
, vm_size_t balign
);
187 extern "C" uintptr_t iopa_free(iopa_t
* a
, uintptr_t addr
, vm_size_t bytes
);
188 extern "C" uint32_t gIOPageAllocChunkBytes
;
190 extern "C" iopa_t gIOBMDPageAllocator
;
192 extern "C" struct timeval gIOLastSleepTime
;
193 extern "C" struct timeval gIOLastWakeTime
;
195 extern clock_sec_t gIOConsoleLockTime
;
197 extern bool gCPUsRunning
;
199 extern OSSet
* gIORemoveOnReadProperties
;
201 extern uint32_t gHaltTimeMaxLog
;
202 extern uint32_t gHaltTimeMaxPanic
;
204 extern "C" void IOKitInitializeTime( void );
205 extern void IOMachPortInitialize(void);
207 extern "C" OSString
* IOCopyLogNameForPID(int pid
);
209 extern "C" void IOKitKernelLogBuffer(const char * title
, const void * buffer
, size_t size
,
210 void (*output
)(const char *format
, ...));
212 #if defined(__i386__) || defined(__x86_64__)
217 extern const OSSymbol
* gIOCreateEFIDevicePathSymbol
;
218 extern "C" void IOSetKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor
* data
);
219 extern "C" void IOSetAPFSKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor
* data
);
221 extern const OSSymbol
* gAKSGetKey
;
223 void IOScreenLockTimeUpdate(clock_sec_t secs
);
225 void IOCPUInitialize(void);
226 IOReturn
IOInstallServicePlatformActions(IOService
* service
);
227 IOReturn
IOInstallServiceSleepPlatformActions(IOService
* service
);
228 IOReturn
IORemoveServicePlatformActions(IOService
* service
);
229 void IOCPUSleepKernel(void);
230 void IOPlatformActionsInitialize(void);
232 #endif /* ! _IOKIT_KERNELINTERNAL_H */