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