apple_bundle/info_plist/kernel_and_drivers.rs
1//! # Kernel and Drivers
2//!
3//! Configure device drivers provided by the app.
4
5use super::DefaultDictionary;
6use serde::{Deserialize, Serialize};
7
8/// Driver Personalities
9#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq)]
10pub struct DriverPersonalities {
11 /// One or more groups of attributes that tell the system about the devices your
12 /// driver supports.
13 ///
14 /// This key contains a dictionary of driver personalities, each of which specifies
15 /// how to pair the driver to a device. Each key in the dictionary is a string you
16 /// designate as the name of a specific personality, and the system doesn’t use your
17 /// key names internally. The value of each key is a dictionary of attributes that
18 /// describe the specific device to match with the driver. Thus, each key and
19 /// dictionary combination represents a single personality of the driver.
20 /// The system uses these personalities to match the driver to an attached device.
21 ///
22 /// During the matching process, the system compares the attributes in each
23 /// personality dictionary to data it obtained from the attached device.
24 /// For example, if the personality dictionary includes the VendorID key, the system
25 /// compares that key to the vendor information from the device. The system picks
26 /// the driver that is compatible with the device and provides the best overall match.
27 /// It then uses additional information from the personality dictionary to load and
28 /// run the driver.
29 ///
30 /// All personality dictionaries must include the following keys:
31 /// * CFBundleIdentifier
32 /// * IOProviderClass
33 /// * IOClass
34 ///
35 /// Include any of the following keys in your personality dictionary to customize the
36 /// match criteria:
37 /// * IOPropertyMatch
38 /// * IONameMatch
39 /// * IOResourceMatch
40 /// * IOParentMatch
41 /// * IOPathMatch
42 /// * IOMatchCategory
43 /// * Device-specific keys, such as DeviceUsagePairs, VendorID, or ProductID.
44 /// See a specific IOService subclass for information about the keys it supports.
45 ///
46 /// Include one of more of the following keys to specify how to load your driver’s
47 /// code:
48 /// * IOUserClass
49 /// * IOUserServerName
50 /// * IOUserClientClass
51 ///
52 /// Use the following keys to further customize your driver’s behavior:
53 /// * IOMatchDefer. Set the value of this key to true to defer the matching process
54 /// until after kextd starts.
55 /// * IOUserServerOneProcess. Set the value of this key to true to run your DriverKit
56 /// services in one process.
57 /// If the key is missing or its value is false, the system creates a separate process
58 /// for each service.
59 ///
60 /// ## Availability
61 /// * macOS 10.0+
62 ///
63 /// ## Framework
64 /// * Kernel
65 #[serde(
66 rename = "IOKitPersonalities",
67 serialize_with = "crate::serialize_option",
68 skip_serializing_if = "Option::is_none"
69 )]
70 pub kit_personalities: Option<KitPersonalities>,
71}
72
73/// Kit Personalities
74#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq)]
75pub struct KitPersonalities {
76 /// The name of your driver’s main class, which is the entry point for interacting
77 /// with your driver’s code.
78 ///
79 /// Include this key only in the personality dictionary of a DriverKit extension, and
80 /// use it to specify the name of the custom IOService subclass that provides your
81 /// driver’s behavior. When it’s time to load your driver, the system instantiates
82 /// the specified class and begins the initialization and startup processes.
83 ///
84 /// ## Availability
85 /// * macOS 10.14+
86 ///
87 /// ## Framework
88 /// * DriverKit
89 #[serde(
90 rename = "IOUserClass",
91 serialize_with = "crate::serialize_option",
92 skip_serializing_if = "Option::is_none"
93 )]
94 pub user_class: Option<String>,
95 /// The name of the class that your driver expects to provide the implementation for
96 /// its provider object.
97 ///
98 /// The value of this key is a string that contains the name of an IOService subclass.
99 /// This class corresponds to the provider object that the system passes to your
100 /// IOService subclass at startup. (For a kernel extension, the system passes the
101 /// provider object to the start method of your IOService subclass.
102 /// For a DriverKit extension, the system passes it to the Start method of your
103 /// IOService subclass.) Use the provider object in your driver you receive to
104 /// communicate with the underlying device.
105 ///
106 /// ## Availability
107 /// * macOS 10.0+
108 ///
109 /// ## Framework
110 /// * Kernel
111 #[serde(
112 rename = "IOProviderClass",
113 serialize_with = "crate::serialize_option",
114 skip_serializing_if = "Option::is_none"
115 )]
116 pub provider_class: Option<String>,
117 /// The name of the class to instantiate from your driver.
118 ///
119 /// The value of this key is a string that contains the name of a custom IOService
120 /// subclass in your driver. When the system successfully matches one of your
121 /// driver’s personalities to a device, it instantiates the class in this key and
122 /// calls its start method.
123 ///
124 /// For the personalities in a DriverKit extension, specify the value IOUserService
125 /// unless otherwise directed by the documentation. For example, the
126 /// IOUserHIDEventService class expects you to specify the value
127 /// AppleUserHIDEventService.
128 ///
129 /// ## Availability
130 /// * macOS 10.0+
131 ///
132 /// ## Framework
133 /// * Kernel
134 #[serde(
135 rename = "IOClass",
136 serialize_with = "crate::serialize_option",
137 skip_serializing_if = "Option::is_none"
138 )]
139 pub class: Option<String>,
140 /// The name of the class to instantiate when the system requires a client connection
141 /// to the driver.
142 ///
143 /// The value of this key is a string that contains the name of an IOService subclass
144 /// in your driver.
145 ///
146 /// ## Availability
147 /// * macOS 10.0+
148 ///
149 /// ## Framework
150 /// * Kernel
151 #[serde(
152 rename = "IOUserClientClass",
153 serialize_with = "crate::serialize_option",
154 skip_serializing_if = "Option::is_none"
155 )]
156 pub user_client_class: Option<String>,
157 /// The name that the system uses to facilitate communication between your driver and
158 /// other clients.
159 ///
160 /// Typically, you set the value of this key to your kext or DriverKit extension’s
161 /// bundle identifier. The system registers your driver under the specified server
162 /// name, and uses that name to facilitate communications between your driver and
163 /// other clients, including the kernel itself.
164 ///
165 /// ## Availability
166 /// * macOS 10.14+
167 ///
168 /// ## Framework
169 /// * DriverKit
170 #[serde(
171 rename = "IOUserServerName",
172 serialize_with = "crate::serialize_option",
173 skip_serializing_if = "Option::is_none"
174 )]
175 pub user_server_name: Option<String>,
176 /// The device-specific keys the system must match in order to use your driver.
177 ///
178 /// The value of this key is a dictionary of device-specific keys and values to use
179 /// during the matching process. For the system to match the driver personality to
180 /// a device, all keys in the dictionary must be present in the device, and all values
181 /// must exactly match the device-provided values.
182 ///
183 /// ## Availability
184 /// * macOS 10.0+
185 ///
186 /// ## Framework
187 /// * Kernel
188 #[serde(
189 rename = "IOPropertyMatch",
190 serialize_with = "crate::serialize_option",
191 skip_serializing_if = "Option::is_none"
192 )]
193 pub property_match: Option<DefaultDictionary>,
194 /// One or more strings that contain the names of possible provider objects in the
195 /// system registry.
196 ///
197 /// The value of this key is a string or an array of strings.
198 /// The system begins the matching process with a provider object, and looks for
199 /// additional drivers or nubs that support that provider object. When this key is
200 /// present, the system compares its values to the provider object’s name.
201 /// (It also compares the strings to the provider’s compatible and device_type
202 /// properties.) If it doesn’t find any matches, the system doesn’t match the
203 /// driver to the provider object.
204 ///
205 /// The default name of a provider object is its class name, but providers may
206 /// register a custom name. For more information about how to set or get
207 /// information for registered services, see IORegistryEntry.
208 ///
209 /// ## Availability
210 /// * macOS 10.0+
211 ///
212 /// ## Framework
213 /// * Kernel
214 #[serde(
215 rename = "IONameMatch",
216 serialize_with = "crate::serialize_option",
217 skip_serializing_if = "Option::is_none"
218 )]
219 pub name_match: Option<Vec<String>>,
220 /// One or more system-specific or device-specific resources that your driver
221 /// requires.
222 ///
223 /// The value of this key is a string or an array of strings.
224 /// Each string contains the name of a resource that must be published in the global
225 /// resource list before the system loads the driver. For example, specify IOBSD
226 /// to prevent the system from loading your driver until after the BSD kernel is
227 /// available.
228 ///
229 /// To access the list of global resources, call the getResourceService method of
230 /// IOService. To publish custom resources from your driver, call the
231 /// publishResource method.
232 ///
233 /// ## Availability
234 /// * macOS 10.0+
235 ///
236 /// ## Framework
237 /// * Kernel
238 #[serde(
239 rename = "IOResourceMatch",
240 serialize_with = "crate::serialize_option",
241 skip_serializing_if = "Option::is_none"
242 )]
243 pub resource_match: Option<String>,
244 /// ## Availability
245 /// * macOS 10.0+
246 ///
247 /// ## Framework
248 /// * Kernel
249 #[serde(
250 rename = "IOParentMatch",
251 serialize_with = "crate::serialize_option",
252 skip_serializing_if = "Option::is_none"
253 )]
254 pub parent_match: Option<DefaultDictionary>,
255 /// ## Availability
256 /// * macOS 10.0+
257 ///
258 /// ## Framework
259 /// * Kernel
260 #[serde(
261 rename = "IOPathMatch",
262 serialize_with = "crate::serialize_option",
263 skip_serializing_if = "Option::is_none"
264 )]
265 pub path_match: Option<String>,
266 /// ## Availability
267 /// * macOS 10.0+
268 ///
269 /// ## Framework
270 /// * Kernel
271 #[serde(
272 rename = "IOMatchCategory",
273 serialize_with = "crate::serialize_option",
274 skip_serializing_if = "Option::is_none"
275 )]
276 pub match_category: Option<String>,
277}
278
279/// Kext Dependencies
280#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq)]
281pub struct KextDependencies {
282 /// The backward limit of compatibility for the current driver.
283 ///
284 /// Specify a previous version for the current driver, or the driver’s current
285 /// version. Format this string the same way you format the value of the
286 /// CFBundleVersion key. The combination of this value and the value in the
287 /// CFBundleVersion key define the range of versions that offers the same level of
288 /// compatibility. Dependent drivers use this information to determine if they are
289 /// compatible with the driver. For example, if the driver’s current version is
290 /// 10.0, and you set the value of this key to 5.0, a driver that depends on version
291 /// 7.0 can successfully use the current driver.
292 ///
293 /// When you change your driver in a way that breaks compatibility with your old code,
294 /// update the value of this key. At that time, set the new value to the current
295 /// version of your driver.
296 ///
297 /// ## Availability
298 /// * macOS 10.0+
299 ///
300 /// ## Framework
301 /// * Kernel
302 #[serde(
303 rename = "OSBundleCompatibleVersion",
304 serialize_with = "crate::serialize_option",
305 skip_serializing_if = "Option::is_none"
306 )]
307 pub bundle_compatible_version: Option<String>,
308 /// The drivers that the system must load before your driver.
309 ///
310 /// Use this key to specify other drivers that your driver depends on.
311 /// For example, specify any drivers that contain symbols your driver creates or uses
312 /// at startup. The system loads the drivers in this list before it attempts to
313 /// load your driver. If the system fails to resolve the dependencies or load the
314 /// corresponding libraries, the kernel doesn’t load your driver.
315 ///
316 /// Each key in the dictionary is the bundle identifier of another driver, and the
317 /// value is a string that contains the minimum version of the driver you require.
318 /// Your driver must be compatible with the specified version of the other driver.
319 ///
320 /// Don’t include this key for codeless kexts.
321 ///
322 /// ## Availability
323 /// * macOS 10.0+
324 ///
325 /// ## Framework
326 /// * Kernel
327 #[serde(
328 rename = "OSBundleLibraries",
329 serialize_with = "crate::serialize_option",
330 skip_serializing_if = "Option::is_none"
331 )]
332 pub bundle_libraries: Option<DefaultDictionary>,
333}
334
335/// Thunderbolt Compatibility
336#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq)]
337pub struct ThunderboltCompatibility {
338 /// A Boolean value that indicates whether your driver supports Thunderbolt devices.
339 ///
340 /// Include this key in the personality dictionary of your driver if that personality
341 /// supports Thunderbolt devices.
342 ///
343 /// ## Availability
344 /// * macOS 10.0+
345 ///
346 /// ## Framework
347 /// * PCIDriverKit
348 #[serde(
349 rename = "IOPCITunnelCompatible",
350 serialize_with = "crate::serialize_option",
351 skip_serializing_if = "Option::is_none"
352 )]
353 pub tunnel_compatible: Option<bool>,
354}