From 6ff5bab8a5f75b05faf3097e93d012e427f31c49 Mon Sep 17 00:00:00 2001 From: jief666 Date: Sat, 3 Apr 2021 17:42:49 +0300 Subject: [PATCH] Create section Smbios and BootGraphics. Move OptionsBits and FlagsBits in GlobalConfig. Move OEMVendor, OEMProduct, OEMBoard in GlobalConfig. Move KernelPatchesAllowed, KextPatchesAllowed, EnabledCores and BlockKexts in GlobalConfig. Create RomVersionUsed, EfiVersionUsed and ReleaseDateUsed in GlobalConfig. Move gFwFeatures, gFwFeaturesMask, gPlatformFeature, SlotDevices in Smbios section. Move UserInUse, UserChannels and User from gRAM to Smbios settings section. Rename enum LANGUAGES to LanguageCode. --- Xcode/CloverX64TestNewParser/src/tmp.c | 22 -- Xcode/CloverX64TestNewParser/src/tmp.h | 14 - rEFIt_UEFI/Platform/AcpiPatcher.cpp | 2 +- rEFIt_UEFI/Platform/DataHubCpu.cpp | 86 ++--- rEFIt_UEFI/Platform/FixBiosDsdt.cpp | 12 +- rEFIt_UEFI/Platform/Settings.cpp | 399 ++++++++++++----------- rEFIt_UEFI/Platform/Settings.h | 310 +++++++----------- rEFIt_UEFI/Platform/gma.cpp | 12 +- rEFIt_UEFI/Platform/guid.h | 3 + rEFIt_UEFI/Platform/kernel_patcher.cpp | 8 +- rEFIt_UEFI/Platform/kext_inject.cpp | 2 +- rEFIt_UEFI/Platform/platformdata.cpp | 290 ++++++++-------- rEFIt_UEFI/Platform/platformdata.h | 12 +- rEFIt_UEFI/Platform/plist/base64.h | 2 +- rEFIt_UEFI/Platform/smbios.cpp | 327 ++++++++++--------- rEFIt_UEFI/Platform/smbios.h | 15 +- rEFIt_UEFI/Platform/spd.cpp | 20 +- rEFIt_UEFI/cpp_foundation/XToolsCommon.h | 2 +- rEFIt_UEFI/gui/REFIT_MAINMENU_SCREEN.cpp | 14 +- rEFIt_UEFI/gui/shared_with_menu.cpp | 8 +- rEFIt_UEFI/include/Languages.h | 2 +- rEFIt_UEFI/libeg/text.cpp | 6 +- rEFIt_UEFI/refit/main.cpp | 80 ++--- rEFIt_UEFI/refit/menu.cpp | 98 +++--- 24 files changed, 841 insertions(+), 905 deletions(-) delete mode 100644 Xcode/CloverX64TestNewParser/src/tmp.c delete mode 100644 Xcode/CloverX64TestNewParser/src/tmp.h diff --git a/Xcode/CloverX64TestNewParser/src/tmp.c b/Xcode/CloverX64TestNewParser/src/tmp.c deleted file mode 100644 index 3dae6386b..000000000 --- a/Xcode/CloverX64TestNewParser/src/tmp.c +++ /dev/null @@ -1,22 +0,0 @@ -// -// tmp.c -// cpp_tests_compare_settings UTF16 signed char -// -// Created by Jief on 06/02/2021. -// Copyright © 2021 JF Knudsen. All rights reserved. -// - -#include "tmp.h" -// -//int __vsnprintf_chk (char* buf, size_t len, int check, size_t size, const char* format, va_list va) -//{ -// return 0; -//} - -extern "C" void tmp() -{ - wprintf(L"%ls\n", L"Hello world൧楔"); - -} - - diff --git a/Xcode/CloverX64TestNewParser/src/tmp.h b/Xcode/CloverX64TestNewParser/src/tmp.h deleted file mode 100644 index c02e3386e..000000000 --- a/Xcode/CloverX64TestNewParser/src/tmp.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// tmp.h -// cpp_tests_compare_settings UTF16 signed char -// -// Created by Jief on 06/02/2021. -// Copyright © 2021 JF Knudsen. All rights reserved. -// - -#ifndef tmp_h -#define tmp_h - -#include - -#endif /* tmp_h */ diff --git a/rEFIt_UEFI/Platform/AcpiPatcher.cpp b/rEFIt_UEFI/Platform/AcpiPatcher.cpp index 4ce6f31b9..d84d388dc 100644 --- a/rEFIt_UEFI/Platform/AcpiPatcher.cpp +++ b/rEFIt_UEFI/Platform/AcpiPatcher.cpp @@ -1855,7 +1855,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, const MacOsVersion& OSVersion) DBG("old FADT length=%X\n", oldLength); CopyMem(newFadt, FadtPointer, oldLength); //old data newFadt->Header.Length = 0xF4; - CopyMem(newFadt->Header.OemId, BiosVendor.c_str(), 6); + CopyMem(newFadt->Header.OemId, AppleBiosVendor.c_str(), 6); if (newFadt->Header.Revision < EFI_ACPI_4_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION) { newFadt->Header.Revision = EFI_ACPI_4_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION; } diff --git a/rEFIt_UEFI/Platform/DataHubCpu.cpp b/rEFIt_UEFI/Platform/DataHubCpu.cpp index 1f22f79d1..4ae7b0af6 100644 --- a/rEFIt_UEFI/Platform/DataHubCpu.cpp +++ b/rEFIt_UEFI/Platform/DataHubCpu.cpp @@ -21,7 +21,7 @@ // // 2019/06/08 // vector sigma -// don't inject REV, RBr and EPCI keys if gSettings.REV is zeroed +// don't inject REV, RBr and EPCI keys if gSettings.Smbios.REV is zeroed // #ifndef DEBUG_ALL @@ -268,18 +268,18 @@ SetVariablesForOSX(LOADER_ENTRY *Entry) SetNvramVariable(L"FirmwareFeatures", &gEfiAppleNvramGuid, Attributes, - sizeof(gFwFeatures), - &gFwFeatures); + sizeof(gSettings.Smbios.gFwFeatures), + &gSettings.Smbios.gFwFeatures); // Download-Fritz: Should be added to SMBIOS or at least to some other config section AddNvramVariable(L"FirmwareFeaturesMask", &gEfiAppleNvramGuid, Attributes, - sizeof(gFwFeaturesMask), - &gFwFeaturesMask); + sizeof(gSettings.Smbios.gFwFeaturesMask), + &gSettings.Smbios.gFwFeaturesMask); // HW_MLB and HW_ROM are also around on some Macs with the same values as MLB and ROM - AddNvramXString8(L"HW_BID", &gEfiAppleNvramGuid, Attributes, gSettings.BoardNumber); + AddNvramXString8(L"HW_BID", &gEfiAppleNvramGuid, Attributes, gSettings.Smbios.BoardNumber); // @@ -295,8 +295,8 @@ SetVariablesForOSX(LOADER_ENTRY *Entry) KbdPrevLang = L"prev-lang:kbd"; OldData = (__typeof__(OldData))GetNvramVariable(KbdPrevLang, &gEfiAppleBootGuid, NULL, NULL); if (OldData == NULL) { - gSettings.Language.trim(); - SetNvramXString8(KbdPrevLang, &gEfiAppleBootGuid, Attributes, gSettings.Language); + gSettings.GUI.Language.trim(); + SetNvramXString8(KbdPrevLang, &gEfiAppleBootGuid, Attributes, gSettings.GUI.Language); } else { FreePool(OldData); } @@ -327,7 +327,7 @@ SetVariablesForOSX(LOADER_ENTRY *Entry) // we should have two UUID: platform and system // NO! Only Platform is the best solution if (!gSettings.ShouldInjectSystemID()) { - if (gSettings.SmUUID.notEmpty()) { + if (gSettings.Smbios.SmUUID.notEmpty()) { SetNvramVariable(L"platform-uuid", &gEfiAppleBootGuid, Attributes, sizeof(uuid), &uuid); } else { AddNvramVariable(L"platform-uuid", &gEfiAppleBootGuid, Attributes, sizeof(uuid), &uuid); @@ -343,13 +343,13 @@ SetVariablesForOSX(LOADER_ENTRY *Entry) } } - if (gSettings.DefaultBackgroundColor == 0x80000000) { + if (gSettings.BootGraphics.DefaultBackgroundColor == 0x80000000) { DeleteNvramVariable(L"DefaultBackgroundColor", &gEfiAppleNvramGuid); } else { UINT16 ActualDensity = 0xE1; UINT16 DensityThreshold = 0x96; UINT64 ConfigStatus = 0; - Color = gSettings.DefaultBackgroundColor; + Color = gSettings.BootGraphics.DefaultBackgroundColor; DBG("set DefaultBackgroundColor=0x%x\n", Color); SetNvramVariable(L"DefaultBackgroundColor", &gEfiAppleNvramGuid, Attributes, 4, &Color); // add some UI variables @@ -358,23 +358,23 @@ SetVariablesForOSX(LOADER_ENTRY *Entry) SetNvramVariable(L"gfx-saved-config-restore-status", &gEfiAppleNvramGuid, Attributes, 8, &ConfigStatus); } - if (gSettings.UIScale == 0x80000000) { + if (gSettings.BootGraphics.UIScale == 0x80000000) { DeleteNvramVariable(L"UIScale", &gEfiAppleNvramGuid); } else { - SetNvramVariable(L"UIScale", &gEfiAppleNvramGuid, Attributes, 1, &gSettings.UIScale); + SetNvramVariable(L"UIScale", &gEfiAppleNvramGuid, Attributes, 1, &gSettings.BootGraphics.UIScale); } - if (gSettings.EFILoginHiDPI == 0x80000000) { + if (gSettings.BootGraphics.EFILoginHiDPI == 0x80000000) { DeleteNvramVariable(L"EFILoginHiDPI", &gEfiAppleBootGuid); } else { - SetNvramVariable(L"EFILoginHiDPI", &gEfiAppleBootGuid, Attributes, 4, &gSettings.EFILoginHiDPI); + SetNvramVariable(L"EFILoginHiDPI", &gEfiAppleBootGuid, Attributes, 4, &gSettings.BootGraphics.EFILoginHiDPI); } // ->GetVariable(flagstate, gEfiAppleBootGuid, 0/0, 20, 10FE110) = Not Found - if (gSettings.flagstate[3] == 0x80) { + if (gSettings.BootGraphics.flagstate[3] == 0x80) { DeleteNvramVariable(L"flagstate", &gEfiAppleBootGuid); } else { - SetNvramVariable(L"flagstate", &gEfiAppleBootGuid, Attributes, 32, &gSettings.flagstate); + SetNvramVariable(L"flagstate", &gEfiAppleBootGuid, Attributes, 32, &gSettings.BootGraphics.flagstate); } // Hack for recovery by Asgorath @@ -456,12 +456,12 @@ SetupDataForOSX(BOOLEAN Hibernate) UINT64 ARTFrequency; UINTN Revision; UINT16 Zero = 0; - BOOLEAN isRevLess = (gSettings.REV[0] == 0 && - gSettings.REV[1] == 0 && - gSettings.REV[2] == 0 && - gSettings.REV[3] == 0 && - gSettings.REV[4] == 0 && - gSettings.REV[5] == 0); + BOOLEAN isRevLess = (gSettings.Smbios.REV[0] == 0 && + gSettings.Smbios.REV[1] == 0 && + gSettings.Smbios.REV[2] == 0 && + gSettings.Smbios.REV[3] == 0 && + gSettings.Smbios.REV[4] == 0 && + gSettings.Smbios.REV[5] == 0); Revision = StrDecimalToUintn(gFirmwareRevision); @@ -497,10 +497,10 @@ SetupDataForOSX(BOOLEAN Hibernate) Status = gBS->LocateProtocol(&gEfiDataHubProtocolGuid, NULL, (void**)&gDataHub); if (!EFI_ERROR(Status)) { XStringW ProductName; - ProductName.takeValueFrom(gSettings.ProductName); + ProductName.takeValueFrom(gSettings.Smbios.ProductName); XStringW SerialNumber; - SerialNumber.takeValueFrom(gSettings.SerialNr); + SerialNumber.takeValueFrom(gSettings.Smbios.SerialNr); LogDataHub(&gEfiProcessorSubClassGuid, L"FSBFrequency", &FrontSideBus, sizeof(UINT64)); @@ -513,8 +513,8 @@ SetupDataForOSX(BOOLEAN Hibernate) LogDataHub(&gEfiProcessorSubClassGuid, L"InitialTSC", &TscFrequency, sizeof(UINT64)); LogDataHub(&gEfiProcessorSubClassGuid, L"CPUFrequency", &CpuSpeed, sizeof(UINT64)); - //gSettings.BoardNumber - LogDataHubXString8(&gEfiMiscSubClassGuid, L"board-id", gSettings.BoardNumber); + //gSettings.Smbios.BoardNumber + LogDataHubXString8(&gEfiMiscSubClassGuid, L"board-id", gSettings.Smbios.BoardNumber); TscFrequency++; LogDataHub(&gEfiProcessorSubClassGuid, L"board-rev", &TscFrequency, 1); @@ -532,18 +532,18 @@ SetupDataForOSX(BOOLEAN Hibernate) LogDataHub(&gEfiProcessorSubClassGuid, L"clovergui-revision", &Revision, sizeof(UINT32)); // collect info about real hardware - LogDataHubXString8(&gEfiMiscSubClassGuid, L"OEMVendor", gSettings.OEMVendor); - LogDataHubXString8(&gEfiMiscSubClassGuid, L"OEMProduct", gSettings.OEMProduct); - LogDataHubXString8(&gEfiMiscSubClassGuid, L"OEMBoard", gSettings.OEMBoard); + LogDataHubXString8(&gEfiMiscSubClassGuid, L"OEMVendor", GlobalConfig.OEMVendorFromSmbios); + LogDataHubXString8(&gEfiMiscSubClassGuid, L"OEMProduct", GlobalConfig.OEMProductFromSmbios); + LogDataHubXString8(&gEfiMiscSubClassGuid, L"OEMBoard", GlobalConfig.OEMBoardFromSmbios); // SMC helper if (!isRevLess) { - LogDataHub(&gEfiMiscSubClassGuid, L"RBr", &gSettings.RBr, 8); - LogDataHub(&gEfiMiscSubClassGuid, L"EPCI", &gSettings.EPCI, 4); - LogDataHub(&gEfiMiscSubClassGuid, L"REV", &gSettings.REV, 6); + LogDataHub(&gEfiMiscSubClassGuid, L"RBr", &gSettings.Smbios.RBr, 8); + LogDataHub(&gEfiMiscSubClassGuid, L"EPCI", &gSettings.Smbios.EPCI, 4); + LogDataHub(&gEfiMiscSubClassGuid, L"REV", &gSettings.Smbios.REV, 6); } - LogDataHub(&gEfiMiscSubClassGuid, L"RPlt", &gSettings.RPlt, 8); - LogDataHub(&gEfiMiscSubClassGuid, L"BEMB", &gSettings.Mobile, 1); + LogDataHub(&gEfiMiscSubClassGuid, L"RPlt", &gSettings.Smbios.RPlt, 8); + LogDataHub(&gEfiMiscSubClassGuid, L"BEMB", &gSettings.Smbios.Mobile, 1); // all current settings // XBuffer xb = gSettings.serialize(); @@ -555,18 +555,18 @@ SetupDataForOSX(BOOLEAN Hibernate) return; } if (!isRevLess) { - AddSMCkey(SMC_MAKE_KEY('R','B','r',' '), 8, SmcKeyTypeCh8, (SMC_DATA *)&gSettings.RBr); - AddSMCkey(SMC_MAKE_KEY('E','P','C','I'), 4, SmcKeyTypeUint32, (SMC_DATA *)&gSettings.EPCI); - AddSMCkey(SMC_MAKE_KEY('R','E','V',' '), 6, SmcKeyTypeCh8, (SMC_DATA *)&gSettings.REV); + AddSMCkey(SMC_MAKE_KEY('R','B','r',' '), 8, SmcKeyTypeCh8, (SMC_DATA *)&gSettings.Smbios.RBr); + AddSMCkey(SMC_MAKE_KEY('E','P','C','I'), 4, SmcKeyTypeUint32, (SMC_DATA *)&gSettings.Smbios.EPCI); + AddSMCkey(SMC_MAKE_KEY('R','E','V',' '), 6, SmcKeyTypeCh8, (SMC_DATA *)&gSettings.Smbios.REV); } - AddSMCkey(SMC_MAKE_KEY('R','P','l','t'), 8, SmcKeyTypeCh8, (SMC_DATA *)&gSettings.RPlt); - AddSMCkey(SMC_MAKE_KEY('B','E','M','B'), 1, SmcKeyTypeFlag, (SMC_DATA *)&gSettings.Mobile); + AddSMCkey(SMC_MAKE_KEY('R','P','l','t'), 8, SmcKeyTypeCh8, (SMC_DATA *)&gSettings.Smbios.RPlt); + AddSMCkey(SMC_MAKE_KEY('B','E','M','B'), 1, SmcKeyTypeFlag, (SMC_DATA *)&gSettings.Smbios.Mobile); //laptop battery keys will be better to import from nvram.plist or read from ACPI(?) //they are needed for FileVault2 who want to draw battery status AddSMCkey(SMC_MAKE_KEY('B','A','T','P'), 1, SmcKeyTypeFlag, (SMC_DATA *)&Zero); //isBatteryPowered - AddSMCkey(SMC_MAKE_KEY('B','N','u','m'), 1, SmcKeyTypeUint8, (SMC_DATA *)&gSettings.Mobile); // Num Batteries - if (gSettings.Mobile) { - AddSMCkey(SMC_MAKE_KEY('B','B','I','N'), 1, SmcKeyTypeUint8, (SMC_DATA *)&gSettings.Mobile); //Battery inserted + AddSMCkey(SMC_MAKE_KEY('B','N','u','m'), 1, SmcKeyTypeUint8, (SMC_DATA *)&gSettings.Smbios.Mobile); // Num Batteries + if (gSettings.Smbios.Mobile) { + AddSMCkey(SMC_MAKE_KEY('B','B','I','N'), 1, SmcKeyTypeUint8, (SMC_DATA *)&gSettings.Smbios.Mobile); //Battery inserted } AddSMCkey(SMC_MAKE_KEY('M','S','T','c'), 1, SmcKeyTypeUint8, (SMC_DATA *)&Zero); // CPU Plimit AddSMCkey(SMC_MAKE_KEY('M','S','A','c'), 2, SmcKeyTypeUint16, (SMC_DATA *)&Zero);// GPU Plimit diff --git a/rEFIt_UEFI/Platform/FixBiosDsdt.cpp b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp index 3809acd9b..4e7aa3a4a 100755 --- a/rEFIt_UEFI/Platform/FixBiosDsdt.cpp +++ b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp @@ -3071,11 +3071,11 @@ UINT32 FIXNetwork (UINT8 *dsdt, UINT32 len, UINT32 card) k = FindName(dsdt + i, Size, "_SUN"); if (k == 0) { aml_add_name(dev, "_SUN"); - aml_add_dword(dev, SlotDevices[5].SlotID); + aml_add_dword(dev, gSettings.Smbios.SlotDevices[5].SlotID); } else { //we have name sun, set the number if (dsdt[k + 4] == 0x0A) { - dsdt[k + 5] = SlotDevices[5].SlotID; + dsdt[k + 5] = gSettings.Smbios.SlotDevices[5].SlotID; } } } @@ -3262,11 +3262,11 @@ UINT32 FIXAirport (UINT8 *dsdt, UINT32 len) k = FindName(dsdt + i, Size, "_SUN"); if (k == 0) { aml_add_name(dev, "_SUN"); - aml_add_dword(dev, SlotDevices[6].SlotID); + aml_add_dword(dev, gSettings.Smbios.SlotDevices[6].SlotID); } else { //we have name sun, set the number if (dsdt[k + 4] == 0x0A) { - dsdt[k + 5] = SlotDevices[6].SlotID; + dsdt[k + 5] = gSettings.Smbios.SlotDevices[6].SlotID; } } } else { @@ -3700,11 +3700,11 @@ UINT32 FIXFirewire (UINT8 *dsdt, UINT32 len) k = FindName(dsdt + i, Size, "_SUN"); if (k == 0) { aml_add_name(device, "_SUN"); - aml_add_dword(device, SlotDevices[12].SlotID); + aml_add_dword(device, gSettings.Smbios.SlotDevices[12].SlotID); } else { //we have name sun, set the number if (dsdt[k + 4] == 0x0A) { - dsdt[k + 5] = SlotDevices[12].SlotID; + dsdt[k + 5] = gSettings.Smbios.SlotDevices[12].SlotID; } } } else { diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 51b53d488..2310bbe4a 100755 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -78,7 +78,6 @@ SETTINGS_DATA gSettings; GFX_PROPERTIES gGraphics[4]; //no more then 4 graphics cards HDA_PROPERTIES gAudios[4]; //no more then 4 Audio Controllers //SLOT_DEVICE Arpt; -SLOT_DEVICE SlotDevices[16]; //assume DEV_XXX, Arpt=6 EFI_EDID_DISCOVERED_PROTOCOL *EdidDiscovered; //UINT8 *gEDID = NULL; //EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; @@ -2481,10 +2480,10 @@ EFI_STATUS GetEarlyUserSettings ( // } // } - gSettings.KextPatchesAllowed = TRUE; // todo move to GlobalConfig + GlobalConfig.KextPatchesAllowed = TRUE; + GlobalConfig.KernelPatchesAllowed = TRUE; gSettings.KernelAndKextPatches.KPAppleRTC = TRUE; gSettings.KernelAndKextPatches.KPDELLSMBIOS = FALSE; // default is false - gSettings.KernelPatchesAllowed = TRUE; // todo move to GlobalConfig if (CfgDict != NULL) { //DBG("Loading early settings\n"); @@ -2881,49 +2880,49 @@ EFI_STATUS GetEarlyUserSettings ( Prop = GUIDict->propertyForKey("Language"); if (Prop != NULL) { - gSettings.Language = Prop->getString()->stringValue(); + gSettings.GUI.Language = Prop->getString()->stringValue(); if ( Prop->getString()->stringValue().contains("en") ) { - gSettings.GUI.Language = english; + gSettings.GUI.languageCode = english; // gSettings.GUI.Codepage = 0xC0; // gSettings.GUI.CodepageSize = 0; } else if ( Prop->getString()->stringValue().contains("ru")) { - gSettings.GUI.Language = russian; + gSettings.GUI.languageCode = russian; // gSettings.GUI.Codepage = 0x410; // gSettings.GUI.CodepageSize = 0x40; } else if ( Prop->getString()->stringValue().contains("ua")) { - gSettings.GUI.Language = ukrainian; + gSettings.GUI.languageCode = ukrainian; // gSettings.GUI.Codepage = 0x400; // gSettings.GUI.CodepageSize = 0x60; } else if ( Prop->getString()->stringValue().contains("fr")) { - gSettings.GUI.Language = french; //default is extended latin + gSettings.GUI.languageCode = french; //default is extended latin } else if ( Prop->getString()->stringValue().contains("it")) { - gSettings.GUI.Language = italian; + gSettings.GUI.languageCode = italian; } else if ( Prop->getString()->stringValue().contains("es")) { - gSettings.GUI.Language = spanish; + gSettings.GUI.languageCode = spanish; } else if ( Prop->getString()->stringValue().contains("pt")) { - gSettings.GUI.Language = portuguese; + gSettings.GUI.languageCode = portuguese; } else if ( Prop->getString()->stringValue().contains("br")) { - gSettings.GUI.Language = brasil; + gSettings.GUI.languageCode = brasil; } else if ( Prop->getString()->stringValue().contains("de")) { - gSettings.GUI.Language = german; + gSettings.GUI.languageCode = german; } else if ( Prop->getString()->stringValue().contains("nl")) { - gSettings.GUI.Language = dutch; + gSettings.GUI.languageCode = dutch; } else if ( Prop->getString()->stringValue().contains("pl")) { - gSettings.GUI.Language = polish; + gSettings.GUI.languageCode = polish; } else if ( Prop->getString()->stringValue().contains("cz")) { - gSettings.GUI.Language = czech; + gSettings.GUI.languageCode = czech; } else if ( Prop->getString()->stringValue().contains("hr")) { - gSettings.GUI.Language = croatian; + gSettings.GUI.languageCode = croatian; } else if ( Prop->getString()->stringValue().contains("id")) { - gSettings.GUI.Language = indonesian; + gSettings.GUI.languageCode = indonesian; } else if ( Prop->getString()->stringValue().contains("zh_CN")) { - gSettings.GUI.Language = chinese; + gSettings.GUI.languageCode = chinese; // gSettings.GUI.Codepage = 0x3400; // gSettings.GUI.CodepageSize = 0x19C0; } else if ( Prop->getString()->stringValue().contains("ro")) { - gSettings.GUI.Language = romanian; + gSettings.GUI.languageCode = romanian; } else if ( Prop->getString()->stringValue().contains("ko")) { - gSettings.GUI.Language = korean; + gSettings.GUI.languageCode = korean; // gSettings.GUI.Codepage = 0x1100; // gSettings.GUI.CodepageSize = 0x100; } @@ -3389,14 +3388,19 @@ EFI_STATUS GetEarlyUserSettings ( return Status; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" void -ParseSMBIOSSettings( - const TagDict* DictPointer - ) +ParseSMBIOSSettings(SETTINGS_DATA& gSettings, const TagDict* DictPointer) { +#pragma GCC diagnostic pop + const TagStruct* Prop; const TagStruct* Prop1; + + + // TODO!!! BOOLEAN Default = FALSE; @@ -3406,24 +3410,24 @@ ParseSMBIOSSettings( MsgLog("ATTENTION : property not string in ProductName\n"); }else{ MACHINE_TYPES Model; - gSettings.ProductName = Prop->getString()->stringValue(); + gSettings.Smbios.ProductName = Prop->getString()->stringValue(); // let's fill all other fields based on this ProductName // to serve as default - Model = GetModelFromString(gSettings.ProductName); + Model = GetModelFromString(gSettings.Smbios.ProductName); if (Model != MaxMachineType) { - SetDMISettingsForModel (Model, FALSE); + SetDMISettingsForModel(gSettings, Model, FALSE); Default = TRUE; } else { //if new model then fill at least as iMac13,2, except custom ProductName // something else? - SetDMISettingsForModel (iMac132, FALSE); + SetDMISettingsForModel(gSettings, iMac132, FALSE); } } } - DBG("Using ProductName from config: %s\n", gSettings.ProductName.c_str()); + DBG("Using ProductName from config: %s\n", gSettings.Smbios.ProductName.c_str()); Prop = DictPointer->propertyForKey("SmbiosVersion"); - gSettings.SmbiosVersion = (UINT16)GetPropertyAsInteger(Prop, 0x204); + gSettings.Smbios.SmbiosVersion = (UINT16)GetPropertyAsInteger(Prop, 0x204); // Check for BiosVersion and BiosReleaseDate by Sherlocks Prop = DictPointer->propertyForKey("BiosVersion"); @@ -3431,7 +3435,9 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { DBG("BiosVersion: not set, Using BiosVersion from clover\n"); }else{ - const CHAR8* i = gSettings.RomVersion.c_str(); + gSettings.Smbios._RomVersion = Prop->getString()->stringValue(); + + const CHAR8* i = GlobalConfig.RomVersionUsed.c_str(); const CHAR8* j = Prop->getString()->stringValue().c_str(); i += AsciiStrLen(i); @@ -3456,22 +3462,22 @@ ParseSMBIOSSettings( } else if ((i[5] == j[5]) && (i[6] == j[6])) { DBG("Found same BiosVersion in clover and config\n"); } else { - gSettings.RomVersion = Prop->getString()->stringValue(); + GlobalConfig.RomVersionUsed = Prop->getString()->stringValue(); DBG("Using latest BiosVersion from config\n"); } } else { - gSettings.RomVersion = Prop->getString()->stringValue(); + GlobalConfig.RomVersionUsed = Prop->getString()->stringValue(); DBG("Using latest BiosVersion from config\n"); } } else { - gSettings.RomVersion = Prop->getString()->stringValue(); + GlobalConfig.RomVersionUsed = Prop->getString()->stringValue(); DBG("Using latest BiosVersion from config\n"); } } } else { DBG("BiosVersion: not set, Using BiosVersion from clover\n"); } - DBG("BiosVersion: %s\n", gSettings.RomVersion.c_str()); + DBG("BiosVersion: %s\n", GlobalConfig.RomVersionUsed.c_str()); Prop1 = DictPointer->propertyForKey("BiosReleaseDate"); if (Prop1 != NULL) { @@ -3479,8 +3485,9 @@ ParseSMBIOSSettings( MsgLog("ATTENTION : property not string in BiosReleaseDate\n"); }else{ if (Prop != NULL) { - const CHAR8* i = gSettings.ReleaseDate.c_str(); - const CHAR8* j = Prop1->getString()->stringValue().c_str(); + gSettings.Smbios._ReleaseDate = Prop1->getString()->stringValue(); + const CHAR8* i = GlobalConfig.ReleaseDateUsed.c_str(); + const CHAR8* j = gSettings.Smbios._ReleaseDate.c_str(); if ((AsciiStrLen(i) == 8) && (AsciiStrLen(j) == 8)) { if (((i[6] > '0') && (j[6] == '0')) || ((i[6] >= j[6]) && (i[7] > j[7]))) { @@ -3498,15 +3505,15 @@ ParseSMBIOSSettings( } else if ((i[3] == j[3]) && (i[4] == j[4])) { //DBG("Found same BiosReleaseDate in clover and config\n"); } else { - gSettings.ReleaseDate = Prop1->getString()->stringValue(); + GlobalConfig.ReleaseDateUsed = gSettings.Smbios._ReleaseDate; //DBG("Using latest BiosReleaseDate from config\n"); } } else { - gSettings.ReleaseDate = Prop1->getString()->stringValue(); + GlobalConfig.ReleaseDateUsed = gSettings.Smbios._ReleaseDate; //DBG("Using latest BiosReleaseDate from config\n"); } } else { - gSettings.ReleaseDate = Prop1->getString()->stringValue(); + GlobalConfig.ReleaseDateUsed = gSettings.Smbios._ReleaseDate; //DBG("Using latest BiosReleaseDate from config\n"); } } else if ((AsciiStrLen(i) == 8) && (AsciiStrLen(j) == 10)) { @@ -3525,15 +3532,15 @@ ParseSMBIOSSettings( } else if ((i[3] == j[3]) && (i[4] == j[4])) { //DBG("Found same BiosReleaseDate in clover and config\n"); } else { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]); //DBG("Using latest BiosReleaseDate from config\n"); } } else { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]); //DBG("Using latest BiosReleaseDate from config\n"); } } else { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]); //DBG("Using latest BiosReleaseDate from config\n"); } } else if ((AsciiStrLen(i) == 10) && (AsciiStrLen(j) == 10)) { @@ -3552,15 +3559,15 @@ ParseSMBIOSSettings( } else if ((i[3] == j[3]) && (i[4] == j[4])) { //DBG("Found same BiosReleaseDate in clover and config\n"); } else { - gSettings.ReleaseDate = Prop1->getString()->stringValue(); + GlobalConfig.ReleaseDateUsed = Prop1->getString()->stringValue(); //DBG("Using latest BiosReleaseDate from config\n"); } } else { - gSettings.ReleaseDate = Prop1->getString()->stringValue(); + GlobalConfig.ReleaseDateUsed = Prop1->getString()->stringValue(); //DBG("Using latest BiosReleaseDate from config\n"); } } else { - gSettings.ReleaseDate = Prop1->getString()->stringValue(); + GlobalConfig.ReleaseDateUsed = Prop1->getString()->stringValue(); //DBG("Using latest BiosReleaseDate from config\n"); } } else if ((AsciiStrLen(i) == 10) && (AsciiStrLen(j) == 8)) { @@ -3579,22 +3586,22 @@ ParseSMBIOSSettings( } else if ((i[3] == j[3]) && (i[4] == j[4])) { //DBG("Found same BiosReleaseDate in clover and config\n"); } else { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]); //DBG("Using latest BiosReleaseDate from config\n"); } } else { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]); //DBG("Using latest BiosReleaseDate from config\n"); } } else { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]); //DBG("Using latest BiosReleaseDate from config\n"); } } else { //DBG("Found unknown date format from config\n"); if (Prop != NULL) { - i = gSettings.ReleaseDate.c_str(); - j = gSettings.RomVersion.c_str(); + i = GlobalConfig.ReleaseDateUsed.c_str(); + j = GlobalConfig.RomVersionUsed.c_str(); j += AsciiStrLen(j); while (*j != '.') { @@ -3602,10 +3609,10 @@ ParseSMBIOSSettings( } if ((AsciiStrLen(i) == 8)) { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); //DBG("Using the date of used BiosVersion\n"); } else if ((AsciiStrLen(i) == 10)) { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/20%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/20%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); //DBG("Using the date of used BiosVersion\n"); } } else { @@ -3619,8 +3626,8 @@ ParseSMBIOSSettings( } } else { if (Prop != NULL) { - const CHAR8* i = gSettings.ReleaseDate.c_str(); - const CHAR8* j = gSettings.RomVersion.c_str(); + const CHAR8* i = GlobalConfig.ReleaseDateUsed.c_str(); + const CHAR8* j = GlobalConfig.RomVersionUsed.c_str(); j += AsciiStrLen(j); while (*j != '.') { @@ -3628,64 +3635,65 @@ ParseSMBIOSSettings( } if ((AsciiStrLen(i) == 8)) { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); //DBG("BiosReleaseDate: not set, Using the date of used BiosVersion\n"); } else if ((AsciiStrLen(i) == 10)) { - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/20%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/20%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); //DBG("BiosReleaseDate: not set, Using the date of used BiosVersion\n"); } } else { //DBG("BiosReleaseDate: not set, Using BiosReleaseDate from clover\n"); } } - DBG("BiosReleaseDate: %s\n", gSettings.ReleaseDate.c_str()); + DBG("BiosReleaseDate: %s\n", GlobalConfig.ReleaseDateUsed.c_str()); Prop = DictPointer->propertyForKey("EfiVersion"); if (Prop != NULL) { if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in EfiVersion\n"); - if ( gSettings.EfiVersion.notEmpty() ) { - DBG("Using EfiVersion from clover: %s\n", gSettings.EfiVersion.c_str()); + if ( GlobalConfig.EfiVersionUsed.notEmpty() ) { + DBG("Using EfiVersion from clover: %s\n", GlobalConfig.EfiVersionUsed.c_str()); } }else{ - if (AsciiStrVersionToUint64(gSettings.EfiVersion, 4, 5) > AsciiStrVersionToUint64(Prop->getString()->stringValue(), 4, 5)) { - DBG("Using latest EfiVersion from clover: %s\n", gSettings.EfiVersion.c_str()); - } else if (AsciiStrVersionToUint64(gSettings.EfiVersion, 4, 5) < AsciiStrVersionToUint64(Prop->getString()->stringValue(), 4, 5)) { - gSettings.EfiVersion = Prop->getString()->stringValue(); - gSettings.EfiVersion.trim(); - DBG("Using latest EfiVersion from config: %s\n", gSettings.EfiVersion.c_str()); + gSettings.Smbios._EfiVersion = Prop->getString()->stringValue(); + gSettings.Smbios._EfiVersion.trim(); + if (AsciiStrVersionToUint64(GlobalConfig.EfiVersionUsed, 4, 5) > AsciiStrVersionToUint64(gSettings.Smbios._EfiVersion, 4, 5)) { + DBG("Using latest EfiVersion from clover: %s\n", GlobalConfig.EfiVersionUsed.c_str()); + } else if (AsciiStrVersionToUint64(GlobalConfig.EfiVersionUsed, 4, 5) < AsciiStrVersionToUint64(gSettings.Smbios._EfiVersion, 4, 5)) { + GlobalConfig.EfiVersionUsed = gSettings.Smbios._EfiVersion; + DBG("Using latest EfiVersion from config: %s\n", GlobalConfig.EfiVersionUsed.c_str()); } else { - DBG("Using EfiVersion from clover: %s\n", gSettings.EfiVersion.c_str()); + DBG("Using EfiVersion from clover: %s\n", GlobalConfig.EfiVersionUsed.c_str()); } } - } else if ( gSettings.EfiVersion.notEmpty() ) { - DBG("Using EfiVersion from clover: %s\n", gSettings.EfiVersion.c_str()); + } else if ( GlobalConfig.EfiVersionUsed.notEmpty() ) { + DBG("Using EfiVersion from clover: %s\n", GlobalConfig.EfiVersionUsed.c_str()); } Prop = DictPointer->propertyForKey("FirmwareFeatures"); if (Prop != NULL) { - gFwFeatures = (UINT32)GetPropertyAsInteger(Prop, gFwFeatures); - DBG("Using FirmwareFeatures from config: 0x%08X\n", gFwFeatures); + gSettings.Smbios.gFwFeatures = (UINT32)GetPropertyAsInteger(Prop, gSettings.Smbios.gFwFeatures); + DBG("Using FirmwareFeatures from config: 0x%08X\n", gSettings.Smbios.gFwFeatures); } else { - DBG("Using FirmwareFeatures from clover: 0x%08X\n", gFwFeatures); + DBG("Using FirmwareFeatures from clover: 0x%08X\n", gSettings.Smbios.gFwFeatures); } Prop = DictPointer->propertyForKey("FirmwareFeaturesMask"); if (Prop != NULL) { - gFwFeaturesMask = (UINT32)GetPropertyAsInteger(Prop, gFwFeaturesMask); - DBG("Using FirmwareFeaturesMask from config: 0x%08X\n", gFwFeaturesMask); + gSettings.Smbios.gFwFeaturesMask = (UINT32)GetPropertyAsInteger(Prop, gSettings.Smbios.gFwFeaturesMask); + DBG("Using FirmwareFeaturesMask from config: 0x%08X\n", gSettings.Smbios.gFwFeaturesMask); } else { - DBG("Using FirmwareFeaturesMask from clover: 0x%08X\n", gFwFeaturesMask); + DBG("Using FirmwareFeaturesMask from clover: 0x%08X\n", gSettings.Smbios.gFwFeaturesMask); } Prop = DictPointer->propertyForKey("PlatformFeature"); if (Prop != NULL) { - gPlatformFeature = (UINT64)GetPropertyAsInteger(Prop, (INTN)gPlatformFeature); + gSettings.Smbios.gPlatformFeature = (UINT64)GetPropertyAsInteger(Prop, (INTN)gSettings.Smbios.gPlatformFeature); } else { - if (gPlatformFeature == 0xFFFF) { + if (gSettings.Smbios.gPlatformFeature == 0xFFFF) { DBG("PlatformFeature will not set in SMBIOS\n"); } else { - DBG("Using PlatformFeature from clover: 0x%llX\n", gPlatformFeature); + DBG("Using PlatformFeature from clover: 0x%llX\n", gSettings.Smbios.gPlatformFeature); } } @@ -3694,7 +3702,7 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in BiosVendor\n"); }else{ - gSettings.VendorName = Prop->getString()->stringValue(); + gSettings.Smbios.BiosVendor = Prop->getString()->stringValue(); } } @@ -3703,7 +3711,7 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in Manufacturer\n"); }else{ - gSettings.ManufactureName = Prop->getString()->stringValue(); + gSettings.Smbios.ManufactureName = Prop->getString()->stringValue(); } } @@ -3712,7 +3720,7 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in Version\n"); }else{ - gSettings.VersionNr = Prop->getString()->stringValue(); + gSettings.Smbios.VersionNr = Prop->getString()->stringValue(); } } @@ -3721,7 +3729,7 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in Family\n"); }else{ - gSettings.FamilyName = Prop->getString()->stringValue(); + gSettings.Smbios.FamilyName = Prop->getString()->stringValue(); } } @@ -3730,7 +3738,7 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in SerialNumber\n"); }else{ - gSettings.SerialNr = Prop->getString()->stringValue(); + gSettings.Smbios.SerialNr = Prop->getString()->stringValue(); } } @@ -3740,7 +3748,7 @@ ParseSMBIOSSettings( MsgLog("ATTENTION : property not string in SmUUID\n"); }else{ if (IsValidGuidString(Prop->getString()->stringValue())) { - gSettings.SmUUID = Prop->getString()->stringValue(); + gSettings.Smbios.SmUUID = Prop->getString()->stringValue(); } else { DBG("Error: invalid SmUUID '%s' - should be in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n", Prop->getString()->stringValue().c_str()); } @@ -3753,7 +3761,7 @@ ParseSMBIOSSettings( MsgLog("ATTENTION : property not string in BoardManufacturer\n"); }else{ if( Prop->getString()->stringValue().notEmpty() ) { - gSettings.BoardManufactureName = Prop->getString()->stringValue(); + gSettings.Smbios.BoardManufactureName = Prop->getString()->stringValue(); } } } @@ -3764,7 +3772,7 @@ ParseSMBIOSSettings( MsgLog("ATTENTION : property not string in BoardSerialNumber\n"); }else{ if( Prop->getString()->stringValue().notEmpty() ) { - gSettings.BoardSerialNumber = Prop->getString()->stringValue(); + gSettings.Smbios.BoardSerialNumber = Prop->getString()->stringValue(); } } } @@ -3774,37 +3782,37 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in Board-ID\n"); }else{ - gSettings.BoardNumber = Prop->getString()->stringValue(); - DBG("Board-ID set from config as %s\n", gSettings.BoardNumber.c_str()); + gSettings.Smbios.BoardNumber = Prop->getString()->stringValue(); + DBG("Board-ID set from config as %s\n", gSettings.Smbios.BoardNumber.c_str()); } } if (!Default) { - gSettings.BoardVersion = gSettings.ProductName; + gSettings.Smbios.BoardVersion = gSettings.Smbios.ProductName; } Prop = DictPointer->propertyForKey("BoardVersion"); if (Prop != NULL) { if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in BoardVersion\n"); }else{ - gSettings.BoardVersion = Prop->getString()->stringValue(); + gSettings.Smbios.BoardVersion = Prop->getString()->stringValue(); } } Prop = DictPointer->propertyForKey("BoardType"); if (Prop != NULL) { - gSettings.BoardType = (UINT8)GetPropertyAsInteger(Prop, gSettings.BoardType); - DBG("BoardType: 0x%hhX\n", gSettings.BoardType); + gSettings.Smbios.BoardType = (UINT8)GetPropertyAsInteger(Prop, gSettings.Smbios.BoardType); + DBG("BoardType: 0x%hhX\n", gSettings.Smbios.BoardType); } Prop = DictPointer->propertyForKey("Mobile"); if (Prop != NULL) { if (IsPropertyNotNullAndFalse(Prop)) - gSettings.Mobile = FALSE; + gSettings.Smbios.Mobile = FALSE; else if (IsPropertyNotNullAndTrue(Prop)) - gSettings.Mobile = TRUE; + gSettings.Smbios.Mobile = TRUE; } else if (!Default) { - gSettings.Mobile = gSettings.ProductName.contains("MacBook"); + gSettings.Smbios.Mobile = gSettings.Smbios.ProductName.contains("MacBook"); } Prop = DictPointer->propertyForKey("LocationInChassis"); @@ -3812,7 +3820,7 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in LocationInChassis\n"); }else{ - gSettings.LocationInChassis = Prop->getString()->stringValue(); + gSettings.Smbios.LocationInChassis = Prop->getString()->stringValue(); } } @@ -3821,7 +3829,7 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in ChassisManufacturer\n"); }else{ - gSettings.ChassisManufacturer = Prop->getString()->stringValue(); + gSettings.Smbios.ChassisManufacturer = Prop->getString()->stringValue(); } } @@ -3830,19 +3838,19 @@ ParseSMBIOSSettings( if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in ChassisAssetTag\n"); }else{ - gSettings.ChassisAssetTag = Prop->getString()->stringValue(); + gSettings.Smbios.ChassisAssetTag = Prop->getString()->stringValue(); } } Prop = DictPointer->propertyForKey("ChassisType"); if (Prop != NULL) { - gSettings.ChassisType = (UINT8)GetPropertyAsInteger(Prop, gSettings.ChassisType); - DBG("ChassisType: 0x%hhX\n", gSettings.ChassisType); + gSettings.Smbios.ChassisType = (UINT8)GetPropertyAsInteger(Prop, gSettings.Smbios.ChassisType); + DBG("ChassisType: 0x%hhX\n", gSettings.Smbios.ChassisType); } Prop = DictPointer->propertyForKey("NoRomInfo"); if (Prop != NULL) { - gSettings.NoRomInfo = IsPropertyNotNullAndTrue(Prop); + gSettings.Smbios.NoRomInfo = IsPropertyNotNullAndTrue(Prop); } } @@ -4418,6 +4426,9 @@ void SETTINGS_DATA::DevicesClass::FillDevicePropertiesOld(SETTINGS_DATA& gSettin if ( !EFI_ERROR(PropertiesDict->getKeyAndValueAtIndex(i, &key, &value)) ) { //take a with DevicePath. If GetKeyValueAtIndex return success, key and value != NULL XStringW DevicePathStr = key->keyStringValue(); // DBG("Device: %ls\n", DevicePathStr); +if (key->keyStringValue().startWithOrEqualTo("#")) { + continue; +} // when key in Devices/Properties is one of the strings "PrimaryGPU" / "SecondaryGPU", use device path of first / second gpu accordingly #ifdef CLOVER_BUILD @@ -4459,6 +4470,7 @@ void SETTINGS_DATA::DevicesClass::FillDevicePropertiesOld(SETTINGS_DATA& gSettin continue; } if (key2->keyStringValue()[0] != '#') { + continue; (*Child)->MenuItem.BValue = TRUE; (*Child)->Key = S8Printf("%s", key2->keyStringValue().c_str()).forgetDataWithoutFreeing(); } @@ -5300,38 +5312,38 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) const TagDict* SMBIOSDict = CfgDict->dictPropertyForKey("SMBIOS"); if (SMBIOSDict != NULL) { - ParseSMBIOSSettings(SMBIOSDict); + ParseSMBIOSSettings(gSettings, SMBIOSDict); const TagStruct* Prop = SMBIOSDict->propertyForKey("Trust"); if (Prop != NULL) { if (IsPropertyNotNullAndFalse(Prop)) { - gSettings.TrustSMBIOS = FALSE; + gSettings.Smbios.TrustSMBIOS = FALSE; } else if (IsPropertyNotNullAndTrue(Prop)) { - gSettings.TrustSMBIOS = TRUE; + gSettings.Smbios.TrustSMBIOS = TRUE; } } Prop = SMBIOSDict->propertyForKey("MemoryRank"); - gSettings.Attribute = (INT8)GetPropertyAsInteger(Prop, -1); //1==Single Rank, 2 == Dual Rank, 0==undefined -1 == keep as is + gSettings.Smbios.Attribute = (INT8)GetPropertyAsInteger(Prop, -1); //1==Single Rank, 2 == Dual Rank, 0==undefined -1 == keep as is // Delete the user memory when a new config is selected INTN i = 0; - for (i = 0; i < gRAM.UserInUse && i < MAX_RAM_SLOTS; i++) { - gRAM.User[i].ModuleSize = 0; - gRAM.User[i].InUse = 0; + for (i = 0; i < gSettings.Smbios.Memory.SlotCounts && i < MAX_RAM_SLOTS; i++) { + gSettings.Smbios.Memory.User[i].ModuleSize = 0; + gSettings.Smbios.Memory.User[i].InUse = 0; } - gRAM.UserInUse = 0; - gRAM.UserChannels = 0; - gSettings.InjectMemoryTables = FALSE; + gSettings.Smbios.Memory.SlotCounts = 0; + gSettings.Smbios.Memory.UserChannels = 0; + gSettings.Smbios.InjectMemoryTables = FALSE; // Inject memory tables into SMBIOS const TagDict* MemoryDict = SMBIOSDict->dictPropertyForKey("Memory"); if (MemoryDict != NULL){ // Get memory table count const TagStruct* Prop2 = MemoryDict->propertyForKey("SlotCount"); - gRAM.UserInUse = (UINT8)GetPropertyAsInteger(Prop2, 0); + gSettings.Smbios.Memory.SlotCounts = (UINT8)GetPropertyAsInteger(Prop2, 0); // Get memory channels Prop2 = MemoryDict->propertyForKey("Channels"); - gRAM.UserChannels = (UINT8)GetPropertyAsInteger(Prop2, 0); + gSettings.Smbios.Memory.UserChannels = (UINT8)GetPropertyAsInteger(Prop2, 0); // Get memory tables const TagArray* ModulesArray = MemoryDict->arrayPropertyForKey("Modules"); // array of dict if (ModulesArray != NULL) { @@ -5358,7 +5370,7 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) continue; } - SlotPtr = &gRAM.User[Slot]; + SlotPtr = &gSettings.Smbios.Memory.User[Slot]; // Get memory size Prop2 = Prop3->propertyForKey("Size"); @@ -5369,17 +5381,17 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) // Get memory vendor Prop2 = Prop3->propertyForKey("Vendor"); if (Prop2 && Prop2->isString() && Prop2->getString()->stringValue().notEmpty()) { - SlotPtr->Vendor = S8Printf("%s", Prop2->getString()->stringValue().c_str()).forgetDataWithoutFreeing(); + SlotPtr->Vendor.S8Printf("%s", Prop2->getString()->stringValue().c_str()); } // Get memory part number Prop2 = Prop3->propertyForKey("Part"); if (Prop2 && Prop2->isString() && Prop2->getString()->stringValue().notEmpty()) { - SlotPtr->PartNo = S8Printf("%s", Prop2->getString()->stringValue().c_str()).forgetDataWithoutFreeing(); + SlotPtr->PartNo.S8Printf("%s", Prop2->getString()->stringValue().c_str()); } // Get memory serial number Prop2 = Prop3->propertyForKey("Serial"); if (Prop2 && Prop2->isString() && Prop2->getString()->stringValue().notEmpty()) { - SlotPtr->SerialNo = S8Printf("%s", Prop2->getString()->stringValue().c_str()).forgetDataWithoutFreeing(); + SlotPtr->SerialNo.S8Printf("%s", Prop2->getString()->stringValue().c_str()); } // Get memory type SlotPtr->Type = MemoryTypeDdr3; @@ -5398,14 +5410,14 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) SlotPtr->InUse = (SlotPtr->ModuleSize > 0); if (SlotPtr->InUse) { - if (gRAM.UserInUse <= Slot) { - gRAM.UserInUse = Slot + 1; + if (gSettings.Smbios.Memory.SlotCounts <= Slot) { + gSettings.Smbios.Memory.SlotCounts = Slot + 1; } } } - if (gRAM.UserInUse > 0) { - gSettings.InjectMemoryTables = TRUE; + if (gSettings.Smbios.Memory.SlotCounts > 0) { + gSettings.Smbios.InjectMemoryTables = TRUE; } } } @@ -5452,7 +5464,7 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) } if (DeviceN >= 0) { - SLOT_DEVICE *SlotDevice = &SlotDevices[DeviceN]; + SLOT_DEVICE *SlotDevice = &gSettings.Smbios.SlotDevices[DeviceN]; Prop2 = SlotsDict->propertyForKey("ID"); SlotDevice->SlotID = (UINT8)GetPropertyAsInteger(Prop2, DeviceN); SlotDevice->SlotType = SlotTypePci; @@ -5491,12 +5503,12 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) } Prop2 = SlotsDict->propertyForKey("Name"); if (Prop2 && (Prop2->isString()) && Prop2->getString()->stringValue().notEmpty()) { - snprintf (SlotDevice->SlotName, 31, "%s", Prop2->getString()->stringValue().c_str()); + SlotDevice->SlotName = Prop2->getString()->stringValue(); } else { - snprintf (SlotDevice->SlotName, 31, "PCI Slot %lld", DeviceN); + SlotDevice->SlotName.S8Printf("PCI Slot %lld", DeviceN); } - DBG(" - %s\n", SlotDevice->SlotName); + DBG(" - %s\n", SlotDevice->SlotName.c_str()); } } } @@ -5711,12 +5723,12 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) // if (gSettings.RtVariables.RtROM.isEmpty()) { // EFI_GUID uuid; -// StrToGuidLE(gSettings.SmUUID, &uuid); +// StrToGuidLE(gSettings.Smbios.SmUUID, &uuid); // gSettings.RtVariables.RtROM.ncpy(&uuid.Data4[2], 6); // } // if (gSettings.RtVariables.RtMLB.isEmpty()) { -// gSettings.RtVariables.RtMLB = gSettings.BoardSerialNumber; +// gSettings.RtVariables.RtMLB = gSettings.Smbios.BoardSerialNumber; // } // if CustomUUID and InjectSystemID are not specified @@ -5782,16 +5794,16 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) const TagDict* BootGraphicsDict = CfgDict->dictPropertyForKey("BootGraphics"); if (BootGraphicsDict != NULL) { const TagStruct* Prop = BootGraphicsDict->propertyForKey("DefaultBackgroundColor"); - gSettings.DefaultBackgroundColor = (UINT32)GetPropertyAsInteger(Prop, 0x80000000); //the value 0x80000000 means not set + gSettings.BootGraphics.DefaultBackgroundColor = (UINT32)GetPropertyAsInteger(Prop, 0x80000000); //the value 0x80000000 means not set Prop = BootGraphicsDict->propertyForKey("UIScale"); - gSettings.UIScale = (UINT32)GetPropertyAsInteger(Prop, 0x80000000); + gSettings.BootGraphics.UIScale = (UINT32)GetPropertyAsInteger(Prop, 0x80000000); Prop = BootGraphicsDict->propertyForKey("EFILoginHiDPI"); - gSettings.EFILoginHiDPI = (UINT32)GetPropertyAsInteger(Prop, 0x80000000); + gSettings.BootGraphics.EFILoginHiDPI = (UINT32)GetPropertyAsInteger(Prop, 0x80000000); Prop = BootGraphicsDict->propertyForKey("flagstate"); - *(UINT32*)&gSettings.flagstate[0] = (UINT32)GetPropertyAsInteger(Prop, 0x80000000); + *(UINT32*)&gSettings.BootGraphics.flagstate[0] = (UINT32)GetPropertyAsInteger(Prop, 0x80000000); } /* @@ -6611,12 +6623,12 @@ GetDevices () // DBG(" - RADEON_BIOS_0_SCRATCH = 0x%08X\n", gfx->Connectors); gfx->ConnChanged = FALSE; - SlotDevice = &SlotDevices[0]; + SlotDevice = &gSettings.Smbios.SlotDevices[0]; SlotDevice->SegmentGroupNum = (UINT16)Segment; SlotDevice->BusNum = (UINT8)Bus; SlotDevice->DevFuncNum = (UINT8)((Device << 3) | (Function & 0x07)); SlotDevice->Valid = TRUE; - snprintf (SlotDevice->SlotName, 31, "PCI Slot 0"); + SlotDevice->SlotName = "PCI Slot 0"_XS8; SlotDevice->SlotID = 1; SlotDevice->SlotType = SlotTypePciExpressX16; break; @@ -6678,12 +6690,12 @@ GetDevices () DBG(" - GFX: Model=%s family %hX (%s)\n", gfx->Model, gfx->Family, CardFamily); gfx->Ports = 0; - SlotDevice = &SlotDevices[1]; + SlotDevice = &gSettings.Smbios.SlotDevices[1]; SlotDevice->SegmentGroupNum = (UINT16)Segment; SlotDevice->BusNum = (UINT8)Bus; SlotDevice->DevFuncNum = (UINT8)((Device << 3) | (Function & 0x07)); SlotDevice->Valid = TRUE; - snprintf (SlotDevice->SlotName, 31, "PCI Slot 0"); + SlotDevice->SlotName = "PCI Slot 0"_XS8; SlotDevice->SlotID = 1; SlotDevice->SlotType = SlotTypePciExpressX16; break; @@ -6703,12 +6715,12 @@ GetDevices () else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_NETWORK) && (Pci.Hdr.ClassCode[1] == PCI_CLASS_NETWORK_OTHER)) { - SlotDevice = &SlotDevices[6]; + SlotDevice = &gSettings.Smbios.SlotDevices[6]; SlotDevice->SegmentGroupNum = (UINT16)Segment; SlotDevice->BusNum = (UINT8)Bus; SlotDevice->DevFuncNum = (UINT8)((Device << 3) | (Function & 0x07)); SlotDevice->Valid = TRUE; - snprintf (SlotDevice->SlotName, 31, "AirPort"); + SlotDevice->SlotName = "AirPort"_XS8; SlotDevice->SlotID = 0; SlotDevice->SlotType = SlotTypePciExpressX1; DBG(" - WIFI: Vendor= "); @@ -6741,12 +6753,12 @@ GetDevices () else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_NETWORK) && (Pci.Hdr.ClassCode[1] == PCI_CLASS_NETWORK_ETHERNET)) { - SlotDevice = &SlotDevices[5]; + SlotDevice = &gSettings.Smbios.SlotDevices[5]; SlotDevice->SegmentGroupNum = (UINT16)Segment; SlotDevice->BusNum = (UINT8)Bus; SlotDevice->DevFuncNum = (UINT8)((Device << 3) | (Function & 0x07)); SlotDevice->Valid = TRUE; - snprintf (SlotDevice->SlotName, 31, "Ethernet"); + SlotDevice->SlotName = "Ethernet"_XS8; SlotDevice->SlotID = 2; SlotDevice->SlotType = SlotTypePciExpressX1; gLanVendor[nLanCards] = Pci.Hdr.VendorId; @@ -6786,12 +6798,12 @@ GetDevices () else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_SERIAL) && (Pci.Hdr.ClassCode[1] == PCI_CLASS_SERIAL_FIREWIRE)) { - SlotDevice = &SlotDevices[12]; + SlotDevice = &gSettings.Smbios.SlotDevices[12]; SlotDevice->SegmentGroupNum = (UINT16)Segment; SlotDevice->BusNum = (UINT8)Bus; SlotDevice->DevFuncNum = (UINT8)((Device << 3) | (Function & 0x07)); SlotDevice->Valid = TRUE; - snprintf (SlotDevice->SlotName, 31, "FireWire"); + SlotDevice->SlotName = "FireWire"_XS8; SlotDevice->SlotID = 3; SlotDevice->SlotType = SlotTypePciExpressX4; } @@ -6813,12 +6825,12 @@ GetDevices () if (IsHDMIAudio(HandleArray[Index])) { DBG(" - HDMI Audio: \n"); - SlotDevice = &SlotDevices[4]; + SlotDevice = &gSettings.Smbios.SlotDevices[4]; SlotDevice->SegmentGroupNum = (UINT16)Segment; SlotDevice->BusNum = (UINT8)Bus; SlotDevice->DevFuncNum = (UINT8)((Device << 3) | (Function & 0x07)); SlotDevice->Valid = TRUE; - snprintf (SlotDevice->SlotName, 31, "HDMI port"); + SlotDevice->SlotName = "HDMI port"_XS8; SlotDevice->SlotID = 5; SlotDevice->SlotType = SlotTypePciExpressX4; } @@ -6860,7 +6872,6 @@ SetDevices (LOADER_ENTRY *Entry) UINTN Function; BOOLEAN StringDirty = FALSE; BOOLEAN TmpDirty = FALSE; - UINT16 PmCon; UINT32 Rcba; UINT32 Hptc; DevPropDevice *device = NULL; @@ -7597,48 +7608,50 @@ SetDevices (LOADER_ENTRY *Entry) else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) && (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA)) { - if (gSettings.LpcTune) { - Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, GEN_PMCON_1, 1, &PmCon); - MsgLog ("Initial PmCon value=%hX\n", PmCon); - - if (GlobalConfig.EnableC6) { - PmCon |= 1 << 11; - DBG("C6 enabled\n"); - } else { - PmCon &= ~(1 << 11); - DBG("C6 disabled\n"); - } - /* - if (GlobalConfig.EnableC2) { - PmCon |= 1 << 10; - DBG("BIOS_PCIE enabled\n"); - } else { - PmCon &= ~(1 << 10); - DBG("BIOS_PCIE disabled\n"); - } - */ - if (GlobalConfig.EnableC4) { - PmCon |= 1 << 7; - DBG("C4 enabled\n"); - } else { - PmCon &= ~(1 << 7); - DBG("C4 disabled\n"); - } - - if (gSettings.ACPI.SSDT.EnableISS) { - PmCon |= 1 << 3; - DBG("SpeedStep enabled\n"); - } else { - PmCon &= ~(1 << 3); - DBG("SpeedStep disabled\n"); - } - - PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, GEN_PMCON_1, 1, &PmCon); - - Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16,GEN_PMCON_1, 1, &PmCon); - MsgLog ("Set PmCon value=%hX\n", PmCon); - - } +// 2021-04 Jief : LpcTune doesn't exist in Settings.cpp. Never set to true. +// if (gSettings.LpcTune) { +// UINT16 PmCon; +// Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, GEN_PMCON_1, 1, &PmCon); +// MsgLog ("Initial PmCon value=%hX\n", PmCon); +// +// if (GlobalConfig.EnableC6) { +// PmCon |= 1 << 11; +// DBG("C6 enabled\n"); +// } else { +// PmCon &= ~(1 << 11); +// DBG("C6 disabled\n"); +// } +// /* +// if (GlobalConfig.EnableC2) { +// PmCon |= 1 << 10; +// DBG("BIOS_PCIE enabled\n"); +// } else { +// PmCon &= ~(1 << 10); +// DBG("BIOS_PCIE disabled\n"); +// } +// */ +// if (GlobalConfig.EnableC4) { +// PmCon |= 1 << 7; +// DBG("C4 enabled\n"); +// } else { +// PmCon &= ~(1 << 7); +// DBG("C4 disabled\n"); +// } +// +// if (gSettings.ACPI.SSDT.EnableISS) { +// PmCon |= 1 << 3; +// DBG("SpeedStep enabled\n"); +// } else { +// PmCon &= ~(1 << 3); +// DBG("SpeedStep disabled\n"); +// } +// +// PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, GEN_PMCON_1, 1, &PmCon); +// +// Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16,GEN_PMCON_1, 1, &PmCon); +// MsgLog ("Set PmCon value=%hX\n", PmCon); +// +// } Rcba = 0; /* Scan Port */ Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0xF0, 1, &Rcba); @@ -7731,7 +7744,7 @@ SaveSettings () { // TODO: SetVariable().. // here we can apply user settings instead of default one - gMobile = gSettings.Mobile; + gMobile = gSettings.Smbios.Mobile; if ((gSettings.CPU.BusSpeed != 0) && (gSettings.CPU.BusSpeed > 10 * Kilo) && (gSettings.CPU.BusSpeed < 500 * Kilo)) { switch (gCPUStructure.Model) { @@ -7935,8 +7948,8 @@ InjectKextsFromDir ( // FSInject->AddStringToList(Blacklist, L"\\System\\Library\\Extensions.mkext"); // 10.6 // FSInject->AddStringToList(Blacklist, L"\\System\\Library\\Caches\\com.apple.kext.caches\\Startup\\kernelcache"); // 10.6/10.6 - 10.9 // -// if (gSettings.BlockKexts[0] != L'\0') { -// FSInject->AddStringToList(Blacklist, SWPrintf("\\System\\Library\\Extensions\\%ls", gSettings.BlockKexts).wc_str()); +// if (gSettings.BlockKexts.notEmpty()) { +// FSInject->AddStringToList(Blacklist, SWPrintf("\\System\\Library\\Extensions\\%ls", gSettings.BlockKexts.wc_str()).wc_str()); // } // } // @@ -7993,7 +8006,7 @@ EFI_GUID nullUUID = {0,0,0,{0}}; const XString8& SETTINGS_DATA::getUUID() { if ( SystemParameters.CustomUuid.notEmpty() ) return SystemParameters.CustomUuid; - return SmUUID; + return Smbios.SmUUID; } const XString8& SETTINGS_DATA::getUUID(EFI_GUID *uuid) @@ -8011,9 +8024,9 @@ const XString8& SETTINGS_DATA::getUUID(EFI_GUID *uuid) #endif return SystemParameters.CustomUuid; } - EFI_STATUS Status = StrToGuidLE(SmUUID, uuid); + EFI_STATUS Status = StrToGuidLE(Smbios.SmUUID, uuid); #ifdef DEBUG - if ( EFI_ERROR(Status) ) panic("SmUUID(%s) is not valid", SmUUID.c_str()); // same as before + if ( EFI_ERROR(Status) ) panic("SmUUID(%s) is not valid", Smbios.SmUUID.c_str()); // same as before #else if ( EFI_ERROR(Status) ) { DBG("SmUUID(%s) is not valid\n", SmUUID.c_str()); @@ -8022,7 +8035,7 @@ const XString8& SETTINGS_DATA::getUUID(EFI_GUID *uuid) } #endif - return SmUUID; + return Smbios.SmUUID; } diff --git a/rEFIt_UEFI/Platform/Settings.h b/rEFIt_UEFI/Platform/Settings.h index ab93b3b87..2f68bb81a 100644 --- a/rEFIt_UEFI/Platform/Settings.h +++ b/rEFIt_UEFI/Platform/Settings.h @@ -13,7 +13,7 @@ #include "../libeg/XIcon.h" #include "../cpp_lib/undefinable.h" #include "../entry_scan/loader.h" // for KERNEL_SCAN_xxx constants - +#include "../Platform/smbios.h" #define CLOVER_SIGN SIGNATURE_32('C','l','v','r') @@ -437,6 +437,20 @@ public: }; +class SLOT_DEVICE +{ +public: + UINT16 SegmentGroupNum; // assigned by GetDevices + UINT8 BusNum; // assigned by GetDevices + UINT8 DevFuncNum; // assigned by GetDevices + bool Valid; // assigned by GetDevices +//UINT8 DeviceN; + UINT8 SlotID; + MISC_SLOT_TYPE SlotType; + XString8 SlotName; +} ; + + class SETTINGS_DATA; class ConfigPlistClass; class TagDict; @@ -594,7 +608,8 @@ public: XStringW ScreenResolution = XStringW(); bool ProvideConsoleGop = 0; INTN ConsoleMode = 0; - LANGUAGES Language = english; + XString8 Language; + LanguageCode languageCode = english; bool KbdPrevLang = 0; XString8Array HVHideStrings = XString8Array(); ScanClass Scan = ScanClass(); @@ -903,14 +918,14 @@ printf("%s", ""); bool compareOldAndCompatibleArb() { - { - size_t oldArbIdx = 0; - const DEV_PROPERTY* arb = ArbProperties; - while ( arb ) { - printf("ArbProperties[%zu].Key = %s\n", oldArbIdx++, arb->Key); - arb = arb->Next; - } - } +// { +// size_t oldArbIdx = 0; +// const DEV_PROPERTY* arb = ArbProperties; +// while ( arb ) { +// printf("ArbProperties[%zu].Key = %s\n", oldArbIdx++, arb->Key); +// arb = arb->Next; +// } +// } const XObjArray compatibleArbProperties = getCompatibleArbProperty(); size_t oldArbIdx = 0; for ( size_t idx = 0 ; idx < compatibleArbProperties.size() ; ++idx ) @@ -1029,6 +1044,78 @@ printf("%s", ""); }; + class SmbiosClass { + public: + + class MemoryClass { + public: + UINT8 SlotCounts; + UINT8 UserChannels; + RAM_SLOT_INFO User[MAX_RAM_SLOTS * 4]; + }; + + // SMBIOS TYPE0 + XString8 BiosVendor; + XString8 _RomVersion; + XString8 _EfiVersion; + XString8 _ReleaseDate; + // SMBIOS TYPE1 + XString8 ManufactureName; + XString8 ProductName; + XString8 VersionNr; + XString8 SerialNr; + XString8 SmUUID; + XString8 FamilyName; + // SMBIOS TYPE2 + XString8 BoardManufactureName; + XString8 BoardSerialNumber; + XString8 BoardNumber; //Board-ID + XString8 LocationInChassis; + XString8 BoardVersion; + UINT8 BoardType; + // SMBIOS TYPE3 + bool Mobile; + UINT8 ChassisType; + XString8 ChassisManufacturer; + XString8 ChassisAssetTag; + // SMBIOS TYPE4 + // SMBIOS TYPE17 + UINT16 SmbiosVersion; + INT8 Attribute; +// These were set but never used. +// XString8 MemoryManufacturer; +// XString8 MemorySerialNumber; +// XString8 MemoryPartNumber; +// XString8 MemorySpeed; + // SMBIOS TYPE131 + // SMBIOS TYPE132 + bool TrustSMBIOS = 0; + bool InjectMemoryTables; // same as Memory.SlotCounts + // SMBIOS TYPE133 + UINT64 gPlatformFeature; + // PatchTableType11 + bool NoRomInfo; + + UINT32 gFwFeatures; + UINT32 gFwFeaturesMask; + MemoryClass Memory = MemoryClass(); + SLOT_DEVICE SlotDevices[16]; //assume DEV_XXX, Arpt=6 + + // These are calculated from ApplePlatformData + CHAR8 RPlt[8] = {0}; + CHAR8 RBr[8] = {0}; + UINT8 EPCI[4] = {0}; + UINT8 REV[6] = {0}; + + + }; + class BootGraphicsClass { + public: + UINT32 DefaultBackgroundColor = 0; + UINT32 UIScale = 0; + UINT32 EFILoginHiDPI = 0; + UINT8 flagstate[32] = {0}; + }; BootClass Boot = BootClass(); ACPIClass ACPI = ACPIClass(); @@ -1041,171 +1128,18 @@ printf("%s", ""); QuirksClass Quirks = QuirksClass(); RtVariablesClass RtVariables = RtVariablesClass(); DevicesClass Devices = DevicesClass(); - - // SMBIOS TYPE0 - XString8 VendorName; - XString8 RomVersion; - XString8 EfiVersion; - XString8 ReleaseDate; - // SMBIOS TYPE1 - XString8 ManufactureName; - XString8 ProductName; - XString8 VersionNr; - XString8 SerialNr; - XString8 SmUUID; -//CHAR8 Uuid; -//CHAR8 SKUNumber; - XString8 FamilyName; - XString8 OEMProduct; - XString8 OEMVendor; - // SMBIOS TYPE2 - XString8 BoardManufactureName; - XString8 BoardSerialNumber; - XString8 BoardNumber; //Board-ID - XString8 LocationInChassis; - XString8 BoardVersion; - XString8 OEMBoard; - UINT8 BoardType; - // SMBIOS TYPE3 - BOOLEAN Mobile; - UINT8 ChassisType; - XString8 ChassisManufacturer; - XString8 ChassisAssetTag; - // SMBIOS TYPE4 - UINT8 EnabledCores; - // SMBIOS TYPE17 - UINT16 SmbiosVersion; - INT8 Attribute; - XString8 MemoryManufacturer; - XString8 MemorySerialNumber; - XString8 MemoryPartNumber; - XString8 MemorySpeed; - // SMBIOS TYPE131 - // SMBIOS TYPE132 - BOOLEAN TrustSMBIOS = 0; - BOOLEAN InjectMemoryTables; - - // SMBIOS TYPE133 - UINT64 PlatformFeature; - - // PatchTableType11 - BOOLEAN NoRomInfo; - - // OS parameters - XString8 Language; + SmbiosClass Smbios = SmbiosClass(); + BootGraphicsClass BootGraphics = BootGraphicsClass(); -//Monitor -//Boot options - BOOLEAN MemoryFix; - BOOLEAN FakeSMCFound; +//other +// UINT16 DropOEM_DSM; // not used anymore. +// BOOLEAN LpcTune; // never set to true. - // GUI parameters - BOOLEAN Debug; - UINT32 DefaultBackgroundColor; - - //ACPI - -// BOOLEAN DropMCFG; - - //Injections - - - - //Graphics -// UINT16 PCIRootUID; - BOOLEAN LpcTune; - UINT16 DropOEM_DSM; //vacant - - - - - // USB DeviceTree injection - - - - //SkyLake - - //Volumes hiding - - // KernelAndKextPatches - BOOLEAN KextPatchesAllowed; - BOOLEAN KernelPatchesAllowed; //From GUI: Only for user patches, not internal Clover - - - // Pre-language - - - - - // SysVariables - - - // Multi-config - CHAR16 ConfigName[30]; -// XString8 MainConfigName; - - //Drivers - - //SMC keys - CHAR8 RPlt[8]; - CHAR8 RBr[8]; - UINT8 EPCI[4]; - UINT8 REV[6]; - - //other devices - - - BOOLEAN SlpWak; - BOOLEAN UseIntelHDMI; - - - //Add custom properties - - //BlackListed kexts - CHAR16 BlockKexts[64]; - - // Disable inject kexts -// UINT32 DisableInjectKextCount; -// CHAR16 **DisabledInjectKext; -// INPUT_ITEM *InjectKextMenuItem; - - //ACPI tables - - //other -// UINT32 AudioVolume; - - // boot.efi - UINT32 OptionsBits; - UINT32 FlagsBits; - UINT32 UIScale; - UINT32 EFILoginHiDPI; - UINT8 flagstate[32]; - - - - - SETTINGS_DATA() : VendorName(), RomVersion(), EfiVersion(), ReleaseDate(), ManufactureName(), ProductName(), VersionNr(), SerialNr(), SmUUID(), - FamilyName(), OEMProduct(), OEMVendor(), BoardManufactureName(), BoardSerialNumber(), BoardNumber(), LocationInChassis(), - BoardVersion(), OEMBoard(), BoardType(0), Mobile(0), ChassisType(0), ChassisManufacturer(), ChassisAssetTag(), - EnabledCores(0), SmbiosVersion(0), Attribute(0), MemoryManufacturer(), - MemorySerialNumber(), MemoryPartNumber(), MemorySpeed(), InjectMemoryTables(0), - PlatformFeature(0), NoRomInfo(0), Language(), - MemoryFix(0), - FakeSMCFound(0), Debug(0), DefaultBackgroundColor(0), - LpcTune(0), DropOEM_DSM(0), - KextPatchesAllowed(0), - KernelPatchesAllowed(0), - ConfigName{0}, /*MainConfigName(0),*/ /*BlackListCount(0),*/ RPlt{0}, RBr{0}, EPCI{0}, REV{0}, - SlpWak(0), UseIntelHDMI(0), - BlockKexts{0}, - OptionsBits(0), FlagsBits(0), UIScale(0), EFILoginHiDPI(0), flagstate{0} - {}; + SETTINGS_DATA() {} SETTINGS_DATA(const SETTINGS_DATA& other) = delete; // Can be defined if needed const SETTINGS_DATA& operator = ( const SETTINGS_DATA & ) = delete; // Can be defined if needed -// XBuffer serialize() const; - ~SETTINGS_DATA() {} const XString8& getUUID(); @@ -1217,7 +1151,7 @@ printf("%s", ""); if ( SystemParameters._InjectSystemID == 2 ) return false; else return SystemParameters._InjectSystemID; } - if ( SmUUID.isEmpty() || SmUUID == nullGuidAsString ) return false; + if ( Smbios.SmUUID.isEmpty() || Smbios.SmUUID == nullGuidAsString ) return false; if ( SystemParameters._InjectSystemID == 2 ) return true; return SystemParameters._InjectSystemID; } @@ -1256,17 +1190,6 @@ typedef struct _DRIVERS_FLAGS { BOOLEAN APFSLoaded; } DRIVERS_FLAGS; -typedef struct { - UINT16 SegmentGroupNum; - UINT8 BusNum; - UINT8 DevFuncNum; - BOOLEAN Valid; -//UINT8 DeviceN; - UINT8 SlotID; - UINT8 SlotType; - CHAR8 SlotName[31]; -} SLOT_DEVICE; - // ACPI/PATCHED/AML class ACPI_PATCHED_AML { @@ -1330,7 +1253,6 @@ extern UINTN NHDA; extern SETTINGS_DATA gSettings; extern BOOLEAN gFirmwareClover; extern DRIVERS_FLAGS gDriversFlags; -extern SLOT_DEVICE SlotDevices[]; extern EFI_EDID_DISCOVERED_PROTOCOL *EdidDiscovered; //extern UINT8 *gEDID; @@ -1415,6 +1337,25 @@ public: bool Turbo = true; + XString8 OEMProductFromSmbios = XString8(); + XString8 OEMVendorFromSmbios = XString8(); + XString8 OEMBoardFromSmbios = XString8(); + UINT8 EnabledCores = 0; + +// XStringW ConfigName; // Set but never used + + UINT32 OptionsBits = 0; + UINT32 FlagsBits = 0; + + XStringW BlockKexts; + // KernelAndKextPatches + BOOLEAN KextPatchesAllowed = 0; + BOOLEAN KernelPatchesAllowed = 0; //From GUI: Only for user patches, not internal Clover + + XString8 RomVersionUsed = XString8(); + XString8 EfiVersionUsed = XString8(); + XString8 ReleaseDateUsed = XString8(); + REFIT_CONFIG() {}; REFIT_CONFIG(const REFIT_CONFIG& other) = delete; // Can be defined if needed const REFIT_CONFIG& operator = ( const REFIT_CONFIG & ) = delete; // Can be defined if needed @@ -1518,10 +1459,7 @@ LoadUserSettings ( TagDict** dict ); -void -ParseSMBIOSSettings ( - const TagDict* dictPointer - ); +void ParseSMBIOSSettings(SETTINGS_DATA& gSettings, const TagDict* DictPointer); void testConfigPlist(); diff --git a/rEFIt_UEFI/Platform/gma.cpp b/rEFIt_UEFI/Platform/gma.cpp index bf1cb30a6..94d8ae7da 100755 --- a/rEFIt_UEFI/Platform/gma.cpp +++ b/rEFIt_UEFI/Platform/gma.cpp @@ -975,7 +975,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) BOOLEAN SetSnb = FALSE; BOOLEAN SetIg = FALSE; - MACHINE_TYPES MacModel = GetModelFromString(gSettings.ProductName); + MACHINE_TYPES MacModel = GetModelFromString(gSettings.Smbios.ProductName); devicepath = get_pci_dev_path(gma_dev); @@ -1509,7 +1509,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) //devprop_add_value(device, "device_type", (UINT8*)"display", 7); // this key displays two intel graphics cards in system report on 10.13.4+ devprop_add_value(device, "subsystem-vendor-id", common_vals[2], 4); devprop_add_value(device, "class-code", (UINT8*)ClassFix, 4); - /*if (gSettings.Mobile) { + /*if (gSettings.Smbios.Mobile) { UINT32 IntelDisplay = 1; // these are not reference keys for all. why add these keys? devprop_add_value(device, "AAPL,backlight-control", (UINT8*)&IntelDisplay, 4); @@ -2023,7 +2023,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) break; default: if (!SetIg) { - if (gSettings.Mobile) { + if (gSettings.Smbios.Mobile) { devprop_add_value(device, "AAPL,ig-platform-id", ivy_bridge_ig_vals[7], 4); DBG(" Found ig-platform-id = 0x01660004\n"); } else { @@ -2501,7 +2501,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) break; default: if (!SetIg) { - if (gSettings.Mobile) { + if (gSettings.Smbios.Mobile) { devprop_add_value(device, "AAPL,ig-platform-id", skylake_ig_vals[1], 4); DBG(" Found ig-platform-id = 0x19120000\n"); } else { @@ -2859,7 +2859,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) break; default: if (!SetIg) { - if (gSettings.Mobile) { + if (gSettings.Smbios.Mobile) { devprop_add_value(device, "AAPL,ig-platform-id", kabylake_ig_vals[0], 4); DBG(" Found ig-platform-id = 0x59120000\n"); } else { @@ -3106,7 +3106,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) break; default: if (!SetIg) { - if (gSettings.Mobile) { + if (gSettings.Smbios.Mobile) { devprop_add_value(device, "AAPL,ig-platform-id", coffeelake_ig_vals[6], 4); DBG(" Found ig-platform-id = 0x3E9B0000\n"); } else { diff --git a/rEFIt_UEFI/Platform/guid.h b/rEFIt_UEFI/Platform/guid.h index 7e502363a..000057cef 100644 --- a/rEFIt_UEFI/Platform/guid.h +++ b/rEFIt_UEFI/Platform/guid.h @@ -11,6 +11,9 @@ #include "../cpp_foundation/XStringArray.h" #include "../cpp_foundation/unicode_conversions.h" +extern "C" { +#include // for EFI_GUID +} extern "C" EFI_GUID gEfiMiscSubClassGuid; diff --git a/rEFIt_UEFI/Platform/kernel_patcher.cpp b/rEFIt_UEFI/Platform/kernel_patcher.cpp index 6382160af..27fd8e242 100644 --- a/rEFIt_UEFI/Platform/kernel_patcher.cpp +++ b/rEFIt_UEFI/Platform/kernel_patcher.cpp @@ -2619,7 +2619,7 @@ LOADER_ENTRY::BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize) // //// DBG_RT("\nKernelToPatch: "); //// DBG_RT("Kernels patches: %d\n", KernelAndKextPatches.KernelPatches.size()); -// if (gSettings.KernelPatchesAllowed && KernelAndKextPatches.KernelPatches.notEmpty()) { +// if (GlobalConfig.KernelPatchesAllowed && KernelAndKextPatches.KernelPatches.notEmpty()) { //// DBG_RT("Enabled: \n"); // DBG("Kernels patches: enabled \n"); //// KernelAndKextPatcherInit(); @@ -2780,16 +2780,16 @@ LOADER_ENTRY::BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize) // if (/*OSFLAG_ISSET(Flags, OSFLAG_WITHKEXTS) || */ // OSFLAG_ISSET(Flags, OSFLAG_CHECKFAKESMC)) { // DBG_RT( "\nAllowing kext patching to check if FakeSMC is present\n"); -// gSettings.KextPatchesAllowed = TRUE; +// GlobalConfig.KextPatchesAllowed = TRUE; // KextPatchesNeeded = TRUE; // } // // DBG_RT( "\nKextPatches Needed: %c, Allowed: %c ... ", // (KextPatchesNeeded ? L'Y' : L'n'), -// (gSettings.KextPatchesAllowed ? L'Y' : L'n') +// (GlobalConfig.KextPatchesAllowed ? L'Y' : L'n') // ); // -// if (KextPatchesNeeded && gSettings.KextPatchesAllowed) { +// if (KextPatchesNeeded && GlobalConfig.KextPatchesAllowed) { //// DBG_RT( "\nKext patching INIT\n"); //// KernelAndKextPatcherInit(); //// if (KernelData == NULL) goto NoKernelData; diff --git a/rEFIt_UEFI/Platform/kext_inject.cpp b/rEFIt_UEFI/Platform/kext_inject.cpp index f8fe9bbb3..e423c0a42 100644 --- a/rEFIt_UEFI/Platform/kext_inject.cpp +++ b/rEFIt_UEFI/Platform/kext_inject.cpp @@ -909,7 +909,7 @@ EFI_STATUS LOADER_ENTRY::InjectKexts(IN UINT32 deviceTreeP, IN UINT32* deviceTre KextBase = RoundPage(KextBase + KextEntry->kext.length); DBG_RT(" %llu - %s\n", Index, (CHAR8 *)(UINTN)drvinfo->bundlePathPhysAddr); DBG(" %llu - %s\n", Index, (CHAR8 *)(UINTN)drvinfo->bundlePathPhysAddr); - if (gSettings.KextPatchesAllowed) { + if (GlobalConfig.KextPatchesAllowed) { CHAR8 SavedValue; CHAR8 *InfoPlist = (CHAR8*)(UINTN)drvinfo->infoDictPhysAddr; SavedValue = InfoPlist[drvinfo->infoDictLength]; diff --git a/rEFIt_UEFI/Platform/platformdata.cpp b/rEFIt_UEFI/Platform/platformdata.cpp index e958a23a7..871104134 100644 --- a/rEFIt_UEFI/Platform/platformdata.cpp +++ b/rEFIt_UEFI/Platform/platformdata.cpp @@ -26,10 +26,6 @@ #define DBG(...) DebugLog(DEBUG_PLATFORMDATA, __VA_ARGS__) #endif -UINT32 gFwFeatures; -UINT32 gFwFeaturesMask; -UINT64 gPlatformFeature; - // All SMBIOS data were updated by Sherlocks, PMheart. // FredWst supported SmcExtract. @@ -598,12 +594,22 @@ PLATFORMDATA ApplePlatformData[] = 0x01, 0x43, 0x0f, 0, 0, 0x04, "NA"_XS8, "NA"_XS8, 0x79001 }, // need rBR RPlt EPCI }; -void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) +/* + * To ease copy/paste and text replacement from GetUserSettings, the parameter has the same name as the global + * and is passed by non-const reference. + * This temporary during the refactoring + * All code from this comes from settings.cpp. I am taking out all the init code from settings.cpp so I can replace the reading layer. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +void SetDMISettingsForModel(SETTINGS_DATA& gSettings, MACHINE_TYPES Model, BOOLEAN Redefine) { +#pragma GCC diagnostic pop + const CHAR8 *i; - gSettings.VendorName = BiosVendor; - gSettings.RomVersion = ApplePlatformData[Model].firmwareVersion; + gSettings.Smbios.BiosVendor = AppleBiosVendor; + GlobalConfig.RomVersionUsed = ApplePlatformData[Model].firmwareVersion; // AppleReleaseDate switch (Model) { @@ -668,7 +674,7 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) while (*i != '.') { i--; } - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/%c%c", i[3], i[4], i[5], i[6], i[1], i[2]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/%c%c", i[3], i[4], i[5], i[6], i[1], i[2]); break; default: @@ -678,26 +684,25 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) while (*i != '.') { i--; } - gSettings.ReleaseDate.S8Printf("%c%c/%c%c/20%c%c", i[3], i[4], i[5], i[6], i[1], i[2]); + GlobalConfig.ReleaseDateUsed.S8Printf("%c%c/%c%c/20%c%c", i[3], i[4], i[5], i[6], i[1], i[2]); break; } - gSettings.EfiVersion.takeValueFrom(ApplePlatformData[Model].efiversion); - gSettings.EfiVersion.trim(); - gSettings.ManufactureName = BiosVendor; + GlobalConfig.EfiVersionUsed.takeValueFrom(ApplePlatformData[Model].efiversion); + gSettings.Smbios.ManufactureName = gSettings.Smbios.BiosVendor; if (Redefine) { - gSettings.ProductName = ApplePlatformData[Model].productName; + gSettings.Smbios.ProductName = ApplePlatformData[Model].productName; } - gSettings.VersionNr = ApplePlatformData[Model].systemVersion; - gSettings.SerialNr = ApplePlatformData[Model].serialNumber; - gSettings.FamilyName = ApplePlatformData[Model].productFamily; - gSettings.BoardManufactureName = BiosVendor; - gSettings.BoardSerialNumber = AppleBoardSN; - gSettings.BoardNumber = ApplePlatformData[Model].boardID; - gSettings.BoardVersion = ApplePlatformData[Model].productName; - gSettings.LocationInChassis = AppleBoardLocation; - gSettings.ChassisManufacturer = BiosVendor; - gSettings.ChassisAssetTag = ApplePlatformData[Model].chassisAsset; + gSettings.Smbios.VersionNr = ApplePlatformData[Model].systemVersion; + gSettings.Smbios.SerialNr = ApplePlatformData[Model].serialNumber; + gSettings.Smbios.FamilyName = ApplePlatformData[Model].productFamily; + gSettings.Smbios.BoardManufactureName = gSettings.Smbios.BiosVendor; + gSettings.Smbios.BoardSerialNumber = AppleBoardSN; + gSettings.Smbios.BoardNumber = ApplePlatformData[Model].boardID; + gSettings.Smbios.BoardVersion = ApplePlatformData[Model].productName; + gSettings.Smbios.LocationInChassis = AppleBoardLocation; + gSettings.Smbios.ChassisManufacturer = gSettings.Smbios.BiosVendor; + gSettings.Smbios.ChassisAssetTag = ApplePlatformData[Model].chassisAsset; // Firmware info for 10.13+ // by Sherlocks @@ -706,14 +711,14 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) // Verified list from Firmware case MacBookPro91: case MacBookPro92: - gFwFeatures = 0xC00DE137; + gSettings.Smbios.gFwFeatures = 0xC00DE137; break; case MacBookAir41: case MacBookAir42: case MacMini51: case MacMini52: case MacMini53: - gFwFeatures = 0xD00DE137; + gSettings.Smbios.gFwFeatures = 0xD00DE137; break; case MacBookPro101: case MacBookPro102: @@ -724,30 +729,30 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac131: case iMac132: case iMac133: - gFwFeatures = 0xE00DE137; + gSettings.Smbios.gFwFeatures = 0xE00DE137; break; case MacMini81: - gFwFeatures = 0xFD8FF466; + gSettings.Smbios.gFwFeatures = 0xFD8FF466; break; case MacBookAir61: case MacBookAir62: case iMac141: case iMac142: case iMac143: - gFwFeatures = 0xE00FE137; + gSettings.Smbios.gFwFeatures = 0xE00FE137; break; case MacBookPro111: case MacBookPro112: case MacBookPro113: case MacBookPro114: case MacBookPro115: - gFwFeatures = 0xE80FE137; + gSettings.Smbios.gFwFeatures = 0xE80FE137; break; case iMac144: - gFwFeatures = 0xF00FE177; + gSettings.Smbios.gFwFeatures = 0xF00FE177; break; case iMac151: - gFwFeatures = 0xF80FE177; + gSettings.Smbios.gFwFeatures = 0xF80FE177; break; case MacBookPro131: case MacBookPro132: @@ -757,41 +762,41 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac181: case iMac182: case iMac183: - gFwFeatures = 0xFC0FE176; + gSettings.Smbios.gFwFeatures = 0xFC0FE176; break; case MacBook91: case MacBook101: case MacBookPro133: case MacBookPro143: - gFwFeatures = 0xFC0FE17E; + gSettings.Smbios.gFwFeatures = 0xFC0FE17E; break; case iMacPro11: - gFwFeatures = 0xFD8FF53F; + gSettings.Smbios.gFwFeatures = 0xFD8FF53F; break; case MacBookAir91: - gFwFeatures = 0xFD8FF42E; + gSettings.Smbios.gFwFeatures = 0xFD8FF42E; break; case iMac191: case iMac192: case iMac201: case iMac202: - gFwFeatures = 0xFD8FF576; + gSettings.Smbios.gFwFeatures = 0xFD8FF576; break; case MacBookPro162: case MacBookPro163: case MacBookPro164: - gFwFeatures = 0xFDAFF066; + gSettings.Smbios.gFwFeatures = 0xFDAFF066; break; // Verified list from Users case MacBookAir31: case MacBookAir32: case MacMini41: - gFwFeatures = 0xD00DE137; + gSettings.Smbios.gFwFeatures = 0xD00DE137; break; case MacBookAir71: case MacBookAir72: - gFwFeatures = 0xE00FE137; + gSettings.Smbios.gFwFeatures = 0xE00FE137; break; case iMac101: case iMac111: @@ -800,16 +805,16 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac121: case iMac122: case MacMini71: - gFwFeatures = 0xE00DE137; + gSettings.Smbios.gFwFeatures = 0xE00DE137; break; case MacPro51: - gFwFeatures = 0xE80FE137; + gSettings.Smbios.gFwFeatures = 0xE80FE137; break; case MacPro61: - gFwFeatures = 0xE80FE176; + gSettings.Smbios.gFwFeatures = 0xE80FE176; break; case MacPro71: - gFwFeatures = 0xFD8FF53F; + gSettings.Smbios.gFwFeatures = 0xFD8FF53F; break; case MacBookPro61: case MacBookPro62: @@ -817,7 +822,7 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case MacBookPro81: case MacBookPro82: case MacBookPro83: - gFwFeatures = 0xC00DE137; + gSettings.Smbios.gFwFeatures = 0xC00DE137; break; case MacBookPro121: case MacBookPro151: @@ -829,16 +834,16 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case MacBookAir82: case iMac161: case iMac162: - gFwFeatures = 0xFC0FE137; + gSettings.Smbios.gFwFeatures = 0xFC0FE137; break; case MacBook61: case MacBook71: case MacBook81: - gFwFeatures = 0xFC0FE13F; + gSettings.Smbios.gFwFeatures = 0xFC0FE13F; break; default: - gFwFeatures = 0xE907F537; //unknown - use oem SMBIOS value to be default + gSettings.Smbios.gFwFeatures = 0xE907F537; //unknown - use oem SMBIOS value to be default break; } @@ -871,7 +876,7 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac141: case iMac142: case iMac143: - gFwFeaturesMask = 0xFF1FFF3F; + gSettings.Smbios.gFwFeaturesMask = 0xFF1FFF3F; break; case MacBook91: @@ -889,23 +894,23 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac182: case iMac183: case MacPro61: - gFwFeaturesMask = 0xFF1FFF7F; + gSettings.Smbios.gFwFeaturesMask = 0xFF1FFF7F; break; case iMacPro11: case MacBookAir91: - gFwFeaturesMask = 0xFF9FFF3F; + gSettings.Smbios.gFwFeaturesMask = 0xFF9FFF3F; break; case iMac191: case iMac192: case iMac201: case iMac202: case MacMini81: - gFwFeaturesMask = 0xFFDFFF7F; + gSettings.Smbios.gFwFeaturesMask = 0xFFDFFF7F; break; case MacBookPro162: case MacBookPro163: case MacBookPro164: - gFwFeaturesMask = 0xFFFFFF7F; + gSettings.Smbios.gFwFeaturesMask = 0xFFFFFF7F; break; // Verified list from Users @@ -941,15 +946,15 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac161: case iMac162: case MacPro51: - gFwFeaturesMask = 0xFF1FFF3F; + gSettings.Smbios.gFwFeaturesMask = 0xFF1FFF3F; break; case MacPro71: - gFwFeaturesMask = 0xFF9FFF3F; + gSettings.Smbios.gFwFeaturesMask = 0xFF9FFF3F; break; default: - gFwFeaturesMask = 0xFFFFFFFF; //unknown - use oem SMBIOS value to be default + gSettings.Smbios.gFwFeaturesMask = 0xFFFFFFFF; //unknown - use oem SMBIOS value to be default break; } @@ -963,7 +968,7 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac182: case iMac183: case MacPro71: - gPlatformFeature = 0x00; + gSettings.Smbios.gPlatformFeature = 0x00; break; case MacMini61: case MacMini62: @@ -975,7 +980,7 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac143: case iMac144: case iMac151: - gPlatformFeature = 0x01; + gSettings.Smbios.gPlatformFeature = 0x01; break; case MacBookPro111: case MacBookPro112: @@ -985,15 +990,15 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case MacBookPro121: case MacBookAir71: case MacBookAir72: - gPlatformFeature = 0x02; + gSettings.Smbios.gPlatformFeature = 0x02; break; case MacMini71: case iMac161: case iMac162: - gPlatformFeature = 0x03; + gSettings.Smbios.gPlatformFeature = 0x03; break; case MacPro61: - gPlatformFeature = 0x04; + gSettings.Smbios.gPlatformFeature = 0x04; break; case MacBook81: case MacBook91: @@ -1004,7 +1009,7 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case MacBookPro141: case MacBookPro142: case MacBookPro143: - gPlatformFeature = 0x1A; + gSettings.Smbios.gPlatformFeature = 0x1A; break; case iMacPro11: case MacMini81: @@ -1012,7 +1017,7 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac192: case iMac201: case iMac202: - gPlatformFeature = 0x20; + gSettings.Smbios.gPlatformFeature = 0x20; break; case MacBookPro151: case MacBookPro152: @@ -1022,12 +1027,12 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case MacBookPro162: case MacBookPro163: case MacBookPro164: - gPlatformFeature = 0x32; + gSettings.Smbios.gPlatformFeature = 0x32; break; case MacBookAir81: case MacBookAir82: case MacBookAir91: - gPlatformFeature = 0x3A; + gSettings.Smbios.gPlatformFeature = 0x3A; break; // It is nonsense, ASCII code сharacter "2" = 0x32 != 0x02. Don't use ioreg, so that not to be confused. Use dmidecode dump. @@ -1035,18 +1040,18 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) // case MacBookPro153: // case MacBookPro154: // case MacBookPro161: - // gPlatformFeature = 0x02; + // gSettings.Smbios.gPlatformFeature = 0x02; // break; default: - gPlatformFeature = 0xFFFF; // disabled + gSettings.Smbios.gPlatformFeature = 0xFFFF; // disabled break; } if ((Model > MacPro31) && (Model < MacPro71)) { - gSettings.BoardType = BaseBoardTypeProcessorMemoryModule; //0xB; + gSettings.Smbios.BoardType = BaseBoardTypeProcessorMemoryModule; //0xB; } else { - gSettings.BoardType = BaseBoardTypeMotherBoard; //0xA; + gSettings.Smbios.BoardType = BaseBoardTypeMotherBoard; //0xA; } // MiscChassisType @@ -1083,13 +1088,13 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case MacBookPro114: case MacBookPro115: case MacMini71: - gSettings.ChassisType = MiscChassisTypeNotebook; //0x0A; + gSettings.Smbios.ChassisType = MiscChassisTypeNotebook; //0x0A; switch (Model) { case MacMini71: - gSettings.Mobile = FALSE; + gSettings.Smbios.Mobile = FALSE; break; default: - gSettings.Mobile = TRUE; + gSettings.Smbios.Mobile = TRUE; break; } break; @@ -1129,7 +1134,7 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac201: case iMac202: case iMacPro11: - gSettings.ChassisType = MiscChassisTypeLapTop; //0x09; + gSettings.Smbios.ChassisType = MiscChassisTypeLapTop; //0x09; switch (Model) { case MacMini81: case iMac161: @@ -1143,10 +1148,10 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac201: case iMac202: case iMacPro11: - gSettings.Mobile = FALSE; + gSettings.Smbios.Mobile = FALSE; break; default: - gSettings.Mobile = TRUE; + gSettings.Smbios.Mobile = TRUE; break; } break; @@ -1165,8 +1170,8 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case MacBookPro61: case MacBookPro62: case MacBookPro71: - gSettings.ChassisType = MiscChassisTypePortable; //0x08; - gSettings.Mobile = TRUE; + gSettings.Smbios.ChassisType = MiscChassisTypePortable; //0x08; + gSettings.Smbios.Mobile = TRUE; break; case iMac41: @@ -1191,14 +1196,14 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case iMac143: case iMac144: case iMac151: - gSettings.ChassisType = MiscChassisTypeAllInOne; //0x0D; - gSettings.Mobile = FALSE; + gSettings.Smbios.ChassisType = MiscChassisTypeAllInOne; //0x0D; + gSettings.Smbios.Mobile = FALSE; break; case MacMini11: case MacMini21: - gSettings.ChassisType = MiscChassisTypeLowProfileDesktop; //0x04; - gSettings.Mobile = FALSE; + gSettings.Smbios.ChassisType = MiscChassisTypeLowProfileDesktop; //0x04; + gSettings.Smbios.Mobile = FALSE; break; case MacMini31: @@ -1208,188 +1213,188 @@ void SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) case MacMini53: case MacMini61: case MacMini62: - gSettings.ChassisType = MiscChassisTypeLunchBox; //0x10; - gSettings.Mobile = FALSE; + gSettings.Smbios.ChassisType = MiscChassisTypeLunchBox; //0x10; + gSettings.Smbios.Mobile = FALSE; break; case MacPro41: case MacPro51: case MacPro71: - gSettings.ChassisType = MiscChassisTypeTower; //0x07; - gSettings.Mobile = FALSE; + gSettings.Smbios.ChassisType = MiscChassisTypeTower; //0x07; + gSettings.Smbios.Mobile = FALSE; break; case MacPro11: case MacPro21: case MacPro31: case MacPro61: - gSettings.ChassisType = MiscChassisTypeUnknown; //0x02; this is a joke but think different! - gSettings.Mobile = FALSE; + gSettings.Smbios.ChassisType = MiscChassisTypeUnknown; //0x02; this is a joke but think different! + gSettings.Smbios.Mobile = FALSE; break; case Xserve11: case Xserve21: case Xserve31: - gSettings.ChassisType = MiscChassisTypeRackMountChassis; //0x17; - gSettings.Mobile = FALSE; + gSettings.Smbios.ChassisType = MiscChassisTypeRackMountChassis; //0x17; + gSettings.Smbios.Mobile = FALSE; break; default: //unknown - use oem SMBIOS value to be default - gSettings.Mobile = gMobile; - gSettings.ChassisType = 0; //let SMBIOS value to be + gSettings.Smbios.Mobile = gMobile; + gSettings.Smbios.ChassisType = 0; //let SMBIOS value to be /*if (gMobile) { - gSettings.ChassisType = 10; //notebook + gSettings.Smbios.ChassisType = 10; //notebook } else { - gSettings.ChassisType = MiscChassisTypeDeskTop; //0x03; + gSettings.Smbios.ChassisType = MiscChassisTypeDeskTop; //0x03; }*/ break; } //RBr helper if (ApplePlatformData[Model].smcBranch[0] != 'N') { - AsciiStrCpyS(gSettings.RBr, 8, ApplePlatformData[Model].smcBranch.c_str()); + AsciiStrCpyS(gSettings.Smbios.RBr, 8, ApplePlatformData[Model].smcBranch.c_str()); } else { switch (gCPUStructure.Model) { case CPU_MODEL_PENTIUM_M: case CPU_MODEL_CELERON: - AsciiStrCpyS (gSettings.RBr, 8, "m70"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "m70"); break; case CPU_MODEL_YONAH: - AsciiStrCpyS (gSettings.RBr, 8, "k22"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "k22"); break; case CPU_MODEL_MEROM: //TODO check for mobile - AsciiStrCpyS (gSettings.RBr, 8, "m75"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "m75"); break; case CPU_MODEL_PENRYN: - if (gSettings.Mobile) { - AsciiStrCpyS (gSettings.RBr, 8, "m82"); + if (gSettings.Smbios.Mobile) { + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "m82"); } else { - AsciiStrCpyS (gSettings.RBr, 8, "k36"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "k36"); } break; case CPU_MODEL_SANDY_BRIDGE: - if (gSettings.Mobile) { - AsciiStrCpyS (gSettings.RBr, 8, "k90i"); + if (gSettings.Smbios.Mobile) { + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "k90i"); } else { - AsciiStrCpyS (gSettings.RBr, 8, "k60"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "k60"); } break; case CPU_MODEL_IVY_BRIDGE: - AsciiStrCpyS (gSettings.RBr, 8, "j30"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "j30"); break; case CPU_MODEL_IVY_BRIDGE_E5: - AsciiStrCpyS (gSettings.RBr, 8, "j90"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "j90"); break; case CPU_MODEL_HASWELL_ULT: - AsciiStrCpyS (gSettings.RBr, 8, "j44"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "j44"); break; case CPU_MODEL_HASWELL_U5: //Mobile - Broadwell - AsciiStrCpyS (gSettings.RBr, 8, "j52"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "j52"); break; case CPU_MODEL_SKYLAKE_D: - AsciiStrCpyS (gSettings.RBr, 8, "j95j95am"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "j95j95am"); break; case CPU_MODEL_SKYLAKE_U: - AsciiStrCpyS (gSettings.RBr, 8, "2016mb"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "2016mb"); break; case CPU_MODEL_KABYLAKE1: //Mobile - AsciiStrCpyS (gSettings.RBr, 8, "2017mbp"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "2017mbp"); break; case CPU_MODEL_KABYLAKE2: //Desktop - AsciiStrCpyS (gSettings.RBr, 8, "j133_4_5"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "j133_4_5"); break; default: - AsciiStrCpyS (gSettings.RBr, 8, "t9"); + AsciiStrCpyS (gSettings.Smbios.RBr, 8, "t9"); break; } } //RPlt helper if (ApplePlatformData[Model].smcPlatform[0] != 'N') { - AsciiStrCpyS(gSettings.RPlt, 8, ApplePlatformData[Model].smcPlatform.c_str()); + AsciiStrCpyS(gSettings.Smbios.RPlt, 8, ApplePlatformData[Model].smcPlatform.c_str()); } else { switch (gCPUStructure.Model) { case CPU_MODEL_PENTIUM_M: case CPU_MODEL_CELERON: - AsciiStrCpyS (gSettings.RPlt, 8, "m70"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "m70"); break; case CPU_MODEL_YONAH: - AsciiStrCpyS (gSettings.RPlt, 8, "k22"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "k22"); break; case CPU_MODEL_MEROM: //TODO check for mobile - AsciiStrCpyS (gSettings.RPlt, 8, "m75"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "m75"); break; case CPU_MODEL_PENRYN: - if (gSettings.Mobile) { - AsciiStrCpyS (gSettings.RPlt, 8, "m82"); + if (gSettings.Smbios.Mobile) { + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "m82"); } else { - AsciiStrCpyS (gSettings.RPlt, 8, "k36"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "k36"); } break; case CPU_MODEL_SANDY_BRIDGE: - if (gSettings.Mobile) { - AsciiStrCpyS (gSettings.RPlt, 8, "k90i"); + if (gSettings.Smbios.Mobile) { + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "k90i"); } else { - AsciiStrCpyS (gSettings.RPlt, 8, "k60"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "k60"); } break; case CPU_MODEL_IVY_BRIDGE: - AsciiStrCpyS (gSettings.RPlt, 8, "j30"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "j30"); break; case CPU_MODEL_IVY_BRIDGE_E5: - AsciiStrCpyS (gSettings.RPlt, 8, "j90"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "j90"); break; case CPU_MODEL_HASWELL_ULT: - AsciiStrCpyS (gSettings.RPlt, 8, "j44"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "j44"); break; case CPU_MODEL_HASWELL_U5: //Mobile - Broadwell - AsciiStrCpyS (gSettings.RPlt, 8, "j52"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "j52"); break; case CPU_MODEL_SKYLAKE_D: - AsciiStrCpyS (gSettings.RPlt, 8, "j95"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "j95"); break; case CPU_MODEL_SKYLAKE_U: - AsciiStrCpyS (gSettings.RPlt, 8, "j79"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "j79"); break; case CPU_MODEL_KABYLAKE1: //Mobile - AsciiStrCpyS (gSettings.RPlt, 8, "j130a"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "j130a"); break; case CPU_MODEL_KABYLAKE2: //Desktop - AsciiStrCpyS (gSettings.RPlt, 8, "j135"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "j135"); break; default: - AsciiStrCpyS (gSettings.RPlt, 8, "t9"); + AsciiStrCpyS (gSettings.Smbios.RPlt, 8, "t9"); break; } } - CopyMem(gSettings.REV, ApplePlatformData[Model].smcRevision, 6); - CopyMem(gSettings.EPCI, &ApplePlatformData[Model].smcConfig, 4); + CopyMem(gSettings.Smbios.REV, ApplePlatformData[Model].smcRevision, 6); + CopyMem(gSettings.Smbios.EPCI, &ApplePlatformData[Model].smcConfig, 4); } MACHINE_TYPES GetModelFromString(const XString8& ProductName) @@ -1434,10 +1439,10 @@ void GetDefaultSettings() gSettings.ACPI.DSDT.DsdtName = L"DSDT.aml"_XSW; gSettings.SystemParameters.BacklightLevel = 0xFFFF; //0x0503; -- the value from MBA52 gSettings.SystemParameters.BacklightLevelConfig = FALSE; - gSettings.TrustSMBIOS = TRUE; + gSettings.Smbios.TrustSMBIOS = TRUE; - gSettings.SmUUID = nullGuidAsString; - gSettings.DefaultBackgroundColor = 0x80000000; //the value to delete the variable + gSettings.Smbios.SmUUID = nullGuidAsString; + gSettings.BootGraphics.DefaultBackgroundColor = 0x80000000; //the value to delete the variable GlobalConfig.RtROM.setEmpty(); gSettings.RtVariables.CsrActiveConfig = 0xFFFF; gSettings.RtVariables.BooterConfig = 0; @@ -1449,19 +1454,28 @@ void GetDefaultSettings() FreePool(OldCfgStr); } gSettings.Boot.DisableCloverHotkeys = FALSE; - gSettings.UIScale = 1; + gSettings.BootGraphics.UIScale = 1; ResumeFromCoreStorage = FALSE; } -void GetDefaultCpuSettings() +/* + * To ease copy/paste and text replacement from GetUserSettings, the parameter has the same name as the global + * and is passed by non-const reference. + * This temporary during the refactoring + * All code from this comes from settings.cpp. I am taking out all the init code from settings.cpp so I can replace the reading layer. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +void GetDefaultCpuSettings(SETTINGS_DATA& gSettings) { +#pragma GCC diagnostic pop DbgHeader("GetDefaultCpuSettings"); MACHINE_TYPES Model; //UINT64 msr = 0; Model = GetDefaultModel(); gSettings.CPU.CpuType = GetAdvancedCpuType(); - SetDMISettingsForModel(Model, TRUE); + SetDMISettingsForModel(gSettings, Model, TRUE); if (gCPUStructure.Model >= CPU_MODEL_IVY_BRIDGE) { gSettings.ACPI.SSDT.Generate.GeneratePStates = TRUE; diff --git a/rEFIt_UEFI/Platform/platformdata.h b/rEFIt_UEFI/Platform/platformdata.h index dbfaea2e6..2fd5492d5 100644 --- a/rEFIt_UEFI/Platform/platformdata.h +++ b/rEFIt_UEFI/Platform/platformdata.h @@ -10,6 +10,7 @@ #include "../cpp_foundation/XString.h" +#include "../Platform/Settings.h" typedef enum { @@ -142,19 +143,14 @@ typedef enum { constexpr LString8 DefaultMemEntry = "N/A"; constexpr LString8 DefaultSerial = "CT288GT9VT6"; -constexpr LString8 BiosVendor = "Apple Inc."; +constexpr LString8 AppleBiosVendor = "Apple Inc."; constexpr LString8 AppleManufacturer = "Apple Computer, Inc."; //Old name, before 2007 constexpr LString8 AppleBoardSN = "C02140302D5DMT31M"; constexpr LString8 AppleBoardLocation = "Part Component"; -extern UINT32 gFwFeatures; -extern UINT32 gFwFeaturesMask; -extern UINT64 gPlatformFeature; - - void -SetDMISettingsForModel ( +SetDMISettingsForModel (SETTINGS_DATA& gSettings, MACHINE_TYPES Model, BOOLEAN Redefine ); @@ -167,6 +163,6 @@ void GetDefaultSettings(void); void -GetDefaultCpuSettings(void); +GetDefaultCpuSettings(SETTINGS_DATA& gSettings); #endif /* PLATFORM_PLATFORMDATA_H_ */ diff --git a/rEFIt_UEFI/Platform/plist/base64.h b/rEFIt_UEFI/Platform/plist/base64.h index 4d364a411..ef237b1d9 100644 --- a/rEFIt_UEFI/Platform/plist/base64.h +++ b/rEFIt_UEFI/Platform/plist/base64.h @@ -3,7 +3,7 @@ // cpp_tests // // Created by Jief on 24/08/2020. -// Copyright © 2020 JF Knudsen. All rights reserved. +// Copyright © 2020 jief_machack. All rights reserved. // #ifndef base64_h diff --git a/rEFIt_UEFI/Platform/smbios.cpp b/rEFIt_UEFI/Platform/smbios.cpp index 21e1af61b..42925e6b9 100644 --- a/rEFIt_UEFI/Platform/smbios.cpp +++ b/rEFIt_UEFI/Platform/smbios.cpp @@ -462,21 +462,21 @@ void PatchTableType0() UniquifySmbiosTableStr(newSmbiosTable, SMBIOS_TABLE_TYPE0_STR_IDX); - gSettings.VendorName.trim(); - if( gSettings.VendorName.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->Vendor, gSettings.VendorName); + gSettings.Smbios.BiosVendor.trim(); + if( gSettings.Smbios.BiosVendor.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->Vendor, gSettings.Smbios.BiosVendor); } - gSettings.RomVersion.trim(); - if( gSettings.RomVersion.notEmpty() ) { - if( gSettings.EfiVersion.notEmpty() ) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->BiosVersion, gSettings.EfiVersion); + GlobalConfig.RomVersionUsed.trim(); + if( GlobalConfig.RomVersionUsed.notEmpty() ) { + if( GlobalConfig.EfiVersionUsed.notEmpty() ) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->BiosVersion, GlobalConfig.EfiVersionUsed); } else { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->BiosVersion, gSettings.RomVersion); + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->BiosVersion, GlobalConfig.RomVersionUsed); } } - gSettings.ReleaseDate.trim(); - if( gSettings.ReleaseDate.notEmpty() ) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->BiosReleaseDate, gSettings.ReleaseDate); + GlobalConfig.ReleaseDateUsed.trim(); + if( GlobalConfig.ReleaseDateUsed.notEmpty() ) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->BiosReleaseDate, GlobalConfig.ReleaseDateUsed); } Handle = LogSmbiosTable(newSmbiosTable); } @@ -492,9 +492,9 @@ void GetTableType1() return; } - gSettings.SmUUID = GuidLEToXString8(SmbiosTable.Type1->Uuid); + gSettings.Smbios.SmUUID = GuidLEToXString8(SmbiosTable.Type1->Uuid); s = GetSmbiosString(SmbiosTable, SmbiosTable.Type1->ProductName); - gSettings.OEMProduct.strncpy(s, iStrLen(s, 64)); //strncpy take care of ending zero + GlobalConfig.OEMProductFromSmbios.strncpy(s, iStrLen(s, 64)); //strncpy take care of ending zero return; } @@ -524,34 +524,34 @@ void PatchTableType1() Once = TRUE; EFI_GUID SmUUID; - StrToGuidLE(gSettings.SmUUID, &SmUUID); + StrToGuidLE(gSettings.Smbios.SmUUID, &SmUUID); if((SmUUID.Data3 & 0xF000) != 0) { CopyMem((void*)&newSmbiosTable.Type1->Uuid, (void*)&SmUUID, sizeof(SmUUID)); } - gSettings.ManufactureName.trim(); - if( gSettings.ManufactureName.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->Manufacturer, gSettings.ManufactureName); + gSettings.Smbios.ManufactureName.trim(); + if( gSettings.Smbios.ManufactureName.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->Manufacturer, gSettings.Smbios.ManufactureName); } - gSettings.ProductName.trim(); - if( gSettings.ProductName.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->ProductName, gSettings.ProductName); + gSettings.Smbios.ProductName.trim(); + if( gSettings.Smbios.ProductName.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->ProductName, gSettings.Smbios.ProductName); } - gSettings.VersionNr.trim(); - if( gSettings.VersionNr.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->Version, gSettings.VersionNr); + gSettings.Smbios.VersionNr.trim(); + if( gSettings.Smbios.VersionNr.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->Version, gSettings.Smbios.VersionNr); } - gSettings.SerialNr.trim(); - if( gSettings.SerialNr.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->SerialNumber, gSettings.SerialNr); + gSettings.Smbios.SerialNr.trim(); + if( gSettings.Smbios.SerialNr.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->SerialNumber, gSettings.Smbios.SerialNr); } - gSettings.BoardNumber.trim(); - if( gSettings.BoardNumber.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->SKUNumber, gSettings.BoardNumber); //iMac17,1 - there is nothing + gSettings.Smbios.BoardNumber.trim(); + if( gSettings.Smbios.BoardNumber.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->SKUNumber, gSettings.Smbios.BoardNumber); //iMac17,1 - there is nothing } - gSettings.FamilyName.trim(); - if( gSettings.FamilyName.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->Family, gSettings.FamilyName); + gSettings.Smbios.FamilyName.trim(); + if( gSettings.Smbios.FamilyName.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->Family, gSettings.Smbios.FamilyName); } Handle = LogSmbiosTable(newSmbiosTable); @@ -569,9 +569,9 @@ void GetTableType2() } s = GetSmbiosString(SmbiosTable, SmbiosTable.Type2->ProductName); - gSettings.OEMBoard.strncpy(s, iStrLen(s, 64) + 1); + GlobalConfig.OEMBoardFromSmbios.strncpy(s, iStrLen(s, 64) + 1); s = GetSmbiosString(SmbiosTable, SmbiosTable.Type2->Manufacturer); - gSettings.OEMVendor.strncpy(s, iStrLen(s, 64) + 1); + GlobalConfig.OEMVendorFromSmbios.strncpy(s, iStrLen(s, 64) + 1); } @@ -603,36 +603,36 @@ void PatchTableType2() newSmbiosTable.Type2->Hdr.Length = (UINT8)NewSize; newSmbiosTable.Type2->ChassisHandle = mHandle3; //from GetTableType3 - newSmbiosTable.Type2->BoardType = gSettings.BoardType; + newSmbiosTable.Type2->BoardType = gSettings.Smbios.BoardType; ZeroMem((void*)&newSmbiosTable.Type2->FeatureFlag, sizeof(BASE_BOARD_FEATURE_FLAGS)); newSmbiosTable.Type2->FeatureFlag.Motherboard = 1; newSmbiosTable.Type2->FeatureFlag.Replaceable = 1; - if (gSettings.BoardType == 11) { + if (gSettings.Smbios.BoardType == 11) { newSmbiosTable.Type2->FeatureFlag.Removable = 1; } Once = TRUE; UniquifySmbiosTableStr(newSmbiosTable, SMBIOS_TABLE_TYPE2_STR_IDX); - gSettings.BoardManufactureName.trim(); - if( gSettings.BoardManufactureName.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->Manufacturer, gSettings.BoardManufactureName); + gSettings.Smbios.BoardManufactureName.trim(); + if( gSettings.Smbios.BoardManufactureName.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->Manufacturer, gSettings.Smbios.BoardManufactureName); } - gSettings.BoardNumber.trim(); - if( gSettings.BoardNumber.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->ProductName, gSettings.BoardNumber); + gSettings.Smbios.BoardNumber.trim(); + if( gSettings.Smbios.BoardNumber.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->ProductName, gSettings.Smbios.BoardNumber); } - gSettings.BoardVersion.trim(); - if( gSettings.BoardVersion.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->Version, gSettings.BoardVersion); //iMac17,1 - there is ProductName + gSettings.Smbios.BoardVersion.trim(); + if( gSettings.Smbios.BoardVersion.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->Version, gSettings.Smbios.BoardVersion); //iMac17,1 - there is ProductName } - gSettings.BoardSerialNumber.trim(); - if( gSettings.BoardSerialNumber.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->SerialNumber, gSettings.BoardSerialNumber); + gSettings.Smbios.BoardSerialNumber.trim(); + if( gSettings.Smbios.BoardSerialNumber.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->SerialNumber, gSettings.Smbios.BoardSerialNumber); } - gSettings.LocationInChassis.trim(); - if( gSettings.LocationInChassis.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->LocationInChassis, gSettings.LocationInChassis); + gSettings.Smbios.LocationInChassis.trim(); + if( gSettings.Smbios.LocationInChassis.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->LocationInChassis, gSettings.Smbios.LocationInChassis); } //what about Asset Tag??? Not used in real mac. till now. @@ -698,26 +698,26 @@ void PatchTableType3() UniquifySmbiosTableStr(newSmbiosTable, SMBIOS_TABLE_TYPE3_STR_IDX); - if (gSettings.ChassisType != 0) { - newSmbiosTable.Type3->Type = gSettings.ChassisType; + if (gSettings.Smbios.ChassisType != 0) { + newSmbiosTable.Type3->Type = gSettings.Smbios.ChassisType; } - gSettings.ChassisManufacturer.trim(); - if( gSettings.ChassisManufacturer.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type3->Manufacturer, gSettings.ChassisManufacturer); + gSettings.Smbios.ChassisManufacturer.trim(); + if( gSettings.Smbios.ChassisManufacturer.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type3->Manufacturer, gSettings.Smbios.ChassisManufacturer); } //SIC! According to iMac there must be the BoardNumber - gSettings.BoardNumber.trim(); - if( gSettings.BoardNumber.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type3->Version, gSettings.BoardNumber); + gSettings.Smbios.BoardNumber.trim(); + if( gSettings.Smbios.BoardNumber.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type3->Version, gSettings.Smbios.BoardNumber); } - gSettings.SerialNr.trim(); - if( gSettings.SerialNr.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type3->SerialNumber, gSettings.SerialNr); + gSettings.Smbios.SerialNr.trim(); + if( gSettings.Smbios.SerialNr.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type3->SerialNumber, gSettings.Smbios.SerialNr); } - gSettings.ChassisAssetTag.trim(); - if( gSettings.ChassisAssetTag.notEmpty() ){ - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type3->AssetTag, gSettings.ChassisAssetTag); + gSettings.Smbios.ChassisAssetTag.trim(); + if( gSettings.Smbios.ChassisAssetTag.notEmpty() ){ + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type3->AssetTag, gSettings.Smbios.ChassisAssetTag); } Handle = LogSmbiosTable(newSmbiosTable); @@ -752,9 +752,9 @@ void GetTableType4() size_t off = OFFSET_OF(SMBIOS_TABLE_TYPE4, EnabledCoreCount); if (SmbiosTable.Type4->Hdr.Length > off) { //Smbios >= 2.5 - gSettings.EnabledCores = SmbiosTable.Type4->EnabledCoreCount; + GlobalConfig.EnabledCores = SmbiosTable.Type4->EnabledCoreCount; } else { - gSettings.EnabledCores = 0; //to change later + GlobalConfig.EnabledCores = 0; //to change later } //snwprintf(gSettings.CpuFreqMHz, 10, "%d", gCPUStructure.CurrentSpeed); @@ -812,7 +812,7 @@ void PatchTableType4() //DBG("insert ExternalClock: %d MHz\n", (INT32)(DivU64x32(gCPUStructure.ExternalClock, Kilo))); newSmbiosTable.Type4->ExternalClock = (UINT16)DivU64x32 (gCPUStructure.ExternalClock, Kilo); - newSmbiosTable.Type4->EnabledCoreCount = gSettings.EnabledCores; + newSmbiosTable.Type4->EnabledCoreCount = GlobalConfig.EnabledCores; //some verifications if ((newSmbiosTable.Type4->ThreadCount < newSmbiosTable.Type4->CoreCount) || newSmbiosTable.Type4->ThreadCount > newSmbiosTable.Type4->CoreCount * 2) { @@ -1061,29 +1061,29 @@ void PatchTableType9() // real PC -> PCI, real Mac -> PCIe for (Index = 0; Index < 15; Index++) { - if (SlotDevices[Index].Valid) { + if (gSettings.Smbios.SlotDevices[Index].Valid) { INTN Dev, Func; ZeroMem((void*)newSmbiosTable.Type9, MAX_TABLE_SIZE); newSmbiosTable.Type9->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_SLOTS; newSmbiosTable.Type9->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE9); newSmbiosTable.Type9->Hdr.Handle = (UINT16)(0x0900 + Index); newSmbiosTable.Type9->SlotDesignation = 1; - newSmbiosTable.Type9->SlotType = SlotDevices[Index].SlotType; + newSmbiosTable.Type9->SlotType = gSettings.Smbios.SlotDevices[Index].SlotType; newSmbiosTable.Type9->SlotDataBusWidth = SlotDataBusWidth1X; newSmbiosTable.Type9->CurrentUsage = SlotUsageAvailable; newSmbiosTable.Type9->SlotLength = SlotLengthShort; - newSmbiosTable.Type9->SlotID = SlotDevices[Index].SlotID; + newSmbiosTable.Type9->SlotID = gSettings.Smbios.SlotDevices[Index].SlotID; newSmbiosTable.Type9->SlotCharacteristics1.Provides33Volts = 1; newSmbiosTable.Type9->SlotCharacteristics2.HotPlugDevicesSupported = 1; // take this from PCI bus for WiFi card - newSmbiosTable.Type9->SegmentGroupNum = SlotDevices[Index].SegmentGroupNum; - newSmbiosTable.Type9->BusNum = SlotDevices[Index].BusNum; - newSmbiosTable.Type9->DevFuncNum = SlotDevices[Index].DevFuncNum; + newSmbiosTable.Type9->SegmentGroupNum = gSettings.Smbios.SlotDevices[Index].SegmentGroupNum; + newSmbiosTable.Type9->BusNum = gSettings.Smbios.SlotDevices[Index].BusNum; + newSmbiosTable.Type9->DevFuncNum = gSettings.Smbios.SlotDevices[Index].DevFuncNum; // - Dev = SlotDevices[Index].DevFuncNum >> 3; - Func = SlotDevices[Index].DevFuncNum & 7; + Dev = gSettings.Smbios.SlotDevices[Index].DevFuncNum >> 3; + Func = gSettings.Smbios.SlotDevices[Index].DevFuncNum & 7; DBG("insert table 9 for dev %llX:%llX\n", Dev, Func); - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type9->SlotDesignation, LString8(SlotDevices[Index].SlotName)); + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type9->SlotDesignation, gSettings.Smbios.SlotDevices[Index].SlotName); LogSmbiosTable(newSmbiosTable); } } @@ -1112,17 +1112,17 @@ void PatchTableType11() // ZeroMem(OEMString, MAX_OEM_STRING); // AsciiStrCatS(OEMString, MAX_OEM_STRING, "Apple ROM Version.\n"); // //AsciiStrCatS(OEMString, MAX_OEM_STRING, " BIOS ID:"); -// //AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.RomVersion, iStrLen(gSettings.RomVersion, 64)); +// //AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.Smbios.RomVersion, iStrLen(gSettings.Smbios.RomVersion, 64)); // // AsciiStrCatS(OEMString, MAX_OEM_STRING, "\n EFI Version:"); -// // AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.EfiVersion, iStrLen(gSettings.EfiVersion, 64)); +// // AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.Smbios.EfiVersion, iStrLen(gSettings.Smbios.EfiVersion, 64)); // AsciiStrCatS(OEMString, MAX_OEM_STRING, " Board-ID : "); -// AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.BoardNumber, iStrLen(gSettings.BoardNumber, 64)); +// AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.Smbios.BoardNumber, iStrLen(gSettings.Smbios.BoardNumber, 64)); // snprintf(TempRev, MAX_OEM_STRING, "\n⌘ Powered by %s\n", gRevisionStr); // AsciiStrCatS(OEMString, MAX_OEM_STRING, TempRev); #ifdef JIEF_DEBUG XString8 OEMString = S8Printf("⌘ Powered by %s\n", gBuildId.c_str()); #else - XString8 OEMString = S8Printf("Apple ROM Version.\nBoard-ID : %s\n⌘ Powered by %s\n", gSettings.BoardNumber.c_str(), gRevisionStr); + XString8 OEMString = S8Printf("Apple ROM Version.\nBoard-ID : %s\n⌘ Powered by %s\n", gSettings.Smbios.BoardNumber.c_str(), gRevisionStr); #endif UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type11->StringCount, OEMString); @@ -1283,9 +1283,15 @@ void GetTableType17() // Fill rest of information if in use if (gRAM.SMBIOS[Index].InUse) { ++(gRAM.SMBIOSInUse); - gRAM.SMBIOS[Index].Vendor = GetSmbiosString(SmbiosTable, SmbiosTable.Type17->Manufacturer); - gRAM.SMBIOS[Index].SerialNo = GetSmbiosString(SmbiosTable, SmbiosTable.Type17->SerialNumber); - gRAM.SMBIOS[Index].PartNo = GetSmbiosString(SmbiosTable, SmbiosTable.Type17->PartNumber); + gRAM.SMBIOS[Index].Vendor.takeValueFrom(GetSmbiosString(SmbiosTable, SmbiosTable.Type17->Manufacturer)); + gRAM.SMBIOS[Index].Vendor.trim(); + gRAM.SMBIOS[Index].Vendor.deleteCharsAtPos(gRAM.SMBIOS[Index].Vendor.indexOf(' '), MAX_XSIZE); + gRAM.SMBIOS[Index].SerialNo.takeValueFrom(GetSmbiosString(SmbiosTable, SmbiosTable.Type17->SerialNumber)); + gRAM.SMBIOS[Index].SerialNo.trim(); + gRAM.SMBIOS[Index].SerialNo.deleteCharsAtPos(gRAM.SMBIOS[Index].SerialNo.indexOf(' '), MAX_XSIZE); + gRAM.SMBIOS[Index].PartNo.takeValueFrom(GetSmbiosString(SmbiosTable, SmbiosTable.Type17->PartNumber)); + gRAM.SMBIOS[Index].PartNo.trim(); + gRAM.SMBIOS[Index].PartNo.deleteCharsAtPos(gRAM.SMBIOS[Index].PartNo.indexOf(' '), MAX_XSIZE); } // DBG("CntMemorySlots = %d\n", gDMI->CntMemorySlots) // DBG("gDMI->MemoryModules = %d\n", gDMI->MemoryModules) @@ -1293,9 +1299,9 @@ void GetTableType17() DBG("SmbiosTable.Type17->Speed = %dMHz\n", gRAM.SMBIOS[Index].Frequency); DBG("SmbiosTable.Type17->Size = %dMB\n", gRAM.SMBIOS[Index].ModuleSize); DBG("SmbiosTable.Type17->Bank/Device = %s %s\n", GetSmbiosString(SmbiosTable, SmbiosTable.Type17->BankLocator), GetSmbiosString(SmbiosTable, SmbiosTable.Type17->DeviceLocator)); - DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SMBIOS[Index].Vendor); - DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SMBIOS[Index].SerialNo); - DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SMBIOS[Index].PartNo); + DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SMBIOS[Index].Vendor.c_str()); + DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SMBIOS[Index].SerialNo.c_str()); + DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SMBIOS[Index].PartNo.c_str()); } /* @@ -1316,34 +1322,34 @@ void PatchTableType17() UINT8 expectedCount = 0; UINT8 channels = 2; BOOLEAN insertingEmpty = TRUE; - BOOLEAN trustSMBIOS = ((gRAM.SPDInUse == 0) || gSettings.TrustSMBIOS); + BOOLEAN trustSMBIOS = ((gRAM.SPDInUse == 0) || gSettings.Smbios.TrustSMBIOS); BOOLEAN wrongSMBIOSBanks = FALSE; BOOLEAN isMacPro = FALSE; - MACHINE_TYPES Model = GetModelFromString(gSettings.ProductName); + MACHINE_TYPES Model = GetModelFromString(gSettings.Smbios.ProductName); if ((Model == MacPro31) || (Model == MacPro41) || (Model == MacPro51) || (Model == MacPro61)) { isMacPro = TRUE; } // Inject user memory tables - if (gSettings.InjectMemoryTables) { + if (gSettings.Smbios.InjectMemoryTables) { DBG("Injecting user memory modules to SMBIOS\n"); - if (gRAM.UserInUse == 0) { + if (gSettings.Smbios.Memory.SlotCounts == 0) { DBG("User SMBIOS contains no memory modules\n"); return; } // Check channels - if ((gRAM.UserChannels == 0) || (gRAM.UserChannels > 8)) { - gRAM.UserChannels = 1; + if ((gSettings.Smbios.Memory.UserChannels == 0) || (gSettings.Smbios.Memory.UserChannels > 8)) { + gSettings.Smbios.Memory.UserChannels = 1; } - if (gRAM.UserInUse >= MAX_RAM_SLOTS) { - gRAM.UserInUse = MAX_RAM_SLOTS; + if (gSettings.Smbios.Memory.SlotCounts >= MAX_RAM_SLOTS) { + gSettings.Smbios.Memory.SlotCounts = MAX_RAM_SLOTS; } - DBG("Channels: %d\n", gRAM.UserChannels); + DBG("Channels: %d\n", gSettings.Smbios.Memory.UserChannels); // Setup interleaved channel map if (channels >= 2) { - UINT8 doubleChannels = (UINT8)gRAM.UserChannels << 1; + UINT8 doubleChannels = (UINT8)gSettings.Smbios.Memory.UserChannels << 1; for (Index = 0; Index < MAX_RAM_SLOTS; ++Index) { channelMap[Index] = (UINT8)(((Index / doubleChannels) * doubleChannels) + - ((Index / gRAM.UserChannels) % 2) + ((Index % gRAM.UserChannels) << 1)); + ((Index / gSettings.Smbios.Memory.UserChannels) % 2) + ((Index % gSettings.Smbios.Memory.UserChannels) << 1)); } } else { for (Index = 0; Index < MAX_RAM_SLOTS; ++Index) { @@ -1359,9 +1365,9 @@ void PatchTableType17() // gRAMCount = 0; // Inject tables - for (Index = 0; Index < gRAM.UserInUse; Index++) { + for (Index = 0; Index < gSettings.Smbios.Memory.SlotCounts; Index++) { UINTN UserIndex = channelMap[Index]; - UINT8 bank = (UINT8)(Index / gRAM.UserChannels); + UINT8 bank = (UINT8)(Index / gSettings.Smbios.Memory.UserChannels); ZeroMem((void*)newSmbiosTable.Type17, MAX_TABLE_SIZE); newSmbiosTable.Type17->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_DEVICE; newSmbiosTable.Type17->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE17); @@ -1380,38 +1386,38 @@ void PatchTableType17() UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->BankLocator, bankLocator); } UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->DeviceLocator, deviceLocator); - if ((gRAM.User[UserIndex].InUse) && (gRAM.User[UserIndex].ModuleSize > 0)) { + if ((gSettings.Smbios.Memory.User[UserIndex].InUse) && (gSettings.Smbios.Memory.User[UserIndex].ModuleSize > 0)) { DBG("user SMBIOS data:\n"); - DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.User[UserIndex].Vendor); - DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.User[UserIndex].SerialNo); - DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.User[UserIndex].PartNo); + DBG("SmbiosTable.Type17->Vendor = %s\n", gSettings.Smbios.Memory.User[UserIndex].Vendor.c_str()); + DBG("SmbiosTable.Type17->SerialNumber = %s\n", gSettings.Smbios.Memory.User[UserIndex].SerialNo.c_str()); + DBG("SmbiosTable.Type17->PartNumber = %s\n", gSettings.Smbios.Memory.User[UserIndex].PartNo.c_str()); - if (gRAM.User[UserIndex].Vendor && iStrLen(gRAM.User[UserIndex].Vendor, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, LString8(gRAM.User[UserIndex].Vendor)); + if (gSettings.Smbios.Memory.User[UserIndex].Vendor.notEmpty()) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gSettings.Smbios.Memory.User[UserIndex].Vendor); } else { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown); } - if (gRAM.User[UserIndex].SerialNo && iStrLen(gRAM.User[UserIndex].SerialNo, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, LString8(gRAM.User[UserIndex].SerialNo)); + if (gSettings.Smbios.Memory.User[UserIndex].SerialNo.notEmpty()) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gSettings.Smbios.Memory.User[UserIndex].SerialNo); } else { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown); } - if (gRAM.User[UserIndex].PartNo && iStrLen(gRAM.User[UserIndex].PartNo, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, LString8(gRAM.User[UserIndex].PartNo)); + if (gSettings.Smbios.Memory.User[UserIndex].PartNo.notEmpty()) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gSettings.Smbios.Memory.User[UserIndex].PartNo); } else { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, unknown); } - newSmbiosTable.Type17->Speed = (UINT16)gRAM.User[UserIndex].Frequency; - if (gRAM.User[UserIndex].ModuleSize > 0x7FFF) { + newSmbiosTable.Type17->Speed = (UINT16)gSettings.Smbios.Memory.User[UserIndex].Frequency; + if (gSettings.Smbios.Memory.User[UserIndex].ModuleSize > 0x7FFF) { newSmbiosTable.Type17->Size = 0x7FFF; - newSmbiosTable.Type17->ExtendedSize = gRAM.User[UserIndex].ModuleSize; + newSmbiosTable.Type17->ExtendedSize = gSettings.Smbios.Memory.User[UserIndex].ModuleSize; mTotalSystemMemory += newSmbiosTable.Type17->ExtendedSize; //Mb } else { - newSmbiosTable.Type17->Size = (UINT16)gRAM.User[UserIndex].ModuleSize; + newSmbiosTable.Type17->Size = (UINT16)gSettings.Smbios.Memory.User[UserIndex].ModuleSize; mTotalSystemMemory += newSmbiosTable.Type17->Size; //Mb } - newSmbiosTable.Type17->MemoryType = gRAM.User[UserIndex].Type; + newSmbiosTable.Type17->MemoryType = gSettings.Smbios.Memory.User[UserIndex].Type; if ((newSmbiosTable.Type17->MemoryType != MemoryTypeDdr2) && (newSmbiosTable.Type17->MemoryType != MemoryTypeDdr4) && (newSmbiosTable.Type17->MemoryType != MemoryTypeDdr)) { @@ -1483,7 +1489,7 @@ void PatchTableType17() DBG("Trusting SMBIOS...\n"); } // Determine expected slot count - expectedCount = (gRAM.UserInUse != 0) ? gRAM.UserInUse : gRAM.SPDInUse; + expectedCount = (gSettings.Smbios.Memory.SlotCounts != 0) ? gSettings.Smbios.Memory.SlotCounts : gRAM.SPDInUse; if (trustSMBIOS) { // Use the smbios in use count if (expectedCount < gRAM.SMBIOSInUse) { @@ -1513,8 +1519,8 @@ void PatchTableType17() DBG("Detected alternating SMBIOS channel banks\n"); } // Determine if using triple or quadruple channel - if (gRAM.UserChannels != 0) { - channels = gRAM.UserChannels; + if (gSettings.Smbios.Memory.UserChannels != 0) { + channels = gSettings.Smbios.Memory.UserChannels; } else if (gRAM.SPDInUse == 0) { if (trustSMBIOS) { if ((gRAM.SMBIOSInUse % 4) == 0) { @@ -1612,31 +1618,31 @@ void PatchTableType17() SmbiosTable = GetSmbiosTableFromType(EntryPoint, EFI_SMBIOS_TYPE_MEMORY_DEVICE, SMBIOSIndex); if (trustSMBIOS && gRAM.SMBIOS[SMBIOSIndex].InUse && (SmbiosTable.Raw != NULL)) { DBG("trusted SMBIOS data:\n"); - DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SMBIOS[SMBIOSIndex].Vendor); - DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SMBIOS[SMBIOSIndex].SerialNo); - DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SMBIOS[SMBIOSIndex].PartNo); + DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SMBIOS[SMBIOSIndex].Vendor.c_str()); + DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SMBIOS[SMBIOSIndex].SerialNo.c_str()); + DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SMBIOS[SMBIOSIndex].PartNo.c_str()); TableSize = SmbiosTableLength(SmbiosTable); CopyMem((void*)newSmbiosTable.Type17, (void *)SmbiosTable.Type17, TableSize); newSmbiosTable.Type17->AssetTag = 0; - if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, LString8(gRAM.SMBIOS[SMBIOSIndex].Vendor)); - gSettings.MemoryManufacturer.takeValueFrom(gRAM.SMBIOS[SMBIOSIndex].Vendor); + if ( gRAM.SMBIOS[SMBIOSIndex].Vendor.notEmpty() ) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SMBIOS[SMBIOSIndex].Vendor); +// gSettings.MemoryManufacturer.takeValueFrom(gRAM.SMBIOS[SMBIOSIndex].Vendor); } else { // newSmbiosTable.Type17->Manufacturer = 0; UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown); } - if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].SerialNo, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, LString8(gRAM.SMBIOS[SMBIOSIndex].SerialNo)); - gSettings.MemorySerialNumber.takeValueFrom(gRAM.SMBIOS[SMBIOSIndex].SerialNo); + if ( gRAM.SMBIOS[SMBIOSIndex].SerialNo.notEmpty() ) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gRAM.SMBIOS[SMBIOSIndex].SerialNo); +// gSettings.MemorySerialNumber.takeValueFrom(gRAM.SMBIOS[SMBIOSIndex].SerialNo); } else { // newSmbiosTable.Type17->SerialNumber = 0; UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown); } - if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].PartNo, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, LString8(gRAM.SMBIOS[SMBIOSIndex].PartNo)); - gSettings.MemoryPartNumber.takeValueFrom(gRAM.SMBIOS[SMBIOSIndex].PartNo); - DBG(" partNum=%s\n", gRAM.SMBIOS[SMBIOSIndex].PartNo); + if ( gRAM.SMBIOS[SMBIOSIndex].PartNo.notEmpty() ) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gRAM.SMBIOS[SMBIOSIndex].PartNo); +// gSettings.MemoryPartNumber.takeValueFrom(gRAM.SMBIOS[SMBIOSIndex].PartNo); + DBG(" partNum=%s\n", gRAM.SMBIOS[SMBIOSIndex].PartNo.c_str()); } else { // newSmbiosTable.Type17->PartNumber = 0; UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, unknown); @@ -1658,25 +1664,25 @@ void PatchTableType17() if (gRAM.SPD[SPDIndex].InUse) { DBG("SPD data in use:\n"); - DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SPD[SPDIndex].Vendor); - DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SPD[SPDIndex].SerialNo); - DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SPD[SPDIndex].PartNo); + DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SPD[SPDIndex].Vendor.c_str()); + DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SPD[SPDIndex].SerialNo.c_str()); + DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SPD[SPDIndex].PartNo.c_str()); - if (iStrLen(gRAM.SPD[SPDIndex].Vendor, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, LString8(gRAM.SPD[SPDIndex].Vendor)); - gSettings.MemoryManufacturer.takeValueFrom(gRAM.SPD[SPDIndex].Vendor); + if ( gRAM.SPD[SPDIndex].Vendor.notEmpty() ) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SPD[SPDIndex].Vendor); +// gSettings.MemoryManufacturer.takeValueFrom(gRAM.SPD[SPDIndex].Vendor); } else { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown); } - if (iStrLen(gRAM.SPD[SPDIndex].SerialNo, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, LString8(gRAM.SPD[SPDIndex].SerialNo)); - gSettings.MemorySerialNumber.takeValueFrom(gRAM.SPD[SPDIndex].SerialNo); + if ( gRAM.SPD[SPDIndex].SerialNo.notEmpty() ) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gRAM.SPD[SPDIndex].SerialNo); +// gSettings.MemorySerialNumber.takeValueFrom(gRAM.SPD[SPDIndex].SerialNo); } else { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown); } - if (iStrLen(gRAM.SPD[SPDIndex].PartNo, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, LString8(gRAM.SPD[SPDIndex].PartNo)); - gSettings.MemoryPartNumber.takeValueFrom(gRAM.SPD[SPDIndex].PartNo); + if ( gRAM.SPD[SPDIndex].PartNo.notEmpty() ) { + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gRAM.SPD[SPDIndex].PartNo); +// gSettings.MemoryPartNumber.takeValueFrom(gRAM.SPD[SPDIndex].PartNo); } else { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, unknown); } @@ -1699,13 +1705,14 @@ void PatchTableType17() newSmbiosTable.Type17->Speed = (UINT16)gRAM.SMBIOS[SMBIOSIndex].Frequency; } if (trustSMBIOS && gRAM.SMBIOS[SMBIOSIndex].InUse && - (iStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor, 64) > 0) && - (!gRAM.SPD[SPDIndex].Vendor || strncmp(gRAM.SPD[SPDIndex].Vendor, "NoName", 6) == 0)) { - DBG("Type17->Manufacturer corrected by SMBIOS from NoName to %s\n", gRAM.SMBIOS[SMBIOSIndex].Vendor); - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, LString8(gRAM.SMBIOS[SMBIOSIndex].Vendor)); + gRAM.SMBIOS[SMBIOSIndex].Vendor.notEmpty() && + ( gRAM.SPD[SPDIndex].Vendor.isEmpty() || gRAM.SPD[SPDIndex].Vendor == "NoName"_XS8 ) + ) { + DBG("Type17->Manufacturer corrected by SMBIOS from NoName to %s\n", gRAM.SMBIOS[SMBIOSIndex].Vendor.c_str()); + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SMBIOS[SMBIOSIndex].Vendor); } - gSettings.MemorySpeed.S8Printf("%d", newSmbiosTable.Type17->Speed); +// gSettings.MemorySpeed.S8Printf("%d", newSmbiosTable.Type17->Speed); // Assume DDR3 unless explicitly set to DDR2/DDR/DDR4 if ((newSmbiosTable.Type17->MemoryType != MemoryTypeDdr2) && @@ -1745,8 +1752,8 @@ void PatchTableType17() // DBG("mTotalSystemMemory = %d\n", mTotalSystemMemory); } newSmbiosTable.Type17->MemoryErrorInformationHandle = 0xFFFF; - if (gSettings.Attribute != -1) { - newSmbiosTable.Type17->Attributes = gSettings.Attribute; + if (gSettings.Smbios.Attribute != -1) { + newSmbiosTable.Type17->Attributes = gSettings.Smbios.Attribute; } mHandle17[gRAMCount++] = LogSmbiosTable(newSmbiosTable); } @@ -1883,9 +1890,9 @@ void PatchTableType128() newSmbiosTable.Type128->Hdr.Handle = 0x8000; // set firmware-features, example: 0x80001417, imac11,2 -> 0x1403. - newSmbiosTable.Type128->FirmwareFeatures = gFwFeatures; + newSmbiosTable.Type128->FirmwareFeatures = gSettings.Smbios.gFwFeatures; // set firmware-features mask - newSmbiosTable.Type128->FirmwareFeaturesMask = gFwFeaturesMask; + newSmbiosTable.Type128->FirmwareFeaturesMask = gSettings.Smbios.gFwFeaturesMask; /** * TODO: I have an idea that region should be the same as Efivar.bin @@ -1978,21 +1985,21 @@ void PatchTableType132() void PatchTableType133() { - if (gPlatformFeature == 0xFFFF) { + if (gSettings.Smbios.gPlatformFeature == 0xFFFF) { return; } // Get Table Type133 SmbiosTable = GetSmbiosTableFromType (EntryPoint, 133, 0); if (SmbiosTable.Raw != NULL) { MsgLog("Table 133 is present, PlatformFeature=%llX\n", SmbiosTable.Type133->PlatformFeature); - MsgLog("Change to: %llX\n", gPlatformFeature); + MsgLog("Change to: %llX\n", gSettings.Smbios.gPlatformFeature); } ZeroMem((void*)newSmbiosTable.Type133, MAX_TABLE_SIZE); newSmbiosTable.Type133->Hdr.Type = 133; newSmbiosTable.Type133->Hdr.Length = sizeof(SMBIOS_STRUCTURE)+8; newSmbiosTable.Type133->Hdr.Handle = 0x8500; //ugly - // newSmbiosTable.Type133->PlatformFeature = gPlatformFeature; - CopyMem((void*)&newSmbiosTable.Type133->PlatformFeature, (void*)&gPlatformFeature, 8); + // newSmbiosTable.Type133->PlatformFeature = gSettings.Smbios.gPlatformFeature; + CopyMem((void*)&newSmbiosTable.Type133->PlatformFeature, (void*)&gSettings.Smbios.gPlatformFeature, 8); Handle = LogSmbiosTable(newSmbiosTable); return; } @@ -2060,9 +2067,9 @@ EFI_STATUS PrepatchSmbios() Current = (UINT8*)Smbios; //begin fill tables from here SmbiosEpsNew->TableAddress = (UINT32)(UINTN)Current; SmbiosEpsNew->EntryPointLength = sizeof(SMBIOS_TABLE_ENTRY_POINT); // no matter on other versions - if (gSettings.SmbiosVersion != 0) { - SmbiosEpsNew->MajorVersion = (UINT8)(gSettings.SmbiosVersion >> 8); - SmbiosEpsNew->MinorVersion = (UINT8)(gSettings.SmbiosVersion & 0xFF); + if (gSettings.Smbios.SmbiosVersion != 0) { + SmbiosEpsNew->MajorVersion = (UINT8)(gSettings.Smbios.SmbiosVersion >> 8); + SmbiosEpsNew->MinorVersion = (UINT8)(gSettings.Smbios.SmbiosVersion & 0xFF); SmbiosEpsNew->SmbiosBcdRevision = (SmbiosEpsNew->MajorVersion << 4) + SmbiosEpsNew->MinorVersion; } else { @@ -2104,7 +2111,7 @@ void PatchSmbios(void) //continue PatchTableType4(); // PatchTableType6(); PatchTableType9(); - if (!gSettings.NoRomInfo) { + if (!gSettings.Smbios.NoRomInfo) { PatchTableType11(); } PatchTableTypeSome(); diff --git a/rEFIt_UEFI/Platform/smbios.h b/rEFIt_UEFI/Platform/smbios.h index 6ebef4a0a..b0c4852e4 100644 --- a/rEFIt_UEFI/Platform/smbios.h +++ b/rEFIt_UEFI/Platform/smbios.h @@ -19,15 +19,13 @@ extern "C" { #define MAX_RAM_FREQUENCY 5000 typedef struct { - BOOLEAN InUse; - UINT8 Type; - UINT16 pad0; - UINT32 pad1; UINT32 ModuleSize; UINT32 Frequency; - CONST CHAR8* Vendor; - CHAR8* PartNo; - CHAR8* SerialNo; + XString8 Vendor; + XString8 PartNo; + XString8 SerialNo; + UINT8 Type; + bool InUse; } RAM_SLOT_INFO; typedef struct @@ -42,13 +40,10 @@ typedef struct UINT8 Type; UINT8 SPDInUse; UINT8 SMBIOSInUse; - UINT8 UserInUse; - UINT8 UserChannels; UINT8 pad[2]; RAM_SLOT_INFO SPD[MAX_RAM_SLOTS * 4]; RAM_SLOT_INFO SMBIOS[MAX_RAM_SLOTS * 4]; - RAM_SLOT_INFO User[MAX_RAM_SLOTS * 4]; } MEM_STRUCTURE; diff --git a/rEFIt_UEFI/Platform/spd.cpp b/rEFIt_UEFI/Platform/spd.cpp index 712278c4c..829d8dcc4 100644 --- a/rEFIt_UEFI/Platform/spd.cpp +++ b/rEFIt_UEFI/Platform/spd.cpp @@ -384,7 +384,7 @@ CONST CHAR8* getVendorName(RAM_SLOT_INFO* slot, UINT8 *spd, UINT32 base, UINT8 s } } /* OK there is no vendor id here lets try to match the partnum if it exists */ - if (AsciiStrStr(slot->PartNo,"GU332") == slot->PartNo) { // Unifosa fingerprint + if ( slot->PartNo.startWithOrEqualTo("GU332") ) { // Unifosa fingerprint return "Unifosa"; } return "NoName"; @@ -808,9 +808,15 @@ STATIC void read_smb(EFI_PCI_IO_PROTOCOL *PciIo, UINT16 vid, UINT16 did) if (gRAM.SPD[i].ModuleSize == 0) continue; //spd_type = (slot->spd[SPD_MEMORY_TYPE] < ((UINT8) 12) ? slot->spd[SPD_MEMORY_TYPE] : 0); //gRAM Type = spd_mem_to_smbios[spd_type]; - gRAM.SPD[i].PartNo = getDDRPartNum(spdbuf, base, i); - gRAM.SPD[i].Vendor = getVendorName(&(gRAM.SPD[i]), spdbuf, base, i); - gRAM.SPD[i].SerialNo = getDDRSerial(spdbuf); + gRAM.SPD[i].PartNo.takeValueFrom(getDDRPartNum(spdbuf, base, i)); + gRAM.SPD[i].PartNo.trim(); + gRAM.SPD[i].PartNo.deleteCharsAtPos(gRAM.SPD[i].PartNo.indexOf(' '), MAX_XSIZE); + gRAM.SPD[i].Vendor.takeValueFrom(getVendorName(&(gRAM.SPD[i]), spdbuf, base, i)); + gRAM.SPD[i].Vendor.trim(); + gRAM.SPD[i].Vendor.deleteCharsAtPos(gRAM.SPD[i].Vendor.indexOf(' '), MAX_XSIZE); + gRAM.SPD[i].SerialNo.takeValueFrom(getDDRSerial(spdbuf)); + gRAM.SPD[i].SerialNo.trim(); + gRAM.SPD[i].SerialNo.deleteCharsAtPos(gRAM.SPD[i].SerialNo.indexOf(' '), MAX_XSIZE); //XXX - when we can FreePool allocated for these buffers? No this is pointer copy // determine spd speed speed = getDDRspeedMhz(spdbuf); @@ -840,9 +846,9 @@ STATIC void read_smb(EFI_PCI_IO_PROTOCOL *PciIo, UINT16 vid, UINT16 did) (int)gRAM.SPD[i].Type, gRAM.SPD[i].ModuleSize, gRAM.SPD[i].Frequency, - gRAM.SPD[i].Vendor, - gRAM.SPD[i].PartNo, - gRAM.SPD[i].SerialNo); + gRAM.SPD[i].Vendor.c_str(), + gRAM.SPD[i].PartNo.c_str(), + gRAM.SPD[i].SerialNo.c_str()); gRAM.SPD[i].InUse = TRUE; ++(gRAM.SPDInUse); diff --git a/rEFIt_UEFI/cpp_foundation/XToolsCommon.h b/rEFIt_UEFI/cpp_foundation/XToolsCommon.h index bb8822f56..3848f6877 100644 --- a/rEFIt_UEFI/cpp_foundation/XToolsCommon.h +++ b/rEFIt_UEFI/cpp_foundation/XToolsCommon.h @@ -3,7 +3,7 @@ // cpp_tests // // Created by jief on 25.04.20. -// Copyright © 2020 JF Knudsen. All rights reserved. +// Copyright © 2020 jief_machack. All rights reserved. // #ifndef XToolsCommon_h diff --git a/rEFIt_UEFI/gui/REFIT_MAINMENU_SCREEN.cpp b/rEFIt_UEFI/gui/REFIT_MAINMENU_SCREEN.cpp index 8279e870c..c8b0dd8ca 100644 --- a/rEFIt_UEFI/gui/REFIT_MAINMENU_SCREEN.cpp +++ b/rEFIt_UEFI/gui/REFIT_MAINMENU_SCREEN.cpp @@ -760,12 +760,12 @@ UINTN REFIT_MAINMENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABS } SubMenuIndex = -1; - gSettings.OptionsBits = EncodeOptions(TmpArgs); - // DBG("main OptionsBits = 0x%X\n", gSettings.OptionsBits); + GlobalConfig.OptionsBits = EncodeOptions(TmpArgs); + // DBG("main OptionsBits = 0x%X\n", GlobalConfig.OptionsBits); if (MainChosenEntry->getLOADER_ENTRY()) { - gSettings.OptionsBits |= EncodeOptions(MainChosenEntry->getLOADER_ENTRY()->LoadOptions); - // DBG("add OptionsBits = 0x%X\n", gSettings.OptionsBits); + GlobalConfig.OptionsBits |= EncodeOptions(MainChosenEntry->getLOADER_ENTRY()->LoadOptions); + // DBG("add OptionsBits = 0x%X\n", GlobalConfig.OptionsBits); } if (MainChosenEntry->getREFIT_MENU_ITEM_BOOTNUM()) { @@ -775,9 +775,9 @@ UINTN REFIT_MAINMENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABS if (MainChosenEntry->getLOADER_ENTRY()) { // Only for non-legacy entries, as LEGACY_ENTRY doesn't have Flags - gSettings.FlagsBits = MainChosenEntry->getLOADER_ENTRY()->Flags; + GlobalConfig.FlagsBits = MainChosenEntry->getLOADER_ENTRY()->Flags; } - // DBG(" MainChosenEntry with FlagsBits = 0x%X\n", gSettings.FlagsBits); + // DBG(" MainChosenEntry with FlagsBits = 0x%X\n", GlobalConfig.FlagsBits); SubMenuExit = 0; while (!SubMenuExit) { @@ -808,7 +808,7 @@ UINTN REFIT_MAINMENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABS DBG(" get MainChosenEntry FlagsBits = 0x%X\n", ((LOADER_ENTRY*)MainChosenEntry)->Flags); if (OSFLAG_ISUNSET(TempChosenEntry->getLOADER_ENTRY()->Flags, OSFLAG_NODEFAULTARGS)) { DecodeOptions(TempChosenEntry->getLOADER_ENTRY()); - // DBG("get OptionsBits = 0x%X\n", gSettings.OptionsBits); + // DBG("get OptionsBits = 0x%X\n", GlobalConfig.OptionsBits); // DBG(" TempChosenEntry FlagsBits = 0x%X\n", ((LOADER_ENTRY*)TempChosenEntry)->Flags); } // copy also loadoptions from subentry to mainentry diff --git a/rEFIt_UEFI/gui/shared_with_menu.cpp b/rEFIt_UEFI/gui/shared_with_menu.cpp index fdd00cf05..7daddd5df 100644 --- a/rEFIt_UEFI/gui/shared_with_menu.cpp +++ b/rEFIt_UEFI/gui/shared_with_menu.cpp @@ -97,13 +97,13 @@ void DecodeOptions(REFIT_MENU_ITEM_BOOTNUM *Entry) return; } for (Index = 0; Index < INX_NVWEBON; Index++) { //not including INX_NVWEBON - if (gSettings.OptionsBits & (1 << Index)) { + if (GlobalConfig.OptionsBits & (1 << Index)) { Entry->LoadOptions.AddID(ArgOptional[Index]); } } //remove unchecked options for (Index = 0; Index < INX_NVWEBON; Index++) { //not including INX_NVWEBON - if ((gSettings.OptionsBits & (1 << Index)) == 0) { + if ((GlobalConfig.OptionsBits & (1 << Index)) == 0) { Entry->LoadOptions.remove(ArgOptional[Index]); } } @@ -111,7 +111,7 @@ void DecodeOptions(REFIT_MENU_ITEM_BOOTNUM *Entry) if (Entry->getLOADER_ENTRY()) { LOADER_ENTRY* loaderEntry = Entry->getLOADER_ENTRY(); // Only for non-legacy entries, as LEGACY_ENTRY doesn't have OSVersion - if (gSettings.OptionsBits & OPT_NVWEBON) { + if (GlobalConfig.OptionsBits & OPT_NVWEBON) { if ( loaderEntry->macOSVersion >= MacOsVersion("10.12"_XS8) ) { gSettings.SystemParameters.NvidiaWeb = TRUE; } else { @@ -120,7 +120,7 @@ void DecodeOptions(REFIT_MENU_ITEM_BOOTNUM *Entry) Entry->LoadOptions.AddID(ArgOptional[INX_NVWEBON]); } } - if ((gSettings.OptionsBits & OPT_NVWEBON) == 0) { + if ((GlobalConfig.OptionsBits & OPT_NVWEBON) == 0) { if ( loaderEntry->macOSVersion >= MacOsVersion("10.12"_XS8)) { gSettings.SystemParameters.NvidiaWeb = FALSE; } else { diff --git a/rEFIt_UEFI/include/Languages.h b/rEFIt_UEFI/include/Languages.h index 7a944477d..f8fb43f95 100644 --- a/rEFIt_UEFI/include/Languages.h +++ b/rEFIt_UEFI/include/Languages.h @@ -29,7 +29,7 @@ typedef enum { chinese, //cn romanian //ro //something else? add, please -} LANGUAGES; +} LanguageCode; #endif /* Languages_h */ diff --git a/rEFIt_UEFI/libeg/text.cpp b/rEFIt_UEFI/libeg/text.cpp index 4fcba302a..173df114a 100644 --- a/rEFIt_UEFI/libeg/text.cpp +++ b/rEFIt_UEFI/libeg/text.cpp @@ -94,7 +94,7 @@ void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols) EFI_GRAPHICS_OUTPUT_BLT_PIXEL *PixelPtr; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FontPtr; EFI_GRAPHICS_OUTPUT_BLT_PIXEL FirstPixel; - BOOLEAN isKorean = (gSettings.GUI.Language == korean); + BOOLEAN isKorean = (gSettings.GUI.languageCode == korean); XStringW fontFilePath; const XStringW& commonFontDir = L"font"_XSW; @@ -108,7 +108,7 @@ void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols) CharWidth = 22; //standard for korean } else { MsgLog("...using english\n"); - gSettings.GUI.Language = english; + gSettings.GUI.languageCode = english; } } @@ -308,7 +308,7 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr, for (UINTN i = 0; i < TextLength && c0 != 0; i++) { UINT16 c = Text.wc_str()[i]; //including UTF8 -> UTF16 conversion DBG("initial char to render 0x%hx\n", c); //good - if (gSettings.GUI.Language != korean) { //russian Codepage = 0x410 + if (gSettings.GUI.languageCode != korean) { //russian Codepage = 0x410 if (c >= 0x410 && c < 0x450) { //we have russian raster fonts with chars at 0xC0 c -= 0x350; diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index b990e6496..1cc32f850 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -386,7 +386,7 @@ void DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches) return; } DBG("Kernel and Kext Patches at %llx:\n", (uintptr_t)Patches); - DBG("\tAllowed: %c\n", gSettings.KextPatchesAllowed ? 'y' : 'n'); + DBG("\tAllowed: %c\n", GlobalConfig.KextPatchesAllowed ? 'y' : 'n'); DBG("\tDebug: %c\n", Patches->KPDebug ? 'y' : 'n'); // DBG("\tKernelCpu: %c\n", Patches->KPKernelCpu ? 'y' : 'n'); DBG("\tKernelLapic: %c\n", Patches->KPKernelLapic ? 'y' : 'n'); @@ -421,7 +421,7 @@ void DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches) #endif void LOADER_ENTRY::FilterKextPatches() { - if ( gSettings.KextPatchesAllowed && KernelAndKextPatches.KextPatches.size() > 0 ) { + if ( GlobalConfig.KextPatchesAllowed && KernelAndKextPatches.KextPatches.size() > 0 ) { DBG("Filtering KextPatches:\n"); for (size_t i = 0; i < KernelAndKextPatches.KextPatches.size(); i++) { DBG(" - [%02zu]: %s :: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]", @@ -452,7 +452,7 @@ void LOADER_ENTRY::FilterKextPatches() void LOADER_ENTRY::FilterKernelPatches() { - if ( gSettings.KernelPatchesAllowed && KernelAndKextPatches.KernelPatches.notEmpty() ) { + if ( GlobalConfig.KernelPatchesAllowed && KernelAndKextPatches.KernelPatches.notEmpty() ) { DBG("Filtering KernelPatches:\n"); for (size_t i = 0; i < KernelAndKextPatches.KernelPatches.size(); ++i) { DBG(" - [%02zu]: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]", @@ -566,9 +566,9 @@ void CheckEmptyFB() (gSettings.Graphics.IgPlatform == 0x59120003) || (gSettings.Graphics.IgPlatform == 0x3E910003); if (EmptyFB) { - gPlatformFeature |= PT_FEATURE_HAS_HEADLESS_GPU; + gSettings.Smbios.gPlatformFeature |= PT_FEATURE_HAS_HEADLESS_GPU; } else { - gPlatformFeature &= ~PT_FEATURE_HAS_HEADLESS_GPU; + gSettings.Smbios.gPlatformFeature &= ~PT_FEATURE_HAS_HEADLESS_GPU; } } @@ -2376,15 +2376,15 @@ void SetVariablesFromNvram() // OEMPath.takeValueFrom("EFI\\CLOVER"); // if ( ConfName.isEmpty() ) { // DBG("set OEMPath (ConfName == NULL): %ls\n", OEMPath.wc_str()); -// } else if ( nLanCards > 0 && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s--%02X-%02X-%02X-%02X-%02X-%02X", gSettings.OEMProduct.c_str(), gLanMac[0][0], gLanMac[0][1], gLanMac[0][2], gLanMac[0][3], gLanMac[0][4], gLanMac[0][5]), ConfName)) { -// } else if ( nLanCards > 1 && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s--%02X-%02X-%02X-%02X-%02X-%02X", gSettings.OEMProduct.c_str(), gLanMac[1][0], gLanMac[1][1], gLanMac[1][2], gLanMac[1][3], gLanMac[1][4], gLanMac[1][5]), ConfName)) { -// } else if ( nLanCards > 2 && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s--%02X-%02X-%02X-%02X-%02X-%02X", gSettings.OEMProduct.c_str(), gLanMac[2][0], gLanMac[2][1], gLanMac[2][2], gLanMac[2][3], gLanMac[2][4], gLanMac[2][5]), ConfName)) { -// } else if ( nLanCards > 3 && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s--%02X-%02X-%02X-%02X-%02X-%02X", gSettings.OEMProduct.c_str(), gLanMac[3][0], gLanMac[3][1], gLanMac[3][2], gLanMac[3][3], gLanMac[3][4], gLanMac[3][5]), ConfName)) { -// } else if (!gFirmwareClover && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s\\UEFI", gSettings.OEMBoard.c_str()), ConfName)) { -// } else if (SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s", gSettings.OEMProduct.c_str()), ConfName)) { -// } else if (SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s-%d", gSettings.OEMProduct.c_str(), (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega))), ConfName)) { -// } else if (SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s", gSettings.OEMBoard.c_str()), ConfName)) { -// } else if (SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s-%d", gSettings.OEMBoard.c_str(), (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega))), ConfName) ) { +// } else if ( nLanCards > 0 && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s--%02X-%02X-%02X-%02X-%02X-%02X", GlobalConfig.OEMProductFromSmbios.c_str(), gLanMac[0][0], gLanMac[0][1], gLanMac[0][2], gLanMac[0][3], gLanMac[0][4], gLanMac[0][5]), ConfName)) { +// } else if ( nLanCards > 1 && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s--%02X-%02X-%02X-%02X-%02X-%02X", GlobalConfig.OEMProductFromSmbios.c_str(), gLanMac[1][0], gLanMac[1][1], gLanMac[1][2], gLanMac[1][3], gLanMac[1][4], gLanMac[1][5]), ConfName)) { +// } else if ( nLanCards > 2 && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s--%02X-%02X-%02X-%02X-%02X-%02X", GlobalConfig.OEMProductFromSmbios.c_str(), gLanMac[2][0], gLanMac[2][1], gLanMac[2][2], gLanMac[2][3], gLanMac[2][4], gLanMac[2][5]), ConfName)) { +// } else if ( nLanCards > 3 && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s--%02X-%02X-%02X-%02X-%02X-%02X", GlobalConfig.OEMProductFromSmbios.c_str(), gLanMac[3][0], gLanMac[3][1], gLanMac[3][2], gLanMac[3][3], gLanMac[3][4], gLanMac[3][5]), ConfName)) { +// } else if (!gFirmwareClover && SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s\\UEFI", GlobalConfig.OEMBoardFromSmbios.c_str()), ConfName)) { +// } else if (SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s", GlobalConfig.OEMProductFromSmbios.c_str()), ConfName)) { +// } else if (SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s-%d", GlobalConfig.OEMProductFromSmbios.c_str(), (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega))), ConfName)) { +// } else if (SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s", GlobalConfig.OEMBoardFromSmbios.c_str()), ConfName)) { +// } else if (SetOEMPathIfExists(&self.getSelfRootDir(), SWPrintf("EFI\\CLOVER\\OEM\\%s-%d", GlobalConfig.OEMBoardFromSmbios.c_str(), (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega))), ConfName) ) { // } else { // DBG("set OEMPath by default: %ls\n", OEMPath.wc_str()); // } @@ -2555,8 +2555,9 @@ GetListOfThemes () */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" -void afterGetUserSettings(const SETTINGS_DATA& gSettings) +void afterGetUserSettings(SETTINGS_DATA& gSettings) { +#pragma GCC diagnostic pop // Secure boot /* this parameter, which should be called SecureBootSetupMode, is ignored if : @@ -2678,19 +2679,19 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings) ThemeX.DarkEmbedded = gSettings.GUI.getDarkEmbedded(ThemeX.Daylight); - if ( gSettings.GUI.Language == english ) { + if ( gSettings.GUI.languageCode == english ) { GlobalConfig.Codepage = 0xC0; GlobalConfig.CodepageSize = 0; - } else if ( gSettings.GUI.Language == russian ) { + } else if ( gSettings.GUI.languageCode == russian ) { GlobalConfig.Codepage = 0x410; GlobalConfig.CodepageSize = 0x40; - } else if ( gSettings.GUI.Language == ukrainian ) { + } else if ( gSettings.GUI.languageCode == ukrainian ) { GlobalConfig.Codepage = 0x400; GlobalConfig.CodepageSize = 0x60; - } else if ( gSettings.GUI.Language == chinese ) { + } else if ( gSettings.GUI.languageCode == chinese ) { GlobalConfig.Codepage = 0x3400; GlobalConfig.CodepageSize = 0x19C0; - } else if ( gSettings.GUI.Language == korean ) { + } else if ( gSettings.GUI.languageCode == korean ) { GlobalConfig.Codepage = 0x1100; GlobalConfig.CodepageSize = 0x100; } @@ -2714,12 +2715,12 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings) } if ( GlobalConfig.RtROM.isEmpty() ) { EFI_GUID uuid; - StrToGuidLE(gSettings.SmUUID, &uuid); + StrToGuidLE(gSettings.Smbios.SmUUID, &uuid); GlobalConfig.RtROM.ncpy(&uuid.Data4[2], 6); } GlobalConfig.RtMLB = gSettings.RtVariables.RtMLBSetting; if ( GlobalConfig.RtMLB.isEmpty() ) { - GlobalConfig.RtMLB = gSettings.BoardSerialNumber; + GlobalConfig.RtMLB = gSettings.Smbios.BoardSerialNumber; } for (size_t i = 0; i < NGFX; i++) { @@ -2757,7 +2758,6 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings) //--------- } -#pragma GCC diagnostic pop // // main entry point @@ -2923,17 +2923,17 @@ RefitMain (IN EFI_HANDLE ImageHandle, //debugStartImageWithOC(); // ok BS_I - GetDefaultSettings(); // do this before PrepatchSmbios() because PrepatchSmbios() change gSettings.SmUUID. + GetDefaultSettings(); // do this before PrepatchSmbios() because PrepatchSmbios() change gSettings.Smbios.SmUUID. // TODO : there is a mixup between SmUUID read from the platform and the SmUUID set by the user. They should be read in 2 different vars. PrepatchSmbios(); //replace / with _ - gSettings.OEMProduct.replaceAll(U'/', U'_'); - gSettings.OEMBoard.replaceAll(U'/', U'_'); - DBG("Running on: '%s' with board '%s'\n", gSettings.OEMProduct.c_str(), gSettings.OEMBoard.c_str()); + GlobalConfig.OEMProductFromSmbios.replaceAll(U'/', U'_'); + GlobalConfig.OEMBoardFromSmbios.replaceAll(U'/', U'_'); + DBG("Running on: '%s' with board '%s'\n", GlobalConfig.OEMProductFromSmbios.c_str(), GlobalConfig.OEMBoardFromSmbios.c_str()); GetCPUProperties(); - GetDefaultCpuSettings(); //split from GetDefaultSettings() because it should be after GetCPUProperties() + GetDefaultCpuSettings(gSettings); //split from GetDefaultSettings() because it should be after GetCPUProperties() GetDevices(); // Do this BEFORE SetOEMPath(); // LoadOptions Parsing @@ -2947,7 +2947,7 @@ RefitMain (IN EFI_HANDLE ImageHandle, if (ConfName.isEmpty()) { gConfigDict[1] = NULL; } else { - selfOem.initialize(ConfName, gFirmwareClover, gSettings.OEMBoard, gSettings.OEMProduct, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega)), nLanCards, gLanMac); + selfOem.initialize(ConfName, gFirmwareClover, GlobalConfig.OEMBoardFromSmbios, GlobalConfig.OEMProductFromSmbios, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega)), nLanCards, gLanMac); Status = LoadUserSettings(ConfName, &gConfigDict[1]); DBG("%ls\\%ls.plist %ls loaded with name from LoadOptions: %s\n", selfOem.getConfigDirFullPath().wc_str(), ConfName.wc_str(), EFI_ERROR(Status) ? L" not" : L"", efiStrError(Status)); if (EFI_ERROR(Status)) { @@ -2965,16 +2965,16 @@ RefitMain (IN EFI_HANDLE ImageHandle, } } if (!gConfigDict[1] || UniteConfigs) { - selfOem.initialize("config"_XS8, gFirmwareClover, gSettings.OEMBoard, gSettings.OEMProduct, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega)), nLanCards, gLanMac); + selfOem.initialize("config"_XS8, gFirmwareClover, GlobalConfig.OEMBoardFromSmbios, GlobalConfig.OEMProductFromSmbios, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega)), nLanCards, gLanMac); // selfOem.unInitialize(); -// selfOem.initialize("config"_XS8, gFirmwareClover, gSettings.OEMBoard, gSettings.OEMProduct, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega)), nLanCards, gLanMac); +// selfOem.initialize("config"_XS8, gFirmwareClover, GlobalConfig.OEMBoardFromSmbios, GlobalConfig.OEMProductFromSmbios, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega)), nLanCards, gLanMac); Status = LoadUserSettings(L"config"_XSW, &gConfigDict[0]); DBG("%ls\\config.plist %ls loaded: %s\n", selfOem.getConfigDirFullPath().wc_str(), EFI_ERROR(Status) ? L" not" : L"", efiStrError(Status)); } - snwprintf(gSettings.ConfigName, 64, "%ls%ls%ls", - gConfigDict[0] ? L"config": L"", - (gConfigDict[0] && gConfigDict[1]) ? L" + ": L"", - !gConfigDict[1] ? L"": (ConfName.notEmpty() ? ConfName.wc_str() : L"Load Options")); +// GlobalConfig.ConfigName.SWPrintf("%ls%ls%ls", +// gConfigDict[0] ? L"config": L"", +// (gConfigDict[0] && gConfigDict[1]) ? L" + ": L"", +// !gConfigDict[1] ? L"": (ConfName.notEmpty() ? ConfName.wc_str() : L"Load Options")); //gSettings.MainConfigName.takeValueFrom(gSettings.ConfigName); gSettings.GUI.Mouse.PointerEnabled = TRUE; @@ -3146,8 +3146,8 @@ RefitMain (IN EFI_HANDLE ImageHandle, GuiEventsInitialize(); - if (!gSettings.EnabledCores) { - gSettings.EnabledCores = gCPUStructure.Cores; + if (!GlobalConfig.EnabledCores) { + GlobalConfig.EnabledCores = gCPUStructure.Cores; } GetMacAddress(); @@ -3245,7 +3245,7 @@ RefitMain (IN EFI_HANDLE ImageHandle, if (!EFI_ERROR(LoadUserSettings(L"smbios"_XSW, &smbiosTags)) && (smbiosTags != NULL)) { const TagDict* dictPointer = smbiosTags->dictPropertyForKey("SMBIOS"); if (dictPointer) { - ParseSMBIOSSettings(dictPointer); + ParseSMBIOSSettings(gSettings, dictPointer); } else { DBG("Invalid smbios.plist, not overriding config.plist!\n"); } @@ -3333,8 +3333,8 @@ RefitMain (IN EFI_HANDLE ImageHandle, XString8Array TmpArgs = Split(gSettings.Boot.BootArgs, " "); DBG("after NVRAM boot-args=%s\n", gSettings.Boot.BootArgs.c_str()); - gSettings.OptionsBits = EncodeOptions(TmpArgs); -// DBG("initial OptionsBits %X\n", gSettings.OptionsBits); + GlobalConfig.OptionsBits = EncodeOptions(TmpArgs); +// DBG("initial OptionsBits %X\n", GlobalConfig.OptionsBits); FillInputs(TRUE); // scan for loaders and tools, add then to the menu diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index 43398622a..3f542e5a4 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -148,7 +148,7 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = UNIString; //1 InputItems[InputItemsCount++].SValue.takeValueFrom(gSettings.ACPI.DSDT.DsdtName); // 1-> 2 InputItems[InputItemsCount].ItemType = UNIString; //2 - InputItems[InputItemsCount++].SValue.takeValueFrom(gSettings.BlockKexts); + InputItems[InputItemsCount++].SValue = GlobalConfig.BlockKexts; InputItems[InputItemsCount].ItemType = RadioSwitch; //3 - Themes chooser InputItems[InputItemsCount++].IValue = 3; @@ -180,7 +180,7 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = BoolValue; //16 InputItems[InputItemsCount++].BValue = gSettings.Graphics.PatchVBios; InputItems[InputItemsCount].ItemType = Decimal; //17 - InputItems[InputItemsCount++].SValue.SWPrintf("0x%llX", gPlatformFeature); + InputItems[InputItemsCount++].SValue.SWPrintf("0x%llX", gSettings.Smbios.gPlatformFeature); InputItems[InputItemsCount].ItemType = Hex; //18 InputItems[InputItemsCount++].SValue.SWPrintf("0x%hX", gSettings.SystemParameters.BacklightLevel); InputItems[InputItemsCount].ItemType = Decimal; //19 @@ -247,7 +247,7 @@ void FillInputs(BOOLEAN New) InputItemsCount = 44; InputItems[InputItemsCount].ItemType = BoolValue; //44 - InputItems[InputItemsCount++].BValue = gSettings.KextPatchesAllowed; + InputItems[InputItemsCount++].BValue = GlobalConfig.KextPatchesAllowed; InputItems[InputItemsCount].ItemType = BoolValue; //45 InputItems[InputItemsCount++].BValue = gSettings.KernelAndKextPatches.EightApple; InputItems[InputItemsCount].ItemType = BoolValue; //46 @@ -294,10 +294,10 @@ void FillInputs(BOOLEAN New) // end of change InputItems[InputItemsCount].ItemType = Hex; //62 - InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gFwFeatures); + InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Smbios.gFwFeatures); InputItems[InputItemsCount].ItemType = Hex; //63 - InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gFwFeaturesMask); + InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Smbios.gFwFeaturesMask); // Debug for KernelAndKextPatches InputItems[InputItemsCount].ItemType = BoolValue; //64 @@ -314,9 +314,9 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = CheckBit; //67 InputItems[InputItemsCount++].IValue = gSettings.ACPI.DSDT.FixDsdt; InputItems[InputItemsCount].ItemType = CheckBit; //68 - InputItems[InputItemsCount++].IValue = gSettings.OptionsBits; + InputItems[InputItemsCount++].IValue = GlobalConfig.OptionsBits; InputItems[InputItemsCount].ItemType = CheckBit; //69 - InputItems[InputItemsCount++].IValue = gSettings.FlagsBits; + InputItems[InputItemsCount++].IValue = GlobalConfig.FlagsBits; InputItems[InputItemsCount].ItemType = Decimal; //70 InputItems[InputItemsCount++].SValue.SWPrintf("%02lld", gSettings.GUI.Mouse.PointerSpeed); @@ -334,30 +334,30 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = Hex; //75 InputItems[InputItemsCount++].SValue.SWPrintf("0x%04hX", GlobalConfig.C3Latency); InputItems[InputItemsCount].ItemType = Decimal; //76 - InputItems[InputItemsCount++].SValue.SWPrintf("%02d", gSettings.EnabledCores); + InputItems[InputItemsCount++].SValue.SWPrintf("%02d", GlobalConfig.EnabledCores); InputItems[InputItemsCount].ItemType = Decimal; //77 InputItems[InputItemsCount++].SValue.SWPrintf("%02d", gSettings.CPU.SavingMode); InputItems[InputItemsCount].ItemType = ASString; //78 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.ProductName.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.Smbios.ProductName.c_str()); InputItems[InputItemsCount].ItemType = ASString; //79 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.VersionNr.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.Smbios.VersionNr.c_str()); InputItems[InputItemsCount].ItemType = ASString; //80 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.SerialNr.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.Smbios.SerialNr.c_str()); InputItems[InputItemsCount].ItemType = ASString; //81 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.BoardNumber.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.Smbios.BoardNumber.c_str()); InputItems[InputItemsCount].ItemType = ASString; //82 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.BoardSerialNumber.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.Smbios.BoardSerialNumber.c_str()); InputItems[InputItemsCount].ItemType = Decimal; //83 - InputItems[InputItemsCount++].SValue.SWPrintf("%d", gSettings.BoardType); + InputItems[InputItemsCount++].SValue.SWPrintf("%d", gSettings.Smbios.BoardType); InputItems[InputItemsCount].ItemType = ASString; //84 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.BoardVersion.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.Smbios.BoardVersion.c_str()); InputItems[InputItemsCount].ItemType = Decimal; //85 - InputItems[InputItemsCount++].SValue.SWPrintf("%d", gSettings.ChassisType); + InputItems[InputItemsCount++].SValue.SWPrintf("%d", gSettings.Smbios.ChassisType); InputItems[InputItemsCount].ItemType = ASString; //86 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.RomVersion.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", GlobalConfig.RomVersionUsed.c_str()); InputItems[InputItemsCount].ItemType = ASString; //87 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.ReleaseDate.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", GlobalConfig.ReleaseDateUsed.c_str()); InputItems[InputItemsCount].ItemType = BoolValue; //88 InputItems[InputItemsCount++].BValue = gSettings.ACPI.SSDT.DoubleFirstState; @@ -408,7 +408,7 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = BoolValue; //107 InputItems[InputItemsCount++].BValue = gSettings.Devices.NoDefaultProperties; InputItems[InputItemsCount].ItemType = BoolValue; //108 - InputItems[InputItemsCount++].BValue = gSettings.KernelPatchesAllowed; + InputItems[InputItemsCount++].BValue = GlobalConfig.KernelPatchesAllowed; InputItems[InputItemsCount].ItemType = Hex; //109 InputItems[InputItemsCount++].SValue.SWPrintf("%01X", gSettings.Graphics.DualLink); @@ -431,7 +431,7 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount++].IValue = 116; InputItems[InputItemsCount].ItemType = ASString; //117 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.EfiVersion.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", GlobalConfig.EfiVersionUsed.c_str()); InputItems[InputItemsCount].ItemType = ASString; //118 InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.RtVariables.BooterCfgStr.c_str()); @@ -485,7 +485,7 @@ void ApplyInputs(void) } i++; //2 if (InputItems[i].Valid) { - snwprintf(gSettings.BlockKexts, sizeof(gSettings.BlockKexts), "%ls", InputItems[i].SValue.wc_str()); + GlobalConfig.BlockKexts = InputItems[i].SValue; } i++; //3 if (InputItems[i].Valid) { @@ -556,8 +556,8 @@ void ApplyInputs(void) } i++; //17 if (InputItems[i].Valid) { - gPlatformFeature = (UINT64)StrHexToUint64(InputItems[i].SValue.wc_str()); - DBG("applied PlatformFeature=0x%llX\n", gPlatformFeature); + gSettings.Smbios.gPlatformFeature = (UINT64)StrHexToUint64(InputItems[i].SValue.wc_str()); + DBG("applied PlatformFeature=0x%llX\n", gSettings.Smbios.gPlatformFeature); } i++; //18 | Download-Fritz: There is no GUI element for BacklightLevel; please revise if (InputItems[i].Valid) { @@ -628,7 +628,7 @@ void ApplyInputs(void) i = 44; if (InputItems[i].Valid) { - gSettings.KextPatchesAllowed = InputItems[i].BValue; + GlobalConfig.KextPatchesAllowed = InputItems[i].BValue; GlobalConfig.gBootChanged = TRUE; } i++; //45 @@ -712,13 +712,13 @@ void ApplyInputs(void) } i++; //62 if (InputItems[i].Valid) { - gFwFeatures = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); - DBG("applied FirmwareFeatures=0x%X\n", gFwFeatures); + gSettings.Smbios.gFwFeatures = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); + DBG("applied FirmwareFeatures=0x%X\n", gSettings.Smbios.gFwFeatures); } i++; //63 if (InputItems[i].Valid) { - gFwFeaturesMask = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); - DBG("applied FirmwareFeaturesMask=0x%X\n", gFwFeaturesMask); + gSettings.Smbios.gFwFeaturesMask = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); + DBG("applied FirmwareFeaturesMask=0x%X\n", gSettings.Smbios.gFwFeaturesMask); } i++; //64 if (InputItems[i].Valid) { @@ -742,11 +742,11 @@ void ApplyInputs(void) } i++; //68 if (InputItems[i].Valid) { - gSettings.OptionsBits = InputItems[i].IValue; + GlobalConfig.OptionsBits = InputItems[i].IValue; } i++; //69 if (InputItems[i].Valid) { - gSettings.FlagsBits = InputItems[i].IValue; + GlobalConfig.FlagsBits = InputItems[i].IValue; } @@ -784,7 +784,7 @@ void ApplyInputs(void) i++; //76 if (InputItems[i].Valid) { - gSettings.EnabledCores = (UINT8)StrDecimalToUintn(InputItems[i].SValue.wc_str()); + GlobalConfig.EnabledCores = (UINT8)StrDecimalToUintn(InputItems[i].SValue.wc_str()); } i++; //77 if (InputItems[i].Valid) { @@ -793,50 +793,50 @@ void ApplyInputs(void) i++; //78 if (InputItems[i].Valid) { - gSettings.ProductName = InputItems[i].SValue; + gSettings.Smbios.ProductName = InputItems[i].SValue; // let's fill all other fields based on this ProductName // to serve as default - Model = GetModelFromString(gSettings.ProductName); + Model = GetModelFromString(gSettings.Smbios.ProductName); if (Model != MaxMachineType) { - SetDMISettingsForModel(Model, FALSE); + SetDMISettingsForModel(gSettings, Model, FALSE); } } i++; //79 if (InputItems[i].Valid) { - gSettings.VersionNr = InputItems[i].SValue; + gSettings.Smbios.VersionNr = InputItems[i].SValue; } i++; //80 if (InputItems[i].Valid) { - gSettings.SerialNr = InputItems[i].SValue; + gSettings.Smbios.SerialNr = InputItems[i].SValue; } i++; //81 if (InputItems[i].Valid) { - gSettings.BoardNumber = InputItems[i].SValue; + gSettings.Smbios.BoardNumber = InputItems[i].SValue; } i++; //82 if (InputItems[i].Valid) { - gSettings.BoardSerialNumber = InputItems[i].SValue; + gSettings.Smbios.BoardSerialNumber = InputItems[i].SValue; } i++; //83 if (InputItems[i].Valid) { - gSettings.BoardType = (UINT8)(StrDecimalToUintn(InputItems[i].SValue.wc_str()) & 0x0F); + gSettings.Smbios.BoardType = (UINT8)(StrDecimalToUintn(InputItems[i].SValue.wc_str()) & 0x0F); } i++; //84 if (InputItems[i].Valid) { - gSettings.BoardVersion = InputItems[i].SValue; + gSettings.Smbios.BoardVersion = InputItems[i].SValue; } i++; //85 if (InputItems[i].Valid) { - gSettings.ChassisType = (UINT8)(StrDecimalToUintn(InputItems[i].SValue.wc_str()) & 0x0F); + gSettings.Smbios.ChassisType = (UINT8)(StrDecimalToUintn(InputItems[i].SValue.wc_str()) & 0x0F); } i++; //86 if (InputItems[i].Valid) { - gSettings.RomVersion = InputItems[i].SValue; + GlobalConfig.RomVersionUsed = InputItems[i].SValue; } i++; //87 if (InputItems[i].Valid) { - gSettings.ReleaseDate = InputItems[i].SValue; + GlobalConfig.ReleaseDateUsed = InputItems[i].SValue; } i++; //88 @@ -858,7 +858,7 @@ void ApplyInputs(void) Status = GetUserSettings(dict, gSettings); if (gConfigDict[2]) gConfigDict[2]->FreeTag(); gConfigDict[2] = dict; - snwprintf(gSettings.ConfigName, 64, "%ls", ConfigsList[OldChosenConfig]); +// GlobalConfig.ConfigName.takeValueFrom(ConfigsList[OldChosenConfig]); } FillInputs(FALSE); NeedSave = FALSE; @@ -962,7 +962,7 @@ void ApplyInputs(void) i++; //108 if (InputItems[i].Valid) { - gSettings.KernelPatchesAllowed = InputItems[i].BValue; + GlobalConfig.KernelPatchesAllowed = InputItems[i].BValue; GlobalConfig.gBootChanged = TRUE; } @@ -1007,7 +1007,7 @@ void ApplyInputs(void) } i++; //117 if (InputItems[i].Valid) { - gSettings.EfiVersion = InputItems[i].SValue; + GlobalConfig.EfiVersionUsed = InputItems[i].SValue; } i++; //118 if (InputItems[i].Valid) { @@ -1139,7 +1139,7 @@ void HelpRefit(void) //else { // HelpMenu.TitleImage.setEmpty(); //} - switch (gSettings.GUI.Language) + switch (gSettings.GUI.languageCode) { case russian: HelpMenu.AddMenuInfo_f("ESC - Выход из подменю, обновление главного меню"); @@ -1999,8 +1999,8 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuSmbios() Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_SMBIOS, "SMBIOS->"_XS8); SubScreen->AddMenuInfoLine_f("%s", gCPUStructure.BrandString); - SubScreen->AddMenuInfoLine_f("%s", gSettings.OEMProduct.c_str()); - SubScreen->AddMenuInfoLine_f("with board %s", gSettings.OEMBoard.c_str()); + SubScreen->AddMenuInfoLine_f("%s", GlobalConfig.OEMProductFromSmbios.c_str()); + SubScreen->AddMenuInfoLine_f("with board %s", GlobalConfig.OEMBoardFromSmbios.c_str()); SubScreen->AddMenuItemInput(78, "Product Name:", TRUE); SubScreen->AddMenuItemInput(79, "Product Version:", TRUE);