]> git.saurik.com Git - apple/xnu.git/blame - iokit/Kernel/IOKitKernelInternal.h
xnu-7195.101.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@
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
91447636
A
45typedef kern_return_t (*IOIteratePageableMapsCallback)(vm_map_t map, void * ref);
46
47void IOLibInit(void);
48kern_return_t IOIteratePageableMaps(vm_size_t size,
0a7de745 49 IOIteratePageableMapsCallback callback, void * ref);
b0d623f7 50vm_map_t IOPageableMapForAddress(uintptr_t address);
2d21ac55 51
0a7de745
A
52struct 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;
3e170ce0
A
59};
60
0a7de745 61kern_return_t
3e170ce0
A
62IOMemoryDescriptorMapAlloc(vm_map_t map, void * ref);
63
91447636 64
0c530ab8 65mach_vm_address_t
0a7de745
A
66IOKernelAllocateWithPhysicalRestrict(mach_vm_size_t size, mach_vm_address_t maxPhys,
67 mach_vm_size_t alignment, bool contiguous);
0c530ab8 68void
0b4c1975
A
69IOKernelFreePhysical(mach_vm_address_t address, mach_vm_size_t size);
70
39037602
A
71#if IOTRACKING
72IOReturn
73IOMemoryMapTracking(IOTrackingUser * tracking, task_t * task,
0a7de745 74 mach_vm_address_t * address, mach_vm_size_t * size);
39037602
A
75#endif /* IOTRACKING */
76
91447636
A
77extern vm_size_t debug_iomallocpageable_size;
78
0c530ab8 79extern ppnum_t gIOLastPage;
91447636 80
99c3a104
A
81extern IOSimpleLock * gIOPageAllocLock;
82extern queue_head_t gIOPageAllocList;
83
91447636 84/* Physical to physical copy (ints must be disabled) */
316670eb 85extern void bcopy_phys(addr64_t from, addr64_t to, vm_size_t size);
91447636
A
86
87__END_DECLS
88
0a7de745
A
89#define __IODEQUALIFY(type, expr) \
90 ({ typeof(expr) expr_ = (type)(uintptr_t)(expr); \
3e170ce0
A
91 (type)(uintptr_t)(expr_); })
92
f427ee49
A
93struct 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};
99c3a104 98
0a7de745
A
99struct IODMACommandInternal {
100 IOMDDMAWalkSegmentState fState;
101 IOMDDMACharacteristics fMDSummary;
102
103 UInt64 fPreparedOffset;
104 UInt64 fPreparedLength;
2d21ac55 105
0a7de745 106 UInt32 fSourceAlignMask;
2d21ac55 107
0a7de745
A
108 UInt8 fCursor;
109 UInt8 fCheckAddressing;
110 UInt8 fIterateOnly;
111 UInt8 fMisaligned;
0a7de745
A
112 UInt8 fPrepared;
113 UInt8 fDoubleBuffer;
114 UInt8 fNewMD;
115 UInt8 fLocalMapperAllocValid;
116 UInt8 fIOVMAddrValid;
117 UInt8 fForceDoubleBuffer;
118 UInt8 fSetActiveNoMapper;
39037602 119
0a7de745
A
120 vm_page_t fCopyPageAlloc;
121 vm_page_t fCopyNext;
122 vm_page_t fNextRemapPage;
0b4c1975 123
0a7de745 124 ppnum_t fCopyPageCount;
2d21ac55 125
0a7de745
A
126 uint64_t fLocalMapperAlloc;
127 uint64_t fLocalMapperAllocLength;
b0d623f7 128
f427ee49 129 OSPtr<IOBufferMemoryDescriptor> fCopyMD;
2d21ac55 130
0a7de745 131 IOService * fDevice;
99c3a104 132
0a7de745
A
133 // IODMAEventSource use
134 IOReturn fStatus;
135 UInt64 fActualByteCount;
136 AbsoluteTime fTimeStamp;
f427ee49
A
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;
2d21ac55
A
145};
146
316670eb 147struct IOMemoryDescriptorDevicePager {
0a7de745
A
148 void * devicePager;
149 unsigned int pagerContig:1;
150 unsigned int unused:31;
151 IOMemoryDescriptor * memory;
316670eb
A
152};
153
154struct IOMemoryDescriptorReserved {
0a7de745 155 IOMemoryDescriptorDevicePager dp;
f427ee49 156 uint64_t descriptorID;
0a7de745
A
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;
cb323159 162 task_t creator;
316670eb
A
163};
164
0a7de745
A
165struct iopa_t {
166 IOLock * lock;
167 queue_head_t list;
168 vm_size_t pagecount;
169 vm_size_t bytecount;
39236c6e
A
170};
171
0a7de745
A
172struct iopa_page_t {
173 queue_chain_t link;
174 uint64_t avail;
175 uint32_t signature;
39236c6e
A
176};
177typedef struct iopa_page_t iopa_page_t;
178
179typedef uintptr_t (*iopa_proc_t)(iopa_t * a);
180
0a7de745
A
181enum{
182 kIOPageAllocSignature = 'iopa'
39236c6e
A
183};
184
185extern "C" void iopa_init(iopa_t * a);
f427ee49 186extern "C" uintptr_t iopa_alloc(iopa_t * a, iopa_proc_t alloc, vm_size_t bytes, vm_size_t balign);
39236c6e 187extern "C" uintptr_t iopa_free(iopa_t * a, uintptr_t addr, vm_size_t bytes);
fe8ab488 188extern "C" uint32_t gIOPageAllocChunkBytes;
39236c6e
A
189
190extern "C" iopa_t gIOBMDPageAllocator;
316670eb 191
2d21ac55
A
192extern "C" struct timeval gIOLastSleepTime;
193extern "C" struct timeval gIOLastWakeTime;
194
316670eb
A
195extern clock_sec_t gIOConsoleLockTime;
196
5ba3f43e
A
197extern bool gCPUsRunning;
198
fe8ab488
A
199extern OSSet * gIORemoveOnReadProperties;
200
c3c9b80d
A
201extern uint32_t gHaltTimeMaxLog;
202extern uint32_t gHaltTimeMaxPanic;
203
2d21ac55 204extern "C" void IOKitInitializeTime( void );
cb323159 205extern void IOMachPortInitialize(void);
2d21ac55
A
206
207extern "C" OSString * IOCopyLogNameForPID(int pid);
208
d26ffc64 209extern "C" void IOKitKernelLogBuffer(const char * title, const void * buffer, size_t size,
0a7de745 210 void (*output)(const char *format, ...));
d26ffc64 211
6d2010ae 212#if defined(__i386__) || defined(__x86_64__)
3e170ce0
A
213#ifndef __cplusplus
214#error xx
215#endif
216
217extern const OSSymbol * gIOCreateEFIDevicePathSymbol;
0a7de745
A
218extern "C" void IOSetKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor * data);
219extern "C" void IOSetAPFSKeyStoreData(LIBKERN_CONSUMED IOMemoryDescriptor* data);
6d2010ae 220#endif
3e170ce0 221extern const OSSymbol * gAKSGetKey;
6d2010ae 222
316670eb
A
223void IOScreenLockTimeUpdate(clock_sec_t secs);
224
3e170ce0
A
225void IOCPUInitialize(void);
226IOReturn IOInstallServicePlatformActions(IOService * service);
f427ee49 227IOReturn IOInstallServiceSleepPlatformActions(IOService * service);
3e170ce0 228IOReturn IORemoveServicePlatformActions(IOService * service);
f427ee49
A
229void IOCPUSleepKernel(void);
230void IOPlatformActionsInitialize(void);
316670eb 231
91447636 232#endif /* ! _IOKIT_KERNELINTERNAL_H */