]> git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOKitKernelInternal.h
xnu-6153.141.1.tar.gz
[apple/xnu.git] / iokit / Kernel / IOKitKernelInternal.h
1 /*
2 * Copyright (c) 1998-2000 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
29
30 #ifndef _IOKIT_KERNELINTERNAL_H
31 #define _IOKIT_KERNELINTERNAL_H
32
33 #include <sys/cdefs.h>
34
35 __BEGIN_DECLS
36
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>
42
43 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
44
45 #if (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD)
46
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 } \
51 } while(0)
52
53 #else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
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
62 #endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
63
64 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
65
66 typedef kern_return_t (*IOIteratePageableMapsCallback)(vm_map_t map, void * ref);
67
68 void IOLibInit(void);
69 kern_return_t IOIteratePageableMaps(vm_size_t size,
70 IOIteratePageableMapsCallback callback, void * ref);
71 vm_map_t IOPageableMapForAddress(uintptr_t address);
72
73 struct 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;
80 };
81
82 kern_return_t
83 IOMemoryDescriptorMapAlloc(vm_map_t map, void * ref);
84
85
86 mach_vm_address_t
87 IOKernelAllocateWithPhysicalRestrict(mach_vm_size_t size, mach_vm_address_t maxPhys,
88 mach_vm_size_t alignment, bool contiguous);
89 void
90 IOKernelFreePhysical(mach_vm_address_t address, mach_vm_size_t size);
91
92 #if IOTRACKING
93 IOReturn
94 IOMemoryMapTracking(IOTrackingUser * tracking, task_t * task,
95 mach_vm_address_t * address, mach_vm_size_t * size);
96 #endif /* IOTRACKING */
97
98 extern vm_size_t debug_iomallocpageable_size;
99
100 extern ppnum_t gIOLastPage;
101
102 extern IOSimpleLock * gIOPageAllocLock;
103 extern queue_head_t gIOPageAllocList;
104
105 /* Physical to physical copy (ints must be disabled) */
106 extern void bcopy_phys(addr64_t from, addr64_t to, vm_size_t size);
107
108 __END_DECLS
109
110 #define __IODEQUALIFY(type, expr) \
111 ({ typeof(expr) expr_ = (type)(uintptr_t)(expr); \
112 (type)(uintptr_t)(expr_); })
113
114
115 struct IODMACommandInternal {
116 IOMDDMAWalkSegmentState fState;
117 IOMDDMACharacteristics fMDSummary;
118
119 UInt64 fPreparedOffset;
120 UInt64 fPreparedLength;
121
122 UInt32 fSourceAlignMask;
123
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;
136
137 vm_page_t fCopyPageAlloc;
138 vm_page_t fCopyNext;
139 vm_page_t fNextRemapPage;
140
141 ppnum_t fCopyPageCount;
142
143 uint64_t fLocalMapperAlloc;
144 uint64_t fLocalMapperAllocLength;
145
146 class IOBufferMemoryDescriptor * fCopyMD;
147
148 IOService * fDevice;
149
150 // IODMAEventSource use
151 IOReturn fStatus;
152 UInt64 fActualByteCount;
153 AbsoluteTime fTimeStamp;
154 };
155
156 struct IOMemoryDescriptorDevicePager {
157 void * devicePager;
158 unsigned int pagerContig:1;
159 unsigned int unused:31;
160 IOMemoryDescriptor * memory;
161 };
162
163 struct IOMemoryDescriptorReserved {
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;
170 task_t creator;
171 };
172
173 struct iopa_t {
174 IOLock * lock;
175 queue_head_t list;
176 vm_size_t pagecount;
177 vm_size_t bytecount;
178 };
179
180 struct iopa_page_t {
181 queue_chain_t link;
182 uint64_t avail;
183 uint32_t signature;
184 };
185 typedef struct iopa_page_t iopa_page_t;
186
187 typedef uintptr_t (*iopa_proc_t)(iopa_t * a);
188
189 enum{
190 kIOPageAllocSignature = 'iopa'
191 };
192
193 extern "C" void iopa_init(iopa_t * a);
194 extern "C" uintptr_t iopa_alloc(iopa_t * a, iopa_proc_t alloc, vm_size_t bytes, uint32_t balign);
195 extern "C" uintptr_t iopa_free(iopa_t * a, uintptr_t addr, vm_size_t bytes);
196 extern "C" uint32_t gIOPageAllocChunkBytes;
197
198 extern "C" iopa_t gIOBMDPageAllocator;
199
200 extern "C" struct timeval gIOLastSleepTime;
201 extern "C" struct timeval gIOLastWakeTime;
202
203 extern clock_sec_t gIOConsoleLockTime;
204
205 extern bool gCPUsRunning;
206
207 extern OSSet * gIORemoveOnReadProperties;
208
209 extern "C" void IOKitInitializeTime( void );
210 extern void IOMachPortInitialize(void);
211
212 extern "C" OSString * IOCopyLogNameForPID(int pid);
213
214 extern "C" void IOKitKernelLogBuffer(const char * title, const void * buffer, size_t size,
215 void (*output)(const char *format, ...));
216
217 #if defined(__i386__) || defined(__x86_64__)
218 #ifndef __cplusplus
219 #error xx
220 #endif
221
222 extern const OSSymbol * gIOCreateEFIDevicePathSymbol;
223 extern "C" void IOSetKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor * data);
224 extern "C" void IOSetAPFSKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor* data);
225 #endif
226 extern const OSSymbol * gAKSGetKey;
227
228 void IOScreenLockTimeUpdate(clock_sec_t secs);
229
230 void IOCPUInitialize(void);
231 IOReturn IOInstallServicePlatformActions(IOService * service);
232 IOReturn IORemoveServicePlatformActions(IOService * service);
233
234 #endif /* ! _IOKIT_KERNELINTERNAL_H */