| 20 | OSDefineMetaClassAndStructors(USBToolBox, IOService) |
| 21 | |
| 22 | OSDictionary* USBToolBox::createMatchingDictionary() { |
| 23 | char pciDevicePath[PARENT_PATH_LENGTH] = { 0 }; |
| 24 | int pciDevicePathLength = sizeof(pciDevicePath); |
| 25 | |
| 26 | bool pciDevicePathStatus = pciDevice->getPath(pciDevicePath, &pciDevicePathLength, gIOServicePlane); |
| 27 | |
| 28 | if (!pciDevicePathStatus) { |
| 29 | SYSTEMLOGPROV("Failed to get PCI device path!"); |
| 30 | return NULL; |
| 31 | } else { |
| 32 | DEBUGLOGPROV("Path is %s, length %d", pciDevicePath, pciDevicePathLength); |
| 33 | } |
| 34 | |
| 35 | OSString* pciDevicePathString = OSString::withCString(pciDevicePath); |
| 36 | |
| 37 | if (!pciDevicePathString) { |
| 38 | SYSTEMLOGPROV("Failed to create OSString of PCI device path!"); |
| 39 | return NULL; |
| 40 | } |
| 41 | |
| 42 | const OSSymbol* pathMatchKey = OSSymbol::withCString("IOPathMatch"); |
| 43 | |
| 44 | if (!pathMatchKey) { |
| 45 | SYSTEMLOGPROV("Failed to create path match key!"); |
| 46 | OSSafeReleaseNULL(pciDevicePathString); |
| 47 | return NULL; |
| 48 | } |
| 49 | |
| 50 | const OSObject* parentMatchObjects[] {pciDevicePathString}; |
| 51 | const OSSymbol* parentMatchSymbols[] {pathMatchKey}; |
| 52 | |
| 53 | OSDictionary* parentMatch = OSDictionary::withObjects(parentMatchObjects, parentMatchSymbols, 1); |
| 54 | |
| 55 | OSSafeReleaseNULL(pathMatchKey); |
| 56 | OSSafeReleaseNULL(pciDevicePathString); |
| 57 | |
| 58 | if (!parentMatch) { |
| 59 | SYSTEMLOGPROV("Failed to create parent match dict!"); |
| 60 | return NULL; |
| 61 | } |
| 62 | |
| 63 | OSDictionary* matchingDict = serviceMatching("AppleUSBHostController"); |
| 64 | |
| 65 | if (!matchingDict) { |
| 66 | SYSTEMLOGPROV("Failed to create matching dict!"); |
| 67 | OSSafeReleaseNULL(parentMatch); |
| 68 | return NULL; |
| 69 | } |
| 70 | |
| 71 | bool setParentMatchStatus = matchingDict->setObject("IOParentMatch", parentMatch); |
| 72 | |
| 73 | OSSafeReleaseNULL(parentMatch); |
| 74 | |
| 75 | if (!setParentMatchStatus) { |
| 76 | SYSTEMLOGPROV("Failed to set parent match!"); |
| 77 | OSSafeReleaseNULL(matchingDict); |
| 78 | return NULL; |
| 79 | } |
nothing calls this directly
no outgoing calls
no test coverage detected