Changeset 59330 in vbox for trunk/src/VBox/Main/src-server/darwin/iokit.cpp
- Timestamp:
- Jan 13, 2016 10:21:15 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/darwin/iokit.cpp
r59122 r59330 50 50 #include <iprt/thread.h> 51 51 #include <iprt/uuid.h> 52 #include <iprt/system.h> 52 53 #ifdef STANDALONE_TESTCASE 53 54 # include <iprt/initterm.h> … … 76 77 #define VBOXUSBDEVICE_CLASS_NAME "org_virtualbox_VBoxUSBDevice" 77 78 79 /** Define the constant for the IOUSBHostDevice class name added in El Capitan. */ 80 #ifndef kIOUSBHostDeviceClassName 81 # define kIOUSBHostDeviceClassName "IOUSBHostDevice" 82 #endif 83 84 /** The major darwin version indicating OS X El Captian, used to take care of the USB changes. */ 85 #define VBOX_OSX_EL_CAPTIAN_VER 15 78 86 79 87 /********************************************************************************************************************************* … … 82 90 /** The IO Master Port. */ 83 91 static mach_port_t g_MasterPort = NULL; 92 /** Major darwin version as returned by uname -r. 93 * Used to changes to */ 94 uint32_t g_uMajorDarwin = 0; 84 95 85 96 … … 95 106 kern_return_t krc = IOMasterPort(MACH_PORT_NULL, &g_MasterPort); 96 107 AssertReturn(krc == KERN_SUCCESS, false); 108 109 /* Get the darwin version we are running on. */ 110 char aszVersion[16] = { 0 }; 111 int rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, &aszVersion[0], sizeof(aszVersion)); 112 if (RT_SUCCESS(rc)) 113 { 114 /* Make sure it is zero terminated (paranoia). */ 115 aszVersion[15] = '\0'; 116 rc = RTStrToUInt32Ex(&aszVersion[0], NULL, 10, &g_uMajorDarwin); 117 if ( rc != VINF_SUCCESS 118 && rc != VWRN_TRAILING_CHARS) 119 LogRel(("IOKit: Failed to convert the major part of the version string \"%s\" into an integer\n", &aszVersion[0])); 120 } 121 else 122 LogRel(("IOKit: Failed to query the OS release version with %Rrc\n", rc)); 97 123 } 98 124 return true; … … 517 543 } DARWINUSBNOTIFY, *PDARWINUSBNOTIFY; 518 544 545 /** 546 * Returns the correct class name to identify USB devices. El Capitan 547 * introduced a reworked USb stack with changed names. 548 * The old names are still available but the objects don't reveal all the 549 * information required. 550 */ 551 DECLINLINE(const char *)darwinGetUsbDeviceClassName(void) 552 { 553 return g_uMajorDarwin >= VBOX_OSX_EL_CAPTIAN_VER 554 ? kIOUSBHostDeviceClassName 555 : kIOUSBDeviceClassName; 556 } 519 557 520 558 /** … … 619 657 kern_return_t rc = IOServiceAddMatchingNotification(pNotify->NotifyPort, 620 658 kIOPublishNotification, 621 IOServiceMatching( kIOUSBDeviceClassName),659 IOServiceMatching(darwinGetUsbDeviceClassName()), 622 660 darwinUSBAttachNotification1, 623 661 pNotify, … … 628 666 rc = IOServiceAddMatchingNotification(pNotify->NotifyPort, 629 667 kIOMatchedNotification, 630 IOServiceMatching( kIOUSBDeviceClassName),668 IOServiceMatching(darwinGetUsbDeviceClassName()), 631 669 darwinUSBAttachNotification2, 632 670 pNotify, … … 637 675 rc = IOServiceAddMatchingNotification(pNotify->NotifyPort, 638 676 kIOTerminatedNotification, 639 IOServiceMatching( kIOUSBDeviceClassName),677 IOServiceMatching(darwinGetUsbDeviceClassName()), 640 678 darwinUSBDetachNotification, 641 679 pNotify, … … 820 858 fUserClientOnly = false; 821 859 822 if (!strcmp(szName, "IOUSBMassStorageClass")) 860 if ( !strcmp(szName, "IOUSBMassStorageClass") 861 || !strcmp(szName, "IOUSBMassStorageInterfaceNub")) 823 862 { 824 863 /* Only permit capturing MSDs that aren't mounted, at least … … 906 945 * Create a matching dictionary for searching for USB Devices in the IOKit. 907 946 */ 908 CFMutableDictionaryRef RefMatchingDict = IOServiceMatching( kIOUSBDeviceClassName);947 CFMutableDictionaryRef RefMatchingDict = IOServiceMatching(darwinGetUsbDeviceClassName()); 909 948 AssertReturn(RefMatchingDict, NULL); 910 949 … … 981 1020 darwinDictGetU8(PropsRef, CFSTR("PortNum"), &pCur->bPort); /* Not present in 10.11 beta 3, so ignore failure. (Is set to zero.) */ 982 1021 uint8_t bSpeed; 983 AssertBreak(darwinDictGetU8(PropsRef, CFSTR(kUSBDevicePropertySpeed), &bSpeed)); 984 Assert(bSpeed <= 3); 985 pCur->enmSpeed = bSpeed == 3 ? USBDEVICESPEED_SUPER 1022 AssertBreak(darwinDictGetU8(PropsRef, 1023 g_uMajorDarwin >= VBOX_OSX_EL_CAPTIAN_VER 1024 ? CFSTR("USBSpeed") 1025 : CFSTR(kUSBDevicePropertySpeed), 1026 &bSpeed)); 1027 Assert(bSpeed <= 4); 1028 pCur->enmSpeed = bSpeed == 3 || bSpeed == 4 ? USBDEVICESPEED_SUPER 986 1029 : bSpeed == 2 ? USBDEVICESPEED_HIGH 987 1030 : bSpeed == 1 ? USBDEVICESPEED_FULL … … 1134 1177 */ 1135 1178 1136 CFMutableDictionaryRef RefMatchingDict = IOServiceMatching( kIOUSBDeviceClassName);1179 CFMutableDictionaryRef RefMatchingDict = IOServiceMatching(darwinGetUsbDeviceClassName()); 1137 1180 AssertReturn(RefMatchingDict, NULL); 1138 1181
Note:
See TracChangeset
for help on using the changeset viewer.