xref: /xnu-8792.41.9/libkern/libkern/OSKextLibPrivate.h (revision 5c2921b07a2480ab43ec66f5b9e41cb872bc554f)
1*5c2921b0SApple OSS Distributions /*
2*5c2921b0SApple OSS Distributions  * Copyright (c) 1998-2000 Apple Inc. All rights reserved.
3*5c2921b0SApple OSS Distributions  *
4*5c2921b0SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*5c2921b0SApple OSS Distributions  *
6*5c2921b0SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*5c2921b0SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*5c2921b0SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*5c2921b0SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*5c2921b0SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*5c2921b0SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*5c2921b0SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*5c2921b0SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*5c2921b0SApple OSS Distributions  *
15*5c2921b0SApple OSS Distributions  * Please obtain a copy of the License at
16*5c2921b0SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*5c2921b0SApple OSS Distributions  *
18*5c2921b0SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*5c2921b0SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*5c2921b0SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*5c2921b0SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*5c2921b0SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*5c2921b0SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*5c2921b0SApple OSS Distributions  * limitations under the License.
25*5c2921b0SApple OSS Distributions  *
26*5c2921b0SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*5c2921b0SApple OSS Distributions  */
28*5c2921b0SApple OSS Distributions 
29*5c2921b0SApple OSS Distributions #ifndef _LIBKERN_OSKEXTLIBPRIVATE_H
30*5c2921b0SApple OSS Distributions #define _LIBKERN_OSKEXTLIBPRIVATE_H
31*5c2921b0SApple OSS Distributions 
32*5c2921b0SApple OSS Distributions 
33*5c2921b0SApple OSS Distributions #include <sys/cdefs.h>
34*5c2921b0SApple OSS Distributions 
35*5c2921b0SApple OSS Distributions __BEGIN_DECLS
36*5c2921b0SApple OSS Distributions 
37*5c2921b0SApple OSS Distributions #include <libkern/OSTypes.h>
38*5c2921b0SApple OSS Distributions #include <mach/kmod.h>
39*5c2921b0SApple OSS Distributions 
40*5c2921b0SApple OSS Distributions #ifdef KERNEL
41*5c2921b0SApple OSS Distributions #include <mach/vm_types.h>
42*5c2921b0SApple OSS Distributions #endif /* KERNEL */
43*5c2921b0SApple OSS Distributions 
44*5c2921b0SApple OSS Distributions __END_DECLS
45*5c2921b0SApple OSS Distributions 
46*5c2921b0SApple OSS Distributions #include <libkern/OSReturn.h>
47*5c2921b0SApple OSS Distributions 
48*5c2921b0SApple OSS Distributions __BEGIN_DECLS
49*5c2921b0SApple OSS Distributions 
50*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
51*5c2921b0SApple OSS Distributions #pragma mark -
52*5c2921b0SApple OSS Distributions /********************************************************************/
53*5c2921b0SApple OSS Distributions #pragma mark Misc Constants
54*5c2921b0SApple OSS Distributions /********************************************************************/
55*5c2921b0SApple OSS Distributions #endif
56*5c2921b0SApple OSS Distributions 
57*5c2921b0SApple OSS Distributions typedef uint8_t OSKextExcludeLevel;
58*5c2921b0SApple OSS Distributions #define kOSKextExcludeNone  (0)
59*5c2921b0SApple OSS Distributions #define kOSKextExcludeKext  (1)
60*5c2921b0SApple OSS Distributions #define kOSKextExcludeAll   (2)
61*5c2921b0SApple OSS Distributions 
62*5c2921b0SApple OSS Distributions #define kIOCatalogManagementEntitlement "com.apple.private.security.iocatalog-management"
63*5c2921b0SApple OSS Distributions #define kOSKextCollectionManagementEntitlement "com.apple.private.security.kext-collection-management"
64*5c2921b0SApple OSS Distributions #define kOSKextOnlyBootKCManagementEntitlement "com.apple.private.security.only-bootkc-management"
65*5c2921b0SApple OSS Distributions 
66*5c2921b0SApple OSS Distributions #define kOSKextCodelessKextLoadAddr (0x7FFFFFFFFFFFFFFFULL)
67*5c2921b0SApple OSS Distributions 
68*5c2921b0SApple OSS Distributions #if XNU_TARGET_OS_OSX
69*5c2921b0SApple OSS Distributions #define kIOKitDaemonName "kernelmanagerd"
70*5c2921b0SApple OSS Distributions #else
71*5c2921b0SApple OSS Distributions #define kIOKitDaemonName "driverkitd"
72*5c2921b0SApple OSS Distributions #endif /* XNU_TARGET_OS_OSX */
73*5c2921b0SApple OSS Distributions 
74*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
75*5c2921b0SApple OSS Distributions #pragma mark -
76*5c2921b0SApple OSS Distributions /********************************************************************/
77*5c2921b0SApple OSS Distributions #pragma mark Kext/OSBundle Property List Keys
78*5c2921b0SApple OSS Distributions /********************************************************************/
79*5c2921b0SApple OSS Distributions #endif
80*5c2921b0SApple OSS Distributions 
81*5c2921b0SApple OSS Distributions /*!
82*5c2921b0SApple OSS Distributions  * @define   kOSBundleHelperKey
83*5c2921b0SApple OSS Distributions  * @abstract Used by loginwindow.
84*5c2921b0SApple OSS Distributions  */
85*5c2921b0SApple OSS Distributions #define kOSBundleHelperKey      "OSBundleHelper"
86*5c2921b0SApple OSS Distributions 
87*5c2921b0SApple OSS Distributions /*!
88*5c2921b0SApple OSS Distributions  * @define   kOSBundleDeveloperOnlyKey
89*5c2921b0SApple OSS Distributions  * @abstract A boolean value indicating whether the kext should only load on
90*5c2921b0SApple OSS Distributions  *           Developer devices.
91*5c2921b0SApple OSS Distributions  */
92*5c2921b0SApple OSS Distributions #define kOSBundleDeveloperOnlyKey               "OSBundleDeveloperOnly"
93*5c2921b0SApple OSS Distributions 
94*5c2921b0SApple OSS Distributions /*!
95*5c2921b0SApple OSS Distributions  * @define   kOSBundleRamDiskOnlyKey
96*5c2921b0SApple OSS Distributions  * @abstract A boolean value indicating whether the kext should only load when
97*5c2921b0SApple OSS Distributions  *           booted from a ram disk.
98*5c2921b0SApple OSS Distributions  */
99*5c2921b0SApple OSS Distributions #define kOSBundleRamDiskOnlyKey         "OSBundleRamDiskOnly"
100*5c2921b0SApple OSS Distributions 
101*5c2921b0SApple OSS Distributions 
102*5c2921b0SApple OSS Distributions /*!
103*5c2921b0SApple OSS Distributions  * @define   kAppleSecurityExtensionKey
104*5c2921b0SApple OSS Distributions  * @abstract A boolean value indicating whether the kext registers
105*5c2921b0SApple OSS Distributions  *           MACF hooks.
106*5c2921b0SApple OSS Distributions  */
107*5c2921b0SApple OSS Distributions #define kAppleSecurityExtensionKey      "AppleSecurityExtension"
108*5c2921b0SApple OSS Distributions 
109*5c2921b0SApple OSS Distributions /*!
110*5c2921b0SApple OSS Distributions  * @define   kAppleKernelExternalComponentKey
111*5c2921b0SApple OSS Distributions  * @abstract A boolean value indicating whether the kext is vending kernel
112*5c2921b0SApple OSS Distributions  *           KPI, and needs special loading behavior.
113*5c2921b0SApple OSS Distributions  */
114*5c2921b0SApple OSS Distributions #define kAppleKernelExternalComponentKey        "AppleKernelExternalComponent"
115*5c2921b0SApple OSS Distributions 
116*5c2921b0SApple OSS Distributions /*!
117*5c2921b0SApple OSS Distributions  * @define kOSKextInfoPlistDigestKey
118*5c2921b0SApple OSS Distributions  * @abstract SHA-256 data of the kext's Info.plist
119*5c2921b0SApple OSS Distributions  */
120*5c2921b0SApple OSS Distributions #define kOSKextInfoPlistDigestKey       "_InfoPlistDigest"
121*5c2921b0SApple OSS Distributions 
122*5c2921b0SApple OSS Distributions /*!
123*5c2921b0SApple OSS Distributions  * @define kOSKextBundleCollectionTypeKey
124*5c2921b0SApple OSS Distributions  * @abstract The type of collection in which a kext is linked. Possible
125*5c2921b0SApple OSS Distributions  *           values: kKCTypePrimary, kKCTypeSystem, kKCTypeAuxiliary,
126*5c2921b0SApple OSS Distributions  *                   kKCTypeCodeless
127*5c2921b0SApple OSS Distributions  */
128*5c2921b0SApple OSS Distributions #define kOSKextBundleCollectionTypeKey  "_BundleCollectionType"
129*5c2921b0SApple OSS Distributions 
130*5c2921b0SApple OSS Distributions /*!
131*5c2921b0SApple OSS Distributions  * @define kOSKextAuxKCAvailabilityKey
132*5c2921b0SApple OSS Distributions  * @abstract boolean value: false if the kext is in the AuxKC and
133*5c2921b0SApple OSS Distributions  *           is not loadable; true otherwise.
134*5c2921b0SApple OSS Distributions  */
135*5c2921b0SApple OSS Distributions #define kOSKextAuxKCAvailabilityKey     "_AuxKCAvailability"
136*5c2921b0SApple OSS Distributions 
137*5c2921b0SApple OSS Distributions 
138*5c2921b0SApple OSS Distributions // properties found in the registry root
139*5c2921b0SApple OSS Distributions #define kOSKernelCPUTypeKey             "OSKernelCPUType"
140*5c2921b0SApple OSS Distributions #define kOSKernelCPUSubtypeKey          "OSKernelCPUSubtype"
141*5c2921b0SApple OSS Distributions #define kOSStartupMkextCRC              "OSStartupMkextCRC"             /* value is 32-bit OSData */
142*5c2921b0SApple OSS Distributions #define kOSPrelinkKextCountKey          "OSPrelinkKextCount"            /* value is 32-bit OSNumber */
143*5c2921b0SApple OSS Distributions #define kOSPrelinkPersonalityCountKey   "OSPrelinkPersonalityCount"     /* value is 32-bit OSNumber */
144*5c2921b0SApple OSS Distributions 
145*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
146*5c2921b0SApple OSS Distributions #pragma mark -
147*5c2921b0SApple OSS Distributions /********************************************************************/
148*5c2921b0SApple OSS Distributions #pragma mark Load Info Keys
149*5c2921b0SApple OSS Distributions /********************************************************************/
150*5c2921b0SApple OSS Distributions #endif
151*5c2921b0SApple OSS Distributions /*********************************************************************
152*5c2921b0SApple OSS Distributions * In addition to the keys defined here, you will find:
153*5c2921b0SApple OSS Distributions *   kCFBundleIdentifierKey
154*5c2921b0SApple OSS Distributions *   kCFBundleVersionKey
155*5c2921b0SApple OSS Distributions *   kOSBundleCompatibleVersionKey
156*5c2921b0SApple OSS Distributions *   kOSBundleIsInterfaceKey
157*5c2921b0SApple OSS Distributions *   kOSKernelResourceKey
158*5c2921b0SApple OSS Distributions *********************************************************************/
159*5c2921b0SApple OSS Distributions #define kOSBundleMachOHeadersKey                "OSBundleMachOHeaders"
160*5c2921b0SApple OSS Distributions #define kOSBundleLogStringsKey                  "OSBundleLogStrings"
161*5c2921b0SApple OSS Distributions #define kOSBundleCPUTypeKey                     "OSBundleCPUType"
162*5c2921b0SApple OSS Distributions #define kOSBundleCPUSubtypeKey                  "OSBundleCPUSubtype"
163*5c2921b0SApple OSS Distributions #define kOSBundlePathKey                        "OSBundlePath"
164*5c2921b0SApple OSS Distributions #define kOSBundleExecutablePathKey              "OSBundleExecutablePath"
165*5c2921b0SApple OSS Distributions #define kOSBundleUUIDKey                        "OSBundleUUID"
166*5c2921b0SApple OSS Distributions #define kOSBundleTextUUIDKey                    "OSBundleTextUUID"
167*5c2921b0SApple OSS Distributions #define kOSBundleStartedKey                     "OSBundleStarted"
168*5c2921b0SApple OSS Distributions #define kOSBundlePrelinkedKey                   "OSBundlePrelinked"
169*5c2921b0SApple OSS Distributions #define kOSBundleLoadTagKey                     "OSBundleLoadTag"
170*5c2921b0SApple OSS Distributions #define kOSBundleLoadAddressKey                 "OSBundleLoadAddress"
171*5c2921b0SApple OSS Distributions #define kOSBundleLoadSizeKey                    "OSBundleLoadSize"
172*5c2921b0SApple OSS Distributions #define kOSBundleExecLoadAddressKey             "OSBundleExecLoadAddress"
173*5c2921b0SApple OSS Distributions #define kOSBundleExecLoadSizeKey                "OSBundleExecLoadSize"
174*5c2921b0SApple OSS Distributions #define kOSBundleWiredSizeKey                   "OSBundleWiredSize"
175*5c2921b0SApple OSS Distributions #define kOSBundleDependenciesKey                "OSBundleDependencies"
176*5c2921b0SApple OSS Distributions #define kOSBundleRetainCountKey                 "OSBundleRetainCount"
177*5c2921b0SApple OSS Distributions #define kOSBundleCacheLoadAddressKey            "OSBundleCacheLoadAddress"
178*5c2921b0SApple OSS Distributions // Kernel TEXT encompasses kexts
179*5c2921b0SApple OSS Distributions #define kOSBundleKextsInKernelTextKey           "OSBundleKextsInKernelText"
180*5c2921b0SApple OSS Distributions // OSKextCopyLoadedKextInfo includes non-started kexts when present:
181*5c2921b0SApple OSS Distributions #define kOSBundleAllPrelinkedKey                "OSBundleAllPrelinked"
182*5c2921b0SApple OSS Distributions // OSKextCopyDextsInfo states:
183*5c2921b0SApple OSS Distributions #define kOSBundleDextStateKey                   "OSBundleDextState"
184*5c2921b0SApple OSS Distributions #define kOSBundleDextStateActiveKey             "OSBundleDextStateActive"
185*5c2921b0SApple OSS Distributions #define kOSBundleDextStateActiveLoadedKey       "OSBundleDextStateActiveLoaded"
186*5c2921b0SApple OSS Distributions #define kOSBundleDextStateActiveUnloadedKey     "OSBundleDextStateActiveUnloaded"
187*5c2921b0SApple OSS Distributions #define kOSBundleDextStatePendingUpgradeKey     "OSBundleDextStatePendingUpgrade"
188*5c2921b0SApple OSS Distributions 
189*5c2921b0SApple OSS Distributions 
190*5c2921b0SApple OSS Distributions /* Dictionary of metaclass info keyed by classname.
191*5c2921b0SApple OSS Distributions  */
192*5c2921b0SApple OSS Distributions #define kOSBundleClassesKey                     "OSBundleClasses"
193*5c2921b0SApple OSS Distributions 
194*5c2921b0SApple OSS Distributions #define kOSBundleDextUniqueIdentifierKey        "kOSBundleDextUniqueIdentifier"
195*5c2921b0SApple OSS Distributions /* These are contained in kOSBundleClassesKey. kOSMetaClassSuperclassNameKey
196*5c2921b0SApple OSS Distributions  * may be absent (for the root class).
197*5c2921b0SApple OSS Distributions  */
198*5c2921b0SApple OSS Distributions #define kOSMetaClassNameKey                     "OSMetaClassName"
199*5c2921b0SApple OSS Distributions #define kOSMetaClassSuperclassNameKey           "OSMetaClassSuperclassName"
200*5c2921b0SApple OSS Distributions #define kOSMetaClassTrackingCountKey            "OSMetaClassTrackingCount"
201*5c2921b0SApple OSS Distributions 
202*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
203*5c2921b0SApple OSS Distributions #pragma mark -
204*5c2921b0SApple OSS Distributions /********************************************************************/
205*5c2921b0SApple OSS Distributions #pragma mark Kext Collection Type Keys
206*5c2921b0SApple OSS Distributions /********************************************************************/
207*5c2921b0SApple OSS Distributions #endif
208*5c2921b0SApple OSS Distributions #define kKCTypePrimary   "Primary"
209*5c2921b0SApple OSS Distributions #define kKCTypeSystem    "System"
210*5c2921b0SApple OSS Distributions #define kKCTypeAuxiliary "Auxiliary"
211*5c2921b0SApple OSS Distributions #define kKCTypeCodeless  "Codeless"
212*5c2921b0SApple OSS Distributions #define kKCTypeAny       "Any"
213*5c2921b0SApple OSS Distributions 
214*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
215*5c2921b0SApple OSS Distributions #pragma mark -
216*5c2921b0SApple OSS Distributions /********************************************************************/
217*5c2921b0SApple OSS Distributions #pragma mark Kext Log Specification
218*5c2921b0SApple OSS Distributions /********************************************************************/
219*5c2921b0SApple OSS Distributions #endif
220*5c2921b0SApple OSS Distributions /*!
221*5c2921b0SApple OSS Distributions  * @group Kext Log Specification
222*5c2921b0SApple OSS Distributions  * Logging levels & flags for kernel extensions.
223*5c2921b0SApple OSS Distributions  * See <code>@link //apple_ref/c/tdef/OSKextLogSpec OSKextLogSpec@/link</code>
224*5c2921b0SApple OSS Distributions  * for an overview.
225*5c2921b0SApple OSS Distributions  */
226*5c2921b0SApple OSS Distributions 
227*5c2921b0SApple OSS Distributions /*!
228*5c2921b0SApple OSS Distributions  * @typedef  OSKextLogSpec
229*5c2921b0SApple OSS Distributions  * @abstract Describes what a log message applies to,
230*5c2921b0SApple OSS Distributions  *           or a filter that determines which log messages are displayed.
231*5c2921b0SApple OSS Distributions  *
232*5c2921b0SApple OSS Distributions  * @discussion
233*5c2921b0SApple OSS Distributions  * A kext log specification is a 32-bit value used as a desription of
234*5c2921b0SApple OSS Distributions  * what a given log message applies to, or as a filter
235*5c2921b0SApple OSS Distributions  * indicating which log messages are desired and which are not.
236*5c2921b0SApple OSS Distributions  * A log specification has three parts (described in detail shortly):
237*5c2921b0SApple OSS Distributions  * <ul>
238*5c2921b0SApple OSS Distributions  *   <li>A <b>level</b> from 0-7 in the lowest-order nibble (0x7).</li>
239*5c2921b0SApple OSS Distributions  *   <li>A flag bit in the lowest-order nibble (0x8) indicating whether
240*5c2921b0SApple OSS Distributions  *       log messages tied to individual kexts are always printed (1)
241*5c2921b0SApple OSS Distributions  *       or printed only if the kext has an
242*5c2921b0SApple OSS Distributions  *       @link //apple_ref/c/macro/kOSBundleEnableKextLoggingKey
243*5c2921b0SApple OSS Distributions  *       OSBundleEnableKextLogging@/link set to <code>true</code>.
244*5c2921b0SApple OSS Distributions  *   <li>A set of <b>activity flags</b> in the remaining nibbles (0xFFFFFFF0),
245*5c2921b0SApple OSS Distributions  *       which describe areas of activity related to kernel extensions.</li>
246*5c2921b0SApple OSS Distributions  * </ul>
247*5c2921b0SApple OSS Distributions  *
248*5c2921b0SApple OSS Distributions  * You can specify a log spec to most of the kext tools with the -v option
249*5c2921b0SApple OSS Distributions  * and a hex number (rather than the escalating decimal levels 0-6).
250*5c2921b0SApple OSS Distributions  * You can also specify a log spec to the kernel with the "kextlog" boot arg
251*5c2921b0SApple OSS Distributions  * or "debug.kextlog" sysctl.
252*5c2921b0SApple OSS Distributions  *
253*5c2921b0SApple OSS Distributions  * <b>Log Levels</b>
254*5c2921b0SApple OSS Distributions  *
255*5c2921b0SApple OSS Distributions  * The log level spans a range from silent (no log messages)
256*5c2921b0SApple OSS Distributions  * to debuging information:
257*5c2921b0SApple OSS Distributions  *
258*5c2921b0SApple OSS Distributions  * <ol start="0">
259*5c2921b0SApple OSS Distributions  * <li>Silent - Not applicable to messages; as a filter, do not print any log messages.</li>
260*5c2921b0SApple OSS Distributions  * <li>Errors - Log message is an error.
261*5c2921b0SApple OSS Distributions  * <li>Warnings - Log message is a warning.
262*5c2921b0SApple OSS Distributions  * <li>Basic information - Log message is basic success/failure.</li>
263*5c2921b0SApple OSS Distributions  * <li>Progress - Provides high-level information about stages in processing.</li>
264*5c2921b0SApple OSS Distributions  * <li>Step - Provides low-level information about complex operations,
265*5c2921b0SApple OSS Distributions  *          typically about individual kexts.</li>
266*5c2921b0SApple OSS Distributions  * <li>Detail - Provides very low-level information about parts of kexts,
267*5c2921b0SApple OSS Distributions  *          including individual Libkern classes and operations on bundle files.</li>
268*5c2921b0SApple OSS Distributions  * <li>Debug - Very verbose logging about internal activities.</li>
269*5c2921b0SApple OSS Distributions  * </ol>
270*5c2921b0SApple OSS Distributions  *
271*5c2921b0SApple OSS Distributions  * Log messages at
272*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogErrorLevel kOSKextLogErrorLevel@/link</code> or
273*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogWarningLevel kOSKextLogWarningLevel@/link</code>
274*5c2921b0SApple OSS Distributions  * ignore activity flags and the
275*5c2921b0SApple OSS Distributions  * @link //apple_ref/c/macro/kOSBundleEnableKextLoggingKey
276*5c2921b0SApple OSS Distributions  * OSBundleEnableKextLogging@/link property;
277*5c2921b0SApple OSS Distributions  * that is, only the filter level is checked for messages at these levels.
278*5c2921b0SApple OSS Distributions  * Log messages at levels above
279*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogWarningLevel kOSKextLogWarningLevel@/link</code>
280*5c2921b0SApple OSS Distributions  * are filtered according both to the activity flags in the current filter
281*5c2921b0SApple OSS Distributions  * and to whether the log message is associated with a kext or not.
282*5c2921b0SApple OSS Distributions  * Normally log messages associated with kexts are not printed
283*5c2921b0SApple OSS Distributions  * unless the kext has a
284*5c2921b0SApple OSS Distributions  * @link //apple_ref/c/macro/kOSBundleEnableKextLoggingKey
285*5c2921b0SApple OSS Distributions  * OSBundleEnableKextLogging@/link property set to <code>true</code>.
286*5c2921b0SApple OSS Distributions  * If you set the high-order bit of the log level (that is, add 8 to the level),
287*5c2921b0SApple OSS Distributions  * then all kext-specific log messages matching the activity flags are printed.
288*5c2921b0SApple OSS Distributions  * This can be very verbose.
289*5c2921b0SApple OSS Distributions  *
290*5c2921b0SApple OSS Distributions  * <b>Activity Flags</b>
291*5c2921b0SApple OSS Distributions  *
292*5c2921b0SApple OSS Distributions  * Each flag governs a category of activity,
293*5c2921b0SApple OSS Distributions  * such as loading, IPC, or archives; by combining them with bitwise OR,
294*5c2921b0SApple OSS Distributions  * you can choose which messages you wish to see (or when logging messages,
295*5c2921b0SApple OSS Distributions  * which bit flags select your message).
296*5c2921b0SApple OSS Distributions  *
297*5c2921b0SApple OSS Distributions  * <b>Byte 1:</b> <code>0xF0</code> - Basic activities
298*5c2921b0SApple OSS Distributions  * (<code>@link kOSKextLogGeneralFlag kOSKextLogGeneralFlag@/link</code>,
299*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogLoadFlag kOSKextLogLoadFlag@/link</code>, and
300*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogArchiveFlag kOSKextLogArchiveFlag@/link</code>).
301*5c2921b0SApple OSS Distributions  *
302*5c2921b0SApple OSS Distributions  * <b>Byte 2:</b> <code>0xF00</code> - Reserved.
303*5c2921b0SApple OSS Distributions  *
304*5c2921b0SApple OSS Distributions  * <b>Byte 4:</b> <code>0xF000</code> - Kext diagnostics
305*5c2921b0SApple OSS Distributions  * (<code>@link kOSKextLogValidationFlag kOSKextLogValidationFlag@/link</code>,
306*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogAuthenticationFlag kOSKextLogAuthenticationFlag@/link</code>, and
307*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogDependenciesFlag kOSKextLogDependenciesFlag@/link</code>).
308*5c2921b0SApple OSS Distributions  *
309*5c2921b0SApple OSS Distributions  * <b>Byte 5:</b> <code>0xF00000</code> - Kext access & bookkeeping
310*5c2921b0SApple OSS Distributions  * (<code>@link kOSKextLogDirectoryScanFlag kOSKextLogDirectoryScanFlag@/link</code>,
311*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogFileAccessFlag kOSKextLogFileAccessFlag@/link</code>,
312*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogKextBookkeepingFlag kOSKextLogKextBookkeepingFlag@/link </code>).
313*5c2921b0SApple OSS Distributions  *
314*5c2921b0SApple OSS Distributions  * <b>Byte 6:</b> <code>0xF000000</code> - Linking & patching
315*5c2921b0SApple OSS Distributions  * (<code>@link kOSKextLogLinkFlag kOSKextLogLinkFlag@/link</code> and
316*5c2921b0SApple OSS Distributions  * <code>@link kOSKextLogPatchFlag kOSKextLogPatchFlag@/link</code>).
317*5c2921b0SApple OSS Distributions  *
318*5c2921b0SApple OSS Distributions  * <b>Byte 7:</b> <code>0xF0000000</code> - Reserved.
319*5c2921b0SApple OSS Distributions  */
320*5c2921b0SApple OSS Distributions typedef uint32_t OSKextLogSpec;
321*5c2921b0SApple OSS Distributions 
322*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
323*5c2921b0SApple OSS Distributions /********************************************************************/
324*5c2921b0SApple OSS Distributions #pragma mark Masks
325*5c2921b0SApple OSS Distributions /********************************************************************/
326*5c2921b0SApple OSS Distributions #endif
327*5c2921b0SApple OSS Distributions /*!
328*5c2921b0SApple OSS Distributions  * @define   kOSKextLogLevelMask
329*5c2921b0SApple OSS Distributions  * @abstract Masks the bottom 3 bits of an
330*5c2921b0SApple OSS Distributions  *           <code>@link OSKextLogSpec OSKextLogSpec@/link</code> to extract
331*5c2921b0SApple OSS Distributions  *           the raw level.
332*5c2921b0SApple OSS Distributions  */
333*5c2921b0SApple OSS Distributions #define kOSKextLogLevelMask              ((OSKextLogSpec) 0x00000007)
334*5c2921b0SApple OSS Distributions 
335*5c2921b0SApple OSS Distributions /*!
336*5c2921b0SApple OSS Distributions  * @define   kOSKextLogKextOrGlobalMask
337*5c2921b0SApple OSS Distributions  * @abstract Determines whether per-kext log messages are output.
338*5c2921b0SApple OSS Distributions  *
339*5c2921b0SApple OSS Distributions  * @discussion
340*5c2921b0SApple OSS Distributions  * In filter specifications, if unset (the usual default),
341*5c2921b0SApple OSS Distributions  * then log messages associated with a kext are only output
342*5c2921b0SApple OSS Distributions  * if the kext has an
343*5c2921b0SApple OSS Distributions  * @link //apple_ref/c/macro/kOSBundleEnableKextLoggingKey
344*5c2921b0SApple OSS Distributions  * OSBundleEnableKextLogging@/link
345*5c2921b0SApple OSS Distributions  * property set to <code>true</code>.
346*5c2921b0SApple OSS Distributions  * If set, then all log messages associated with kexts
347*5c2921b0SApple OSS Distributions  * are output.
348*5c2921b0SApple OSS Distributions  *
349*5c2921b0SApple OSS Distributions  * In message specifications, if set it indicates that the message is either
350*5c2921b0SApple OSS Distributions  * not associated with a kext, or is associated with a kext that has an
351*5c2921b0SApple OSS Distributions  * @link //apple_ref/c/macro/kOSBundleEnableKextLoggingKey
352*5c2921b0SApple OSS Distributions  * OSBundleEnableKextLogging@/link
353*5c2921b0SApple OSS Distributions  * property set to <code>true</code>.
354*5c2921b0SApple OSS Distributions  */
355*5c2921b0SApple OSS Distributions #define kOSKextLogKextOrGlobalMask       ((OSKextLogSpec) 0x00000008)
356*5c2921b0SApple OSS Distributions 
357*5c2921b0SApple OSS Distributions 
358*5c2921b0SApple OSS Distributions /*!
359*5c2921b0SApple OSS Distributions  * @define   kOSKextLogFlagsMask
360*5c2921b0SApple OSS Distributions  * @abstract Masks the flag bits of an
361*5c2921b0SApple OSS Distributions  *           <code>@link OSKextLogSpec OSKextLogSpec@/link</code>.
362*5c2921b0SApple OSS Distributions  */
363*5c2921b0SApple OSS Distributions #define kOSKextLogFlagsMask              ((OSKextLogSpec) 0x0ffffff0)
364*5c2921b0SApple OSS Distributions 
365*5c2921b0SApple OSS Distributions /*!
366*5c2921b0SApple OSS Distributions  * @define   kOSKextLogFlagsMask
367*5c2921b0SApple OSS Distributions  * @abstract Masks the flag bits of an
368*5c2921b0SApple OSS Distributions  *           <code>@link OSKextLogSpec OSKextLogSpec@/link</code>
369*5c2921b0SApple OSS Distributions  *           to which command-line <code>-v</code> levels apply.
370*5c2921b0SApple OSS Distributions  */
371*5c2921b0SApple OSS Distributions #define kOSKextLogVerboseFlagsMask       ((OSKextLogSpec) 0x00000ff0)
372*5c2921b0SApple OSS Distributions 
373*5c2921b0SApple OSS Distributions /*!
374*5c2921b0SApple OSS Distributions  * @define   kOSKextLogConfigMask
375*5c2921b0SApple OSS Distributions  * @abstract Masks the config bits of an
376*5c2921b0SApple OSS Distributions  *           <code>@link OSKextLogSpec OSKextLogSpec@/link</code>.
377*5c2921b0SApple OSS Distributions  */
378*5c2921b0SApple OSS Distributions #define kOSKextLogConfigMask             ((OSKextLogSpec) 0xf0000000)
379*5c2921b0SApple OSS Distributions 
380*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
381*5c2921b0SApple OSS Distributions /********************************************************************/
382*5c2921b0SApple OSS Distributions #pragma mark 0xF - Log Level
383*5c2921b0SApple OSS Distributions /********************************************************************/
384*5c2921b0SApple OSS Distributions #endif
385*5c2921b0SApple OSS Distributions 
386*5c2921b0SApple OSS Distributions /*!
387*5c2921b0SApple OSS Distributions  * @define   kOSKextLogExplicitLevel
388*5c2921b0SApple OSS Distributions  * @abstract Used when logging a message to overrides the current log filter,
389*5c2921b0SApple OSS Distributions  *           even if it's set to silent for log messages.
390*5c2921b0SApple OSS Distributions  *           This is essentially a pass-through for
391*5c2921b0SApple OSS Distributions  *           unconditional print messages to go
392*5c2921b0SApple OSS Distributions  *           through the logging engine.
393*5c2921b0SApple OSS Distributions  */
394*5c2921b0SApple OSS Distributions #define kOSKextLogExplicitLevel          ((OSKextLogSpec)        0x0)
395*5c2921b0SApple OSS Distributions 
396*5c2921b0SApple OSS Distributions /*!
397*5c2921b0SApple OSS Distributions  * @define   kOSKextLogErrorLevel
398*5c2921b0SApple OSS Distributions  * @abstract Log messages concerning error conditions in any category.
399*5c2921b0SApple OSS Distributions  */
400*5c2921b0SApple OSS Distributions #define kOSKextLogErrorLevel            ((OSKextLogSpec)        0x1)
401*5c2921b0SApple OSS Distributions 
402*5c2921b0SApple OSS Distributions 
403*5c2921b0SApple OSS Distributions /*!
404*5c2921b0SApple OSS Distributions  * @define   kOSKextLogWarningLevel
405*5c2921b0SApple OSS Distributions  * @abstract Log messages concerning warning conditions in any category,
406*5c2921b0SApple OSS Distributions  *           which indicate potential error conditions,
407*5c2921b0SApple OSS Distributions  *           and notices, which may explain unexpected but correct behavior.
408*5c2921b0SApple OSS Distributions  */
409*5c2921b0SApple OSS Distributions #define kOSKextLogWarningLevel          ((OSKextLogSpec)        0x2)
410*5c2921b0SApple OSS Distributions 
411*5c2921b0SApple OSS Distributions 
412*5c2921b0SApple OSS Distributions /*!
413*5c2921b0SApple OSS Distributions  * @define   kOSKextLogBasicLevel
414*5c2921b0SApple OSS Distributions  * @abstract Log messages concerning top-level outcome in any category
415*5c2921b0SApple OSS Distributions  *           (kext load/unload, kext cache creation/extration w/# kexts).
416*5c2921b0SApple OSS Distributions  */
417*5c2921b0SApple OSS Distributions #define kOSKextLogBasicLevel           ((OSKextLogSpec)        0x3)
418*5c2921b0SApple OSS Distributions 
419*5c2921b0SApple OSS Distributions 
420*5c2921b0SApple OSS Distributions /*!
421*5c2921b0SApple OSS Distributions  * @define   kOSKextLogProgressLevel
422*5c2921b0SApple OSS Distributions  * @abstract Log messages concerning high-level progress in any category,
423*5c2921b0SApple OSS Distributions  *           such as sending a load request to the kernel,
424*5c2921b0SApple OSS Distributions  *           allocation/link/map/start (load operation),
425*5c2921b0SApple OSS Distributions  *           stop/unmap (unload operation), kext added/extracted (archive).
426*5c2921b0SApple OSS Distributions  */
427*5c2921b0SApple OSS Distributions #define kOSKextLogProgressLevel          ((OSKextLogSpec)        0x4)
428*5c2921b0SApple OSS Distributions 
429*5c2921b0SApple OSS Distributions 
430*5c2921b0SApple OSS Distributions /*!
431*5c2921b0SApple OSS Distributions  * @define   kOSKextLogStepLevel
432*5c2921b0SApple OSS Distributions  * @abstract Log messages concerning major steps in any category,
433*5c2921b0SApple OSS Distributions  *           such as sending personalities to the IOCatalogue when loading,
434*5c2921b0SApple OSS Distributions  *           detailed IPC with the kernel, or filtering of kexts for an archive.
435*5c2921b0SApple OSS Distributions  */
436*5c2921b0SApple OSS Distributions #define kOSKextLogStepLevel             ((OSKextLogSpec)        0x5)
437*5c2921b0SApple OSS Distributions 
438*5c2921b0SApple OSS Distributions 
439*5c2921b0SApple OSS Distributions /*!
440*5c2921b0SApple OSS Distributions  * @define   kOSKextLogDetailLevel
441*5c2921b0SApple OSS Distributions  * @abstract Log messages concerning specific details in any category,
442*5c2921b0SApple OSS Distributions  *           such as classes being registered/unregistered or
443*5c2921b0SApple OSS Distributions  *           operations on indivdual files in a kext.
444*5c2921b0SApple OSS Distributions  */
445*5c2921b0SApple OSS Distributions #define kOSKextLogDetailLevel           ((OSKextLogSpec)        0x6)
446*5c2921b0SApple OSS Distributions 
447*5c2921b0SApple OSS Distributions 
448*5c2921b0SApple OSS Distributions /*!
449*5c2921b0SApple OSS Distributions  * @define   kOSKextLogDebugLevel
450*5c2921b0SApple OSS Distributions  * @abstract Log messages concerning very low-level actions that are
451*5c2921b0SApple OSS Distributions  *           useful mainly for debugging the kext system itself.
452*5c2921b0SApple OSS Distributions  */
453*5c2921b0SApple OSS Distributions #define kOSKextLogDebugLevel             ((OSKextLogSpec)        0x7)
454*5c2921b0SApple OSS Distributions 
455*5c2921b0SApple OSS Distributions 
456*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
457*5c2921b0SApple OSS Distributions /********************************************************************/
458*5c2921b0SApple OSS Distributions #pragma mark 0xF0 - General Activity, Load, Kernel IPC, Personalities
459*5c2921b0SApple OSS Distributions /********************************************************************/
460*5c2921b0SApple OSS Distributions #endif
461*5c2921b0SApple OSS Distributions 
462*5c2921b0SApple OSS Distributions /*!
463*5c2921b0SApple OSS Distributions  * @define   kOSKextLogGeneralFlag
464*5c2921b0SApple OSS Distributions  * @abstract Log messages about general activity in the kext system.
465*5c2921b0SApple OSS Distributions  */
466*5c2921b0SApple OSS Distributions #define kOSKextLogGeneralFlag            ((OSKextLogSpec)       0x10)
467*5c2921b0SApple OSS Distributions 
468*5c2921b0SApple OSS Distributions /*!
469*5c2921b0SApple OSS Distributions  * @define   kOSKextLogLoadFlag
470*5c2921b0SApple OSS Distributions  * @abstract Log messages regarding kernel extension load, start/stop, or unload activity
471*5c2921b0SApple OSS Distributions  *           in the kernel.
472*5c2921b0SApple OSS Distributions  */
473*5c2921b0SApple OSS Distributions #define kOSKextLogLoadFlag               ((OSKextLogSpec)       0x20)
474*5c2921b0SApple OSS Distributions 
475*5c2921b0SApple OSS Distributions /*!
476*5c2921b0SApple OSS Distributions  * @define   kOSKextLogIPCFlag
477*5c2921b0SApple OSS Distributions  * @abstract Log messages about any interaction between kernel and user space
478*5c2921b0SApple OSS Distributions  *           regarding kernel extensions.
479*5c2921b0SApple OSS Distributions  */
480*5c2921b0SApple OSS Distributions #define kOSKextLogIPCFlag                ((OSKextLogSpec)       0x40)
481*5c2921b0SApple OSS Distributions 
482*5c2921b0SApple OSS Distributions /*!
483*5c2921b0SApple OSS Distributions  * @define   kOSKextLogArchiveFlag
484*5c2921b0SApple OSS Distributions  * @abstract Log messages about creating or processing a kext startup cache file
485*5c2921b0SApple OSS Distributions  *           (mkext or prelinked kernel).
486*5c2921b0SApple OSS Distributions  */
487*5c2921b0SApple OSS Distributions #define kOSKextLogArchiveFlag           ((OSKextLogSpec)       0x80)
488*5c2921b0SApple OSS Distributions 
489*5c2921b0SApple OSS Distributions 
490*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
491*5c2921b0SApple OSS Distributions /********************************************************************/
492*5c2921b0SApple OSS Distributions #pragma mark 0xF00 - Reserved Verbose Area
493*5c2921b0SApple OSS Distributions /********************************************************************/
494*5c2921b0SApple OSS Distributions #endif
495*5c2921b0SApple OSS Distributions // reserved slot for group               ((OSKextLogSpec)      0x100)
496*5c2921b0SApple OSS Distributions // reserved slot for group               ((OSKextLogSpec)      0x200)
497*5c2921b0SApple OSS Distributions // reserved slot for group               ((OSKextLogSpec)      0x400)
498*5c2921b0SApple OSS Distributions // reserved slot for group               ((OSKextLogSpec)      0x800)
499*5c2921b0SApple OSS Distributions 
500*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
501*5c2921b0SApple OSS Distributions /********************************************************************/
502*5c2921b0SApple OSS Distributions #pragma mark 0xF000 - Kext diagnostic activity
503*5c2921b0SApple OSS Distributions /********************************************************************/
504*5c2921b0SApple OSS Distributions #endif
505*5c2921b0SApple OSS Distributions 
506*5c2921b0SApple OSS Distributions /*!
507*5c2921b0SApple OSS Distributions  * @define   kOSKextLogValidationFlag
508*5c2921b0SApple OSS Distributions  * @abstract Log messages when validating kernel extensions.
509*5c2921b0SApple OSS Distributions  */
510*5c2921b0SApple OSS Distributions #define kOSKextLogValidationFlag         ((OSKextLogSpec)     0x1000)
511*5c2921b0SApple OSS Distributions 
512*5c2921b0SApple OSS Distributions /*!
513*5c2921b0SApple OSS Distributions  * @define   kOSKextLogAuthenticationFlag
514*5c2921b0SApple OSS Distributions  * @abstract Log messages when autnenticating kernel extension files.
515*5c2921b0SApple OSS Distributions  *           Irrelevant in the kernel.
516*5c2921b0SApple OSS Distributions  */
517*5c2921b0SApple OSS Distributions #define kOSKextLogAuthenticationFlag     ((OSKextLogSpec)     0x2000)
518*5c2921b0SApple OSS Distributions 
519*5c2921b0SApple OSS Distributions /*!
520*5c2921b0SApple OSS Distributions  * @define   kOSKextLogDependenciesFlag
521*5c2921b0SApple OSS Distributions  * @abstract Log messages when resolving dependencies for a kernel extension.
522*5c2921b0SApple OSS Distributions  */
523*5c2921b0SApple OSS Distributions #define kOSKextLogDependenciesFlag       ((OSKextLogSpec)     0x4000)
524*5c2921b0SApple OSS Distributions 
525*5c2921b0SApple OSS Distributions // reserved slot for group               ((OSKextLogSpec)     0x8000)
526*5c2921b0SApple OSS Distributions 
527*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
528*5c2921b0SApple OSS Distributions /********************************************************************/
529*5c2921b0SApple OSS Distributions #pragma mark 0xF0000 - Archives, caches, directory scan, file access
530*5c2921b0SApple OSS Distributions /********************************************************************/
531*5c2921b0SApple OSS Distributions #endif
532*5c2921b0SApple OSS Distributions 
533*5c2921b0SApple OSS Distributions /*!
534*5c2921b0SApple OSS Distributions  * @define   kOSKextLogDirectoryScanFlag
535*5c2921b0SApple OSS Distributions  * @abstract Log messages when scanning directories for kernel extensions.
536*5c2921b0SApple OSS Distributions  *           In the kernel logs every booter kext entry processed.
537*5c2921b0SApple OSS Distributions  */
538*5c2921b0SApple OSS Distributions #define kOSKextLogDirectoryScanFlag      ((OSKextLogSpec)    0x10000)
539*5c2921b0SApple OSS Distributions 
540*5c2921b0SApple OSS Distributions /*!
541*5c2921b0SApple OSS Distributions  * @define   kOSKextLogFileAccessFlag
542*5c2921b0SApple OSS Distributions  * @abstract Log messages when performing any filesystem access (very verbose).
543*5c2921b0SApple OSS Distributions  *           Irrelevant in the kernel.
544*5c2921b0SApple OSS Distributions  */
545*5c2921b0SApple OSS Distributions #define kOSKextLogFileAccessFlag         ((OSKextLogSpec)    0x20000)
546*5c2921b0SApple OSS Distributions 
547*5c2921b0SApple OSS Distributions /*!
548*5c2921b0SApple OSS Distributions  * @define   kOSKextLogKextBookkeepingFlag
549*5c2921b0SApple OSS Distributions  * @abstract Log messages about internal tracking of kexts. Can be very verbose.
550*5c2921b0SApple OSS Distributions  */
551*5c2921b0SApple OSS Distributions #define kOSKextLogKextBookkeepingFlag    ((OSKextLogSpec)    0x40000)
552*5c2921b0SApple OSS Distributions 
553*5c2921b0SApple OSS Distributions // reserved slot for group               ((OSKextLogSpec)    0x80000)
554*5c2921b0SApple OSS Distributions 
555*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
556*5c2921b0SApple OSS Distributions /********************************************************************/
557*5c2921b0SApple OSS Distributions #pragma mark 0xF00000 - Linking & Patching
558*5c2921b0SApple OSS Distributions /********************************************************************/
559*5c2921b0SApple OSS Distributions #endif
560*5c2921b0SApple OSS Distributions 
561*5c2921b0SApple OSS Distributions /*!
562*5c2921b0SApple OSS Distributions  * @define   kOSKextLogLinkFlag
563*5c2921b0SApple OSS Distributions  * @abstract Log messages about linking.
564*5c2921b0SApple OSS Distributions  */
565*5c2921b0SApple OSS Distributions #define kOSKextLogLinkFlag               ((OSKextLogSpec)   0x100000)
566*5c2921b0SApple OSS Distributions 
567*5c2921b0SApple OSS Distributions /*!
568*5c2921b0SApple OSS Distributions  * @define   kOSKextLogPatchFlag
569*5c2921b0SApple OSS Distributions  * @abstract Log messages about patching.
570*5c2921b0SApple OSS Distributions  */
571*5c2921b0SApple OSS Distributions #define kOSKextLogPatchFlag              ((OSKextLogSpec)   0x200000)
572*5c2921b0SApple OSS Distributions 
573*5c2921b0SApple OSS Distributions // reserved slot for group               ((OSKextLogSpec)   0x400000)
574*5c2921b0SApple OSS Distributions // reserved slot for group               ((OSKextLogSpec)   0x800000)
575*5c2921b0SApple OSS Distributions 
576*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
577*5c2921b0SApple OSS Distributions /********************************************************************/
578*5c2921b0SApple OSS Distributions #pragma mark 0xF000000 - Reserved
579*5c2921b0SApple OSS Distributions /********************************************************************/
580*5c2921b0SApple OSS Distributions #endif
581*5c2921b0SApple OSS Distributions 
582*5c2921b0SApple OSS Distributions // reserved slot for grouping            ((OSKextLogSpec)  0x1000000)
583*5c2921b0SApple OSS Distributions // reserved slot for grouping            ((OSKextLogSpec)  0x2000000)
584*5c2921b0SApple OSS Distributions // reserved slot for grouping            ((OSKextLogSpec)  0x4000000)
585*5c2921b0SApple OSS Distributions // reserved slot for grouping            ((OSKextLogSpec)  0x8000000)
586*5c2921b0SApple OSS Distributions 
587*5c2921b0SApple OSS Distributions 
588*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
589*5c2921b0SApple OSS Distributions /********************************************************************/
590*5c2921b0SApple OSS Distributions #pragma mark 0xF0000000 - Config Flags
591*5c2921b0SApple OSS Distributions /********************************************************************/
592*5c2921b0SApple OSS Distributions #endif
593*5c2921b0SApple OSS Distributions 
594*5c2921b0SApple OSS Distributions // reserved slot for grouping            ((OSKextLogSpec) 0x10000000)
595*5c2921b0SApple OSS Distributions // reserved slot for grouping            ((OSKextLogSpec) 0x20000000)
596*5c2921b0SApple OSS Distributions // reserved slot for grouping            ((OSKextLogSpec) 0x40000000)
597*5c2921b0SApple OSS Distributions 
598*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
599*5c2921b0SApple OSS Distributions /********************************************************************/
600*5c2921b0SApple OSS Distributions #pragma mark Predefined Specifications
601*5c2921b0SApple OSS Distributions /********************************************************************/
602*5c2921b0SApple OSS Distributions #endif
603*5c2921b0SApple OSS Distributions 
604*5c2921b0SApple OSS Distributions /*!
605*5c2921b0SApple OSS Distributions  * @define   kOSKextLogSilentFilter
606*5c2921b0SApple OSS Distributions  * @abstract For use in filter specs:
607*5c2921b0SApple OSS Distributions  *           Ignore all log messages with a log level greater than
608*5c2921b0SApple OSS Distributions  *           <code>@link kOSKextLogExplicitLevel kOSKextLogExplicitLevel@/link</code>.
609*5c2921b0SApple OSS Distributions  */
610*5c2921b0SApple OSS Distributions #define kOSKextLogSilentFilter           ((OSKextLogSpec)        0x0)
611*5c2921b0SApple OSS Distributions 
612*5c2921b0SApple OSS Distributions /*!
613*5c2921b0SApple OSS Distributions  * @define   kOSKextLogShowAllFilter
614*5c2921b0SApple OSS Distributions  * @abstract For use in filter specs:
615*5c2921b0SApple OSS Distributions  *           Print all log messages not associated with a kext or
616*5c2921b0SApple OSS Distributions  *           associated with a kext that has
617*5c2921b0SApple OSS Distributions  *           @link //apple_ref/c/macro/kOSBundleEnableKextLoggingKey
618*5c2921b0SApple OSS Distributions  *           OSBundleEnableKextLogging@/link
619*5c2921b0SApple OSS Distributions  *           set to <code>true</code>.
620*5c2921b0SApple OSS Distributions  */
621*5c2921b0SApple OSS Distributions #define kOSKextLogShowAllFilter          ((OSKextLogSpec) 0x0ffffff7)
622*5c2921b0SApple OSS Distributions 
623*5c2921b0SApple OSS Distributions /*!
624*5c2921b0SApple OSS Distributions  * @define   kOSKextLogShowAllKextsFilter
625*5c2921b0SApple OSS Distributions  * @abstract For use in filter specs:
626*5c2921b0SApple OSS Distributions  *           Print all log messages has
627*5c2921b0SApple OSS Distributions  *           @link //apple_ref/c/macro/kOSBundleEnableKextLoggingKey
628*5c2921b0SApple OSS Distributions  *           OSBundleEnableKextLogging@/link
629*5c2921b0SApple OSS Distributions  *           set to <code>true</code>.
630*5c2921b0SApple OSS Distributions  */
631*5c2921b0SApple OSS Distributions #define kOSKextLogShowAllKextsFilter     ((OSKextLogSpec) \
632*5c2921b0SApple OSS Distributions 	                                   (kOSKextLogShowAllFilter | \
633*5c2921b0SApple OSS Distributions 	                                    kOSKextLogKextOrGlobalMask))
634*5c2921b0SApple OSS Distributions 
635*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
636*5c2921b0SApple OSS Distributions #pragma mark -
637*5c2921b0SApple OSS Distributions /********************************************************************/
638*5c2921b0SApple OSS Distributions #pragma mark Kext Version String Processing
639*5c2921b0SApple OSS Distributions /********************************************************************/
640*5c2921b0SApple OSS Distributions #endif
641*5c2921b0SApple OSS Distributions /*!
642*5c2921b0SApple OSS Distributions  * @group Kext Version String Processing
643*5c2921b0SApple OSS Distributions  * Functions for working with kext versions and compatible versions.
644*5c2921b0SApple OSS Distributions  */
645*5c2921b0SApple OSS Distributions 
646*5c2921b0SApple OSS Distributions /*!
647*5c2921b0SApple OSS Distributions  * @typedef   OSKextVersion
648*5c2921b0SApple OSS Distributions  * @abstract  An encoded kext version that can be compared arithmetically.
649*5c2921b0SApple OSS Distributions  *
650*5c2921b0SApple OSS Distributions  * @discussion
651*5c2921b0SApple OSS Distributions  * A value of zero (<code>@link kOSKextVersionUndefined kOSKextVersionUndefined@/link</code>)
652*5c2921b0SApple OSS Distributions  * is <i>not</i> equivalent to a version string of "0.0",
653*5c2921b0SApple OSS Distributions  * and typically means there is no version specified
654*5c2921b0SApple OSS Distributions  * (for example, that there is no CFBundleVersion property at all).
655*5c2921b0SApple OSS Distributions  * Values below zero are invalid.
656*5c2921b0SApple OSS Distributions  *
657*5c2921b0SApple OSS Distributions  * The encoding used is subject to change,
658*5c2921b0SApple OSS Distributions  * and should never be saved to permanent storage.
659*5c2921b0SApple OSS Distributions  * Always use proper version strings in files and interprocess communication.
660*5c2921b0SApple OSS Distributions  */
661*5c2921b0SApple OSS Distributions typedef int64_t OSKextVersion;
662*5c2921b0SApple OSS Distributions 
663*5c2921b0SApple OSS Distributions /*!
664*5c2921b0SApple OSS Distributions  * @define    kOSKextVersionMaxLength
665*5c2921b0SApple OSS Distributions  * @abstract  The length of a string buffer
666*5c2921b0SApple OSS Distributions  *            guaranteed to be able to hold a kext version.
667*5c2921b0SApple OSS Distributions  *
668*5c2921b0SApple OSS Distributions  * @discussion
669*5c2921b0SApple OSS Distributions  * Kext versions use an extended Mac OS 'vers' format with double the number
670*5c2921b0SApple OSS Distributions  * of digits before the build stage: ####.##.##s{1-255} where 's'
671*5c2921b0SApple OSS Distributions  * is a build stage 'd', 'a', 'b', 'f' or 'fc'.
672*5c2921b0SApple OSS Distributions  */
673*5c2921b0SApple OSS Distributions #define kOSKextVersionMaxLength (20)
674*5c2921b0SApple OSS Distributions // with a few bytes to spare including a nul byte
675*5c2921b0SApple OSS Distributions // xx-review: Should we make this much bigger in case we ever need longer strings?
676*5c2921b0SApple OSS Distributions 
677*5c2921b0SApple OSS Distributions /*!
678*5c2921b0SApple OSS Distributions  * @define    kOSKextVersionUndefined
679*5c2921b0SApple OSS Distributions  * @abstract  The undefined version.
680*5c2921b0SApple OSS Distributions  *
681*5c2921b0SApple OSS Distributions  * @discussion
682*5c2921b0SApple OSS Distributions  * This value of <code>@link OSKextVersion OSKextVersion@/link</code> represents the
683*5c2921b0SApple OSS Distributions  * lack of a version
684*5c2921b0SApple OSS Distributions  * (for example, that there is no CFBundleVersion property at all).
685*5c2921b0SApple OSS Distributions  */
686*5c2921b0SApple OSS Distributions #define kOSKextVersionUndefined  (0)
687*5c2921b0SApple OSS Distributions 
688*5c2921b0SApple OSS Distributions /*!
689*5c2921b0SApple OSS Distributions  * @function OSKextParseVersionString
690*5c2921b0SApple OSS Distributions  *
691*5c2921b0SApple OSS Distributions  * @abstract
692*5c2921b0SApple OSS Distributions  * Parses a kext version string into an <code>@link OSKextVersion OSKextVersion@/link</code>.
693*5c2921b0SApple OSS Distributions  *
694*5c2921b0SApple OSS Distributions  * @param  versionString  The kext version string to parse.
695*5c2921b0SApple OSS Distributions  *
696*5c2921b0SApple OSS Distributions  * @result
697*5c2921b0SApple OSS Distributions  * An encoded kext version that can be compared numerically
698*5c2921b0SApple OSS Distributions  * against other encoded kext versions,
699*5c2921b0SApple OSS Distributions  * <0 if <code>versionString</code> is <code>NULL</code>, empty,
700*5c2921b0SApple OSS Distributions  * or cannot be parsed.
701*5c2921b0SApple OSS Distributions  *
702*5c2921b0SApple OSS Distributions  * @discussion
703*5c2921b0SApple OSS Distributions  * Kext versions use an extended Mac OS 'vers' format with double the number
704*5c2921b0SApple OSS Distributions  * of digits before the build stage: ####.##.##s{1-255} where 's'
705*5c2921b0SApple OSS Distributions  * is a build stage 'd', 'a', 'b', 'f' or 'fc'.
706*5c2921b0SApple OSS Distributions  */
707*5c2921b0SApple OSS Distributions OSKextVersion OSKextParseVersionString(const char * versionString);
708*5c2921b0SApple OSS Distributions 
709*5c2921b0SApple OSS Distributions 
710*5c2921b0SApple OSS Distributions /*!
711*5c2921b0SApple OSS Distributions  * @function OSKextVersionGetString
712*5c2921b0SApple OSS Distributions  *
713*5c2921b0SApple OSS Distributions  * @abstract
714*5c2921b0SApple OSS Distributions  * Formats an encoded <code>@link OSKextVersion OSKextVersion@/link</code> into a string
715*5c2921b0SApple OSS Distributions  * representation.
716*5c2921b0SApple OSS Distributions  *
717*5c2921b0SApple OSS Distributions  * @param  aVersion
718*5c2921b0SApple OSS Distributions  *         The encoded version to format.
719*5c2921b0SApple OSS Distributions  * @param  buffer
720*5c2921b0SApple OSS Distributions  *         A C string buffer of at least
721*5c2921b0SApple OSS Distributions  *         <code>@link kOSKextVersionMaxLength kOSKextVersionMaxLength@/link</code> bytes.
722*5c2921b0SApple OSS Distributions  * @param  bufferSize  The size in bytes of <code>buffer</code>.
723*5c2921b0SApple OSS Distributions  *
724*5c2921b0SApple OSS Distributions  * @result
725*5c2921b0SApple OSS Distributions  * <code>TRUE</code> if the encoded version is formatted successfully.
726*5c2921b0SApple OSS Distributions  * <code>FALSE</code> if <code>buffer</code> is <code>NULL</code> or
727*5c2921b0SApple OSS Distributions  * <code>bufferSize</code> is less than
728*5c2921b0SApple OSS Distributions  * <code>@link kOSKextVersionMaxLength kOSKextVersionMaxLength@/link</code>.
729*5c2921b0SApple OSS Distributions  *
730*5c2921b0SApple OSS Distributions  * @discussion
731*5c2921b0SApple OSS Distributions  * The return value strictly indicates whether <code>buffer</code>
732*5c2921b0SApple OSS Distributions  * is large enough to hold the result.
733*5c2921b0SApple OSS Distributions  * If <code>aVersion</code> is 0, the resulting string is "(missing)".
734*5c2921b0SApple OSS Distributions  * If <code>aVersion</code> is less than 0
735*5c2921b0SApple OSS Distributions  * or is not a valid kext version encoding,
736*5c2921b0SApple OSS Distributions  * the resulting string is "(invalid)".
737*5c2921b0SApple OSS Distributions  */
738*5c2921b0SApple OSS Distributions Boolean OSKextVersionGetString(
739*5c2921b0SApple OSS Distributions 	OSKextVersion   aVersion,
740*5c2921b0SApple OSS Distributions 	char          * buffer,
741*5c2921b0SApple OSS Distributions 	uint32_t        bufferSize);
742*5c2921b0SApple OSS Distributions 
743*5c2921b0SApple OSS Distributions 
744*5c2921b0SApple OSS Distributions #define KOSBundleDextUniqueIdentifierMaxLength (1024)
745*5c2921b0SApple OSS Distributions 
746*5c2921b0SApple OSS Distributions #ifdef KERNEL
747*5c2921b0SApple OSS Distributions 
748*5c2921b0SApple OSS Distributions 
749*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
750*5c2921b0SApple OSS Distributions /********************************************************************/
751*5c2921b0SApple OSS Distributions #pragma mark -
752*5c2921b0SApple OSS Distributions #pragma mark Weak linking
753*5c2921b0SApple OSS Distributions /********************************************************************/
754*5c2921b0SApple OSS Distributions #endif
755*5c2921b0SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE
756*5c2921b0SApple OSS Distributions void kext_weak_symbol_referenced(void) __abortlike;
757*5c2921b0SApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */
758*5c2921b0SApple OSS Distributions 
759*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
760*5c2921b0SApple OSS Distributions #pragma mark -
761*5c2921b0SApple OSS Distributions /********************************************************************/
762*5c2921b0SApple OSS Distributions #pragma mark Miscellaneous Kernel-Only Kext Functions
763*5c2921b0SApple OSS Distributions /********************************************************************/
764*5c2921b0SApple OSS Distributions #endif
765*5c2921b0SApple OSS Distributions 
766*5c2921b0SApple OSS Distributions /*!
767*5c2921b0SApple OSS Distributions  * @function kext_get_vm_map
768*5c2921b0SApple OSS Distributions  * @abstract Returns the vm_map from which the kext was allocated.
769*5c2921b0SApple OSS Distributions  *
770*5c2921b0SApple OSS Distributions  * @param info The kmod_info_t structure of the kext.
771*5c2921b0SApple OSS Distributions  * @result The vm_map from which the kext was allocated.  This function
772*5c2921b0SApple OSS Distributions  * cannot return <code>NULL</code>.
773*5c2921b0SApple OSS Distributions  */
774*5c2921b0SApple OSS Distributions vm_map_t kext_get_vm_map(kmod_info_t * info);
775*5c2921b0SApple OSS Distributions 
776*5c2921b0SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE
777*5c2921b0SApple OSS Distributions 
778*5c2921b0SApple OSS Distributions #if CONFIG_DTRACE
779*5c2921b0SApple OSS Distributions /*!
780*5c2921b0SApple OSS Distributions  * @function OSKextRegisterKextsWithDTrace
781*5c2921b0SApple OSS Distributions  * @abstract
782*5c2921b0SApple OSS Distributions  * DTrace calls this once when it has started up so that the kext system
783*5c2921b0SApple OSS Distributions  * will register any already-loaded kexts with it.
784*5c2921b0SApple OSS Distributions  */
785*5c2921b0SApple OSS Distributions void OSKextRegisterKextsWithDTrace(void);
786*5c2921b0SApple OSS Distributions 
787*5c2921b0SApple OSS Distributions #endif /* CONFIG_DTRACE */
788*5c2921b0SApple OSS Distributions 
789*5c2921b0SApple OSS Distributions /*!
790*5c2921b0SApple OSS Distributions  * @function kext_dump_panic_lists
791*5c2921b0SApple OSS Distributions  * @abstract Prints compacted lists of last unloaded & all loaded kexts
792*5c2921b0SApple OSS Distributions  *           during a panic.
793*5c2921b0SApple OSS Distributions  *
794*5c2921b0SApple OSS Distributions  * @param printf_func The printf-style function to use for output.
795*5c2921b0SApple OSS Distributions  */
796*5c2921b0SApple OSS Distributions void kext_dump_panic_lists(int (*printf_func)(const char *fmt, ...));
797*5c2921b0SApple OSS Distributions 
798*5c2921b0SApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */
799*5c2921b0SApple OSS Distributions 
800*5c2921b0SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE
801*5c2921b0SApple OSS Distributions 
802*5c2921b0SApple OSS Distributions /*!
803*5c2921b0SApple OSS Distributions  * @define kOSKextReceiptQueried
804*5c2921b0SApple OSS Distributions  * @abstract Whether or not the kext receipt has been successfully loaded.
805*5c2921b0SApple OSS Distributions  */
806*5c2921b0SApple OSS Distributions #define kOSKextReceiptQueried  "OSKextReceiptQueried"
807*5c2921b0SApple OSS Distributions 
808*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
809*5c2921b0SApple OSS Distributions #pragma mark -
810*5c2921b0SApple OSS Distributions /********************************************************************/
811*5c2921b0SApple OSS Distributions #pragma mark Kext Loading C Functions
812*5c2921b0SApple OSS Distributions /********************************************************************/
813*5c2921b0SApple OSS Distributions #endif
814*5c2921b0SApple OSS Distributions /*!
815*5c2921b0SApple OSS Distributions  * @function OSKextGetLoadTagForBundleIdentifier
816*5c2921b0SApple OSS Distributions  * @abstract Look up the load tag for a kext.
817*5c2921b0SApple OSS Distributions  *
818*5c2921b0SApple OSS Distributions  * @param  kextIdentifier  The bundle identifier of the kext to look up.
819*5c2921b0SApple OSS Distributions  * @result
820*5c2921b0SApple OSS Distributions  * The load tag of the requested kext, or
821*5c2921b0SApple OSS Distributions  * <code>@link //apple_ref/c/macro/kOSKextInvalidLoadTag kOSKextInvalidLoadTag@/link</code>
822*5c2921b0SApple OSS Distributions  * if the kext was not found.
823*5c2921b0SApple OSS Distributions  *
824*5c2921b0SApple OSS Distributions  * @discussion
825*5c2921b0SApple OSS Distributions  * A load tag uniquely identifies a loaded kext.
826*5c2921b0SApple OSS Distributions  * It can be found as the <code>id</code> field of a loaded kext's
827*5c2921b0SApple OSS Distributions  * <code>kmod_info_t</code> struct.
828*5c2921b0SApple OSS Distributions  *
829*5c2921b0SApple OSS Distributions  * Note that a load tag represents a specific loaded instance of a kext.
830*5c2921b0SApple OSS Distributions  * If that kext is unloaded, the load tag is no longer a valid reference.
831*5c2921b0SApple OSS Distributions  * If the same kext is later reloaded, it will have a new load tag.
832*5c2921b0SApple OSS Distributions  *
833*5c2921b0SApple OSS Distributions  * You can use the load tag to adjust a kext's reference count
834*5c2921b0SApple OSS Distributions  * via
835*5c2921b0SApple OSS Distributions  * <code>@link //apple_ref/c/func/OSKextRetainKextWithLoadTag
836*5c2921b0SApple OSS Distributions  * OSKextRetainKextWithLoadTag@/link</code>
837*5c2921b0SApple OSS Distributions  * and
838*5c2921b0SApple OSS Distributions  * <code>@link //apple_ref/c/func/OSKextReleaseKextWithLoadTag
839*5c2921b0SApple OSS Distributions  * OSKextReleaseKextWithLoadTag@/link</code>,
840*5c2921b0SApple OSS Distributions  * so that the kext is automatically unloaded when no references remain,
841*5c2921b0SApple OSS Distributions  * or to unload the kext immediately
842*5c2921b0SApple OSS Distributions  * with <code>@link //apple_ref/c/func/OSKextUnloadKextWithLoadTag OSKextUnloadKextWithLoadTag@/link</code>.
843*5c2921b0SApple OSS Distributions  *
844*5c2921b0SApple OSS Distributions  * Those functions are intended for use with non-IOKit kexts
845*5c2921b0SApple OSS Distributions  * (specifically, kexts that define no subclasses of
846*5c2921b0SApple OSS Distributions  * <code>@link //apple_ref/doc/class/IOServiceIOService@/link</code>).
847*5c2921b0SApple OSS Distributions  * Pure IOKit kexts are managed via instance counts
848*5c2921b0SApple OSS Distributions  * of their libkern C++ object classes;
849*5c2921b0SApple OSS Distributions  * using those functions on them will only interfere with that mechanism.
850*5c2921b0SApple OSS Distributions  * If you have a hybrid kext with both IOService subclasses and non-IOKit code,
851*5c2921b0SApple OSS Distributions  * however, you may want to use reference counting for the non-IOKit portions:
852*5c2921b0SApple OSS Distributions  * that way the kext will only unload automaticaly
853*5c2921b0SApple OSS Distributions  * when there are no C++ objects and the kext reference count is zero.
854*5c2921b0SApple OSS Distributions  */
855*5c2921b0SApple OSS Distributions uint32_t OSKextGetLoadTagForBundleIdentifier(
856*5c2921b0SApple OSS Distributions 	const char * kextIdentifier);
857*5c2921b0SApple OSS Distributions 
858*5c2921b0SApple OSS Distributions 
859*5c2921b0SApple OSS Distributions /*!
860*5c2921b0SApple OSS Distributions  * @function OSKextUnloadKextWithLoadTag
861*5c2921b0SApple OSS Distributions  * @abstract Stop and unload a kext based on its load tag.
862*5c2921b0SApple OSS Distributions  *
863*5c2921b0SApple OSS Distributions  * @param  loadTag   The load tag of the kext to unload.
864*5c2921b0SApple OSS Distributions  * @result
865*5c2921b0SApple OSS Distributions  * <code>@link //apple_ref/c/macro/kOSReturnSuccess kOSReturnSuccess@/link</code>
866*5c2921b0SApple OSS Distributions  * if the kext was found and unloaded.
867*5c2921b0SApple OSS Distributions  * <code>@link //apple_ref/c/macro/kOSKextReturnNotFound
868*5c2921b0SApple OSS Distributions  * kOSKextReturnNotFound@/link</code>
869*5c2921b0SApple OSS Distributions  * if the kext was not found.
870*5c2921b0SApple OSS Distributions  * <code>@link //apple_ref/c/macro/kOSKextReturnInUse
871*5c2921b0SApple OSS Distributions  * kOSKextReturnInUse@/link</code>
872*5c2921b0SApple OSS Distributions  * if the kext has outstanding references
873*5c2921b0SApple OSS Distributions  * or if there are instances of its libkern C++ subclasses.
874*5c2921b0SApple OSS Distributions  * Other return values indicate a failure to unload the kext,
875*5c2921b0SApple OSS Distributions  * typically because the module stop routine failed.
876*5c2921b0SApple OSS Distributions  *
877*5c2921b0SApple OSS Distributions  * @discussion
878*5c2921b0SApple OSS Distributions  * A panic will occur if a kext calls this function to unload itself.
879*5c2921b0SApple OSS Distributions  * The safest way for a kext to unload itself is to call
880*5c2921b0SApple OSS Distributions  * <code>@link //apple_ref/c/func/OSKextRetainKextWithLoadTag
881*5c2921b0SApple OSS Distributions  * OSKextRetainKextWithLoadTag@/link</code>
882*5c2921b0SApple OSS Distributions  * with its own load tag
883*5c2921b0SApple OSS Distributions  * (the <code>id</code> field of its <code>kmod_info_t</code> struct),
884*5c2921b0SApple OSS Distributions  * followed by
885*5c2921b0SApple OSS Distributions  * <code>@link //apple_ref/c/func/OSKextReleaseKextWithLoadTag
886*5c2921b0SApple OSS Distributions  * OSKextReleaseKextWithLoadTag@/link</code>;
887*5c2921b0SApple OSS Distributions  * this will schedule the kext for unload on a separate thread.
888*5c2921b0SApple OSS Distributions  *
889*5c2921b0SApple OSS Distributions  * This function can be used when reference-based autounloading is not
890*5c2921b0SApple OSS Distributions  * appropriate.
891*5c2921b0SApple OSS Distributions  * If a kernel system or kext is already monitoring
892*5c2921b0SApple OSS Distributions  * the need for a kext,
893*5c2921b0SApple OSS Distributions  * it can simply call this function when it's known that the kext is not needed.
894*5c2921b0SApple OSS Distributions  */
895*5c2921b0SApple OSS Distributions OSReturn OSKextUnloadKextWithLoadTag(uint32_t loadTag);
896*5c2921b0SApple OSS Distributions 
897*5c2921b0SApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */
898*5c2921b0SApple OSS Distributions 
899*5c2921b0SApple OSS Distributions #endif /* KERNEL */
900*5c2921b0SApple OSS Distributions 
901*5c2921b0SApple OSS Distributions #if PRAGMA_MARK
902*5c2921b0SApple OSS Distributions #pragma mark -
903*5c2921b0SApple OSS Distributions /********************************************************************/
904*5c2921b0SApple OSS Distributions #pragma mark Loaded Kext Summary
905*5c2921b0SApple OSS Distributions /********************************************************************/
906*5c2921b0SApple OSS Distributions #endif
907*5c2921b0SApple OSS Distributions 
908*5c2921b0SApple OSS Distributions /*!
909*5c2921b0SApple OSS Distributions  * @define kOSKextLoadedKextSummaryVersion
910*5c2921b0SApple OSS Distributions  * @abstract The current version of the loaded kext summary headers.
911*5c2921b0SApple OSS Distributions  */
912*5c2921b0SApple OSS Distributions #define kOSKextLoadedKextSummaryVersion 2
913*5c2921b0SApple OSS Distributions 
914*5c2921b0SApple OSS Distributions /*!
915*5c2921b0SApple OSS Distributions  * @typedef OSKextLoadedKextSummary
916*5c2921b0SApple OSS Distributions  * @abstract A structure that describes a loaded kext.
917*5c2921b0SApple OSS Distributions  *
918*5c2921b0SApple OSS Distributions  * @field name The kext's bundle identifier.
919*5c2921b0SApple OSS Distributions  * @field uuid The kext's UUID;
920*5c2921b0SApple OSS Distributions  * @field address The kext's load address.
921*5c2921b0SApple OSS Distributions  * @field size The kext's load size.
922*5c2921b0SApple OSS Distributions  * @field version The binary format (OSKextVersion) version of the kext.
923*5c2921b0SApple OSS Distributions  * @field loadTag The kext's load tag.
924*5c2921b0SApple OSS Distributions  * @field flags Internal tracking flags.
925*5c2921b0SApple OSS Distributions  * @field reference_list who this refs (links on).
926*5c2921b0SApple OSS Distributions  * @field text_exec_address The address of the __TEXT_EXEC segment (if it exists), otherwise __TEXT
927*5c2921b0SApple OSS Distributions  * @field text_exec_size The size of the segment pointed to by text_address
928*5c2921b0SApple OSS Distributions  *
929*5c2921b0SApple OSS Distributions  * @discussion
930*5c2921b0SApple OSS Distributions  * The OSKextLoadedKextSummary structure contains a basic set of information
931*5c2921b0SApple OSS Distributions  * about the kext to facilitate kext debugging and panic debug log output.
932*5c2921b0SApple OSS Distributions  */
933*5c2921b0SApple OSS Distributions typedef struct _loaded_kext_summary {
934*5c2921b0SApple OSS Distributions 	char        name[KMOD_MAX_NAME];
935*5c2921b0SApple OSS Distributions 	uuid_t      uuid;
936*5c2921b0SApple OSS Distributions 	uint64_t    address;
937*5c2921b0SApple OSS Distributions 	uint64_t    size;
938*5c2921b0SApple OSS Distributions 	uint64_t    version;
939*5c2921b0SApple OSS Distributions 	uint32_t    loadTag;
940*5c2921b0SApple OSS Distributions 	uint32_t    flags;
941*5c2921b0SApple OSS Distributions 	uint64_t    reference_list;
942*5c2921b0SApple OSS Distributions 	uint64_t    text_exec_address;
943*5c2921b0SApple OSS Distributions 	size_t      text_exec_size;
944*5c2921b0SApple OSS Distributions } OSKextLoadedKextSummary;
945*5c2921b0SApple OSS Distributions 
946*5c2921b0SApple OSS Distributions /*!
947*5c2921b0SApple OSS Distributions  * @typedef OSKextLoadedKextSummaryHeader
948*5c2921b0SApple OSS Distributions  * @abstract A structure that describes the set of loaded kext summaries.
949*5c2921b0SApple OSS Distributions  *
950*5c2921b0SApple OSS Distributions  * @field version The version of the loaded kext summary structures.
951*5c2921b0SApple OSS Distributions  * @field entry_size The size of each entry in summaries.
952*5c2921b0SApple OSS Distributions  * @field numSummaries The number of OSKextLoadedKextSummary structures
953*5c2921b0SApple OSS Distributions  *        following the header.
954*5c2921b0SApple OSS Distributions  * @field summaries A convenience pointer to the array of summaries following
955*5c2921b0SApple OSS Distributions  *        the header.
956*5c2921b0SApple OSS Distributions  *
957*5c2921b0SApple OSS Distributions  * @discussion
958*5c2921b0SApple OSS Distributions  * The OSKextLoadedKextSummaryHeader describes the set of loaded kext summaries
959*5c2921b0SApple OSS Distributions  * available for use by the debugger or panic log routine.
960*5c2921b0SApple OSS Distributions  * The array of summaries contains one OSKextLoadedKextSummary for every kext
961*5c2921b0SApple OSS Distributions  * that declares an executable and is not an interface to the kernel.
962*5c2921b0SApple OSS Distributions  */
963*5c2921b0SApple OSS Distributions typedef struct _loaded_kext_summary_header {
964*5c2921b0SApple OSS Distributions 	uint32_t version;
965*5c2921b0SApple OSS Distributions 	uint32_t entry_size;
966*5c2921b0SApple OSS Distributions 	uint32_t numSummaries;
967*5c2921b0SApple OSS Distributions 	uint32_t reserved; /* explicit alignment for gdb  */
968*5c2921b0SApple OSS Distributions 	OSKextLoadedKextSummary summaries[0];
969*5c2921b0SApple OSS Distributions } OSKextLoadedKextSummaryHeader;
970*5c2921b0SApple OSS Distributions 
971*5c2921b0SApple OSS Distributions /*!
972*5c2921b0SApple OSS Distributions  * @var gLoadedKextSummaries
973*5c2921b0SApple OSS Distributions  * @abstract The global pointer to the current set of loaded kext summaries.
974*5c2921b0SApple OSS Distributions  */
975*5c2921b0SApple OSS Distributions extern OSKextLoadedKextSummaryHeader * gLoadedKextSummaries;
976*5c2921b0SApple OSS Distributions 
977*5c2921b0SApple OSS Distributions /*!
978*5c2921b0SApple OSS Distributions  * @var gLoadedKextSummariesTimestamp
979*5c2921b0SApple OSS Distributions  *
980*5c2921b0SApple OSS Distributions  * @abstract This will be set to mach_absolute_time() around updates to
981*5c2921b0SApple OSS Distributions  * gLoadedKextSummaries.  Ie. immediately before gLoadedKextSummaries is set to
982*5c2921b0SApple OSS Distributions  * zero, and immediately after it is set to a new value.
983*5c2921b0SApple OSS Distributions  */
984*5c2921b0SApple OSS Distributions extern uint64_t gLoadedKextSummariesTimestamp;
985*5c2921b0SApple OSS Distributions 
986*5c2921b0SApple OSS Distributions /*!
987*5c2921b0SApple OSS Distributions  * @function OSKextLoadedKextSummariesUpdated
988*5c2921b0SApple OSS Distributions  * @abstract Called when gLoadedKextSummaries has been updated.
989*5c2921b0SApple OSS Distributions  *
990*5c2921b0SApple OSS Distributions  * @discussion
991*5c2921b0SApple OSS Distributions  * gLoadedKextSummaries is updated when a kext is loaded or unloaded.
992*5c2921b0SApple OSS Distributions  * When the update is complete, OSKextLoadedKextSummariesUpdated is called.
993*5c2921b0SApple OSS Distributions  * gdb can set a breakpoint on this function to detect kext loads and unloads.
994*5c2921b0SApple OSS Distributions  */
995*5c2921b0SApple OSS Distributions void OSKextLoadedKextSummariesUpdated(void);
996*5c2921b0SApple OSS Distributions 
997*5c2921b0SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE
998*5c2921b0SApple OSS Distributions 
999*5c2921b0SApple OSS Distributions extern const vm_allocation_site_t * OSKextGetAllocationSiteForCaller(uintptr_t address);
1000*5c2921b0SApple OSS Distributions extern uint32_t                     OSKextGetKmodIDForSite(const vm_allocation_site_t * site,
1001*5c2921b0SApple OSS Distributions     char * name, vm_size_t namelen);
1002*5c2921b0SApple OSS Distributions extern void                         OSKextFreeSite(vm_allocation_site_t * site);
1003*5c2921b0SApple OSS Distributions 
1004*5c2921b0SApple OSS Distributions extern kern_return_t                OSKextSetReceiptQueried(void);
1005*5c2921b0SApple OSS Distributions 
1006*5c2921b0SApple OSS Distributions #if DEVELOPMENT || DEBUG
1007*5c2921b0SApple OSS Distributions extern void                         OSKextGetRefGrpForCaller(uintptr_t address,
1008*5c2921b0SApple OSS Distributions     void (^)(struct os_refgrp *));
1009*5c2921b0SApple OSS Distributions #endif
1010*5c2921b0SApple OSS Distributions 
1011*5c2921b0SApple OSS Distributions #if CONFIG_IMAGEBOOT
1012*5c2921b0SApple OSS Distributions extern int OSKextGetUUIDForName(const char *, uuid_t);
1013*5c2921b0SApple OSS Distributions #endif
1014*5c2921b0SApple OSS Distributions 
1015*5c2921b0SApple OSS Distributions extern vm_tag_t gIOSurfaceTag;
1016*5c2921b0SApple OSS Distributions 
1017*5c2921b0SApple OSS Distributions extern void *OSKextKextForAddress(const void *addr);
1018*5c2921b0SApple OSS Distributions 
1019*5c2921b0SApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */
1020*5c2921b0SApple OSS Distributions 
1021*5c2921b0SApple OSS Distributions __END_DECLS
1022*5c2921b0SApple OSS Distributions 
1023*5c2921b0SApple OSS Distributions #endif /* ! _LIBKERN_OSKEXTLIBPRIVATE_H */
1024