diff --git a/Changelog.md b/Changelog.md index 2b59b50..f5cb45f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ VirtualSMC Changelog ==================== +#### v1.1.2 +- Improved performance with Lilu 1.4.3 APIs + #### v1.1.1 - Fixed SMCSuperIO crashes with unsupported chips - SMCSuperIO detected chip name to ioreg diff --git a/Sensors/SMCProcessor/SMCProcessor.cpp b/Sensors/SMCProcessor/SMCProcessor.cpp index e3ba649..e7580e9 100644 --- a/Sensors/SMCProcessor/SMCProcessor.cpp +++ b/Sensors/SMCProcessor/SMCProcessor.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -267,7 +268,11 @@ bool SMCProcessor::start(IOService *provider) { return false; } - cpuGeneration = CPUInfo::getGeneration(&cpuFamily, &cpuModel, &cpuStepping); + auto &bdi = BaseDeviceInfo::get(); + cpuGeneration = bdi.cpuGeneration; + cpuFamily = bdi.cpuFamily; + cpuModel = bdi.cpuModel; + cpuStepping = bdi.cpuStepping; if (cpuGeneration == CPUInfo::CpuGeneration::Unknown || cpuGeneration < CPUInfo::CpuGeneration::Penryn) { SYSLOG("scpu", "failed to find a compatible processor"); @@ -331,36 +336,34 @@ bool SMCProcessor::start(IOService *provider) { // Some laptop models start core sensors not with 0, but actually with 1. size_t coreOffset = 0; - char model[80]; - if (WIOKit::getComputerInfo(model, sizeof(model), nullptr, 0)) { - if (!strncmp(model, "MacBook", strlen("MacBook"))) { - auto rmodel = model + strlen("MacBook"); - auto isdigit = [](auto l) { return l >= '0' && l <= '9'; }; - - if (!strncmp(rmodel, "Air", strlen("Air"))) { - // MacBookAir6,1 and above - const char *suffix = rmodel + strlen("Air"); - if (isdigit(suffix[0]) && (isdigit(suffix[1]) || suffix[0] >= '6')) - coreOffset = 1; - } else if (!strncmp(model, "Pro", strlen("Pro"))) { - const char *suffix = rmodel + strlen("Pro"); - if (isdigit(suffix[0]) && isdigit(suffix[1]) && ((suffix[0] == '1' && suffix[1] >= '3') || suffix[0] > '1')) { - // MacBookPro13,1 and above - coreOffset = 1; - } else { - // Select MacBookPro models of previous generations (excluding: 10,2; 11,1; 12,x) - const char *matches[] { "8,", "9,", "10,1", "11,2", "11,3", "11,4", "11,5" }; - for (auto &match : matches) { - if (!strncmp(suffix, match, strlen(match))) { - coreOffset = 1; - break; - } + auto model = BaseDeviceInfo::get().modelIdentifier; + if (!strncmp(model, "MacBook", strlen("MacBook"))) { + auto rmodel = model + strlen("MacBook"); + auto isdigit = [](auto l) { return l >= '0' && l <= '9'; }; + + if (!strncmp(rmodel, "Air", strlen("Air"))) { + // MacBookAir6,1 and above + const char *suffix = rmodel + strlen("Air"); + if (isdigit(suffix[0]) && (isdigit(suffix[1]) || suffix[0] >= '6')) + coreOffset = 1; + } else if (!strncmp(model, "Pro", strlen("Pro"))) { + const char *suffix = rmodel + strlen("Pro"); + if (isdigit(suffix[0]) && isdigit(suffix[1]) && ((suffix[0] == '1' && suffix[1] >= '3') || suffix[0] > '1')) { + // MacBookPro13,1 and above + coreOffset = 1; + } else { + // Select MacBookPro models of previous generations (excluding: 10,2; 11,1; 12,x) + const char *matches[] { "8,", "9,", "10,1", "11,2", "11,3", "11,4", "11,5" }; + for (auto &match : matches) { + if (!strncmp(suffix, match, strlen(match))) { + coreOffset = 1; + break; } } - } else if (isdigit(rmodel[0]) && (isdigit(rmodel[1]) || rmodel[0] >= '8')) { - // MacBook8,1 and above - coreOffset = 1; } + } else if (isdigit(rmodel[0]) && (isdigit(rmodel[1]) || rmodel[0] >= '8')) { + // MacBook8,1 and above + coreOffset = 1; } } else { SYSLOG("scpu", "failed to get system model"); diff --git a/VirtualSMC.xcodeproj/project.pbxproj b/VirtualSMC.xcodeproj/project.pbxproj index b1eb65c..8bcb75d 100644 --- a/VirtualSMC.xcodeproj/project.pbxproj +++ b/VirtualSMC.xcodeproj/project.pbxproj @@ -1097,7 +1097,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1010; - LastUpgradeCheck = 1130; + LastUpgradeCheck = 1140; ORGANIZATIONNAME = vit9696; TargetAttributes = { 1C748C261C21952C0024EED2 = { @@ -1461,7 +1461,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; - MODULE_VERSION = 1.1.1; + MODULE_VERSION = 1.1.2; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; VALID_ARCHS = x86_64; @@ -1509,7 +1509,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; - MODULE_VERSION = 1.1.1; + MODULE_VERSION = 1.1.2; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; VALID_ARCHS = x86_64; @@ -2128,7 +2128,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; - MODULE_VERSION = 1.1.1; + MODULE_VERSION = 1.1.2; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; VALID_ARCHS = x86_64; diff --git a/VirtualSMC/kern_keystore.cpp b/VirtualSMC/kern_keystore.cpp index 9f1358a..482c263 100644 --- a/VirtualSMC/kern_keystore.cpp +++ b/VirtualSMC/kern_keystore.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -348,7 +349,7 @@ bool VirtualSMCKeystore::mergePredefined(const char *board, int model) { if (!addKey(KeyNum, valueNum)) return false; - SMC_DATA dataBEMB[] {WIOKit::getComputerModel() == WIOKit::ComputerModel::ComputerLaptop}; + SMC_DATA dataBEMB[] {BaseDeviceInfo::get().modelType == WIOKit::ComputerModel::ComputerLaptop}; if (!addKey(KeyBEMB, VirtualSMCValueVariable::withData( dataBEMB, sizeof(dataBEMB), SmcKeyTypeFlag, SMC_KEY_ATTRIBUTE_READ))) return false; diff --git a/VirtualSMC/kern_vsmc.cpp b/VirtualSMC/kern_vsmc.cpp index 835ee66..b38dcb9 100644 --- a/VirtualSMC/kern_vsmc.cpp +++ b/VirtualSMC/kern_vsmc.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -70,16 +71,13 @@ bool VirtualSMC::start(IOService *provider) { SYSLOG("vsmc", "watchdog loop allocation failure"); } - int computerModel = WIOKit::getComputerModel(); + int computerModel = BaseDeviceInfo::get().modelType; if (computerModel == WIOKit::ComputerModel::ComputerAny) { DBGLOG("vsmc", "failed to determine laptop or desktop model"); computerModel = WIOKit::ComputerModel::ComputerInvalid; } - char boardIdentifier[64]; - if (!WIOKit::getComputerInfo(nullptr, 0, boardIdentifier, sizeof(boardIdentifier))) { - DBGLOG("vsmc", "failed to obtain board-id"); - } + auto boardIdentifier = BaseDeviceInfo::get().boardIdentifier; SMCInfo deviceInfo {};