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