]> git.saurik.com Git - apple/xnu.git/blame - iokit/Kernel/IOKitKernelInternal.h
xnu-6153.81.5.tar.gz
[apple/xnu.git] / iokit / Kernel / IOKitKernelInternal.h
CommitLineData
91447636
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
A
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.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
0a7de745 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
91447636
A
27 */
28
29
30#ifndef _IOKIT_KERNELINTERNAL_H
31#define _IOKIT_KERNELINTERNAL_H
32
33#include <sys/cdefs.h>
34
35__BEGIN_DECLS
36
0b4c1975 37#include <vm/vm_pageout.h>
91447636
A
38#include <mach/memory_object_types.h>
39#include <device/device_port.h>
3e170ce0 40#include <IOKit/IODMACommand.h>
a39ff7e2 41#include <IOKit/IOKitServer.h>
91447636 42
6d2010ae
A
43/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
44
316670eb 45#if (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD)
6d2010ae 46
0a7de745
A
47#define IOServiceTrace(csc, a, b, c, d) do { \
48 if(kIOTraceIOService & gIOKitTrace) { \
49 KERNEL_DEBUG_CONSTANT(IODBG_IOSERVICE(csc), a, b, c, d, 0); \
50 } \
6d2010ae
A
51} while(0)
52
316670eb 53#else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
6d2010ae 54
0a7de745
A
55#define IOServiceTrace(csc, a, b, c, d) do { \
56 (void)a; \
57 (void)b; \
58 (void)c; \
59 (void)d; \
6d2010ae
A
60} while (0)
61
316670eb 62#endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
6d2010ae
A
63
64/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
65
91447636
A
66typedef kern_return_t (*IOIteratePageableMapsCallback)(vm_map_t map, void * ref);
67
68void IOLibInit(void);
69kern_return_t IOIteratePageableMaps(vm_size_t size,
0a7de745 70 IOIteratePageableMapsCallback callback, void * ref);
b0d623f7 71vm_map_t IOPageableMapForAddress(uintptr_t address);
2d21ac55 72
0a7de745
A
73struct IOMemoryDescriptorMapAllocRef {
74 vm_map_t map;
75 mach_vm_address_t mapped;
76 mach_vm_size_t size;
77 vm_prot_t prot;
78 vm_tag_t tag;
79 IOOptionBits options;
3e170ce0
A
80};
81
0a7de745 82kern_return_t
3e170ce0
A
83IOMemoryDescriptorMapAlloc(vm_map_t map, void * ref);
84
91447636 85
0c530ab8 86mach_vm_address_t
0a7de745
A
87IOKernelAllocateWithPhysicalRestrict(mach_vm_size_t size, mach_vm_address_t maxPhys,
88 mach_vm_size_t alignment, bool contiguous);
0c530ab8 89void
0b4c1975
A
90IOKernelFreePhysical(mach_vm_address_t address, mach_vm_size_t size);
91
39037602
A
92#if IOTRACKING
93IOReturn
94IOMemoryMapTracking(IOTrackingUser * tracking, task_t * task,
0a7de745 95 mach_vm_address_t * address, mach_vm_size_t * size);
39037602
A
96#endif /* IOTRACKING */
97
91447636
A
98extern vm_size_t debug_iomallocpageable_size;
99
0c530ab8 100extern ppnum_t gIOLastPage;
91447636 101
99c3a104
A
102extern IOSimpleLock * gIOPageAllocLock;
103extern queue_head_t gIOPageAllocList;
104
91447636 105/* Physical to physical copy (ints must be disabled) */
316670eb 106extern void bcopy_phys(addr64_t from, addr64_t to, vm_size_t size);
91447636
A
107
108__END_DECLS
109
0a7de745
A
110#define __IODEQUALIFY(type, expr) \
111 ({ typeof(expr) expr_ = (type)(uintptr_t)(expr); \
3e170ce0
A
112 (type)(uintptr_t)(expr_); })
113
99c3a104 114
0a7de745
A
115struct IODMACommandInternal {
116 IOMDDMAWalkSegmentState fState;
117 IOMDDMACharacteristics fMDSummary;
118
119 UInt64 fPreparedOffset;
120 UInt64 fPreparedLength;
2d21ac55 121
0a7de745 122 UInt32 fSourceAlignMask;
2d21ac55 123
0a7de745
A
124 UInt8 fCursor;
125 UInt8 fCheckAddressing;
126 UInt8 fIterateOnly;
127 UInt8 fMisaligned;
128 UInt8 fMapContig;
129 UInt8 fPrepared;
130 UInt8 fDoubleBuffer;
131 UInt8 fNewMD;
132 UInt8 fLocalMapperAllocValid;
133 UInt8 fIOVMAddrValid;
134 UInt8 fForceDoubleBuffer;
135 UInt8 fSetActiveNoMapper;
39037602 136
0a7de745
A
137 vm_page_t fCopyPageAlloc;
138 vm_page_t fCopyNext;
139 vm_page_t fNextRemapPage;
0b4c1975 140
0a7de745 141 ppnum_t fCopyPageCount;
2d21ac55 142
0a7de745
A
143 uint64_t fLocalMapperAlloc;
144 uint64_t fLocalMapperAllocLength;
b0d623f7 145
0a7de745 146 class IOBufferMemoryDescriptor * fCopyMD;
2d21ac55 147
0a7de745 148 IOService * fDevice;
99c3a104 149
0a7de745
A
150 // IODMAEventSource use
151 IOReturn fStatus;
152 UInt64 fActualByteCount;
153 AbsoluteTime fTimeStamp;
2d21ac55
A
154};
155
316670eb 156struct IOMemoryDescriptorDevicePager {
0a7de745
A
157 void * devicePager;
158 unsigned int pagerContig:1;
159 unsigned int unused:31;
160 IOMemoryDescriptor * memory;
316670eb
A
161};
162
163struct IOMemoryDescriptorReserved {
0a7de745
A
164 IOMemoryDescriptorDevicePager dp;
165 uint64_t preparationID;
166 // for kernel IOMD subclasses... they have no expansion
167 uint64_t kernReserved[4];
168 vm_tag_t kernelTag;
169 vm_tag_t userTag;
cb323159 170 task_t creator;
316670eb
A
171};
172
0a7de745
A
173struct iopa_t {
174 IOLock * lock;
175 queue_head_t list;
176 vm_size_t pagecount;
177 vm_size_t bytecount;
39236c6e
A
178};
179
0a7de745
A
180struct iopa_page_t {
181 queue_chain_t link;
182 uint64_t avail;
183 uint32_t signature;
39236c6e
A
184};
185typedef struct iopa_page_t iopa_page_t;
186
187typedef uintptr_t (*iopa_proc_t)(iopa_t * a);
188
0a7de745
A
189enum{
190 kIOPageAllocSignature = 'iopa'
39236c6e
A
191};
192
193extern "C" void iopa_init(iopa_t * a);
194extern "C" uintptr_t iopa_alloc(iopa_t * a, iopa_proc_t alloc, vm_size_t bytes, uint32_t balign);
195extern "C" uintptr_t iopa_free(iopa_t * a, uintptr_t addr, vm_size_t bytes);
fe8ab488 196extern "C" uint32_t gIOPageAllocChunkBytes;
39236c6e
A
197
198extern "C" iopa_t gIOBMDPageAllocator;
316670eb 199
2d21ac55
A
200extern "C" struct timeval gIOLastSleepTime;
201extern "C" struct timeval gIOLastWakeTime;
202
316670eb
A
203extern clock_sec_t gIOConsoleLockTime;
204
5ba3f43e
A
205extern bool gCPUsRunning;
206
fe8ab488
A
207extern OSSet * gIORemoveOnReadProperties;
208
2d21ac55 209extern "C" void IOKitInitializeTime( void );
cb323159 210extern void IOMachPortInitialize(void);
2d21ac55
A
211
212extern "C" OSString * IOCopyLogNameForPID(int pid);
213
d26ffc64 214extern "C" void IOKitKernelLogBuffer(const char * title, const void * buffer, size_t size,
0a7de745 215 void (*output)(const char *format, ...));
d26ffc64 216
6d2010ae 217#if defined(__i386__) || defined(__x86_64__)
3e170ce0
A
218#ifndef __cplusplus
219#error xx
220#endif
221
222extern const OSSymbol * gIOCreateEFIDevicePathSymbol;
0a7de745
A
223extern "C" void IOSetKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor * data);
224extern "C" void IOSetAPFSKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor* data);
6d2010ae 225#endif
3e170ce0 226extern const OSSymbol * gAKSGetKey;
6d2010ae 227
316670eb
A
228void IOScreenLockTimeUpdate(clock_sec_t secs);
229
3e170ce0
A
230void IOCPUInitialize(void);
231IOReturn IOInstallServicePlatformActions(IOService * service);
232IOReturn IORemoveServicePlatformActions(IOService * service);
316670eb 233
91447636 234#endif /* ! _IOKIT_KERNELINTERNAL_H */