From 9d50e555ca4b2437b537b9d40e3543608c84c2fc Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sun, 27 Jan 2019 21:07:49 +0300 Subject: [PATCH] Added support for VMware device scanning --- Changelog.md | 1 + Lilu/Headers/kern_iokit.hpp | 5 +++-- Lilu/Sources/kern_devinfo.cpp | 26 +++++++++++++++----------- Lilu/Sources/kern_patcher.cpp | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Changelog.md b/Changelog.md index 29218464..45693d79 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ Lilu Changelog ============== #### v1.3.3 - Added support for modern AMD device scanning by @AlGreyy +- Added support for VMware device scanning #### v1.3.2 - Extended supported firmware vendor list diff --git a/Lilu/Headers/kern_iokit.hpp b/Lilu/Headers/kern_iokit.hpp index 38e20528..a9b8c138 100644 --- a/Lilu/Headers/kern_iokit.hpp +++ b/Lilu/Headers/kern_iokit.hpp @@ -139,8 +139,9 @@ namespace WIOKit { enum : uint16_t { ATIAMD = 0x1002, AMDZEN = 0x1022, - NVIDIA = 0x10de, - Intel = 0x8086 + NVIDIA = 0x10DE, + Intel = 0x8086, + VMware = 0x15AD }; }; diff --git a/Lilu/Sources/kern_devinfo.cpp b/Lilu/Sources/kern_devinfo.cpp index 40504928..940d5dda 100644 --- a/Lilu/Sources/kern_devinfo.cpp +++ b/Lilu/Sources/kern_devinfo.cpp @@ -231,7 +231,8 @@ void DeviceInfo::grabDevicesFromPciRoot(IORegistryEntry *pciRoot) { // Strip interface, as we only care about class and subclass code &= WIOKit::ClassCode::PCISubclassMask; - if (!gotVendor || !gotClass || (vendor != WIOKit::VendorID::Intel && vendor != WIOKit::VendorID::ATIAMD && vendor != WIOKit::VendorID::AMDZEN)) + if (!gotVendor || !gotClass || (vendor != WIOKit::VendorID::Intel && vendor != WIOKit::VendorID::ATIAMD && + vendor != WIOKit::VendorID::AMDZEN && vendor != WIOKit::VendorID::VMware)) continue; if (vendor == WIOKit::VendorID::Intel && (code == WIOKit::ClassCode::DisplayController || code == WIOKit::ClassCode::VGAController)) { @@ -272,24 +273,27 @@ void DeviceInfo::grabDevicesFromPciRoot(IORegistryEntry *pciRoot) { safeString(pciobj->getName()), safeString(name), pcivendor); v.video = pciobj; v.vendor = pcivendor; - } else if (pcicode == WIOKit::ClassCode::HDADevice && pcivendor != WIOKit::VendorID::AMDZEN) { - DBGLOG("dev", "found HDAU device %s at %s by %04X", - safeString(pciobj->getName()), safeString(name), pcivendor); - v.audio = pciobj; } else if (pcicode == WIOKit::ClassCode::HDADevice) { - // On modern AMD platforms built-in audio devices sits on a PCI bridge just any other device. - // Luckily it has a distinct device-id for the time being. - DBGLOG("dev", "found AMD HDEF device %s at %s by %04X", + DBGLOG("dev", "found audio device %s at %s by %04X", safeString(pciobj->getName()), safeString(name), pcivendor); - audioBuiltinAnalog = pciobj; + v.audio = pciobj; } } } pciiterator->release(); - if (v.video && !videoExternal.push_back(v)) - SYSLOG("dev", "failed to push video gpu"); + if (v.video) { + DBGLOG_COND(v.audio, "dev", "marking audio device as HDAU at %s", safeString(v.audio->getName())); + if (!videoExternal.push_back(v)) + SYSLOG("dev", "failed to push video gpu"); + } else if (v.audio && !audioBuiltinAnalog) { + // On modern AMD platforms or VMware built-in audio devices sits on a PCI bridge just any other device. + // On AMD it has a distinct Ryzen device-id for the time being, yet on VMware it is just Intel. + // To distinguish the devices we use audio card presence as a marker. + DBGLOG("dev", "marking audio device as HDEF at %s", safeString(v.audio->getName())); + audioBuiltinAnalog = v.audio; + } } } } diff --git a/Lilu/Sources/kern_patcher.cpp b/Lilu/Sources/kern_patcher.cpp index 2a9fe9cb..c396b1a1 100644 --- a/Lilu/Sources/kern_patcher.cpp +++ b/Lilu/Sources/kern_patcher.cpp @@ -587,7 +587,7 @@ void KernelPatcher::onKextSummariesUpdated() { } if (that->khandlers.size() > 0) { OSKextLoadedKextSummary &last = (*that->loadedKextSummaries)->summaries[num-1]; - DBGLOG("patcher", "last kext is %llX and its name is %.*s", last.address, KMOD_MAX_NAME, last.name); + DBGLOG("patcher", "last kext is " PRIKADDR " and its name is %.*s", CASTKADDR(last.address), KMOD_MAX_NAME, last.name); // We may add khandlers items inside the handler for (size_t i = 0; i < that->khandlers.size(); i++) { auto handler = that->khandlers[i];