]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/kext_request_keys.h
36dd2ab3fc18f5beda398b2f0d7aeb7c3ba74f5d
2 * Copyright (c) 2008 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _LIBKERN_KEXT_REQUEST_KEYS_H
30 #define _LIBKERN_KEXT_REQUEST_KEYS_H
34 #endif /* __cplusplus */
36 /*********************************************************************
37 * This file defines keys (and values) for properties in kext_request
38 * collections and mkext archives used for loading in the kernel.
39 * An incoming request is always a serialized XML plist with at least
40 * a predicate, and optionally a dictionary of arguments.
42 * Some requests generate serialized XML plist responses, while others
43 * return raw data. See the predicate description for more.
45 * All of these keys are strictly for internal run-time communication
46 * between IOKitUser's OSKext module and xnu's OSKext class.
47 * Keys and values may change at any time without notice.
48 *********************************************************************/
51 /********************************************************************/
52 #pragma mark Top-Level Request Properties
53 /********************************************************************/
57 * The value of this key indicates the operation to perform or the
58 * information desired.
60 #define kKextRequestPredicateKey "Kext Request Predicate"
63 * The value of this key is a dictionary containing the arguments
66 #define kKextRequestArgumentsKey "Kext Request Arguments"
69 /********************************************************************/
70 #pragma mark Request Predicates - User-Space to Kernel
71 /********************************************************************/
74 /*********************************************************************
75 * Nonprivileged requests from user -> kernel
77 * These requests do not require a privileged host port, as they just
78 * return information about loaded kexts.
81 /* Predicate: Get Loaded Kext Info
83 * Response: An array of information about loaded kexts (see OSKextLib.h).
84 * Op result: OSReturn indicating any errors in processing (see OSKextLib.h)
86 * Retrieves an array of dictionaries whose properties describe every kext
87 * loaded at the time of the call.
89 #define kKextRequestPredicateGetLoaded "Get Loaded Kext Info"
91 /* Predicate: Get All Load Requests
93 * Response: A set of bundle identifiers of all requested kext loads..
94 * Op result: OSReturn indicating any errors in processing (see OSKextLib.h)
96 * Retrieves the bundle identifiers of all kexts that were requested to be
97 * loaded since power on.
100 #define kKextRequestPredicateGetAllLoadRequests "Get All Load Requests"
103 /*********************************************************************
104 * Privileged requests from user -> kernel
106 * These requests all do something with kexts in the kernel or to
107 * the OSKext system overall. The user-space caller of kext_request()
108 * must have access to a privileged host port or these requests result
109 * in an op_result of kOSKextReturnNotPrivileged.
112 /* Predicate: Get Kernel Requests
114 * Response: An array of kernel requests (see below).
115 * Op result: OSReturn indicating any errors in processing (see OSKextLib.h)
117 * Retrieve the list of deferred load (and other) requests from OSKext.
118 * This predicate is reserved for kextd, and we may be enforcing access
119 * to the kextd process only.
121 #define kKextRequestPredicateGetKernelRequests "Get Kernel Requests"
124 * Argument: kKextRequestArgumentLoadRequestsKey
125 * Response: None (yet, may become an array of log message strings)
126 * Op result: OSReturn indicating processing/load+start result (see OSKextLib.h)
128 * Load one or more kexts per the load requests in the arguments dict.
129 * See kKextRequestArgumentLoadRequestsKey for more info.
131 #define kKextRequestPredicateLoad "Load"
134 * Argument: kKextRequestArgumentBundleIdentifierKey (CFBundleIdentifier)
135 * Response: None (yet, may become an array of log message strings)
136 * Op result: OSReturn indicating start result (see OSKextLib.h)
138 * Start a kext by bundle id. If it's already started, returns success.
139 * If a kext's dependencies need to be started, they are also started.
141 #define kKextRequestPredicateStart "Start"
144 * Argument: kKextRequestArgumentBundleIdentifierKey (CFBundleIdentifier)
145 * Response: None (yet, may become an array of log message strings)
146 * Op result: OSReturn indicating stop result (see OSKextLib.h)
148 * Stop a kext by bundle id if it can be stoppoed.
149 * If it's already stopped, returns success.
150 * Does not attempt to stop dependents; that will return an error.
152 #define kKextRequestPredicateStop "Stop"
155 * Argument: kKextRequestArgumentBundleIdentifierKey (CFBundleIdentifier)
156 * Response: None (yet, may become an array of log message strings)
157 * Op result: OSReturn indicating stop+unload result (see OSKextLib.h)
159 * Stop and unload a kext by bundle id if it can be.
160 * Does not attempt to stop dependents; that will return an error.
162 #define kKextRequestPredicateUnload "Unload"
165 /********************************************************************/
166 #pragma mark Requests Predicates - Kernel to User Space (kextd)
167 /********************************************************************/
169 /* Predicate: Send Resource
170 * Argument: kKextRequestArgumentRequestTagKey
171 * Argument: kKextRequestArgumentBundleIdentifierKey
172 * Argument: kKextRequestArgumentNameKey
173 * Argument: kKextRequestArgumentValueKey
174 * Argument: kKextRequestArgumentResult
176 * Op result: OSReturn indicating result (see OSKextLib.h)
178 * Retrieves a resource file from a kext bundle. The callback corresponding
179 * to the request will be invoked.
181 #define kKextRequestPredicateSendResource "Send Resource"
183 /*********************************************************************
184 * Kernel Requests: from the kernel or loaded kexts up to kextd
186 * These requests come from within the kernel, and kextd retrieves
187 * them using kKextRequestPredicateGetKernelRequests.
190 /* Predicate: Kext Load Request
191 * Argument: kKextRequestArgumentBundleIdentifierKey
192 * Response: Asynchronous via a kKextRequestPredicateLoad from kextd
193 * Op result: OSReturn indicating result (see OSKextLib.h)
195 * Requests that kextd load the kext with the given identifier.
196 * When kexts loads the kext, it informs the IOCatalogue of the load.
197 * If the kext cannot be loaded, kextd or OSKext removes its personalities
200 #define kKextRequestPredicateRequestLoad "Kext Load Request"
202 /* Predicate: Kext Load Notification
203 * Argument: kext identifier
205 * Op result: OSReturn indicating result (see OSKextLib.h)
207 * Informs kextd that the kernel has successfully loaded and started
210 #define kKextRequestPredicateLoadNotification "Kext Load Notification"
212 /* Predicate: Kext Unload Notification
213 * Argument: kext identifier
215 * Op result: OSReturn indicating result (see OSKextLib.h)
217 * Informs kextd that the kernel has successfully stopped and unloaded
220 #define kKextRequestPredicateUnloadNotification "Kext Unload Notification"
222 /* Predicate: Prelinked Kernel Request
225 * Op result: OSReturn indicating result (see OSKextLib.h)
227 * Notifies kextd that the kernel we booted from was not prelinked, therefore
228 * that kextd should try to create a prelinked kernel now.
230 #define kKextRequestPredicateRequestPrelink "Kext Prelinked Kernel Request"
232 /* Predicate: Kext Resource Request
233 * Argument: kKextRequestArgumentRequestTagKey
234 * Argument: kKextRequestArgumentBundleIdentifierKey
235 * Argument: kKextRequestArgumentNameKey
236 * Response: Asynchronous via a kKextRequestPredicateSendResource from kextd
237 * Op result: OSReturn indicating result (see OSKextLib.h)
239 * Requests a resource file from a kext bundle by identifier + filename.
241 #define kKextRequestPredicateRequestResource "Kext Resource Request"
243 /* Predicate: Kext Kextd Exit Request
246 * Op result: OSReturn indicating result (see OSKextLib.h)
248 * Requests kextd exit for system shutdown.
250 #define kKextRequestPredicateRequestKextdExit "Kextd Exit"
253 /********************************************************************/
255 #pragma mark Generic Request Arguments
256 /********************************************************************/
258 /* Argument: Kext Load Requests
259 * Type: Array of dictionaries (see Load Request Arguments below)
260 * Used by: kKextRequestPredicateLoad
262 * An array of dictionaries, each describing a single load operation to
263 * be performed with its options. A kext load request is effectively a
264 * nested series requests. Currently only one load request is embedded
265 * in a user-space Load request, so the result is unambiguous. We might
266 * change this, specifically for kextd, to allow all pending kernel
267 * load requests to be rolled up into one blob. Might not be much win
268 * in that, however. The nested logic makes the code difficult to read.
270 #define kKextRequestArgumentLoadRequestsKey "Kext Load Requests"
272 /* Argument: CFBundleIdentifier
276 * Any request that takes a bundle identifier uses this key.
278 #define kKextRequestArgumentBundleIdentifierKey "CFBundleIdentifier"
280 /* Argument: OSReturn
282 * Used by: OSKext::copyInfo()
284 * Used to specify a subset of all possible info to be returned.
286 #define kKextRequestArgumentInfoKeysKey "Kext Request Info Keys"
288 /* Argument: OSReturn
289 * Type: Number (OSReturn)
292 * Contains the OSReturn/kern_return_t result of the request.
294 #define kKextRequestArgumentResultKey "Kext Request Result Code"
297 * Type: Varies with the predicate
300 * Used for all the Set-Enabled predicates, and also for Send Resource (OSData).
302 #define kKextRequestArgumentValueKey "Value"
304 /* Argument: Filename
306 * Used by: kKextRequestPredicateSendResource
308 * Names the resource being sent to the kext
310 #define kKextRequestArgumentNameKey "Name"
312 /* Argument: Filename
314 * Used by: kKextRequestPredicateSendResource
316 * Contains the contents of the resource file being sent.
318 #define kKextRequestArgumentFileContentsKey "File Contents"
320 /* Argument: Delay Autounload
324 * Normally all kexts loaded are subject to normal autounload behavior:
325 * when no OSMetaClass instances remain for a kext that defines an IOService
326 * subclass, or when a non-IOService kext turns on autounload and its reference
327 * count drops to zero (external) references.
329 * Setting this property to true in a load request makes the kext being loaded
330 * skip ONE autounload pass, giving about an extra minute of time before the
331 * kext is subject to autounload. This is how kextutil(8) to delays autounload
332 * so that there's more time to set up a debug session.
334 * Setting this property in any other request causes OSKext::considerUnloads()
335 * to be called before processing the request, ensuring a window where kexts
336 * will not be unloaded. The user-space kext library uses this so that it can
337 * avoid including kexts that are already loaded in a load request.
339 #define kKextRequestArgumentDelayAutounloadKey "Delay Autounload"
342 #pragma mark Load Request Arguments
345 /*********************************************************************
346 * Kext Load Request Properties
348 * In addition to a bundle identifier, load requests can contain
349 * these optional keys.
351 * These properties are used primarily by kextutil(8) to alter default
352 * load behavior, but the OSKext user-level library makes them all
353 * available in OSKextLoadWithOptions().
356 /* Argument: StartExclude
357 * Type: Integer, corresponding to OSKextExcludeLevel
358 * Default: kOSKextExcludeNone if not specified
360 * Normally all kexts in the load list for a load request are started.
361 * This property is used primarily by kextutil(8) to delay start of
362 * either the primary kext, or the whole load list (any that weren't
363 * already loaded & started).
365 #define kKextRequestArgumentStartExcludeKey "Start Exclude Level"
367 /* Argument: Start Matching Exclude Level
368 * Type: Integer, corresponding to OSKextExcludeLevel
369 * Default: kOSKextExcludeAll if not specified
371 * Normally no personalities are sent to the IOCatalogue for a regular
372 * kext load; the assumption is that they are already there and triggered
373 * the load request in the first place.
375 * This property is used primarily by kextutil(8) to delay matching for
376 * either the primary kext, or the whole load list (any that didn't
377 * already have personalities in the IOCatalogue).
379 #define kKextRequestArgumentStartMatchingExcludeKey "Start Matching Exclude Level"
381 // see also Delay Autounload
383 /* Argument: Personality Names
384 * Type: Array of strings
385 * Default: All personalities are used
387 * Normally when personalities are sent to the IOCatalogue, they are all sent.
388 * This property restricts the personalities sent, for the primary kext
389 * being loaded, to those named. Personalities for dependencies are all sent,
390 * and there is currently no mechanism to filter them.
392 * This property is used primarily by kextutil(8) to help debug matching
395 #define kKextRequestArgumentPersonalityNamesKey "Personality Names"
398 #pragma mark Unload Request Arguments
401 /* Argument: Terminate
405 * An unload request may optionally specify via this key that all IOService
406 * objects are to be terminated before attempting to unload. Kexts with
407 * dependents will not attempt to terminate and will return kOSKextReturnInUse.
409 #define kKextRequestArgumentTerminateIOServicesKey "Terminate IOServices"
412 #pragma mark Internal Tracking Properties
414 /*********************************************************************
415 * Internal Tracking Properties
418 /* Argument: Request Tag
419 * Type: Number (uint32_t)
420 * Used by: internal tracking for requests with callbacks
422 * Most requests to get resources (files) use this.
424 #define kKextRequestArgumentRequestTagKey "Request Tag"
426 /* Argument: Request Callback
427 * Type: Data (pointer)
428 * Used by: internal tracking
430 * Most requests to get resources (files) use this.
432 #define kKextRequestArgumentCallbackKey "Request Callback"
434 /* Argument: Request context.
435 * Type: OSData (wraps a void *)
438 #define kKextRequestArgumentContextKey "Context"
440 /* Argument: Request Stale
442 * Used by: internal tracking
444 * _OSKextConsiderUnloads sets this on any callback record lacking
445 * it, and deletes any callback record that has it.
447 #define kKextRequestStaleKey "Request Stale"
451 #endif /* __cplusplus */
453 #endif /* _LIBKERN_KEXT_REQUEST_KEYS_H */