]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 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@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * | |
30 | */ | |
31 | ||
3e170ce0 | 32 | #define TEST_HEADERS 0 |
1c79356b | 33 | |
3e170ce0 | 34 | #if TEST_HEADERS |
1c79356b | 35 | |
3e170ce0 A |
36 | #include <libkern/OSByteOrder.h> |
37 | #include <libkern/c++/OSArray.h> | |
38 | #include <libkern/c++/OSBoolean.h> | |
39 | #include <libkern/c++/OSCollection.h> | |
40 | #include <libkern/c++/OSCollectionIterator.h> | |
41 | #include <libkern/c++/OSContainers.h> | |
42 | #include <libkern/c++/OSCPPDebug.h> | |
43 | #include <libkern/c++/OSData.h> | |
44 | #include <libkern/c++/OSDictionary.h> | |
45 | #include <libkern/c++/OSEndianTypes.h> | |
46 | #include <libkern/c++/OSIterator.h> | |
47 | #include <libkern/c++/OSKext.h> | |
48 | #include <libkern/c++/OSLib.h> | |
49 | #include <libkern/c++/OSMetaClass.h> | |
50 | #include <libkern/c++/OSNumber.h> | |
51 | #include <libkern/c++/OSObject.h> | |
52 | #include <libkern/c++/OSOrderedSet.h> | |
53 | #include <libkern/c++/OSSerialize.h> | |
54 | #include <libkern/c++/OSSet.h> | |
55 | #include <libkern/c++/OSString.h> | |
56 | #include <libkern/c++/OSSymbol.h> | |
57 | #include <libkern/c++/OSUnserialize.h> | |
58 | #include <libkern/crypto/aes.h> | |
59 | #include <libkern/crypto/aesxts.h> | |
60 | #include <libkern/crypto/crypto_internal.h> | |
61 | #include <libkern/crypto/des.h> | |
62 | #include <libkern/crypto/md5.h> | |
63 | #include <libkern/crypto/register_crypto.h> | |
64 | #include <libkern/crypto/sha1.h> | |
65 | #include <libkern/crypto/sha2.h> | |
66 | #include <libkern/kernel_mach_header.h> | |
67 | #include <libkern/kext_request_keys.h> | |
68 | #include <libkern/kxld.h> | |
69 | #include <libkern/kxld_types.h> | |
70 | #include <libkern/locks.h> | |
71 | #include <libkern/mkext.h> | |
72 | #include <libkern/OSAtomic.h> | |
73 | #include <libkern/OSBase.h> | |
74 | #include <libkern/OSDebug.h> | |
75 | #include <libkern/OSKextLib.h> | |
76 | #include <libkern/OSKextLibPrivate.h> | |
77 | #include <libkern/OSMalloc.h> | |
78 | #include <libkern/OSReturn.h> | |
79 | #include <libkern/OSSerializeBinary.h> | |
80 | #include <libkern/OSTypes.h> | |
81 | #include <libkern/prelink.h> | |
82 | #include <libkern/stack_protector.h> | |
83 | #include <libkern/sysctl.h> | |
84 | #include <libkern/tree.h> | |
85 | #include <libkern/zconf.h> | |
86 | #include <libkern/zlib.h> | |
87 | ||
88 | #include <IOKit/AppleKeyStoreInterface.h> | |
89 | #include <IOKit/assert.h> | |
90 | #include <IOKit/IOBSD.h> | |
91 | #include <IOKit/IOBufferMemoryDescriptor.h> | |
92 | #include <IOKit/IOCatalogue.h> | |
93 | #include <IOKit/IOCommand.h> | |
94 | #include <IOKit/IOCommandGate.h> | |
95 | #include <IOKit/IOCommandPool.h> | |
96 | #include <IOKit/IOCommandQueue.h> | |
97 | #include <IOKit/IOConditionLock.h> | |
98 | #include <IOKit/IOCPU.h> | |
99 | //#include <IOKit/IODataQueue.h> | |
100 | #include <IOKit/IODataQueueShared.h> | |
101 | #include <IOKit/IODeviceMemory.h> | |
102 | #include <IOKit/IODeviceTreeSupport.h> | |
103 | #include <IOKit/IODMACommand.h> | |
104 | #include <IOKit/IODMAController.h> | |
105 | #include <IOKit/IODMAEventSource.h> | |
106 | #include <IOKit/IOEventSource.h> | |
107 | #include <IOKit/IOFilterInterruptEventSource.h> | |
108 | #include <IOKit/IOHibernatePrivate.h> | |
109 | #include <IOKit/IOInterleavedMemoryDescriptor.h> | |
110 | #include <IOKit/IOInterruptAccounting.h> | |
111 | #include <IOKit/IOInterruptAccountingPrivate.h> | |
112 | #include <IOKit/IOInterruptController.h> | |
113 | #include <IOKit/IOInterruptEventSource.h> | |
114 | #include <IOKit/IOInterrupts.h> | |
115 | #include <IOKit/IOKernelReporters.h> | |
116 | #include <IOKit/IOKernelReportStructs.h> | |
117 | #include <IOKit/IOKitDebug.h> | |
118 | #include <IOKit/IOKitDiagnosticsUserClient.h> | |
119 | #include <IOKit/IOKitKeys.h> | |
120 | #include <IOKit/IOKitKeysPrivate.h> | |
121 | #include <IOKit/IOKitServer.h> | |
122 | #include <IOKit/IOLib.h> | |
123 | #include <IOKit/IOLocks.h> | |
124 | #include <IOKit/IOLocksPrivate.h> | |
125 | #include <IOKit/IOMapper.h> | |
126 | #include <IOKit/IOMemoryCursor.h> | |
127 | #include <IOKit/IOMemoryDescriptor.h> | |
128 | #include <IOKit/IOMessage.h> | |
129 | #include <IOKit/IOMultiMemoryDescriptor.h> | |
130 | #include <IOKit/IONotifier.h> | |
131 | #include <IOKit/IONVRAM.h> | |
132 | #include <IOKit/IOPlatformExpert.h> | |
133 | #include <IOKit/IOPolledInterface.h> | |
134 | #include <IOKit/IORangeAllocator.h> | |
135 | #include <IOKit/IORegistryEntry.h> | |
136 | #include <IOKit/IOReportMacros.h> | |
137 | #include <IOKit/IOReportTypes.h> | |
138 | #include <IOKit/IOReturn.h> | |
139 | #include <IOKit/IOService.h> | |
140 | #include <IOKit/IOServicePM.h> | |
141 | #include <IOKit/IOSharedDataQueue.h> | |
142 | #include <IOKit/IOSharedLock.h> | |
143 | #include <IOKit/IOStatistics.h> | |
144 | #include <IOKit/IOStatisticsPrivate.h> | |
145 | #include <IOKit/IOSubMemoryDescriptor.h> | |
146 | #include <IOKit/IOSyncer.h> | |
147 | #include <IOKit/IOTimerEventSource.h> | |
148 | #include <IOKit/IOTimeStamp.h> | |
149 | #include <IOKit/IOTypes.h> | |
150 | #include <IOKit/IOUserClient.h> | |
151 | #include <IOKit/IOWorkLoop.h> | |
152 | #include <IOKit/nvram/IONVRAMController.h> | |
153 | #include <IOKit/OSMessageNotification.h> | |
154 | #include <IOKit/platform/AppleMacIO.h> | |
155 | #include <IOKit/platform/AppleMacIODevice.h> | |
156 | #include <IOKit/platform/AppleNMI.h> | |
157 | #include <IOKit/platform/ApplePlatformExpert.h> | |
158 | #include <IOKit/power/IOPwrController.h> | |
159 | #include <IOKit/pwr_mgt/IOPM.h> | |
160 | #include <IOKit/pwr_mgt/IOPMinformee.h> | |
161 | #include <IOKit/pwr_mgt/IOPMinformeeList.h> | |
162 | #include <IOKit/pwr_mgt/IOPMLibDefs.h> | |
163 | #include <IOKit/pwr_mgt/IOPMlog.h> | |
164 | #include <IOKit/pwr_mgt/IOPMPowerSource.h> | |
165 | #include <IOKit/pwr_mgt/IOPMPowerSourceList.h> | |
166 | #include <IOKit/pwr_mgt/IOPMpowerState.h> | |
167 | #include <IOKit/pwr_mgt/IOPMPrivate.h> | |
168 | #include <IOKit/pwr_mgt/IOPowerConnection.h> | |
169 | #include <IOKit/pwr_mgt/RootDomain.h> | |
170 | #include <IOKit/rtc/IORTCController.h> | |
171 | #include <IOKit/system.h> | |
172 | #include <IOKit/system_management/IOWatchDogTimer.h> | |
173 | ||
174 | #endif /* TEST_HEADERS */ | |
175 | ||
176 | #include <sys/sysctl.h> | |
177 | #include <libkern/c++/OSData.h> | |
178 | #include "Tests.h" | |
179 | ||
5ba3f43e A |
180 | #include <IOKit/IOTimerEventSource.h> |
181 | #include <IOKit/IOWorkLoop.h> | |
182 | ||
183 | #if DEVELOPMENT || DEBUG | |
184 | ||
185 | static uint64_t gIOWorkLoopTestDeadline; | |
186 | ||
187 | static void | |
188 | TESAction(OSObject * owner, IOTimerEventSource * tes) | |
189 | { | |
190 | if (mach_absolute_time() < gIOWorkLoopTestDeadline) tes->setTimeout(1, kMicrosecondScale); | |
191 | } | |
192 | ||
193 | static int | |
194 | IOWorkLoopTest(int newValue) | |
195 | { | |
196 | IOReturn err; | |
197 | uint32_t idx; | |
198 | IOWorkLoop * wl; | |
199 | IOTimerEventSource * tes; | |
200 | ||
201 | wl = IOWorkLoop::workLoop(); | |
202 | assert(wl); | |
203 | tes = IOTimerEventSource::timerEventSource(kIOTimerEventSourceOptionsPriorityWorkLoop, wl, &TESAction); | |
204 | assert(tes); | |
205 | err = wl->addEventSource(tes); | |
206 | assert(kIOReturnSuccess == err); | |
207 | clock_interval_to_deadline(2000, kMillisecondScale, &gIOWorkLoopTestDeadline); | |
208 | for (idx = 0; mach_absolute_time() < gIOWorkLoopTestDeadline; idx++) | |
209 | { | |
210 | tes->setTimeout(idx & 1023, kNanosecondScale); | |
211 | } | |
212 | tes->cancelTimeout(); | |
213 | wl->removeEventSource(tes); | |
214 | tes->release(); | |
215 | wl->release(); | |
216 | ||
217 | return (0); | |
218 | } | |
219 | ||
220 | #endif /* DEVELOPMENT || DEBUG */ | |
221 | ||
3e170ce0 A |
222 | static int |
223 | sysctl_iokittest(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req) | |
1c79356b | 224 | { |
3e170ce0 A |
225 | int error; |
226 | int newValue, changed; | |
227 | ||
228 | error = sysctl_io_number(req, 0, sizeof(int), &newValue, &changed); | |
229 | if (error) return (error); | |
230 | ||
231 | #if DEVELOPMENT || DEBUG | |
232 | if (changed && (999==newValue)) | |
233 | { | |
234 | OSData * data = OSData::withCapacity(16); | |
235 | data->release(); | |
236 | data->release(); | |
1c79356b A |
237 | } |
238 | ||
5ba3f43e A |
239 | if (changed && newValue) |
240 | { | |
241 | error = IOWorkLoopTest(newValue); | |
242 | assert(KERN_SUCCESS == error); | |
243 | error = IOMemoryDescriptorTest(newValue); | |
244 | assert(KERN_SUCCESS == error); | |
245 | } | |
3e170ce0 | 246 | #endif /* DEVELOPMENT || DEBUG */ |
1c79356b | 247 | |
3e170ce0 | 248 | return (error); |
1c79356b A |
249 | } |
250 | ||
3e170ce0 A |
251 | SYSCTL_PROC(_kern, OID_AUTO, iokittest, |
252 | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NOAUTO | CTLFLAG_KERN | CTLFLAG_LOCKED, | |
253 | 0, 0, sysctl_iokittest, "I", ""); | |
1c79356b | 254 | |
1c79356b | 255 |