MCPcopy Create free account
hub / github.com/USBToolBox/kext / mergeProperties

Method mergeProperties

USBToolBox/USBToolBox.cpp:276–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276void USBToolBox::mergeProperties(IORegistryEntry* instance) {
277 const OSSymbol* portsSymbol = OSSymbol::withCString("ports");
278
279 if (instance) {
280 this->controllerInstance = instance;
281 }
282 DEBUGLOGPROV("Merging properties");
283
284 if (!(checkKernelArgument(bootargAppleOff) || checkProperty(propertyAppleOff))) {
285 DEBUGLOGPROV("Removing any preexisting ports");
286 deleteProperty(this->controllerInstance, "ports");
287 deleteProperty(this->controllerInstance, "port-count");
288 } else {
289 SYSTEMLOGPROV("Apple off specified, not removing any preexisting ports");
290 }
291
292 if (!(checkKernelArgument(bootargMapOff) || checkProperty(propertyMapOff))) {
293 OSDictionary* properties = NULL;
294 if ((properties = OSDynamicCast(OSDictionary, getProperty("IOProviderMergeProperties")))) {
295 DEBUGLOGPROV("Applying map");
296 } else if ((properties = OSDynamicCast(OSDictionary, this->pciDevice->getProperty("IOProviderMergeProperties")))) {
297 DEBUGLOGPROV("Applying map from provider");
298 }
299
300 if (properties) {
301 if (OSCollectionIterator* propertyIterator = OSCollectionIterator::withCollection(properties)) {
302 DEBUGLOGPROV("Starting iteration over properties");
303 while (OSSymbol* key = OSDynamicCast(OSSymbol, propertyIterator->getNextObject())) {
304 OSObject* value = properties->getObject(key);
305 if (!value) {
306 DEBUGLOGPROV("Property %s is null, skipping", key->getCStringNoCopy());
307 continue;
308 }
309 value->retain(); // Needed for proper handling in fixMapForTahoe
310
311 if (key == portsSymbol && version_major >= 25) {
312 DEBUGLOGPROV("Fixing map");
313 value = fixMapForTahoe(value);
314 }
315
316 //DEBUGLOGPROV("Applied property %s", key->getCStringNoCopy());
317 this->controllerInstance->setProperty(key, value);
318 OSSafeReleaseNULL(value);
319 }
320 SYSTEMLOGPROV("Successfully applied map");
321 OSSafeReleaseNULL(propertyIterator);
322 } else {
323 SYSTEMLOGPROV("Failed to create property iterator!");
324 }
325 } else {
326 DEBUGLOGPROV("No properties to apply");
327 }
328
329 } else {
330 SYSTEMLOGPROV("Map disabled, continuing");
331 }
332 this->controllerInstance->release();
333 OSSafeReleaseNULL(portsSymbol);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected