]> git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOKitKernelInternal.h
xnu-7195.101.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 typedef kern_return_t (*IOIteratePageableMapsCallback)(vm_map_t map, void * ref);
46
47 void IOLibInit(void);
48 kern_return_t IOIteratePageableMaps(vm_size_t size,
49 IOIteratePageableMapsCallback callback, void * ref);
50 vm_map_t IOPageableMapForAddress(uintptr_t address);
51
52 struct IOMemoryDescriptorMapAllocRef {
53 vm_map_t map;
54 mach_vm_address_t mapped;
55 mach_vm_size_t size;
56 vm_prot_t prot;
57 vm_tag_t tag;
58 IOOptionBits options;
59 };
60
61 kern_return_t
62 IOMemoryDescriptorMapAlloc(vm_map_t map, void * ref);
63
64
65 mach_vm_address_t
66 IOKernelAllocateWithPhysicalRestrict(mach_vm_size_t size, mach_vm_address_t maxPhys,
67 mach_vm_size_t alignment, bool contiguous);
68 void
69 IOKernelFreePhysical(mach_vm_address_t address, mach_vm_size_t size);
70
71 #if IOTRACKING
72 IOReturn
73 IOMemoryMapTracking(IOTrackingUser * tracking, task_t * task,
74 mach_vm_address_t * address, mach_vm_size_t * size);
75 #endif /* IOTRACKING */
76
77 extern vm_size_t debug_iomallocpageable_size;
78
79 extern ppnum_t gIOLastPage;
80
81 extern IOSimpleLock * gIOPageAllocLock;
82 extern queue_head_t gIOPageAllocList;
83
84 /* Physical to physical copy (ints must be disabled) */
85 extern void bcopy_phys(addr64_t from, addr64_t to, vm_size_t size);
86
87 __END_DECLS
88
89 #define __IODEQUALIFY(type, expr) \
90 ({ typeof(expr) expr_ = (type)(uintptr_t)(expr); \
91 (type)(uintptr_t)(expr_); })
92
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
97 };
98
99 struct IODMACommandInternal {
100 IOMDDMAWalkSegmentState fState;
101 IOMDDMACharacteristics fMDSummary;
102
103 UInt64 fPreparedOffset;
104 UInt64 fPreparedLength;
105
106 UInt32 fSourceAlignMask;
107
108 UInt8 fCursor;
109 UInt8 fCheckAddressing;
110 UInt8 fIterateOnly;
111 UInt8 fMisaligned;
112 UInt8 fPrepared;
113 UInt8 fDoubleBuffer;
114 UInt8 fNewMD;
115 UInt8 fLocalMapperAllocValid;
116 UInt8 fIOVMAddrValid;
117 UInt8 fForceDoubleBuffer;
118 UInt8 fSetActiveNoMapper;
119
120 vm_page_t fCopyPageAlloc;
121 vm_page_t fCopyNext;
122 vm_page_t fNextRemapPage;
123
124 ppnum_t fCopyPageCount;
125
126 uint64_t fLocalMapperAlloc;
127 uint64_t fLocalMapperAllocLength;
128
129 OSPtr<IOBufferMemoryDescriptor> fCopyMD;
130
131 IOService * fDevice;
132
133 // IODMAEventSource use
134 IOReturn fStatus;
135 UInt64 fActualByteCount;
136 AbsoluteTime fTimeStamp;
137
138 // Multisegment vars
139 IODMACommandMapSegment * fMapSegments;
140 uint32_t fMapSegmentsCount;
141 uint64_t fLocalMapperAllocBase;
142 uint64_t fOffset2Index;
143 uint64_t fNextOffset;
144 uint64_t fIndex;
145 };
146
147 struct IOMemoryDescriptorDevicePager {
148 void * devicePager;
149 unsigned int pagerContig:1;
150 unsigned int unused:31;
151 IOMemoryDescriptor * memory;
152 };
153
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];
160 vm_tag_t kernelTag;
161 vm_tag_t userTag;
162 task_t creator;
163 };
164
165 struct iopa_t {
166 IOLock * lock;
167 queue_head_t list;
168 vm_size_t pagecount;
169 vm_size_t bytecount;
170 };
171
172 struct iopa_page_t {
173 queue_chain_t link;
174 uint64_t avail;
175 uint32_t signature;
176 };
177 typedef struct iopa_page_t iopa_page_t;
178
179 typedef uintptr_t (*iopa_proc_t)(iopa_t * a);
180
181 enum{
182 kIOPageAllocSignature = 'iopa'
183 };
184
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;
189
190 extern "C" iopa_t gIOBMDPageAllocator;
191
192 extern "C" struct timeval gIOLastSleepTime;
193 extern "C" struct timeval gIOLastWakeTime;
194
195 extern clock_sec_t gIOConsoleLockTime;
196
197 extern bool gCPUsRunning;
198
199 extern OSSet * gIORemoveOnReadProperties;
200
201 extern uint32_t gHaltTimeMaxLog;
202 extern uint32_t gHaltTimeMaxPanic;
203
204 extern "C" void IOKitInitializeTime( void );
205 extern void IOMachPortInitialize(void);
206
207 extern "C" OSString * IOCopyLogNameForPID(int pid);
208
209 extern "C" void IOKitKernelLogBuffer(const char * title, const void * buffer, size_t size,
210 void (*output)(const char *format, ...));
211
212 #if defined(__i386__) || defined(__x86_64__)
213 #ifndef __cplusplus
214 #error xx
215 #endif
216
217 extern const OSSymbol * gIOCreateEFIDevicePathSymbol;
218 extern "C" void IOSetKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor * data);
219 extern "C" void IOSetAPFSKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor* data);
220 #endif
221 extern const OSSymbol * gAKSGetKey;
222
223 void IOScreenLockTimeUpdate(clock_sec_t secs);
224
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);
231
232 #endif /* ! _IOKIT_KERNELINTERNAL_H */