diff --git a/Include/Library/VideoBiosPatchLib.h b/Include/Library/VideoBiosPatchLib.h index 557f2d16c..0637303b2 100644 --- a/Include/Library/VideoBiosPatchLib.h +++ b/Include/Library/VideoBiosPatchLib.h @@ -58,7 +58,7 @@ VideoBiosLock ( EFI_STATUS EFIAPI VideoBiosPatchBytes ( - IN VBIOS_PATCH_BYTES *FindAndReplace, + IN JCONST VBIOS_PATCH_BYTES *FindAndReplace, IN UINTN FindAndReplaceCount ); diff --git a/Library/VideoBiosPatchLib/VideoBiosPatchLib.c b/Library/VideoBiosPatchLib/VideoBiosPatchLib.c index 21ffd8ef0..5842e8c09 100644 --- a/Library/VideoBiosPatchLib/VideoBiosPatchLib.c +++ b/Library/VideoBiosPatchLib/VideoBiosPatchLib.c @@ -202,7 +202,7 @@ VideoBiosLock ( EFI_STATUS EFIAPI VideoBiosPatchBytes ( - IN VBIOS_PATCH_BYTES *FindAndReplace, + IN JCONST VBIOS_PATCH_BYTES *FindAndReplace, IN UINTN FindAndReplaceCount ) { diff --git a/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj b/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj index 3b10774ca..75fd53759 100644 --- a/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj +++ b/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj @@ -2386,6 +2386,12 @@ SUPPORTED_PLATFORMS = macosx; USE_HEADERMAP = NO; VALID_ARCHS = x86_64; + WARNING_CFLAGS = ( + "-Wno-c99-extensions", + "-Wno-gnu-zero-variadic-macro-arguments", + "-Wignored-qualifiers", + "-Wreorder", + ); }; name = Debug; }; @@ -2472,6 +2478,12 @@ SUPPORTED_PLATFORMS = macosx; USE_HEADERMAP = NO; VALID_ARCHS = x86_64; + WARNING_CFLAGS = ( + "-Wno-c99-extensions", + "-Wno-gnu-zero-variadic-macro-arguments", + "-Wignored-qualifiers", + "-Wreorder", + ); }; name = Release; }; diff --git a/Xcode/CloverX64TestNewParser/CloverX64TestNewParser.xcodeproj/project.pbxproj b/Xcode/CloverX64TestNewParser/CloverX64TestNewParser.xcodeproj/project.pbxproj index a9925eadb..00bc32602 100644 --- a/Xcode/CloverX64TestNewParser/CloverX64TestNewParser.xcodeproj/project.pbxproj +++ b/Xcode/CloverX64TestNewParser/CloverX64TestNewParser.xcodeproj/project.pbxproj @@ -16192,7 +16192,12 @@ OTHER_LDFLAGS = ""; SDKROOT = macosx; USE_HEADERMAP = NO; - WARNING_CFLAGS = "-Wno-c99-extensions"; + WARNING_CFLAGS = ( + "-Wno-c99-extensions", + "-Wno-gnu-zero-variadic-macro-arguments", + "-Wignored-qualifiers", + "-Wreorder", + ); }; name = Debug; }; @@ -16304,7 +16309,12 @@ OTHER_LDFLAGS = ""; SDKROOT = macosx; USE_HEADERMAP = NO; - WARNING_CFLAGS = "-Wno-c99-extensions"; + WARNING_CFLAGS = ( + "-Wno-c99-extensions", + "-Wno-gnu-zero-variadic-macro-arguments", + "-Wignored-qualifiers", + "-Wreorder", + ); }; name = Release; }; diff --git a/rEFIt_UEFI/Platform/DataHubCpu.cpp b/rEFIt_UEFI/Platform/DataHubCpu.cpp index 9b4423102..9a7fd1b28 100644 --- a/rEFIt_UEFI/Platform/DataHubCpu.cpp +++ b/rEFIt_UEFI/Platform/DataHubCpu.cpp @@ -184,11 +184,11 @@ OvrSetVariable( EFI_STATUS Status; UINTN i; - for (i = 0; i < BlockRtVariableArray.size(); i++) { - if (!CompareGuid(&BlockRtVariableArray[i].VarGuid, VendorGuid)) { + for (i = 0; i < gSettings.RtVariables.BlockRtVariableArray.size(); i++) { + if (!CompareGuid(&gSettings.RtVariables.BlockRtVariableArray[i].VarGuid, VendorGuid)) { continue; } - if (BlockRtVariableArray[i].Name.isEmpty() || BlockRtVariableArray[i].Name[0] == L'*' || BlockRtVariableArray[i].Name == LStringW(VariableName) ) { + if (gSettings.RtVariables.BlockRtVariableArray[i].Name.isEmpty() || gSettings.RtVariables.BlockRtVariableArray[i].Name[0] == L'*' || gSettings.RtVariables.BlockRtVariableArray[i].Name == LStringW(VariableName) ) { return EFI_SUCCESS; } } @@ -230,7 +230,7 @@ SetVariablesForOSX(LOADER_ENTRY *Entry) // // firmware Variables // - if (BlockRtVariableArray.size() > 0) { + if (gSettings.RtVariables.BlockRtVariableArray.size() > 0) { OvrRuntimeServices(gRT); } @@ -243,23 +243,23 @@ SetVariablesForOSX(LOADER_ENTRY *Entry) Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; - if (gSettings.RtMLB.notEmpty()) { - if ( gSettings.RtMLB.length() != 17 ) { + if (GlobalConfig.RtMLB.notEmpty()) { + if ( GlobalConfig.RtMLB.length() != 17 ) { DBG("** Warning: Your MLB is not suitable for iMessage(must be 17 chars long) !\n"); } SetNvramXString8(L"MLB", &gEfiAppleNvramGuid, Attributes, - gSettings.RtMLB); + GlobalConfig.RtMLB); } - if (gSettings.RtROM.notEmpty()) { + if (GlobalConfig.RtROM.notEmpty()) { SetNvramVariable(L"ROM", &gEfiAppleNvramGuid, Attributes, - gSettings.RtROM.size(), - gSettings.RtROM.vdata()); + GlobalConfig.RtROM.size(), + GlobalConfig.RtROM.vdata()); } SetNvramVariable(L"FirmwareFeatures", @@ -375,16 +375,16 @@ SetVariablesForOSX(LOADER_ENTRY *Entry) } // Hack for recovery by Asgorath - if (gSettings.CsrActiveConfig != 0xFFFF) { - SetNvramVariable(L"csr-active-config", &gEfiAppleBootGuid, Attributes, sizeof(gSettings.CsrActiveConfig), &gSettings.CsrActiveConfig); + if (gSettings.RtVariables.CsrActiveConfig != 0xFFFF) { + SetNvramVariable(L"csr-active-config", &gEfiAppleBootGuid, Attributes, sizeof(gSettings.RtVariables.CsrActiveConfig), &gSettings.RtVariables.CsrActiveConfig); } /* - if (gSettings.BooterConfig != 0) { - SetNvramVariable(L"bootercfg", &gEfiAppleBootGuid, Attributes, sizeof(gSettings.BooterConfig), &gSettings.BooterConfig); + if (gSettings.RtVariables.BooterConfig != 0) { + SetNvramVariable(L"bootercfg", &gEfiAppleBootGuid, Attributes, sizeof(gSettings.RtVariables.BooterConfig), &gSettings.RtVariables.BooterConfig); } */ - if ( gSettings.BooterCfgStr.notEmpty() ) { - SetNvramXString8(L"bootercfg", &gEfiAppleBootGuid, Attributes, gSettings.BooterCfgStr); + if ( gSettings.RtVariables.BooterCfgStr.notEmpty() ) { + SetNvramXString8(L"bootercfg", &gEfiAppleBootGuid, Attributes, gSettings.RtVariables.BooterCfgStr); } else { DeleteNvramVariable(L"bootercfg", &gEfiAppleBootGuid); } diff --git a/rEFIt_UEFI/Platform/Edid.cpp b/rEFIt_UEFI/Platform/Edid.cpp index a037bbbde..19d599da3 100644 --- a/rEFIt_UEFI/Platform/Edid.cpp +++ b/rEFIt_UEFI/Platform/Edid.cpp @@ -24,7 +24,7 @@ EFI_STATUS EFIAPI GetEdidImpl( IN OUT UINT8 **Edid ) { - *Edid = gSettings.CustomEDID; + *Edid = gSettings.Graphics.EDID.CustomEDID.data(); *EdidSize = 128; *Attributes = 0; if (*Edid) { @@ -91,14 +91,14 @@ void DebugDumpEDID(CONST CHAR8 *Message, INTN N) DBG("%03lld |", i); for (j=0; j<10; j++) { if (i+j > N-1) break; - DBG(" %02hhX", gSettings.CustomEDID[i+j]); + DBG(" %02hhX", gSettings.Graphics.EDID.CustomEDID[i+j]); } DBG("\n"); } } //Used at OS start -// if EFI_SUCCESS then result in gSettings.CustomEDID != NULL +// if EFI_SUCCESS then result in gSettings.Graphics.EDID.CustomEDID != NULL // first priority is CustomEDID // second is UEFI EDID from EdidDiscoveredProtocol EFI_STATUS GetEdidDiscovered(void) @@ -108,8 +108,8 @@ EFI_STATUS GetEdidDiscovered(void) UINT8 NewChecksum; //gEDID = NULL; - if (gSettings.CustomEDID) { - N = gSettings.CustomEDIDsize; + if (gSettings.Graphics.EDID.CustomEDID.notEmpty()) { + N = gSettings.Graphics.EDID.CustomEDID.size(); DebugDumpEDID("--- Custom EDID Table", N); } else { Status = gBS->LocateProtocol (&gEfiEdidDiscoveredProtocolGuid, NULL, (void **)&EdidDiscovered); @@ -121,47 +121,47 @@ EFI_STATUS GetEdidDiscovered(void) if (N == 0) { return EFI_NOT_FOUND; } - gSettings.CustomEDID = (__typeof__(gSettings.CustomEDID))AllocateAlignedPages(EFI_SIZE_TO_PAGES(N), 128); - CopyMem(gSettings.CustomEDID, EdidDiscovered->Edid, N); +// gSettings.Graphics.EDID.CustomEDID = (__typeof__(gSettings.Graphics.EDID.CustomEDID))AllocateAlignedPages(EFI_SIZE_TO_PAGES(N), 128); + gSettings.Graphics.EDID.CustomEDID.ncpy(EdidDiscovered->Edid, N); DebugDumpEDID("--- Discovered EDID Table", N); } } - if (gSettings.CustomEDID) { + if (gSettings.Graphics.EDID.CustomEDID.notEmpty()) { // begin patching result - if (gSettings.VendorEDID) { - DBG(" VendorID = 0x%04hx changed to 0x%04hx\n", ((UINT16*)gSettings.CustomEDID)[4], gSettings.VendorEDID); - ((UINT16*)gSettings.CustomEDID)[4] = gSettings.VendorEDID; + if (gSettings.Graphics.EDID.VendorEDID) { + DBG(" VendorID = 0x%04hx changed to 0x%04hx\n", ((UINT16*)gSettings.Graphics.EDID.CustomEDID.data())[4], gSettings.Graphics.EDID.VendorEDID); + ((UINT16*)gSettings.Graphics.EDID.CustomEDID.data())[4] = gSettings.Graphics.EDID.VendorEDID; } - if (gSettings.ProductEDID) { - DBG(" ProductID = 0x%04hx changed to 0x%04hx\n", ((UINT16*)gSettings.CustomEDID)[5], gSettings.ProductEDID); - ((UINT16*)gSettings.CustomEDID)[5] = gSettings.ProductEDID; + if (gSettings.Graphics.EDID.ProductEDID) { + DBG(" ProductID = 0x%04hx changed to 0x%04hx\n", ((UINT16*)gSettings.Graphics.EDID.CustomEDID.data())[5], gSettings.Graphics.EDID.ProductEDID); + ((UINT16*)gSettings.Graphics.EDID.CustomEDID.data())[5] = gSettings.Graphics.EDID.ProductEDID; } - if (gSettings.EdidFixHorizontalSyncPulseWidth) { - DBG(" HorizontalSyncPulseWidth = 0x%02hhx changed to 0x%02hx\n", ((UINT8*)gSettings.CustomEDID)[63], gSettings.EdidFixHorizontalSyncPulseWidth); + if (gSettings.Graphics.EDID.EdidFixHorizontalSyncPulseWidth) { + DBG(" HorizontalSyncPulseWidth = 0x%02hhx changed to 0x%02hx\n", ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[63], gSettings.Graphics.EDID.EdidFixHorizontalSyncPulseWidth); UINT8 LsBits, MsBits; - LsBits = gSettings.EdidFixHorizontalSyncPulseWidth & 0xff; - MsBits = (gSettings.EdidFixHorizontalSyncPulseWidth >> 8) & 0x03; - ((UINT8*)gSettings.CustomEDID)[63] = LsBits; - LsBits = ((UINT8*)gSettings.CustomEDID)[65] & ~0x30; - ((UINT8*)gSettings.CustomEDID)[65] = LsBits | (MsBits << 4); + LsBits = gSettings.Graphics.EDID.EdidFixHorizontalSyncPulseWidth & 0xff; + MsBits = (gSettings.Graphics.EDID.EdidFixHorizontalSyncPulseWidth >> 8) & 0x03; + ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[63] = LsBits; + LsBits = ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[65] & ~0x30; + ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[65] = LsBits | (MsBits << 4); } - if (gSettings.EdidFixVideoInputSignal) { - DBG(" VideoInputSignal = 0x%02hhx changed to 0x%02hhx\n", ((UINT8*)gSettings.CustomEDID)[20], gSettings.EdidFixVideoInputSignal); - ((UINT8*)gSettings.CustomEDID)[20] = gSettings.EdidFixVideoInputSignal; + if (gSettings.Graphics.EDID.EdidFixVideoInputSignal) { + DBG(" VideoInputSignal = 0x%02hhx changed to 0x%02hhx\n", ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[20], gSettings.Graphics.EDID.EdidFixVideoInputSignal); + ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[20] = gSettings.Graphics.EDID.EdidFixVideoInputSignal; } - NewChecksum = (UINT8)(256 - Checksum8(gSettings.CustomEDID, 127)); - if ((gSettings.VendorEDID) || (gSettings.ProductEDID) || (gSettings.EdidFixHorizontalSyncPulseWidth) || (gSettings.EdidFixVideoInputSignal)) { - ((UINT8*)gSettings.CustomEDID)[127] = NewChecksum; + NewChecksum = (UINT8)(256 - Checksum8(gSettings.Graphics.EDID.CustomEDID.data(), 127)); + if ((gSettings.Graphics.EDID.VendorEDID) || (gSettings.Graphics.EDID.ProductEDID) || (gSettings.Graphics.EDID.EdidFixHorizontalSyncPulseWidth) || (gSettings.Graphics.EDID.EdidFixVideoInputSignal)) { + ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[127] = NewChecksum; DebugDumpEDID("--- Patched EDID Table", N); - } else if (((UINT8*)gSettings.CustomEDID)[127] != NewChecksum) { - DBG(" Fix wrong checksum = 0x%02hhx changed to ", ((UINT8*)gSettings.CustomEDID)[127]); - ((UINT8*)gSettings.CustomEDID)[127] = NewChecksum; - DBG("0x%02hhx\n", ((UINT8*)gSettings.CustomEDID)[127]); + } else if (((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[127] != NewChecksum) { + DBG(" Fix wrong checksum = 0x%02hhx changed to ", ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[127]); + ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[127] = NewChecksum; + DBG("0x%02hhx\n", ((UINT8*)gSettings.Graphics.EDID.CustomEDID.data())[127]); DebugDumpEDID("--- Patched EDID Table", N); } } diff --git a/rEFIt_UEFI/Platform/FixBiosDsdt.cpp b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp index e848f14a0..8ec378d29 100755 --- a/rEFIt_UEFI/Platform/FixBiosDsdt.cpp +++ b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp @@ -2634,9 +2634,9 @@ UINT32 FIXDisplay (UINT8 *dsdt, UINT32 len, INT32 VCard) ( !NeedHDMI && ( - ((DisplayVendor[VCard] == 0x8086) && (gSettings.InjectIntel || !gSettings.FakeIntel)) || - ((DisplayVendor[VCard] == 0x10DE) && (gSettings.InjectNVidia || !gSettings.FakeNVidia)) || - ((DisplayVendor[VCard] == 0x1002) && (gSettings.InjectATI || !gSettings.FakeATI)) + ((DisplayVendor[VCard] == 0x8086) && (gSettings.Graphics.InjectAsDict.InjectIntel || !gSettings.FakeIntel)) || + ((DisplayVendor[VCard] == 0x10DE) && (gSettings.Graphics.InjectAsDict.InjectNVidia || !gSettings.FakeNVidia)) || + ((DisplayVendor[VCard] == 0x1002) && (gSettings.Graphics.InjectAsDict.InjectATI || !gSettings.FakeATI)) ) ) ) { diff --git a/rEFIt_UEFI/Platform/Net.cpp b/rEFIt_UEFI/Platform/Net.cpp index 63883ca2f..caf0af7f8 100644 --- a/rEFIt_UEFI/Platform/Net.cpp +++ b/rEFIt_UEFI/Platform/Net.cpp @@ -3,6 +3,7 @@ #include // Only use angled for Platform, else, xcode project won't compile #include "../refit/lib.h" #include "Net.h" +#include "../Platform/Settings.h" #ifndef DEBUG_MAC #ifndef DEBUG_ALL @@ -25,8 +26,6 @@ UINT8 gLanMac[4][6]; // their MAC addresses UINTN nLanPaths; // number of UEFI LAN -extern BOOLEAN GetLegacyLanAddress; - //Marvell Yukon #define B2_MAC_1 0x0100 /* NA reg MAC Address 1 */ #define B2_MAC_2 0x0108 /* NA reg MAC Address 2 */ @@ -152,7 +151,7 @@ GetMacAddress() if (HandleBuffer != NULL) { FreePool(HandleBuffer); } - if (!Found && GetLegacyLanAddress) { + if (!Found && gSettings.RtVariables.GetLegacyLanAddress()) { //// // // Legacy boot. Get MAC-address from hardwaredirectly diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index f967de7b4..39beea7b9 100755 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -92,7 +92,6 @@ CHAR16 *ConfigsList[20]; UINTN DsdtsNum = 0; CHAR16 *DsdtsList[20]; XObjArray AudioList; -XObjArray BlockRtVariableArray; // firmware BOOLEAN gFirmwareClover = FALSE; @@ -101,7 +100,6 @@ UINT16 gBacklightLevel; //BOOLEAN defDSM; //UINT16 dropDSM; -BOOLEAN GetLegacyLanAddress; BOOLEAN ResumeFromCoreStorage; //BOOLEAN gRemapSmBiosIsRequire; @@ -2406,44 +2404,46 @@ GetEDIDSettings(const TagDict* DictPointer, SETTINGS_DATA& gSettings) Dict = DictPointer->dictPropertyForKey("EDID"); if (Dict != NULL) { Prop = Dict->propertyForKey("Inject"); - gSettings.InjectEDID = IsPropertyNotNullAndTrue(Prop); // default = false! + gSettings.Graphics.EDID.InjectEDID = IsPropertyNotNullAndTrue(Prop); // default = false! - if (gSettings.InjectEDID){ + if (gSettings.Graphics.EDID.InjectEDID){ //DBG("Inject EDID\n"); Prop = Dict->propertyForKey("Custom"); if (Prop != NULL) { - gSettings.CustomEDID = GetDataSetting(Dict, "Custom", &j); + UINT8* Data = GetDataSetting(Dict, "Custom", &j); + gSettings.Graphics.EDID.CustomEDID.stealValueFrom(Data, j); if ((j % 128) != 0) { DBG(" Custom EDID has wrong length=%llu\n", j); + gSettings.Graphics.EDID.CustomEDID.setEmpty(); } else { DBG(" Custom EDID is ok\n"); - gSettings.CustomEDIDsize = (UINT16)j; +// gSettings.CustomEDIDsize = (UINT16)j; // InitializeEdidOverride(); } } Prop = Dict->propertyForKey("VendorID"); if (Prop) { - gSettings.VendorEDID = (UINT16)GetPropertyAsInteger(Prop, gSettings.VendorEDID); - //DBG(" VendorID = 0x%04lx\n", gSettings.VendorEDID); + gSettings.Graphics.EDID.VendorEDID = (UINT16)GetPropertyAsInteger(Prop, gSettings.Graphics.EDID.VendorEDID); + //DBG(" VendorID = 0x%04lx\n", gSettings.Graphics.EDID.VendorEDID); } Prop = Dict->propertyForKey("ProductID"); if (Prop) { - gSettings.ProductEDID = (UINT16)GetPropertyAsInteger(Prop, gSettings.ProductEDID); - //DBG(" ProductID = 0x%04lx\n", gSettings.ProductEDID); + gSettings.Graphics.EDID.ProductEDID = (UINT16)GetPropertyAsInteger(Prop, gSettings.Graphics.EDID.ProductEDID); + //DBG(" ProductID = 0x%04lx\n", gSettings.Graphics.EDID.ProductEDID); } Prop = Dict->propertyForKey("HorizontalSyncPulseWidth"); if (Prop) { - gSettings.EdidFixHorizontalSyncPulseWidth = (UINT16)GetPropertyAsInteger(Prop, gSettings.EdidFixHorizontalSyncPulseWidth); - //DBG(" EdidFixHorizontalSyncPulseWidth = 0x%02lx\n", gSettings.EdidFixHorizontalSyncPulseWidth); + gSettings.Graphics.EDID.EdidFixHorizontalSyncPulseWidth = (UINT16)GetPropertyAsInteger(Prop, gSettings.Graphics.EDID.EdidFixHorizontalSyncPulseWidth); + //DBG(" EdidFixHorizontalSyncPulseWidth = 0x%02lx\n", gSettings.Graphics.EDID.EdidFixHorizontalSyncPulseWidth); } Prop = Dict->propertyForKey("VideoInputSignal"); if (Prop) { - gSettings.EdidFixVideoInputSignal = (UINT8)GetPropertyAsInteger(Prop, gSettings.EdidFixVideoInputSignal); - //DBG(" EdidFixVideoInputSignal = 0x%02lx\n", gSettings.EdidFixVideoInputSignal); + gSettings.Graphics.EDID.EdidFixVideoInputSignal = (UINT8)GetPropertyAsInteger(Prop, gSettings.Graphics.EDID.EdidFixVideoInputSignal); + //DBG(" EdidFixVideoInputSignal = 0x%02lx\n", gSettings.Graphics.EDID.EdidFixVideoInputSignal); } } else { //DBG("Not Inject EDID\n"); @@ -2479,10 +2479,10 @@ EFI_STATUS GetEarlyUserSettings ( // } // } - gSettings.KextPatchesAllowed = TRUE; + gSettings.KextPatchesAllowed = TRUE; // todo move to GlobalConfig gSettings.KernelAndKextPatches.KPAppleRTC = TRUE; gSettings.KernelAndKextPatches.KPDELLSMBIOS = FALSE; // default is false - gSettings.KernelPatchesAllowed = TRUE; + gSettings.KernelPatchesAllowed = TRUE; // todo move to GlobalConfig if (CfgDict != NULL) { //DBG("Loading early settings\n"); @@ -3089,7 +3089,81 @@ EFI_STATUS GetEarlyUserSettings ( } } } + const TagDict* GraphicsDict = CfgDict->dictPropertyForKey("Graphics"); + if (GraphicsDict != NULL) { + const TagStruct* Prop = GraphicsDict->propertyForKey("PatchVBios"); + gSettings.Graphics.PatchVBios = IsPropertyNotNullAndTrue(Prop); + + gSettings.Graphics.PatchVBiosBytesNew.setEmpty(); + + const TagArray* Dict2 = GraphicsDict->arrayPropertyForKey("PatchVBiosBytes"); // array of dict + if (Dict2 != NULL) { + INTN Count = Dict2->arrayContent().size(); + if (Count > 0) { + UINTN FindSize = 0; + UINTN ReplaceSize = 0; + BOOLEAN Valid; + // alloc space for up to 16 entries +// gSettings.Graphics.PatchVBiosBytes = (__typeof__(gSettings.Graphics.PatchVBiosBytes))AllocateZeroPool(Count * sizeof(VBIOS_PATCH_BYTES)); + + // get all entries + for (INTN i = 0; i < Count; i++) { + const TagDict* dict3 = Dict2->dictElementAt(i, "Graphics/PatchVBiosBytes"_XS8); + Valid = TRUE; + // read entry + VBIOS_PATCH* VBiosPatchPtr = new VBIOS_PATCH; + VBIOS_PATCH& VBiosPatch = *VBiosPatchPtr; +// VBiosPatch = &gSettings.Graphics.PatchVBiosBytes[gSettings.Graphics.PatchVBiosBytesCount]; + UINT8* DataSetting = GetDataSetting (dict3, "Find", &FindSize); + VBiosPatch.Find.stealValueFrom(DataSetting, FindSize); + DataSetting = GetDataSetting (dict3, "Replace", &ReplaceSize); + VBiosPatch.Replace.stealValueFrom(DataSetting, ReplaceSize); + + if ( VBiosPatch.Find.size() == 0 ) { + Valid = FALSE; + DBG("PatchVBiosBytes[%lld]: missing Find data\n", i); + } + + if ( VBiosPatch.Replace.size() == 0 ) { + Valid = FALSE; + DBG("PatchVBiosBytes[%lld]: missing Replace data\n", i); + } + + if (VBiosPatch.Find.size() != VBiosPatch.Replace.size()) { + Valid = FALSE; + DBG("PatchVBiosBytes[%lld]: Find and Replace data are not the same size\n", i); + } + + if (Valid) { +// VBiosPatch->NumberOfBytes = FindSize; + // go to next entry +// ++gSettings.Graphics.PatchVBiosBytesCount; + gSettings.Graphics.PatchVBiosBytesNew.AddReference(VBiosPatchPtr, true); + } else { + // error - release mem + delete VBiosPatchPtr; +// if (VBiosPatch->Find != NULL) { +// FreePool(VBiosPatch->Find); +// VBiosPatch->Find = NULL; +// } +// if (VBiosPatch->Replace != NULL) { +// FreePool(VBiosPatch->Replace); +// VBiosPatch->Replace = NULL; +// } + } + } + +// if (gSettings.Graphics.PatchVBiosBytesCount == 0) { +// FreePool(gSettings.Graphics.PatchVBiosBytes); +// gSettings.Graphics.PatchVBiosBytes = NULL; +// } + } + } + + GetEDIDSettings(GraphicsDict, gSettings); + } + //done until here @@ -3097,76 +3171,6 @@ EFI_STATUS GetEarlyUserSettings ( - const TagDict* GraphicsDict = CfgDict->dictPropertyForKey("Graphics"); - if (GraphicsDict != NULL) { - - const TagStruct* Prop = GraphicsDict->propertyForKey("PatchVBios"); - gSettings.PatchVBios = IsPropertyNotNullAndTrue(Prop); - - gSettings.PatchVBiosBytesCount = 0; - - const TagArray* Dict2 = GraphicsDict->arrayPropertyForKey("PatchVBiosBytes"); // array of dict - if (Dict2 != NULL) { - INTN Count = Dict2->arrayContent().size(); - if (Count > 0) { - VBIOS_PATCH_BYTES *VBiosPatch; - UINTN FindSize = 0; - UINTN ReplaceSize = 0; - BOOLEAN Valid; - // alloc space for up to 16 entries - gSettings.PatchVBiosBytes = (__typeof__(gSettings.PatchVBiosBytes))AllocateZeroPool(Count * sizeof(VBIOS_PATCH_BYTES)); - - // get all entries - for (INTN i = 0; i < Count; i++) { - const TagDict* dict3 = Dict2->dictElementAt(i, "Graphics/PatchVBiosBytes"_XS8); - Valid = TRUE; - // read entry - VBiosPatch = &gSettings.PatchVBiosBytes[gSettings.PatchVBiosBytesCount]; - VBiosPatch->Find = GetDataSetting (dict3, "Find", &FindSize); - VBiosPatch->Replace = GetDataSetting (dict3, "Replace", &ReplaceSize); - - if (VBiosPatch->Find == NULL || FindSize == 0) { - Valid = FALSE; - DBG("PatchVBiosBytes[%lld]: missing Find data\n", i); - } - - if (VBiosPatch->Replace == NULL || ReplaceSize == 0) { - Valid = FALSE; - DBG("PatchVBiosBytes[%lld]: missing Replace data\n", i); - } - - if (FindSize != ReplaceSize) { - Valid = FALSE; - DBG("PatchVBiosBytes[%lld]: Find and Replace data are not the same size\n", i); - } - - if (Valid) { - VBiosPatch->NumberOfBytes = FindSize; - // go to next entry - ++gSettings.PatchVBiosBytesCount; - } else { - // error - release mem - if (VBiosPatch->Find != NULL) { - FreePool(VBiosPatch->Find); - VBiosPatch->Find = NULL; - } - - if (VBiosPatch->Replace != NULL) { - FreePool(VBiosPatch->Replace); - VBiosPatch->Replace = NULL; - } - } - } - - if (gSettings.PatchVBiosBytesCount == 0) { - FreePool(gSettings.PatchVBiosBytes); - gSettings.PatchVBiosBytes = NULL; - } - } - } - - GetEDIDSettings(GraphicsDict, gSettings); - } const TagArray* DisableDriversArray = CfgDict->arrayPropertyForKey("DisableDrivers"); // array of string if (DisableDriversArray != NULL) { @@ -3192,7 +3196,7 @@ EFI_STATUS GetEarlyUserSettings ( if (Dict2 != NULL) { // HDA const TagStruct* Prop = Dict2->propertyForKey("ResetHDA"); - gSettings.ResetHDA = IsPropertyNotNullAndTrue(Prop); + gSettings.Devices.Audio.ResetHDA = IsPropertyNotNullAndTrue(Prop); } } @@ -3205,7 +3209,7 @@ EFI_STATUS GetEarlyUserSettings ( }else{ if ((Prop->getString()->stringValue().equalIC("UseMacAddr0")) || (Prop->getString()->stringValue().equalIC("UseMacAddr1"))) { - GetLegacyLanAddress = TRUE; +// gSettings.RtVariables.GetLegacyLanAddress = TRUE; } } } @@ -4422,62 +4426,63 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) const TagStruct* Prop = GraphicsDict->propertyForKey("Inject"); if (Prop != NULL) { if (IsPropertyNotNullAndTrue(Prop)) { - gSettings.GraphicsInjector = TRUE; - gSettings.InjectIntel = TRUE; - gSettings.InjectATI = TRUE; - gSettings.InjectNVidia = TRUE; + gSettings.Graphics.InjectAsBool = true; +// gSettings.GraphicsInjector = TRUE; +// gSettings.InjectIntel = TRUE; +// gSettings.InjectATI = TRUE; +// gSettings.InjectNVidia = TRUE; } else if (Prop->isDict()) { const TagDict* Dict2 = Prop->getDict(); const TagStruct* Prop2 = Dict2->propertyForKey("Intel"); if (Prop2 != NULL) { - gSettings.InjectIntel = IsPropertyNotNullAndTrue(Prop2); + gSettings.Graphics.InjectAsDict.InjectIntel = IsPropertyNotNullAndTrue(Prop2); } Prop2 = Dict2->propertyForKey("ATI"); if (Prop2 != NULL) { - gSettings.InjectATI = IsPropertyNotNullAndTrue(Prop2); + gSettings.Graphics.InjectAsDict.InjectATI = IsPropertyNotNullAndTrue(Prop2); } Prop2 = Dict2->propertyForKey("NVidia"); if (Prop2 != NULL) { - gSettings.InjectNVidia = IsPropertyNotNullAndTrue(Prop2); + gSettings.Graphics.InjectAsDict.InjectNVidia = IsPropertyNotNullAndTrue(Prop2); } } else { - gSettings.GraphicsInjector = FALSE; - gSettings.InjectIntel = FALSE; - gSettings.InjectATI = FALSE; - gSettings.InjectNVidia = FALSE; +// gSettings.GraphicsInjector = FALSE; +// gSettings.InjectIntel = FALSE; +// gSettings.InjectATI = FALSE; +// gSettings.InjectNVidia = FALSE; } } Prop = GraphicsDict->propertyForKey("RadeonDeInit"); - gSettings.DeInit = IsPropertyNotNullAndTrue(Prop); + gSettings.Graphics.RadeonDeInit = IsPropertyNotNullAndTrue(Prop); Prop = GraphicsDict->propertyForKey("VRAM"); - gSettings.VRAM = (UINTN)GetPropertyAsInteger(Prop, (INTN)gSettings.VRAM); //Mb + gSettings.Graphics.VRAM = (UINTN)GetPropertyAsInteger(Prop, (INTN)gSettings.Graphics.VRAM); //Mb // Prop = GraphicsDict->propertyForKey("RefCLK"); - gSettings.RefCLK = (UINT16)GetPropertyAsInteger(Prop, 0); + gSettings.Graphics.RefCLK = (UINT16)GetPropertyAsInteger(Prop, 0); Prop = GraphicsDict->propertyForKey("LoadVBios"); - gSettings.LoadVBios = IsPropertyNotNullAndTrue(Prop); - - for (i = 0; i < (INTN)NGFX; i++) { - gGraphics[i].LoadVBios = gSettings.LoadVBios; //default - } + gSettings.Graphics.LoadVBios = IsPropertyNotNullAndTrue(Prop); +// +// for (i = 0; i < (INTN)NGFX; i++) { +// gGraphics[i].LoadVBios = gSettings.Graphics.LoadVBios; //default +// } Prop = GraphicsDict->propertyForKey("VideoPorts"); - gSettings.VideoPorts = (UINT16)GetPropertyAsInteger(Prop, gSettings.VideoPorts); + gSettings.Graphics.VideoPorts = (UINT16)GetPropertyAsInteger(Prop, gSettings.Graphics.VideoPorts); Prop = GraphicsDict->propertyForKey("BootDisplay"); - gSettings.BootDisplay = (INT8)GetPropertyAsInteger(Prop, -1); + gSettings.Graphics.BootDisplay = (INT8)GetPropertyAsInteger(Prop, -1); Prop = GraphicsDict->propertyForKey("FBName"); if (Prop != NULL) { if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in FBName\n"); }else{ - gSettings.FBName = Prop->getString()->stringValue(); + gSettings.Graphics.FBName = Prop->getString()->stringValue(); } } @@ -4486,11 +4491,11 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in NVCAP\n"); }else{ - hex2bin (Prop->getString()->stringValue(), (UINT8*)&gSettings.NVCAP[0], sizeof(gSettings.NVCAP)); + hex2bin (Prop->getString()->stringValue(), (UINT8*)&gSettings.Graphics.NVCAP[0], sizeof(gSettings.Graphics.NVCAP)); DBG("Read NVCAP:"); for (i = 0; i<20; i++) { - DBG("%02hhX", gSettings.NVCAP[i]); + DBG("%02hhX", gSettings.Graphics.NVCAP[i]); } DBG("\n"); @@ -4503,12 +4508,12 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) if ( !Prop->isString() ) { MsgLog("ATTENTION : property not string in display-cfg\n"); }else{ - hex2bin (Prop->getString()->stringValue(), (UINT8*)&gSettings.Dcfg[0], sizeof(gSettings.Dcfg)); + hex2bin (Prop->getString()->stringValue(), (UINT8*)&gSettings.Graphics.Dcfg[0], sizeof(gSettings.Graphics.Dcfg)); } } Prop = GraphicsDict->propertyForKey("DualLink"); - gSettings.DualLink = (UINT32)GetPropertyAsInteger(Prop, gSettings.DualLink); + gSettings.Graphics.DualLink = (UINT32)GetPropertyAsInteger(Prop, gSettings.Graphics.DualLink); //InjectEDID - already done in earlysettings //No! Take again @@ -4516,19 +4521,19 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) // ErmaC: NvidiaGeneric Prop = GraphicsDict->propertyForKey("NvidiaGeneric"); - gSettings.NvidiaGeneric = IsPropertyNotNullAndTrue(Prop); + gSettings.Graphics.NvidiaGeneric = IsPropertyNotNullAndTrue(Prop); Prop = GraphicsDict->propertyForKey("NvidiaNoEFI"); - gSettings.NvidiaNoEFI = IsPropertyNotNullAndTrue(Prop); + gSettings.Graphics.NvidiaNoEFI = IsPropertyNotNullAndTrue(Prop); Prop = GraphicsDict->propertyForKey("NvidiaSingle"); - gSettings.NvidiaSingle = IsPropertyNotNullAndTrue(Prop); + gSettings.Graphics.NvidiaSingle = IsPropertyNotNullAndTrue(Prop); Prop = GraphicsDict->propertyForKey("ig-platform-id"); - gSettings.IgPlatform = (UINT32)GetPropertyAsInteger(Prop, gSettings.IgPlatform); + gSettings.Graphics.IgPlatform = (UINT32)GetPropertyAsInteger(Prop, gSettings.Graphics.IgPlatform); Prop = GraphicsDict->propertyForKey("snb-platform-id"); - gSettings.IgPlatform = (UINT32)GetPropertyAsInteger(Prop, gSettings.IgPlatform); + gSettings.Graphics.IgPlatform = (UINT32)GetPropertyAsInteger(Prop, gSettings.Graphics.IgPlatform); FillCardList(GraphicsDict); //#@ Getcardslist } @@ -4810,7 +4815,7 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) //Special case. In future there must be more such cases if ((AsciiStrStr(gSettings.ArbProperties->Key, "-platform-id") != NULL)) { - CopyMem((CHAR8*)&gSettings.IgPlatform, gSettings.ArbProperties->Value, 4); + CopyMem((CHAR8*)&gSettings.Graphics.IgPlatform, gSettings.ArbProperties->Value, 4); } } //for() device properties } @@ -5343,7 +5348,7 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) #ifdef CLOVER_BUILD UINT64 msr = AsmReadMsr64(MSR_IA32_MISC_ENABLE); #endif - gSettings.CPU.Turbo = 0; + gSettings.CPU.TurboDisabled = 1; #ifdef CLOVER_BUILD msr &= ~(1ULL<<38); AsmWriteMsr64 (MSR_IA32_MISC_ENABLE, msr); @@ -5352,20 +5357,20 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) } // RtVariables - gSettings.RtROM.setEmpty(); + gSettings.RtVariables.RtROMAsData.setEmpty(); const TagDict* RtVariablesDict = CfgDict->dictPropertyForKey("RtVariables"); if (RtVariablesDict != NULL) { // ROM: bin data or base 64 encoded bin data const TagStruct* Prop = RtVariablesDict->propertyForKey("ROM"); if (Prop != NULL) { if ( Prop->isString() && Prop->getString()->stringValue().equalIC("UseMacAddr0") ) { - gSettings.RtROM.ncpy(&gLanMac[0][0], 6); + gSettings.RtVariables.RtROMAsString = Prop->getString()->stringValue(); } else if ( Prop->isString() && Prop->getString()->stringValue().equalIC("UseMacAddr1") ) { - gSettings.RtROM.ncpy(&gLanMac[1][0], 6); + gSettings.RtVariables.RtROMAsString = Prop->getString()->stringValue(); } else if ( Prop->isString() || Prop->isData() ) { // GetDataSetting accept both UINTN ROMLength = 0; - void* ROM = GetDataSetting(RtVariablesDict, "ROM", &ROMLength); - gSettings.RtROM.ncpy(ROM, ROMLength); + uint8_t* ROM = GetDataSetting(RtVariablesDict, "ROM", &ROMLength); + gSettings.RtVariables.RtROMAsData.stealValueFrom(ROM, ROMLength); } else { MsgLog("MALFORMED PLIST : property not string or data in RtVariables/ROM\n"); } @@ -5378,17 +5383,17 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) MsgLog("ATTENTION : property not string in RtVariables/MLB\n"); }else{ if( Prop->getString()->stringValue().notEmpty() ) { - gSettings.RtMLB = Prop->getString()->stringValue(); + gSettings.RtVariables.RtMLBSetting = Prop->getString()->stringValue(); } } } // CsrActiveConfig Prop = RtVariablesDict->propertyForKey("CsrActiveConfig"); - gSettings.CsrActiveConfig = (UINT32)GetPropertyAsInteger(Prop, 0x2E7); //the value 0xFFFF means not set + gSettings.RtVariables.CsrActiveConfig = (UINT32)GetPropertyAsInteger(Prop, 0x2E7); //the value 0xFFFF means not set //BooterConfig Prop = RtVariablesDict->propertyForKey("BooterConfig"); - gSettings.BooterConfig = (UINT16)GetPropertyAsInteger(Prop, 0); //the value 0 means not set + gSettings.RtVariables.BooterConfig = (UINT16)GetPropertyAsInteger(Prop, 0); //the value 0 means not set //let it be string like "log=0" Prop = RtVariablesDict->propertyForKey("BooterCfg"); if ( Prop != NULL ) { @@ -5396,7 +5401,7 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) MsgLog("ATTENTION : property not string in RtVariables/BooterCfg\n"); }else{ if( Prop->getString()->stringValue().notEmpty() ) { - gSettings.BooterCfgStr = Prop->getString()->stringValue(); + gSettings.RtVariables.BooterCfgStr = Prop->getString()->stringValue(); } } } @@ -5405,9 +5410,9 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) if (BlockArray != NULL) { INTN i; INTN Count = BlockArray->arrayContent().size(); - BlockRtVariableArray.setEmpty(); - RT_VARIABLES* RtVariablePtr = new RT_VARIABLES(); - RT_VARIABLES& RtVariable = *RtVariablePtr; + gSettings.RtVariables.BlockRtVariableArray.setEmpty(); + SETTINGS_DATA::RtVariablesClass::RT_VARIABLES* RtVariablePtr = new SETTINGS_DATA::RtVariablesClass::RT_VARIABLES(); + SETTINGS_DATA::RtVariablesClass::RT_VARIABLES& RtVariable = *RtVariablePtr; for (i = 0; i < Count; i++) { const TagDict* BlockDict = BlockArray->dictElementAt(i, "Block"_XS8); const TagStruct* Prop2 = BlockDict->propertyForKey("Comment"); @@ -5417,6 +5422,7 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) }else{ if( Prop2->getString()->stringValue().notEmpty() ) { DBG(" %s\n", Prop2->getString()->stringValue().c_str()); + RtVariable.Comment = Prop2->getString()->stringValue(); } } } @@ -5450,20 +5456,20 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings) } } } - BlockRtVariableArray.AddReference(RtVariablePtr, true); + gSettings.RtVariables.BlockRtVariableArray.AddReference(RtVariablePtr, true); } } } - if (gSettings.RtROM.isEmpty()) { - EFI_GUID uuid; - StrToGuidLE(gSettings.SmUUID, &uuid); - gSettings.RtROM.ncpy(&uuid.Data4[2], 6); - } +// if (gSettings.RtVariables.RtROM.isEmpty()) { +// EFI_GUID uuid; +// StrToGuidLE(gSettings.SmUUID, &uuid); +// gSettings.RtVariables.RtROM.ncpy(&uuid.Data4[2], 6); +// } - if (gSettings.RtMLB.isEmpty()) { - gSettings.RtMLB = gSettings.BoardSerialNumber; - } +// if (gSettings.RtVariables.RtMLB.isEmpty()) { +// gSettings.RtVariables.RtMLB = gSettings.BoardSerialNumber; +// } // if CustomUUID and InjectSystemID are not specified // then use InjectSystemID=TRUE and SMBIOS UUID @@ -6568,7 +6574,7 @@ GetDevices () SlotDevice->SlotID = 5; SlotDevice->SlotType = SlotTypePciExpressX4; } - if (gSettings.ResetHDA) { + if (gSettings.Devices.Audio.ResetHDA) { //Slice method from VoodooHDA //PCI_HDA_TCSEL_OFFSET = 0x44 UINT8 Value = 0; @@ -6632,15 +6638,15 @@ SetDevices (LOADER_ENTRY *Entry) while (Prop2) { if (Prop2->MenuItem.BValue) { if (AsciiStrStr(Prop2->Key, "-platform-id") != NULL) { - if (gSettings.IgPlatform == 0 && Prop2->Value) { - CopyMem((UINT8*)&gSettings.IgPlatform, (UINT8*)Prop2->Value, Prop2->ValueLen); + if (gSettings.Graphics.IgPlatform == 0 && Prop2->Value) { + CopyMem((UINT8*)&gSettings.Graphics.IgPlatform, (UINT8*)Prop2->Value, Prop2->ValueLen); } - devprop_add_value(device, Prop2->Key, (UINT8*)&gSettings.IgPlatform, 4); + devprop_add_value(device, Prop2->Key, (UINT8*)&gSettings.Graphics.IgPlatform, 4); DBG(" Add key=%s valuelen=%llu\n", Prop2->Key, Prop2->ValueLen); } else if ((AsciiStrStr(Prop2->Key, "override-no-edid") || AsciiStrStr(Prop2->Key, "override-no-connect")) - && gSettings.InjectEDID && gSettings.CustomEDID) { + && gSettings.Graphics.EDID.InjectEDID && gSettings.Graphics.EDID.CustomEDID.notEmpty()) { // special case for EDID properties - devprop_add_value(device, Prop2->Key, gSettings.CustomEDID, 128); + devprop_add_value(device, Prop2->Key, gSettings.Graphics.EDID.CustomEDID.data(), 128); DBG(" Add key=%s from custom EDID\n", Prop2->Key); } else { devprop_add_value(device, Prop2->Key, (UINT8*)Prop2->Value, Prop2->ValueLen); @@ -6706,7 +6712,7 @@ SetDevices (LOADER_ENTRY *Entry) //special corrections if (Prop->MenuItem.BValue) { if (AsciiStrStr(Prop->Key, "-platform-id") != NULL) { - devprop_add_value(device, Prop->Key, (UINT8*)&gSettings.IgPlatform, 4); + devprop_add_value(device, Prop->Key, (UINT8*)&gSettings.Graphics.IgPlatform, 4); } else { devprop_add_value(device, Prop->Key, (UINT8*)Prop->Value, Prop->ValueLen); } @@ -6731,7 +6737,7 @@ SetDevices (LOADER_ENTRY *Entry) switch (Pci.Hdr.VendorId) { case 0x1002: - if (gSettings.InjectATI) { + if (gSettings.Graphics.InjectAsDict.InjectATI) { //can't do this in one step because of C-conventions TmpDirty = setup_ati_devprop(Entry, &PCIdevice); StringDirty |= TmpDirty; @@ -6748,7 +6754,7 @@ SetDevices (LOADER_ENTRY *Entry) } } - if (gSettings.DeInit) { + if (gSettings.Graphics.RadeonDeInit) { for (j = 0; j < 4; j++) { if (gGraphics[j].Handle == PCIdevice.DeviceHandle) { *(UINT32*)(gGraphics[j].Mmio + 0x6848) = 0; //EVERGREEN_GRPH_FLIP_CONTROL, 1<<0 SURFACE_UPDATE_H_RETRACE_EN @@ -6765,7 +6771,7 @@ SetDevices (LOADER_ENTRY *Entry) break; case 0x8086: - if (gSettings.InjectIntel) { + if (gSettings.Graphics.InjectAsDict.InjectIntel) { TmpDirty = setup_gma_devprop(Entry, &PCIdevice); StringDirty |= TmpDirty; MsgLog ("Intel GFX revision = 0x%hhX\n", PCIdevice.revision); @@ -6871,8 +6877,8 @@ SetDevices (LOADER_ENTRY *Entry) case 0x0116: // "Intel HD Graphics 3000" case 0x0122: // "Intel HD Graphics 3000" case 0x0126: // "Intel HD Graphics 3000" - if (gSettings.IgPlatform) { - switch (gSettings.IgPlatform) { + if (gSettings.Graphics.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x00030010: case (UINT32)0x00050000: FBLEVX = 0xFFFF; @@ -6917,8 +6923,8 @@ SetDevices (LOADER_ENTRY *Entry) case 0x0D2A: // "Intel Iris Pro Graphics 5200" case 0x0D2B: // "Intel Iris Pro Graphics 5200" case 0x0D2E: // "Intel Iris Pro Graphics 5200" - if (gSettings.IgPlatform) { - switch (gSettings.IgPlatform) { + if (gSettings.Graphics.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x04060000: case (UINT32)0x0c060000: case (UINT32)0x04160000: @@ -6978,8 +6984,8 @@ SetDevices (LOADER_ENTRY *Entry) case 0x162D: // "Intel Iris Pro Graphics P6300" case 0x1622: // "Intel Iris Pro Graphics 6200" case 0x162A: // "Intel Iris Pro Graphics P6300" - if (gSettings.IgPlatform) { - switch (gSettings.IgPlatform) { + if (gSettings.Graphics.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x16060000: case (UINT32)0x160e0000: case (UINT32)0x16160000: @@ -7045,8 +7051,8 @@ SetDevices (LOADER_ENTRY *Entry) case 0x193A: // "Intel Iris Pro Graphics P580" case 0x193B: // "Intel Iris Pro Graphics 580" case 0x193D: // "Intel Iris Pro Graphics P580" - if (gSettings.IgPlatform) { - switch (gSettings.IgPlatform) { + if (gSettings.Graphics.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x19120001: FBLEVX = 0xFFFF; break; @@ -7284,7 +7290,7 @@ SetDevices (LOADER_ENTRY *Entry) break; case 0x10de: - if (gSettings.InjectNVidia) { + if (gSettings.Graphics.InjectAsDict.InjectNVidia) { TmpDirty = setup_nvidia_devprop(&PCIdevice); StringDirty |= TmpDirty; } else { @@ -7323,7 +7329,7 @@ SetDevices (LOADER_ENTRY *Entry) TmpDirty = setup_hda_devprop (PciIo, &PCIdevice, Entry->macOSVersion); StringDirty |= TmpDirty; } - if (gSettings.ResetHDA) { + if (gSettings.Devices.Audio.ResetHDA) { //PCI_HDA_TCSEL_OFFSET = 0x44 UINT8 Value = 0; diff --git a/rEFIt_UEFI/Platform/Settings.h b/rEFIt_UEFI/Platform/Settings.h index 149460bd5..ab52eeac2 100644 --- a/rEFIt_UEFI/Platform/Settings.h +++ b/rEFIt_UEFI/Platform/Settings.h @@ -13,6 +13,7 @@ #include "../libeg/XIcon.h" #include "../cpp_lib/undefinable.h" #include "../entry_scan/loader.h" // for KERNEL_SCAN_xxx constants +//#include "card_vlist.h" #define CLOVER_SIGN SIGNATURE_32('C','l','v','r') @@ -443,6 +444,37 @@ public : MMIOWhiteList& operator=(const MMIOWhiteList&) = delete; }; + +/** + Set of Search & replace bytes for VideoBiosPatchBytes(). + this is supposed to be a replacement of VBIOS_PATCH_BYTES, but that would need VbiosPatchLibrary to be update to C++. Quite easy, but need cpp_fundation to become a library. TODO +**/ +class VBIOS_PATCH { +public: + XBuffer Find = XBuffer(); + XBuffer Replace = XBuffer(); +}; + +class PatchVBiosBytesNewClass : public XObjArray +{ + mutable XArray VBIOS_PATCH_BYTES_array = XArray(); +public: + // Temporary bridge to old struct. + const VBIOS_PATCH_BYTES* getVBIOS_PATCH_BYTES() { + VBIOS_PATCH_BYTES_array.setSize(size()); + for ( size_t idx = 0 ; idx < size() ; ++idx ) { + VBIOS_PATCH_BYTES_array[idx].Find = ElementAt(idx).Find.data(); + VBIOS_PATCH_BYTES_array[idx].Replace = ElementAt(idx).Replace.data(); + VBIOS_PATCH_BYTES_array[idx].NumberOfBytes = ElementAt(idx).Replace.size(); + } + return VBIOS_PATCH_BYTES_array; + } + size_t getVBIOS_PATCH_BYTES_count() const { + return size(); + } +}; + + class SETTINGS_DATA; class ConfigPlist; class TagDict; @@ -601,15 +633,15 @@ public: UINT16 QPI = 0; UINT32 CpuFreqMHz = 0; UINT16 CpuType = 0; - BOOLEAN QEMU = 0; - BOOLEAN UseARTFreq = 0; + bool QEMU = 0; + bool UseARTFreq = 0; UINT32 BusSpeed = 0; //in kHz - BOOLEAN UserChange = 0; + bool UserChange = 0; UINT8 SavingMode = 0; bool HWPEnable = false; undefinable_uint32 HWPValue = undefinable_uint32(); UINT8 TDP = 0; - BOOLEAN Turbo = 0; + bool TurboDisabled = 0; undefinable_bool _EnableC6 = undefinable_bool(); undefinable_bool _EnableC4 = undefinable_bool(); undefinable_bool _EnableC2 = undefinable_bool(); @@ -635,27 +667,129 @@ public: } SystemParameters = SystemParametersClass(); + KERNEL_AND_KEXT_PATCHES KernelAndKextPatches = KERNEL_AND_KEXT_PATCHES(); + + class GraphicsClass { + public: + bool PatchVBios = bool(); + PatchVBiosBytesNewClass PatchVBiosBytesNew = PatchVBiosBytesNewClass(); + + class EDIDClass { + public: + bool InjectEDID = bool(); + XBuffer CustomEDID = XBuffer (); + UINT16 VendorEDID = UINT16(); + UINT16 ProductEDID = UINT16(); + UINT16 EdidFixHorizontalSyncPulseWidth = UINT16(); + UINT8 EdidFixVideoInputSignal = UINT8(); + } EDID = EDIDClass(); + + undefinable_bool InjectAsBool = undefinable_bool(); + class InjectAsDictClass { + public: + bool InjectIntel = bool(); + bool InjectATI = bool(); + bool InjectNVidia = bool(); + } InjectAsDict = InjectAsDictClass(); + + bool RadeonDeInit = bool(); + bool LoadVBios = bool(); + UINT64 VRAM = bool(); + UINT32 RefCLK = UINT32(); + XStringW FBName = XStringW(); + UINT16 VideoPorts = UINT16(); + bool NvidiaGeneric = bool(); + bool NvidiaNoEFI = bool(); + bool NvidiaSingle = bool(); + UINT8 Dcfg[8] = {0}; + UINT8 NVCAP[20] = {0}; + INT8 BootDisplay = INT8(); + UINT32 DualLink = UINT32(); + UINT32 IgPlatform = UINT32(); //could also be snb-platform-id + + + class GRAPHIC_CARD { + public: + UINT32 Signature = 0; + XString8 Model = XString8(); + UINT32 Id = 0; + UINT32 SubId = 0; + UINT64 VideoRam = 0; + UINTN VideoPorts = 0; + bool LoadVBios = 0; + }; + XObjArray gCardList = XObjArray(); + + +// bool getGraphicsInjector() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.GraphicsInjector; } + bool InjectIntel() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectIntel; } + bool InjectATI() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectATI; } + bool InjectNVidia() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectNVidia; } + + + + } Graphics = GraphicsClass(); + + class DevicesClass { + public: + + class AudioClass { + public: + bool ResetHDA = bool(); + } Audio = AudioClass(); + + } Devices = DevicesClass(); + class QuirksClass { public: bool FuzzyMatch = bool(); XString8 OcKernelCache = XString8(); OC_KERNEL_QUIRKS OcKernelQuirks = OC_KERNEL_QUIRKS(); } Quirks = QuirksClass(); + + XStringWArray DisabledDriverArray = XStringWArray(); + + class RtVariablesClass { + public: + + XString8 RtROMAsString = XString8(); + XBuffer RtROMAsData = XBuffer(); + XString8 RtMLBSetting = XString8(); + UINT32 CsrActiveConfig = UINT32(); + UINT16 BooterConfig = UINT16(); + XString8 BooterCfgStr = XString8(); + + class RT_VARIABLES + { + public: + XString8 Comment = XStringW(); + XStringW Name = XStringW(); + EFI_GUID VarGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; + }; + XObjArray BlockRtVariableArray = XObjArray(); + + bool GetLegacyLanAddress() const { + return RtROMAsString.equalIC("UseMacAddr0") || RtROMAsString.equalIC("UseMacAddr1"); + } + + } RtVariables = RtVariablesClass(); + + bool getEnableC6() const { - if ( CPU._EnableC6.isDefined() ) return CPU._EnableC6; + if ( CPU._EnableC6.isDefined() ) return CPU._EnableC6.value(); return ACPI.SSDT._EnableC6; } bool getEnableC4() const { - if ( CPU._EnableC4.isDefined() ) return CPU._EnableC4; + if ( CPU._EnableC4.isDefined() ) return CPU._EnableC4.value(); return ACPI.SSDT._EnableC4; } bool getEnableC2() const { - if ( CPU._EnableC2.isDefined() ) return CPU._EnableC2; + if ( CPU._EnableC2.isDefined() ) return CPU._EnableC2.value(); return ACPI.SSDT._EnableC2; } bool getC3Latency() const { - if ( CPU._C3Latency.isDefined() ) return CPU._C3Latency; + if ( CPU._C3Latency.isDefined() ) return CPU._C3Latency.value(); return ACPI.SSDT._C3Latency; } @@ -670,7 +804,6 @@ public: XString8 VersionNr; XString8 SerialNr; XString8 SmUUID; - CHAR8 pad0[7]; //CHAR8 Uuid; //CHAR8 SKUNumber; XString8 FamilyName; @@ -684,7 +817,6 @@ public: XString8 BoardVersion; XString8 OEMBoard; UINT8 BoardType; - UINT8 pad1; // SMBIOS TYPE3 BOOLEAN Mobile; UINT8 ChassisType; @@ -695,7 +827,6 @@ public: // SMBIOS TYPE17 UINT16 SmbiosVersion; INT8 Attribute; - INT8 pad17[1]; XString8 MemoryManufacturer; XString8 MemorySerialNumber; XString8 MemoryPartNumber; @@ -704,7 +835,6 @@ public: // SMBIOS TYPE132 BOOLEAN TrustSMBIOS = 0; BOOLEAN InjectMemoryTables; - INT8 pad18[3]; // SMBIOS TYPE133 UINT64 PlatformFeature; @@ -713,17 +843,11 @@ public: BOOLEAN NoRomInfo; // OS parameters - INT8 pad181[7]; XString8 Language; - INT8 pad19[2]; - INT8 pad20[6]; //Monitor BOOLEAN IntelMaxBacklight; - UINT8 pad21[1]; - UINT16 VendorEDID; - UINT16 ProductEDID; BOOLEAN IntelBacklight; //Boot options BOOLEAN MemoryFix; @@ -731,12 +855,9 @@ public: // GUI parameters BOOLEAN Debug; -// BOOLEAN Proportional; //never used - UINT8 pad22[2]; UINT32 DefaultBackgroundColor; //ACPI - UINT8 pad23[1]; // BOOLEAN DropMCFG; @@ -757,39 +878,9 @@ public: //Graphics // UINT16 PCIRootUID; - BOOLEAN GraphicsInjector; - BOOLEAN InjectIntel; - BOOLEAN InjectATI; - BOOLEAN InjectNVidia; - BOOLEAN DeInit; - BOOLEAN LoadVBios; - BOOLEAN PatchVBios; - UINT8 pad24[5]; - VBIOS_PATCH_BYTES *PatchVBiosBytes; - UINTN PatchVBiosBytesCount; - BOOLEAN InjectEDID; BOOLEAN LpcTune; UINT16 DropOEM_DSM; //vacant - UINT8 pad25[4]; - UINT8 *CustomEDID; - UINT16 CustomEDIDsize; - UINT16 EdidFixHorizontalSyncPulseWidth; - UINT8 EdidFixVideoInputSignal; - UINT8 pad26[1]; - XStringW FBName; - UINT16 VideoPorts; - BOOLEAN NvidiaGeneric; - BOOLEAN NvidiaNoEFI; - BOOLEAN NvidiaSingle; - UINT8 pad27[5]; - UINT64 VRAM; - UINT8 Dcfg[8]; - UINT8 NVCAP[20]; - INT8 BootDisplay; - UINT8 pad41[2]; - UINT32 DualLink; - UINT32 IgPlatform; // HDA @@ -807,15 +898,12 @@ public: BOOLEAN LANInjection; BOOLEAN HDMIInjection; - // UINT8 pad61[2]; - //SkyLake //Volumes hiding // KernelAndKextPatches - KERNEL_AND_KEXT_PATCHES KernelAndKextPatches; BOOLEAN KextPatchesAllowed; BOOLEAN KernelPatchesAllowed; //From GUI: Only for user patches, not internal Clover @@ -823,30 +911,17 @@ public: // Pre-language - //Pointer - UINT8 pad28[7]; -// UINT8 pad7[6]; - UINT8 pad29[6]; - UINT32 RefCLK; // SysVariables - UINT8 pad30[4]; - XString8 RtMLB; - XBuffer RtROM; - UINT32 CsrActiveConfig; - UINT16 BooterConfig; - XString8 BooterCfgStr; // Multi-config CHAR16 ConfigName[30]; - UINT8 pad31[4]; // XString8 MainConfigName; //Drivers - XStringWArray DisabledDriverArray; //SMC keys CHAR8 RPlt[8]; @@ -856,32 +931,14 @@ public: //other devices BOOLEAN ForceHPET; - BOOLEAN ResetHDA; - UINT8 pad32[2]; UINT32 DisableFunctions; - //Patch DSDT arbitrary -// UINT32 PatchDsdtNum; -// UINT8 **PatchDsdtFind; -// UINT32 *LenToFind; -// UINT8 **PatchDsdtReplace; -// UINT32 *LenToReplace; -// CHAR8 **PatchDsdtLabel; -// CHAR8 **PatchDsdtTgt; -// INPUT_ITEM *PatchDsdtMenuItem; BOOLEAN SlpWak; BOOLEAN UseIntelHDMI; UINT8 AFGLowPowerState; -// UINT8 pad83[4]; - // Table dropping - UINT8 pad34[3]; - - // Custom entries - UINT8 pad35[3]; - //Add custom properties UINTN NrAddProperties; DEV_PROPERTY *AddProperties; @@ -896,9 +953,6 @@ public: //ACPI tables - // ACPI/PATCHED/AML - UINT8 pad36[4]; - //other UINT32 IntelMaxValue; // UINT32 AudioVolume; @@ -910,11 +964,9 @@ public: UINT32 EFILoginHiDPI; UINT8 flagstate[32]; - UINT8 pad37[4]; DEV_PROPERTY *ArbProperties; UINT32 QuirksMask; - UINT8 pad38[4]; UINTN MaxSlide; OC_BOOTER_QUIRKS ocBooterQuirks; @@ -923,23 +975,21 @@ public: SETTINGS_DATA() : VendorName(), RomVersion(), EfiVersion(), ReleaseDate(), ManufactureName(), ProductName(), VersionNr(), SerialNr(), SmUUID(), - pad0{0}, FamilyName(), OEMProduct(), OEMVendor(), BoardManufactureName(), BoardSerialNumber(), BoardNumber(), LocationInChassis(), - BoardVersion(), OEMBoard(), BoardType(0), pad1(0), Mobile(0), ChassisType(0), ChassisManufacturer(), ChassisAssetTag(), - EnabledCores(0), SmbiosVersion(0), Attribute(0), pad17{0}, MemoryManufacturer(), + 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(), - IntelMaxBacklight(0), VendorEDID(0), ProductEDID(0), IntelBacklight(0), MemoryFix(0), - FakeSMCFound(0), Debug(0), pad22{0}, DefaultBackgroundColor(0), StringInjector(0), NoDefaultProperties(0), - FakeATI(0), FakeNVidia(0), FakeIntel(0), FakeLAN(0), FakeWIFI(0), FakeSATA(0), FakeXHCI(0), FakeIMEI(0), GraphicsInjector(0), - InjectIntel(0), InjectATI(0), InjectNVidia(0), DeInit(0), LoadVBios(0), PatchVBios(0), PatchVBiosBytes(0), PatchVBiosBytesCount(0), InjectEDID(0), - LpcTune(0), DropOEM_DSM(0), CustomEDID(0), CustomEDIDsize(0), EdidFixHorizontalSyncPulseWidth(0), EdidFixVideoInputSignal(0), FBName(), VideoPorts(0), NvidiaGeneric(0), - NvidiaNoEFI(0), NvidiaSingle(0), VRAM(0), Dcfg{0}, NVCAP{0}, BootDisplay(0), pad41{0}, DualLink(0), - IgPlatform(0), HDAInjection(0), + IntelMaxBacklight(0), IntelBacklight(0), MemoryFix(0), + FakeSMCFound(0), Debug(0), DefaultBackgroundColor(0), StringInjector(0), NoDefaultProperties(0), + FakeATI(0), FakeNVidia(0), FakeIntel(0), FakeLAN(0), FakeWIFI(0), FakeSATA(0), FakeXHCI(0), FakeIMEI(0), + LpcTune(0), DropOEM_DSM(0), + HDAInjection(0), HDALayoutId(0), USBInjection(0), USBFixOwnership(0), InjectClockID(0), HighCurrent(0), NameEH00(0), NameXH00(0), LANInjection(0), HDMIInjection(0), - KernelAndKextPatches(), KextPatchesAllowed(0), + KextPatchesAllowed(0), KernelPatchesAllowed(0), AirportBridgeDeviceName(), - RefCLK(0), RtMLB(), RtROM(), CsrActiveConfig(0), BooterConfig(0), BooterCfgStr(), - ConfigName{0}, /*MainConfigName(0),*/ /*BlackListCount(0),*/ DisabledDriverArray(), RPlt{0}, RBr{0}, EPCI{0}, REV{0}, ForceHPET(0), ResetHDA(0), DisableFunctions(0), SlpWak(0), UseIntelHDMI(0), + ConfigName{0}, /*MainConfigName(0),*/ /*BlackListCount(0),*/ RPlt{0}, RBr{0}, EPCI{0}, REV{0}, + ForceHPET(0), DisableFunctions(0), SlpWak(0), UseIntelHDMI(0), AFGLowPowerState(0), NrAddProperties(0), AddProperties(0), BlockKexts{0}, IntelMaxValue(0), OptionsBits(0), FlagsBits(0), UIScale(0), EFILoginHiDPI(0), flagstate{0}, ArbProperties(0), QuirksMask(0), MaxSlide(0), ocBooterQuirks{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, mmioWhiteListArray() @@ -1021,21 +1071,9 @@ public: ~SIDELOAD_KEXT() { } }; -class RT_VARIABLES -{ -public: - XStringW Name; - EFI_GUID VarGuid; - -RT_VARIABLES() : Name(), VarGuid{0,0,0,{0}} {}; - RT_VARIABLES(const RT_VARIABLES& other) = delete; // Can be defined if needed - const RT_VARIABLES& operator = ( const RT_VARIABLES & ) = delete; // Can be defined if needed - ~RT_VARIABLES() { } -}; - -extern XObjArray BlockRtVariableArray; +//extern XObjArray gSettings.RtVariables.BlockRtVariableArray; extern XObjArray AudioList; extern XStringWArray ThemeNameArray; @@ -1147,6 +1185,10 @@ public: bool KPKernelPm = bool(); bool KPAppleIntelCPUPM = bool(); + XBuffer RtROM = XBuffer(); + XString8 RtMLB = XString8(); + + bool Turbo; REFIT_CONFIG() {}; REFIT_CONFIG(const REFIT_CONFIG& other) = delete; // Can be defined if needed diff --git a/rEFIt_UEFI/Platform/StateGenerator.cpp b/rEFIt_UEFI/Platform/StateGenerator.cpp index e4de3712f..14a647c85 100644 --- a/rEFIt_UEFI/Platform/StateGenerator.cpp +++ b/rEFIt_UEFI/Platform/StateGenerator.cpp @@ -166,7 +166,7 @@ SSDT_TABLE *generate_pss_ssdt(UINTN Number) maximum.Control.Control = (RShiftU64(AsmReadMsr64(MSR_IA32_PERF_STATUS), 32) & 0x1F3F) | (0x4000 * cpu_noninteger_bus_ratio); DBG("Maximum control=0x%hX\n", maximum.Control.Control); - if (gSettings.CPU.Turbo) { + if (GlobalConfig.Turbo) { maximum.Control.VID_FID.FID++; MsgLog("Turbo FID=0x%hhX\n", maximum.Control.VID_FID.FID); } @@ -284,7 +284,7 @@ SSDT_TABLE *generate_pss_ssdt(UINTN Number) realMax = maximum.Control.Control; DBG("Maximum control=0x%hX\n", realMax); - if (gSettings.CPU.Turbo) { + if (GlobalConfig.Turbo) { realTurbo = (gCPUStructure.Turbo4 > gCPUStructure.Turbo1) ? (gCPUStructure.Turbo4 / 10) : (gCPUStructure.Turbo1 / 10); maximum.Control.Control = realTurbo; diff --git a/rEFIt_UEFI/Platform/ati.cpp b/rEFIt_UEFI/Platform/ati.cpp index d05b9c4c2..42220d563 100644 --- a/rEFIt_UEFI/Platform/ati.cpp +++ b/rEFIt_UEFI/Platform/ati.cpp @@ -1247,8 +1247,8 @@ BOOLEAN get_dual_link_val(value_t *val, INTN index, BOOLEAN Sier) return FALSE; } - if ((gSettings.DualLink == 0) || (gSettings.DualLink == 1)) { - v = gSettings.DualLink; + if ((gSettings.Graphics.DualLink == 0) || (gSettings.Graphics.DualLink == 1)) { + v = gSettings.Graphics.DualLink; } else { v = DualLink; } @@ -1269,7 +1269,7 @@ BOOLEAN get_vrammemory_val(value_t *val, INTN index, BOOLEAN Sier) BOOLEAN get_edid_val(value_t *val, INTN index, BOOLEAN Sier) { static UINT32 v = 0; - if (!gSettings.InjectEDID) { + if (!gSettings.Graphics.EDID.InjectEDID) { return FALSE; } @@ -1277,13 +1277,13 @@ BOOLEAN get_edid_val(value_t *val, INTN index, BOOLEAN Sier) return FALSE; } //CustomEDID will point to user EDID if set else to EdidDiscovered - if (!gSettings.CustomEDID) { + if (gSettings.Graphics.EDID.CustomEDID.isEmpty()) { return FALSE; } v = 1; val->type = kPtr; val->size = 128; - val->data = (__typeof__(val->data))AllocateCopyPool(val->size, gSettings.CustomEDID); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, gSettings.Graphics.EDID.CustomEDID.data()); return TRUE; } @@ -1445,7 +1445,7 @@ BOOLEAN get_binimage_val(value_t *val, INTN index, BOOLEAN Sier) BOOLEAN get_binimage_owr(value_t *val, INTN index, BOOLEAN Sier) { - if (!gSettings.LoadVBios) { + if (!gSettings.Graphics.LoadVBios) { return FALSE; } val->type = kCst; @@ -1498,13 +1498,13 @@ BOOLEAN get_sclk_val(value_t *val, INTN index, BOOLEAN Sier) BOOLEAN get_refclk_val(value_t *val, INTN index, BOOLEAN Sier) { - if (!gSettings.RefCLK) { + if (!gSettings.Graphics.RefCLK) { return FALSE; } // val->type = kCst; val->size = 4; - val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)&gSettings.RefCLK); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)&gSettings.Graphics.RefCLK); return TRUE; } @@ -1688,9 +1688,9 @@ void get_vram_size(void) ati_chip_family_t chip_family = card->info->chip_family; card->vram_size = 128 << 20; //default 128Mb, this is minimum for OS - if (gSettings.VRAM != 0) { - card->vram_size = gSettings.VRAM << 20; - DBG("Set VRAM from config=%lluMb\n", gSettings.VRAM); + if (gSettings.Graphics.VRAM != 0) { + card->vram_size = gSettings.Graphics.VRAM << 20; + DBG("Set VRAM from config=%lluMb\n", gSettings.Graphics.VRAM); // WRITEREG32(card->mmio, RADEON_CONFIG_MEMSIZE, card->vram_size); } else { if (chip_family >= CHIP_FAMILY_CEDAR) { @@ -1712,7 +1712,7 @@ void get_vram_size(void) DBG("Set VRAM for %s =%lluMb\n", chip_family_name[card->info->chip_family], (UINT64)RShiftU64(card->vram_size, 20)); } - gSettings.VRAM = (UINT64)RShiftU64(card->vram_size, 20); + gSettings.Graphics.VRAM = (UINT64)RShiftU64(card->vram_size, 20); DBG("ATI: get_vram_size returned 0x%llX\n", card->vram_size); } @@ -1924,7 +1924,7 @@ BOOLEAN devprop_add_pci_config_space(void) static BOOLEAN init_card(pci_dt_t *pci_dev) { - BOOLEAN add_vbios = gSettings.LoadVBios; + BOOLEAN add_vbios = gSettings.Graphics.LoadVBios; CHAR8 *name; CHAR8 *name_parent; // CHAR8 *model; @@ -2027,9 +2027,9 @@ static BOOLEAN init_card(pci_dt_t *pci_dev) card->flags |= FLAGNOTFAKE; - NameLen = gSettings.FBName.length(); + NameLen = gSettings.Graphics.FBName.length(); if (NameLen > 2) { //fool proof: cfg_name is 3 character or more. - card->cfg_name = S8Printf("%ls", gSettings.FBName.wc_str()).forgetDataWithoutFreeing(); + card->cfg_name = S8Printf("%ls", gSettings.Graphics.FBName.wc_str()).forgetDataWithoutFreeing(); DBG("Users config name %s\n", card->cfg_name); } else { // use cfg_name on radeon_cards, to retrive the default name from card_configs, @@ -2040,8 +2040,8 @@ static BOOLEAN init_card(pci_dt_t *pci_dev) DBG(" N ports defaults to %lld\n", n_ports); } - if (gSettings.VideoPorts != 0) { - n_ports = gSettings.VideoPorts; + if (gSettings.Graphics.VideoPorts != 0) { + n_ports = gSettings.Graphics.VideoPorts; DBG(" use N ports setting from config.plist: %lld\n", n_ports); } diff --git a/rEFIt_UEFI/Platform/card_vlist.cpp b/rEFIt_UEFI/Platform/card_vlist.cpp index c43819299..99a06ddcb 100644 --- a/rEFIt_UEFI/Platform/card_vlist.cpp +++ b/rEFIt_UEFI/Platform/card_vlist.cpp @@ -5,7 +5,7 @@ #include // Only use angled for Platform, else, xcode project won't compile #include "nvidia.h" - +#include "../Platform/Settings.h" /* injection for NVIDIA card usage e.g (to be placed in the config.plist, under graphics tag): @@ -65,26 +65,25 @@ #endif //LIST_ENTRY gCardList = INITIALIZE_LIST_HEAD_VARIABLE (gCardList); -XObjArray gCardList; -void AddCard(CONST CHAR8* Model, UINT32 Id, UINT32 SubId, UINT64 VideoRam, UINTN VideoPorts, BOOLEAN LoadVBios) +//void AddCard(CONST CHAR8* Model, UINT32 Id, UINT32 SubId, UINT64 VideoRam, UINTN VideoPorts, BOOLEAN LoadVBios) +//{ +// CARDLIST* new_card = new CARDLIST; +// new_card->Signature = CARDLIST_SIGNATURE; +// new_card->Id = Id; +// new_card->SubId = SubId; +// new_card->VideoRam = VideoRam; +// new_card->VideoPorts = VideoPorts; +// new_card->LoadVBios = LoadVBios; +// new_card->Model.takeValueFrom(Model); +// gCardList.AddReference(new_card, true); +//} + +const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD* FindCardWithIds(UINT32 Id, UINT32 SubId) { - CARDLIST* new_card = new CARDLIST; - new_card->Signature = CARDLIST_SIGNATURE; - new_card->Id = Id; - new_card->SubId = SubId; - new_card->VideoRam = VideoRam; - new_card->VideoPorts = VideoPorts; - new_card->LoadVBios = LoadVBios; - new_card->Model.takeValueFrom(Model); - gCardList.AddReference(new_card, true); -} - -const CARDLIST* FindCardWithIds(UINT32 Id, UINT32 SubId) -{ - for ( size_t idx = 0; idx < gCardList._Len; ++idx ) { - const CARDLIST& entry = gCardList[idx]; + for ( size_t idx = 0; idx < gSettings.Graphics.gCardList.size(); ++idx ) { + const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD& entry = gSettings.Graphics.gCardList[idx]; if(entry.Id == Id) { return &entry; } @@ -94,7 +93,7 @@ const CARDLIST* FindCardWithIds(UINT32 Id, UINT32 SubId) void FillCardList(const TagDict* CfgDict) { - if (gCardList.isEmpty() && (CfgDict != NULL)) { + if (gSettings.Graphics.gCardList.isEmpty() && (CfgDict != NULL)) { CONST CHAR8 *VEN[] = { "NVIDIA", "ATI" }; size_t Count = sizeof(VEN) / sizeof(VEN[0]); @@ -109,13 +108,16 @@ void FillCardList(const TagDict* CfgDict) const TagStruct* prop2 = 0; const TagStruct* element = 0; count = prop->arrayContent().size(); - for (i = 0; i < count; i++) { - CONST CHAR8 *model_name = NULL; - UINT32 dev_id = 0; - UINT32 subdev_id = 0; - UINT64 VramSize = 0; - UINTN VideoPorts = 0; - BOOLEAN LoadVBios = FALSE; + for (i = 0; i < count; i++) + { + SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD* new_card = new SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD; + +// CONST CHAR8 *model_name = NULL; +// UINT32 dev_id = 0; +// UINT32 subdev_id = 0; +// UINT64 VramSize = 0; +// UINTN VideoPorts = 0; +// BOOLEAN LoadVBios = FALSE; element = &prop->arrayContent()[i]; if ( !element->isDict()) { MsgLog("MALFORMED PLIST in FillCardList() : element is not a dict"); @@ -125,31 +127,39 @@ void FillCardList(const TagDict* CfgDict) prop2 = dictElement->propertyForKey("Model"); if ( prop2->isString() && prop2->getString()->stringValue().notEmpty() ) { - model_name = prop2->getString()->stringValue().c_str(); + new_card->Model = prop2->getString()->stringValue(); } else { - model_name = "VideoCard"; + new_card->Model = "VideoCard"_XS8; } prop2 = dictElement->propertyForKey("IOPCIPrimaryMatch"); - dev_id = (UINT32)GetPropertyAsInteger(prop2, 0); + new_card->Id = (UINT32)GetPropertyAsInteger(prop2, 0); prop2 = dictElement->propertyForKey("IOPCISubDevId"); - subdev_id = (UINT32)GetPropertyAsInteger(prop2, 0); + new_card->SubId = (UINT32)GetPropertyAsInteger(prop2, 0); prop2 = dictElement->propertyForKey("VRAM"); - VramSize = LShiftU64((UINTN)GetPropertyAsInteger(prop2, (INTN)VramSize), 20); //Mb -> bytes + new_card->VideoRam = LShiftU64((UINTN)GetPropertyAsInteger(prop2, 0), 20); //Mb -> bytes prop2 = dictElement->propertyForKey("VideoPorts"); - VideoPorts = (UINT16)GetPropertyAsInteger(prop2, VideoPorts); + new_card->VideoPorts = (UINT16)GetPropertyAsInteger(prop2, 0); prop2 = dictElement->propertyForKey("LoadVBios"); if (prop2 != NULL && IsPropertyNotNullAndTrue(prop2)) { - LoadVBios = TRUE; + new_card->LoadVBios = TRUE; } - DBG("FillCardList :: %s : \"%s\" (%08X, %08X)\n", key, model_name, dev_id, subdev_id); + DBG("FillCardList :: %s : \"%s\" (%08X, %08X)\n", key, new_card->Model.c_str(), new_card->Id, new_card->SubId); - AddCard(model_name, dev_id, subdev_id, VramSize, VideoPorts, LoadVBios); +// AddCard(model_name, dev_id, subdev_id, VramSize, VideoPorts, LoadVBios); + new_card->Signature = CARDLIST_SIGNATURE; +// new_card->Id = dev_id; +// new_card->SubId = subdev_id; +// new_card->VideoRam = VramSize; +// new_card->VideoPorts = VideoPorts; +// new_card->LoadVBios = LoadVBios; +// new_card->Model.takeValueFrom(model_name); + gSettings.Graphics.gCardList.AddReference(new_card, true); } } } diff --git a/rEFIt_UEFI/Platform/card_vlist.h b/rEFIt_UEFI/Platform/card_vlist.h index e5f62a66d..2cf363922 100644 --- a/rEFIt_UEFI/Platform/card_vlist.h +++ b/rEFIt_UEFI/Platform/card_vlist.h @@ -9,24 +9,7 @@ #define PLATFORM_CARD_VLIST_H_ #include "../Platform/plist/plist.h" - - -class CARDLIST { - public: - UINT32 Signature = 0; - XString8 Model = XString8(); - UINT32 Id = 0; - UINT32 SubId = 0; - UINT64 VideoRam = 0; - UINTN VideoPorts = 0; - BOOLEAN LoadVBios = 0; - - CARDLIST() {} - CARDLIST(const CARDLIST& other) = delete; // Can be defined if needed - const CARDLIST& operator = ( const CARDLIST & ) = delete; // Can be defined if needed - ~CARDLIST() {} -}; - +#include "../Platform/Settings.h" #define CARDLIST_SIGNATURE SIGNATURE_32('C','A','R','D') @@ -36,21 +19,21 @@ FillCardList ( const TagDict* CfgDict ); -const CARDLIST* +const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD* FindCardWithIds ( UINT32 Id, UINT32 SubId ); -void -AddCard ( - CONST CHAR8 *Model, - UINT32 Id, - UINT32 SubId, - UINT64 VideoRam, - UINTN VideoPorts, - BOOLEAN LoadVBios - ); +//void +//AddCard ( +// CONST CHAR8 *Model, +// UINT32 Id, +// UINT32 SubId, +// UINT64 VideoRam, +// UINTN VideoPorts, +// BOOLEAN LoadVBios +// ); diff --git a/rEFIt_UEFI/Platform/gma.cpp b/rEFIt_UEFI/Platform/gma.cpp index daca3da99..b35e47ef3 100755 --- a/rEFIt_UEFI/Platform/gma.cpp +++ b/rEFIt_UEFI/Platform/gma.cpp @@ -1364,7 +1364,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) MsgLog(" IntelHDMI: used\n"); } - if (gSettings.InjectEDID && gSettings.CustomEDID) { + if (gSettings.Graphics.EDID.InjectEDID && gSettings.Graphics.EDID.CustomEDID.notEmpty()) { switch (gma_dev->device_id) { case 0x2772: // "Intel GMA 950" case 0x2776: // "Intel GMA 950" @@ -1379,11 +1379,11 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) case 0x2A03: // "Intel GMA X3100" case 0x2A12: // "Intel GMA X3100" case 0x2A13: // "Intel GMA X3100" - devprop_add_value(device, "AAPL01,override-no-connect", gSettings.CustomEDID, 128); + devprop_add_value(device, "AAPL01,override-no-connect", gSettings.Graphics.EDID.CustomEDID.data(), 128); DBG(" AAPL01,override-no-connect: added\n"); break; default: - devprop_add_value(device, "AAPL00,override-no-connect", gSettings.CustomEDID, 128); + devprop_add_value(device, "AAPL00,override-no-connect", gSettings.Graphics.EDID.CustomEDID.data(), 128); DBG(" AAPL00,override-no-connect: added\n"); break; } @@ -1407,10 +1407,10 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) case 0x2A03: // "Intel GMA X3100" case 0x2A12: // "Intel GMA X3100" case 0x2A13: // "Intel GMA X3100" - if ((gSettings.DualLink == 0) || (gSettings.DualLink == 1)) { - if (gSettings.DualLink == 1) { + if ((gSettings.Graphics.DualLink == 0) || (gSettings.Graphics.DualLink == 1)) { + if (gSettings.Graphics.DualLink == 1) { DBG(" DualLink: set to 1\n"); - devprop_add_value(device, "AAPL01,DualLink", (UINT8*)&gSettings.DualLink, 1); + devprop_add_value(device, "AAPL01,DualLink", (UINT8*)&gSettings.Graphics.DualLink, 1); DBG(" AAPL01,DualLink = 1\n"); } else { DBG(" DualLink: set to 0\n"); @@ -1435,10 +1435,10 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) } break; default: - if ((gSettings.DualLink == 0) || (gSettings.DualLink == 1)) { - if (gSettings.DualLink == 1) { + if ((gSettings.Graphics.DualLink == 0) || (gSettings.Graphics.DualLink == 1)) { + if (gSettings.Graphics.DualLink == 1) { DBG(" DualLink: set to 1\n"); - devprop_add_value(device, "AAPL00,DualLink", (UINT8*)&gSettings.DualLink, 1); + devprop_add_value(device, "AAPL00,DualLink", (UINT8*)&gSettings.Graphics.DualLink, 1); DBG(" AAPL00,DualLink = 1\n"); } else { DBG(" DualLink: set to 0\n"); @@ -1484,18 +1484,18 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) case 0x0116: // "Intel HD Graphics 3000" case 0x0122: // "Intel HD Graphics 3000" case 0x0126: // "Intel HD Graphics 3000" - if (gSettings.IgPlatform != 0) { - devprop_add_value(device, "AAPL,snb-platform-id", (UINT8*)&gSettings.IgPlatform, 4); - MsgLog(" snb-platform-id = 0x%08x\n", gSettings.IgPlatform); + if (gSettings.Graphics.IgPlatform != 0) { + devprop_add_value(device, "AAPL,snb-platform-id", (UINT8*)&gSettings.Graphics.IgPlatform, 4); + MsgLog(" snb-platform-id = 0x%08x\n", gSettings.Graphics.IgPlatform); SetSnb = TRUE; } else { DBG(" snb-platform-id: not set\n"); } break; default: - if (gSettings.IgPlatform != 0) { - devprop_add_value(device, "AAPL,ig-platform-id", (UINT8*)&gSettings.IgPlatform, 4); - MsgLog(" ig-platform-id = 0x%08x\n", gSettings.IgPlatform); + if (gSettings.Graphics.IgPlatform != 0) { + devprop_add_value(device, "AAPL,ig-platform-id", (UINT8*)&gSettings.Graphics.IgPlatform, 4); + MsgLog(" ig-platform-id = 0x%08x\n", gSettings.Graphics.IgPlatform); SetIg = TRUE; } else { DBG(" ig-platform-id: not set\n"); @@ -1912,7 +1912,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) break; } } - switch (gSettings.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x00030030: case (UINT32)0x00050000: break; @@ -2036,7 +2036,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) } break; } - switch (gSettings.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x01620006: case (UINT32)0x01620007: break; @@ -2197,7 +2197,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) break; } } - switch (gSettings.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x04120004: case (UINT32)0x0412000B: break; @@ -2514,7 +2514,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) } break; } - switch (gSettings.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x19020001: case (UINT32)0x19120001: case (UINT32)0x19170001: @@ -2872,7 +2872,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) } break; } - switch (gSettings.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x59120003: case (UINT32)0x59180002: break; @@ -3119,7 +3119,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) } break; } - switch (gSettings.IgPlatform) { + switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x3E910003: case (UINT32)0x3E920003: case (UINT32)0x3E980003: @@ -3287,7 +3287,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) default: break; } - /*switch (gSettings.IgPlatform) { + /*switch (gSettings.Graphics.IgPlatform) { case (UINT32)0x5A510003: case (UINT32)0x5A520003: break; diff --git a/rEFIt_UEFI/Platform/nvidia.cpp b/rEFIt_UEFI/Platform/nvidia.cpp index e7e6d4885..f385ba7b0 100644 --- a/rEFIt_UEFI/Platform/nvidia.cpp +++ b/rEFIt_UEFI/Platform/nvidia.cpp @@ -2012,14 +2012,14 @@ static INT32 patch_nvidia_rom(UINT8 *rom) return (has_lvds ? PATCH_ROM_SUCCESS_HAS_LVDS : PATCH_ROM_SUCCESS); } -CONST CHAR8 *get_nvidia_model(UINT32 device_id, UINT32 subsys_id, const CARDLIST * nvcard) +CONST CHAR8 *get_nvidia_model(UINT32 device_id, UINT32 subsys_id, const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD * nvcard) { UINTN i, j; //DBG("get_nvidia_model for (%08X, %08X)\n", device_id, subsys_id); //ErmaC added selector for nVidia "old" style in System Profiler - //DBG("NvidiaGeneric = %ls\n", gSettings.NvidiaGeneric?L"YES":L"NO"); - if (gSettings.NvidiaGeneric == FALSE) { + //DBG("NvidiaGeneric = %ls\n", gSettings.Graphics.NvidiaGeneric?L"YES":L"NO"); + if (gSettings.Graphics.NvidiaGeneric == FALSE) { // First check in the plist, (for e.g this can override any hardcoded devices) //CARDLIST * nvcard = FindCardWithIds(device_id, subsys_id); if (nvcard && (nvcard->Id == device_id) && (nvcard->SubId == subsys_id)) { @@ -2042,7 +2042,7 @@ CONST CHAR8 *get_nvidia_model(UINT32 device_id, UINT32 subsys_id, const CARDLIST if (nvidia_card_generic[i].device == device_id) { //-- //ErmaC added selector for nVidia "old" style in System Profiler - if (gSettings.NvidiaGeneric) { + if (gSettings.Graphics.NvidiaGeneric) { DBG("Apply NvidiaGeneric\n"); snprintf(generic_name, 128, "NVIDIA %s", nvidia_card_generic[i].name_model); return &generic_name[0]; // generic_name; @@ -2094,9 +2094,9 @@ static INT32 devprop_add_nvidia_template(DevPropDevice *device, INTN n_ports) snprintf(nkey, 24, "@%lld,display-cfg", pnum); if (pnum == 0) { - devprop_add_value(device, nkey, (gSettings.Dcfg[0] != 0) ? &gSettings.Dcfg[0] : default_dcfg_0, DCFG0_LEN); + devprop_add_value(device, nkey, (gSettings.Graphics.Dcfg[0] != 0) ? &gSettings.Graphics.Dcfg[0] : default_dcfg_0, DCFG0_LEN); } else { - devprop_add_value(device, nkey, (gSettings.Dcfg[1] != 0) ? &gSettings.Dcfg[4] : default_dcfg_1, DCFG1_LEN); + devprop_add_value(device, nkey, (gSettings.Graphics.Dcfg[1] != 0) ? &gSettings.Graphics.Dcfg[4] : default_dcfg_1, DCFG1_LEN); } } @@ -2182,7 +2182,7 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev) EFI_STATUS Status = EFI_NOT_FOUND; DevPropDevice *device = NULL; XString8 devicepath; - BOOLEAN load_vbios = gSettings.LoadVBios; + BOOLEAN load_vbios = gSettings.Graphics.LoadVBios; BOOLEAN Injected = FALSE; UINT8 *rom = NULL; UINT16 nvCardType = 0; @@ -2201,7 +2201,7 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev) XString8 version_str; BOOLEAN RomAssigned = FALSE; UINT32 device_id, subsys_id; - const CARDLIST *nvcard; + const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD *nvcard; devicepath = get_pci_dev_path(nvda_dev); bar[0] = pci_config_read32(nvda_dev, PCI_BASE_ADDRESS_0); @@ -2229,14 +2229,14 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev) } else { // Amount of VRAM in Mb - if (gSettings.VRAM != 0) { - videoRam = gSettings.VRAM << 20; + if (gSettings.Graphics.VRAM != 0) { + videoRam = gSettings.Graphics.VRAM << 20; } else { videoRam = mem_detect(nvCardType, nvda_dev); } } - if (gSettings.NvidiaGeneric) { + if (gSettings.Graphics.NvidiaGeneric) { // Get Model from the PCI // model = get_nvidia_model(((nvda_dev->vendor_id << 16) | nvda_dev->device_id), subsystem); if (model == NULL) { // !nvcard->Model @@ -2409,20 +2409,20 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev) DBG("Nvidia: VideoPorts:"); if (n_ports > 0) { DBG(" user defined (GUI-menu): %llu\n", n_ports); - } else if (gSettings.VideoPorts > 0) { - n_ports = gSettings.VideoPorts; + } else if (gSettings.Graphics.VideoPorts > 0) { + n_ports = gSettings.Graphics.VideoPorts; DBG(" user defined from config.plist: %llu\n", n_ports); } else { n_ports = 2; //default DBG(" undefined, default to: %llu\n", n_ports); } - if (gSettings.NvidiaNoEFI) { + if (gSettings.Graphics.NvidiaNoEFI) { devprop_add_value(device, "NVDA,noEFI", (UINT8*)"true", 5); } //There are custom properties, injected if set by user - if (gSettings.NvidiaSingle && (devices_number >=1)) { + if (gSettings.Graphics.NvidiaSingle && (devices_number >=1)) { DBG("NVidia: NvidiaSingle :: skip injecting other then first card\n"); goto done; } @@ -2458,26 +2458,26 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev) devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4); } - if (gSettings.NVCAP[0] != 0) { - devprop_add_value(device, "NVCAP", &gSettings.NVCAP[0], NVCAP_LEN); + if (gSettings.Graphics.NVCAP[0] != 0) { + devprop_add_value(device, "NVCAP", &gSettings.Graphics.NVCAP[0], NVCAP_LEN); DBG("set NVCAP: %02hhX%02hhX%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX\n", - gSettings.NVCAP[0], gSettings.NVCAP[1], gSettings.NVCAP[2], gSettings.NVCAP[3], - gSettings.NVCAP[4], gSettings.NVCAP[5], gSettings.NVCAP[6], gSettings.NVCAP[7], - gSettings.NVCAP[8], gSettings.NVCAP[9], gSettings.NVCAP[10], gSettings.NVCAP[11], - gSettings.NVCAP[12], gSettings.NVCAP[13], gSettings.NVCAP[14], gSettings.NVCAP[15], - gSettings.NVCAP[16], gSettings.NVCAP[17], gSettings.NVCAP[18], gSettings.NVCAP[19]); + gSettings.Graphics.NVCAP[0], gSettings.Graphics.NVCAP[1], gSettings.Graphics.NVCAP[2], gSettings.Graphics.NVCAP[3], + gSettings.Graphics.NVCAP[4], gSettings.Graphics.NVCAP[5], gSettings.Graphics.NVCAP[6], gSettings.Graphics.NVCAP[7], + gSettings.Graphics.NVCAP[8], gSettings.Graphics.NVCAP[9], gSettings.Graphics.NVCAP[10], gSettings.Graphics.NVCAP[11], + gSettings.Graphics.NVCAP[12], gSettings.Graphics.NVCAP[13], gSettings.Graphics.NVCAP[14], gSettings.Graphics.NVCAP[15], + gSettings.Graphics.NVCAP[16], gSettings.Graphics.NVCAP[17], gSettings.Graphics.NVCAP[18], gSettings.Graphics.NVCAP[19]); } - if (gSettings.InjectEDID && gSettings.CustomEDID) { - devprop_add_value(device, "AAPL00,override-no-connect", gSettings.CustomEDID, 128); + if (gSettings.Graphics.EDID.InjectEDID && gSettings.Graphics.EDID.CustomEDID.notEmpty()) { + devprop_add_value(device, "AAPL00,override-no-connect", gSettings.Graphics.EDID.CustomEDID.data(), 128); } if ((devices_number == 1) && - ((gSettings.BootDisplay >= 0) && (gSettings.BootDisplay < (INT8)n_ports))) { + ((gSettings.Graphics.BootDisplay >= 0) && (gSettings.Graphics.BootDisplay < (INT8)n_ports))) { CHAR8 nkey[24]; - snprintf(nkey, 24, "@%d,AAPL,boot-display", gSettings.BootDisplay); + snprintf(nkey, 24, "@%d,AAPL,boot-display", gSettings.Graphics.BootDisplay); devprop_add_value(device, nkey, (UINT8*)&boot_display, 4); - DBG("Nvidia: BootDisplay: %d\n", gSettings.BootDisplay); + DBG("Nvidia: BootDisplay: %d\n", gSettings.Graphics.BootDisplay); } //there are default or calculated properties, can be skipped @@ -2486,11 +2486,11 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev) // goto done; //} - if (gSettings.BootDisplay < 0) { + if (gSettings.Graphics.BootDisplay < 0) { // if not set this is default property devprop_add_value(device, "@0,AAPL,boot-display", (UINT8*)&boot_display, 4); }/* else { - DBG("Nvidia: BootDisplay: %hhX\n", gSettings.BootDisplay); + DBG("Nvidia: BootDisplay: %hhX\n", gSettings.Graphics.BootDisplay); }*/ if (gSettings.UseIntelHDMI) { diff --git a/rEFIt_UEFI/Platform/nvidia.h b/rEFIt_UEFI/Platform/nvidia.h index 0510d0838..d7d2715a6 100644 --- a/rEFIt_UEFI/Platform/nvidia.h +++ b/rEFIt_UEFI/Platform/nvidia.h @@ -186,7 +186,7 @@ CONST CHAR8 *get_nvidia_model ( UINT32 device_id, UINT32 subsys_id, - const CARDLIST * nvcard + const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD * nvcard ); #endif /* !__LIBSAIO_NVIDIA_H */ diff --git a/rEFIt_UEFI/Platform/platformdata.cpp b/rEFIt_UEFI/Platform/platformdata.cpp index ae9d0b977..2ad396a19 100644 --- a/rEFIt_UEFI/Platform/platformdata.cpp +++ b/rEFIt_UEFI/Platform/platformdata.cpp @@ -1400,20 +1400,20 @@ void GetDefaultSettings() //default values will be overritten by config.plist //use explicitly settings TRUE or FALSE (Yes or No) - gSettings.InjectIntel = (gGraphics[0].Vendor == Intel) || (gGraphics[1].Vendor == Intel); + gSettings.Graphics.InjectAsDict.InjectIntel = (gGraphics[0].Vendor == Intel) || (gGraphics[1].Vendor == Intel); - gSettings.InjectATI = (((gGraphics[0].Vendor == Ati) && ((gGraphics[0].DeviceID & 0xF000) != 0x6000)) || + gSettings.Graphics.InjectAsDict.InjectATI = (((gGraphics[0].Vendor == Ati) && ((gGraphics[0].DeviceID & 0xF000) != 0x6000)) || ((gGraphics[1].Vendor == Ati) && ((gGraphics[1].DeviceID & 0xF000) != 0x6000))); - gSettings.InjectNVidia = (((gGraphics[0].Vendor == Nvidia) && (gGraphics[0].Family < 0xE0)) || + gSettings.Graphics.InjectAsDict.InjectNVidia = (((gGraphics[0].Vendor == Nvidia) && (gGraphics[0].Family < 0xE0)) || ((gGraphics[1].Vendor == Nvidia) && (gGraphics[1].Family < 0xE0))); - gSettings.GraphicsInjector = gSettings.InjectATI || gSettings.InjectNVidia; - CopyMem(gSettings.NVCAP, default_NVCAP, 20); - CopyMem(gSettings.Dcfg, default_dcfg_0, 4); - CopyMem(&gSettings.Dcfg[4], default_dcfg_1, 4); - //gSettings.CustomEDID = NULL; //no sense to assign 0 as the structure is zeroed - gSettings.DualLink = 0xA; // A(auto): DualLink auto-detection +// gSettings.GraphicsInjector = gSettings.InjectATI || gSettings.InjectNVidia; + CopyMem(gSettings.Graphics.NVCAP, default_NVCAP, 20); + CopyMem(gSettings.Graphics.Dcfg, default_dcfg_0, 4); + CopyMem(&gSettings.Graphics.Dcfg[4], default_dcfg_1, 4); + //gSettings.Graphics.EDID.CustomEDID = NULL; //no sense to assign 0 as the structure is zeroed + gSettings.Graphics.DualLink = 0xA; // A(auto): DualLink auto-detection gSettings.HDAInjection = FALSE; //gSettings.HDALayoutId = 0; gSettings.USBInjection = TRUE; // enabled by default to have the same behavior as before @@ -1424,14 +1424,14 @@ void GetDefaultSettings() gSettings.SmUUID = nullGuid; gSettings.DefaultBackgroundColor = 0x80000000; //the value to delete the variable - gSettings.RtROM.setEmpty(); - gSettings.CsrActiveConfig = 0xFFFF; - gSettings.BooterConfig = 0; -// MemSet(gSettings.BooterCfgStr, 64, 0); -// AsciiStrCpyS(gSettings.BooterCfgStr, 64, "log=0"); + GlobalConfig.RtROM.setEmpty(); + gSettings.RtVariables.CsrActiveConfig = 0xFFFF; + gSettings.RtVariables.BooterConfig = 0; +// MemSet(gSettings.RtVariables.BooterCfgStr, 64, 0); +// AsciiStrCpyS(gSettings.RtVariables.BooterCfgStr, 64, "log=0"); CHAR8 *OldCfgStr = (__typeof__(OldCfgStr))GetNvramVariable(L"bootercfg", &gEfiAppleBootGuid, NULL, NULL); if (OldCfgStr) { - gSettings.BooterCfgStr.takeValueFrom(OldCfgStr); + gSettings.RtVariables.BooterCfgStr.takeValueFrom(OldCfgStr); FreePool(OldCfgStr); } gSettings.Boot.DisableCloverHotkeys = FALSE; @@ -1468,7 +1468,7 @@ void GetDefaultCpuSettings() //gSettings.ACPI.SSDT.DropSSDT = TRUE; //why drop all??? gSettings.ACPI.SSDT._C3Latency = 0x00FA; } - gSettings.CPU.Turbo = gCPUStructure.Turbo; +// gSettings.CPU.Turbo = gCPUStructure.Turbo; gSettings.CPU.SavingMode = 0xFF; //means not set if (gCPUStructure.Model >= CPU_MODEL_SKYLAKE_D) { diff --git a/rEFIt_UEFI/cpp_foundation/XArray.h b/rEFIt_UEFI/cpp_foundation/XArray.h index 5a94906e1..752e065c5 100755 --- a/rEFIt_UEFI/cpp_foundation/XArray.h +++ b/rEFIt_UEFI/cpp_foundation/XArray.h @@ -12,6 +12,7 @@ #define __XARRAY_H__ #include +#include "XToolsCommon.h" #if 0 @@ -57,19 +58,27 @@ class XArray //-------------------------------------------------- - const TYPE& ElementAt(size_t nIndex) const; - TYPE& ElementAt(size_t nIndex); - const TYPE& ElementAt(int nIndex) const; - TYPE& ElementAt(int nIndex); + template + const TYPE& ElementAt(IntegralType index) const + { + #ifdef DEBUG + if ( index < 0 ) { + panic("XArray::ElementAt(int) -> Operator [] : index < 0"); + } + if ( (unsigned int)index >= m_len ) { // cast safe, index > 0 + panic("XArray::ElementAt(int) -> Operator [] : index > m_len"); + } + #endif + return m_data[index]; + } + template + TYPE& ElementAt(IntegralType index) { return const_cast(const_cast*>(this)->ElementAt(index)); } + + template + const TYPE &operator[](IntegralType nIndex) const { return ElementAt(nIndex); } + template + TYPE &operator[](IntegralType nIndex) { return ElementAt(nIndex); } -// const TYPE& operator[](size_t nIndex) const { return ElementAt(nIndex); } -// TYPE& operator[](size_t nIndex) { return ElementAt(nIndex); } -// const TYPE& operator[]( int nIndex) const { return ElementAt(nIndex); } - TYPE& operator[]( int nIndex) { return ElementAt(nIndex); } -// const TYPE& operator[]( unsigned long long nIndex) const { return ElementAt((size_t)nIndex); } -// const TYPE& operator[]( long long nIndex) const { return ElementAt((size_t)nIndex); } - TYPE& operator[]( unsigned long long nIndex) { return ElementAt((size_t)nIndex); } - TYPE& operator[]( long long nIndex) { return ElementAt((size_t)nIndex); } operator const void *() const { return m_data; }; operator void *() { return m_data; }; @@ -214,60 +223,6 @@ void XArray::setSize(size_t l) } -/* ElementAt() */ -template -TYPE &XArray::ElementAt(size_t index) -{ - #ifdef DEBUG - if ( index >= m_len ) { - panic("XArray::ElementAt(size_t) -> Operator [] : index > m_len"); - } - #endif - return m_data[index]; -} - -/* ElementAt() */ -template -const TYPE& XArray::ElementAt(size_t index) const -{ - #ifdef DEBUG - if ( index >= m_len ) { - panic("XArray::ElementAt(size_t) const -> Operator [] : index > m_len"); - } - #endif - return m_data[index]; -} - -/* ElementAt() */ -template -TYPE &XArray::ElementAt(int index) -{ - #ifdef DEBUG - if ( index < 0 ) { - panic("XArray::ElementAt(int) -> Operator [] : index < 0"); - } - if ( (unsigned int)index >= m_len ) { // cast safe, index > 0 - panic("XArray::ElementAt(int) -> Operator [] : index > m_len"); - } - #endif - return m_data[index]; -} - -/* ElementAt() */ -template -const TYPE& XArray::ElementAt(int index) const -{ - #ifdef DEBUG - if ( index < 0 ) { - panic("XArray::ElementAt(int) const -> Operator [] : index < 0"); - } - if ( (unsigned int)index >= m_len ) { // cast ok as index > 0. Ideally cast would be like '(unsigned __typeof__(index))' - panic("XArray::ElementAt(int) const -> Operator [] : index > m_len"); - } - #endif - return m_data[index]; -} - /* Add(size_t) */ template size_t XArray::AddUninitialized(size_t count) diff --git a/rEFIt_UEFI/cpp_foundation/XObjArray.h b/rEFIt_UEFI/cpp_foundation/XObjArray.h index 1ffe4f9fa..d13162079 100755 --- a/rEFIt_UEFI/cpp_foundation/XObjArray.h +++ b/rEFIt_UEFI/cpp_foundation/XObjArray.h @@ -34,7 +34,7 @@ class XObjArrayEntry template class XObjArrayNC { - public: + protected: XObjArrayEntry *_Data; size_t _Len; size_t m_allocatedSize; diff --git a/rEFIt_UEFI/cpp_lib/undefinable.h b/rEFIt_UEFI/cpp_lib/undefinable.h index 17ecf14e8..13bc6ee7d 100644 --- a/rEFIt_UEFI/cpp_lib/undefinable.h +++ b/rEFIt_UEFI/cpp_lib/undefinable.h @@ -28,7 +28,7 @@ public: } const T& dgetValue() const { return m_value; } // if !m_defined, m_value = T() - operator const T&() const { + explicit operator const T&() const { if ( !isDefined() ) panic("get value of an undefined undefinable type"); return m_value; } @@ -43,6 +43,8 @@ class undefinable_bool : public undefinable { using super = undefinable; public: + undefinable_bool() { } + undefinable_bool(bool newValue) { super::operator=(newValue); } undefinable_bool& operator = (bool newValue) { super::operator=(newValue); return *this; } }; @@ -50,6 +52,8 @@ class undefinable_uint16 : public undefinable { using super = undefinable; public: + undefinable_uint16() { } + undefinable_uint16(uint32_t newValue) { super::operator=(newValue); } undefinable_uint16& operator = (uint16_t newValue) { super::operator=(newValue); return *this; } }; @@ -57,6 +61,8 @@ class undefinable_uint32 : public undefinable { using super = undefinable; public: + undefinable_uint32() { } + undefinable_uint32(uint32_t newValue) { super::operator=(newValue); } undefinable_uint32& operator = (uint32_t newValue) { super::operator=(newValue); return *this; } }; diff --git a/rEFIt_UEFI/entry_scan/loader.cpp b/rEFIt_UEFI/entry_scan/loader.cpp index 0c0a68547..f4e02d377 100644 --- a/rEFIt_UEFI/entry_scan/loader.cpp +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -898,7 +898,7 @@ void LOADER_ENTRY::AddDefaultMenu() // SubScreen->AddMenuCheck("Disable AppleALC (-alcoff)", OPT_APPLEALC, 68); // SubScreen->AddMenuCheck("Disable Shiki (-shikioff)", OPT_SHIKI, 68); - if (gSettings.CsrActiveConfig == 0) { + if (gSettings.RtVariables.CsrActiveConfig == 0) { SubScreen->AddMenuCheck("No SIP", OSFLAG_NOSIP, 69); } diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index 4eda6468f..d6bdf6837 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -512,7 +512,7 @@ void LOADER_ENTRY::FilterBootPatches() /* void ReadSIPCfg() { - UINT32 csrCfg = gSettings.CsrActiveConfig & CSR_VALID_FLAGS; + UINT32 csrCfg = gSettings.RtVariables.CsrActiveConfig & CSR_VALID_FLAGS; CHAR16 *csrLog = (__typeof__(csrLog))AllocateZeroPool(SVALUE_MAX_SIZE); if (csrCfg & CSR_ALLOW_UNTRUSTED_KEXTS) @@ -559,12 +559,12 @@ NullConOutOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *, IN CONST CHAR16 *) void CheckEmptyFB() { - BOOLEAN EmptyFB = (gSettings.IgPlatform == 0x00050000) || - (gSettings.IgPlatform == 0x01620007) || - (gSettings.IgPlatform == 0x04120004) || - (gSettings.IgPlatform == 0x19120001) || - (gSettings.IgPlatform == 0x59120003) || - (gSettings.IgPlatform == 0x3E910003); + BOOLEAN EmptyFB = (gSettings.Graphics.IgPlatform == 0x00050000) || + (gSettings.Graphics.IgPlatform == 0x01620007) || + (gSettings.Graphics.IgPlatform == 0x04120004) || + (gSettings.Graphics.IgPlatform == 0x19120001) || + (gSettings.Graphics.IgPlatform == 0x59120003) || + (gSettings.Graphics.IgPlatform == 0x3E910003); if (EmptyFB) { gPlatformFeature |= PT_FEATURE_HAS_HEADLESS_GPU; } else { @@ -1329,8 +1329,8 @@ void LOADER_ENTRY::StartLoader() if ( macOSVersion >= MacOsVersion("10.11"_XS8) ) { if (OSFLAG_ISSET(Flags, OSFLAG_NOSIP)) { - gSettings.CsrActiveConfig = (UINT32)0xB7F; - gSettings.BooterConfig = 0x28; + gSettings.RtVariables.CsrActiveConfig = (UINT32)0xB7F; + gSettings.RtVariables.BooterConfig = 0x28; } // ReadSIPCfg(); } @@ -2083,11 +2083,11 @@ void DisconnectSomeDevices(void) void PatchVideoBios(UINT8 *Edid) { - if (gSettings.PatchVBiosBytesCount > 0 && gSettings.PatchVBiosBytes != NULL) { - VideoBiosPatchBytes(gSettings.PatchVBiosBytes, gSettings.PatchVBiosBytesCount); + if ( gSettings.Graphics.PatchVBiosBytesNew.notEmpty() ) { + VideoBiosPatchBytes(gSettings.Graphics.PatchVBiosBytesNew.getVBIOS_PATCH_BYTES(), gSettings.Graphics.PatchVBiosBytesNew.getVBIOS_PATCH_BYTES_count()); } - if (gSettings.PatchVBios) { + if (gSettings.Graphics.PatchVBios) { VideoBiosPatchNativeFromEdid(Edid); } } @@ -2122,7 +2122,7 @@ static void LoadDrivers(void) ScanDriverDir(L"drivers32", &DriversToConnect, &DriversToConnectNum); #endif - VBiosPatchNeeded = gSettings.PatchVBios || (gSettings.PatchVBiosBytesCount > 0 && gSettings.PatchVBiosBytes != NULL); + VBiosPatchNeeded = gSettings.Graphics.PatchVBios || gSettings.Graphics.PatchVBiosBytesNew.getVBIOS_PATCH_BYTES_count() > 0; if (VBiosPatchNeeded) { // check if it is already done in CloverEFI BiosVideo Status = gRT->GetVariable ( @@ -2138,7 +2138,7 @@ static void LoadDrivers(void) } } - if (((gSettings.CustomEDID != NULL) && gFirmwareClover) || (VBiosPatchNeeded && !gDriversFlags.VideoLoaded)) { + if ( (gSettings.Graphics.EDID.CustomEDID.notEmpty() && gFirmwareClover) || (VBiosPatchNeeded && !gDriversFlags.VideoLoaded)) { // we have video bios patch - force video driver reconnect DBG("Video bios patch requested or CustomEDID - forcing video reconnect\n"); gDriversFlags.VideoLoaded = TRUE; @@ -2152,14 +2152,14 @@ static void LoadDrivers(void) // will use DriversToConnect - do not release it RegisterDriversToHighestPriority(DriversToConnect); if (VBiosPatchNeeded) { - if (gSettings.CustomEDID != NULL) { - Edid = gSettings.CustomEDID; + if (gSettings.Graphics.EDID.CustomEDID.notEmpty()) { + Edid = gSettings.Graphics.EDID.CustomEDID.data(); } else { Edid = getCurrentEdid(); } DisconnectSomeDevices(); PatchVideoBios(Edid); - if (gSettings.CustomEDID == NULL) { + if (gSettings.Graphics.EDID.CustomEDID.isEmpty()) { FreePool(Edid); } } else { @@ -2623,7 +2623,7 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings) GlobalConfig.HWP = TRUE; AsmWriteMsr64 (MSR_IA32_PM_ENABLE, 1); if ( gSettings.CPU.HWPValue.isDefined() ) { - AsmWriteMsr64 (MSR_IA32_HWP_REQUEST, gSettings.CPU.HWPValue); + AsmWriteMsr64 (MSR_IA32_HWP_REQUEST, gSettings.CPU.HWPValue.value()); } } @@ -2686,9 +2686,9 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings) GlobalConfig.CodepageSize = 0x100; } - if (gSettings.InjectEDID){ + if (gSettings.Graphics.EDID.InjectEDID){ //DBG("Inject EDID\n"); - if ( gSettings.CustomEDIDsize > 0 && gSettings.CustomEDIDsize % 128 == 0 ) { + if ( gSettings.Graphics.EDID.CustomEDID.size() > 0 && gSettings.Graphics.EDID.CustomEDID.size() % 128 == 0 ) { InitializeEdidOverride(); } } @@ -2696,6 +2696,32 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings) GlobalConfig.KPKernelPm = gSettings.KernelAndKextPatches._KPKernelPm || GlobalConfig.NeedPMfix; GlobalConfig.KPAppleIntelCPUPM = gSettings.KernelAndKextPatches._KPAppleIntelCPUPM || GlobalConfig.NeedPMfix; + if ( gSettings.RtVariables.RtROMAsString.equalIC("UseMacAddr0") ) { + GlobalConfig.RtROM.ncpy(&gLanMac[0][0], 6); + } else if ( gSettings.RtVariables.RtROMAsString.equalIC("UseMacAddr1") ) { + GlobalConfig.RtROM.ncpy(&gLanMac[1][0], 6); + }else{ + GlobalConfig.RtROM = gSettings.RtVariables.RtROMAsData; + } + if ( GlobalConfig.RtROM.isEmpty() ) { + EFI_GUID uuid; + StrToGuidLE(gSettings.SmUUID, &uuid); + GlobalConfig.RtROM.ncpy(&uuid.Data4[2], 6); + } + GlobalConfig.RtMLB = gSettings.RtVariables.RtMLBSetting; + if ( GlobalConfig.RtMLB.isEmpty() ) { + GlobalConfig.RtMLB = gSettings.BoardSerialNumber; + } + + for (size_t i = 0; i < NGFX; i++) { + gGraphics[i].LoadVBios = gSettings.Graphics.LoadVBios; //default + } + + if ( gSettings.CPU.TurboDisabled ) { + GlobalConfig.Turbo = false; + }else{ + GlobalConfig.Turbo = gCPUStructure.Turbo; + } } #pragma GCC diagnostic pop diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index 11de2fddc..9d2ed148e 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -177,7 +177,7 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = BoolValue; //15 InputItems[InputItemsCount++].BValue = gSettings.ACPI.PatchNMI; InputItems[InputItemsCount].ItemType = BoolValue; //16 - InputItems[InputItemsCount++].BValue = gSettings.PatchVBios; + InputItems[InputItemsCount++].BValue = gSettings.Graphics.PatchVBios; InputItems[InputItemsCount].ItemType = Decimal; //17 InputItems[InputItemsCount++].SValue.SWPrintf("0x%llX", gPlatformFeature); InputItems[InputItemsCount].ItemType = Hex; //18 @@ -195,35 +195,35 @@ void FillInputs(BOOLEAN New) if (gGraphics[i].Vendor == Ati) { InputItems[InputItemsCount].ItemType = BoolValue; //21+i*6 - InputItems[InputItemsCount++].BValue = gSettings.InjectATI; + InputItems[InputItemsCount++].BValue = gSettings.Graphics.InjectAsDict.InjectATI; InputItems[InputItemsCount].ItemType = ASString; //22+6i - if ( gSettings.FBName.length() > 2 ) { //fool proof: cfg_name is 3 character or more. - InputItems[InputItemsCount++].SValue.SWPrintf("%ls", gSettings.FBName.wc_str()); + if ( gSettings.Graphics.FBName.length() > 2 ) { //fool proof: cfg_name is 3 character or more. + InputItems[InputItemsCount++].SValue.SWPrintf("%ls", gSettings.Graphics.FBName.wc_str()); } else { InputItems[InputItemsCount++].SValue.SWPrintf("%s", gGraphics[i].Config); } } else if (gGraphics[i].Vendor == Nvidia) { InputItems[InputItemsCount].ItemType = BoolValue; //21+i*6 - InputItems[InputItemsCount++].BValue = gSettings.InjectNVidia; + InputItems[InputItemsCount++].BValue = gSettings.Graphics.InjectAsDict.InjectNVidia; InputItems[InputItemsCount].ItemType = ASString; //22+6i for (j=0; j<8; j++) { - snprintf((CHAR8*)&tmp[2*j], 3, "%02hhX", gSettings.Dcfg[j]); + snprintf((CHAR8*)&tmp[2*j], 3, "%02hhX", gSettings.Graphics.Dcfg[j]); } InputItems[InputItemsCount++].SValue.SWPrintf("%s", tmp); - //InputItems[InputItemsCount++].SValue = P__oolPrint(L"%08x",*(UINT64*)&gSettings.Dcfg[0]); + //InputItems[InputItemsCount++].SValue = P__oolPrint(L"%08x",*(UINT64*)&gSettings.Graphics.Dcfg[0]); } else /*if (gGraphics[i].Vendor == Intel) */ { InputItems[InputItemsCount].ItemType = BoolValue; //21+i*6 - InputItems[InputItemsCount++].BValue = gSettings.InjectIntel; + InputItems[InputItemsCount++].BValue = gSettings.Graphics.InjectAsDict.InjectIntel; InputItems[InputItemsCount].ItemType = Hex; //22+6i - InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.IgPlatform); + InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Graphics.IgPlatform); // InputItemsCount += 3; // continue; } InputItems[InputItemsCount].ItemType = Decimal; //23+6i - if (gSettings.VideoPorts > 0) { - InputItems[InputItemsCount++].SValue.SWPrintf("%02d", gSettings.VideoPorts); + if (gSettings.Graphics.VideoPorts > 0) { + InputItems[InputItemsCount++].SValue.SWPrintf("%02d", gSettings.Graphics.VideoPorts); } else { InputItems[InputItemsCount++].SValue.SWPrintf("%02d", gGraphics[i].Ports); } @@ -231,7 +231,7 @@ void FillInputs(BOOLEAN New) if (gGraphics[i].Vendor == Nvidia) { InputItems[InputItemsCount].ItemType = ASString; //24+6i for (j=0; j<20; j++) { - snprintf((CHAR8*)&tmp[2*j], 3, "%02hhX", gSettings.NVCAP[j]); + snprintf((CHAR8*)&tmp[2*j], 3, "%02hhX", gSettings.Graphics.NVCAP[j]); } InputItems[InputItemsCount++].SValue.SWPrintf("%s", tmp); } else { //ATI and others there will be connectors @@ -259,27 +259,27 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount++].BValue = gSettings.ACPI.FixMCFG; InputItems[InputItemsCount].ItemType = Decimal; //50 - InputItems[InputItemsCount++].SValue.SWPrintf("%06d", gSettings.RefCLK); + InputItems[InputItemsCount++].SValue.SWPrintf("%06d", gSettings.Graphics.RefCLK); InputItems[InputItemsCount].ItemType = ASString; //51 OS version if non-detected InputItems[InputItemsCount++].SValue.SWPrintf("%s ", NonDetected.c_str()); InputItems[InputItemsCount].ItemType = BoolValue; //52 - InputItems[InputItemsCount++].BValue = gSettings.InjectEDID; + InputItems[InputItemsCount++].BValue = gSettings.Graphics.EDID.InjectEDID; //VendorEDID & ProductEDID 53, 54 InputItems[InputItemsCount].ItemType = Decimal; //53 - InputItems[InputItemsCount++].SValue.SWPrintf("0x%04hX", gSettings.VendorEDID); + InputItems[InputItemsCount++].SValue.SWPrintf("0x%04hX", gSettings.Graphics.EDID.VendorEDID); InputItems[InputItemsCount].ItemType = Decimal; //54 - InputItems[InputItemsCount++].SValue.SWPrintf("0x%04hX", gSettings.ProductEDID); + InputItems[InputItemsCount++].SValue.SWPrintf("0x%04hX", gSettings.Graphics.EDID.ProductEDID); // ErmaC: NvidiaGeneric menu selector y/n InputItems[InputItemsCount].ItemType = BoolValue; //55 - InputItems[InputItemsCount++].BValue = gSettings.NvidiaGeneric; + InputItems[InputItemsCount++].BValue = gSettings.Graphics.NvidiaGeneric; InputItems[InputItemsCount].ItemType = BoolValue; //56 InputItems[InputItemsCount++].BValue = gSettings.SystemParameters.NvidiaWeb; InputItems[InputItemsCount].ItemType = BoolValue; //57 - InputItems[InputItemsCount++].BValue = gSettings.ResetHDA; + InputItems[InputItemsCount++].BValue = gSettings.Devices.Audio.ResetHDA; InputItems[InputItemsCount].ItemType = BoolValue; //58 InputItems[InputItemsCount++].BValue = gSettings.AFGLowPowerState; InputItems[InputItemsCount].ItemType = BoolValue; //59 @@ -305,9 +305,9 @@ void FillInputs(BOOLEAN New) // CSR - aka System Integrity Protection configuration InputItems[InputItemsCount].ItemType = CheckBit; //65 - InputItems[InputItemsCount++].IValue = gSettings.BooterConfig; + InputItems[InputItemsCount++].IValue = gSettings.RtVariables.BooterConfig; InputItems[InputItemsCount].ItemType = CheckBit; //66 - InputItems[InputItemsCount++].IValue = gSettings.CsrActiveConfig; + InputItems[InputItemsCount++].IValue = gSettings.RtVariables.CsrActiveConfig; InputItems[InputItemsCount].ItemType = CheckBit; //67 @@ -410,12 +410,12 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount++].BValue = gSettings.KernelPatchesAllowed; InputItems[InputItemsCount].ItemType = Hex; //109 - InputItems[InputItemsCount++].SValue.SWPrintf("%01X", gSettings.DualLink); + InputItems[InputItemsCount++].SValue.SWPrintf("%01X", gSettings.Graphics.DualLink); InputItems[InputItemsCount].ItemType = BoolValue; //110 - InputItems[InputItemsCount++].BValue = gSettings.NvidiaNoEFI; + InputItems[InputItemsCount++].BValue = gSettings.Graphics.NvidiaNoEFI; InputItems[InputItemsCount].ItemType = BoolValue; //111 - InputItems[InputItemsCount++].BValue = gSettings.NvidiaSingle; + InputItems[InputItemsCount++].BValue = gSettings.Graphics.NvidiaSingle; InputItems[InputItemsCount].ItemType = Hex; //112 InputItems[InputItemsCount++].SValue.SWPrintf("0x%04X", gSettings.IntelMaxValue); @@ -423,7 +423,7 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = BoolValue; //113 InputItems[InputItemsCount++].BValue = gSettings.ACPI.AutoMerge; InputItems[InputItemsCount].ItemType = BoolValue; //114 - InputItems[InputItemsCount++].BValue = gSettings.DeInit; + InputItems[InputItemsCount++].BValue = gSettings.Graphics.RadeonDeInit; InputItems[InputItemsCount].ItemType = BoolValue; //115 InputItems[InputItemsCount++].BValue = gSettings.SystemParameters.NoCaches; InputItems[InputItemsCount].ItemType = RadioSwitch; //116 - DSDT chooser @@ -432,7 +432,7 @@ void FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = ASString; //117 InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.EfiVersion.c_str()); InputItems[InputItemsCount].ItemType = ASString; //118 - InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.BooterCfgStr.c_str()); + InputItems[InputItemsCount++].SValue.SWPrintf("%s", gSettings.RtVariables.BooterCfgStr.c_str()); InputItems[InputItemsCount].ItemType = RadioSwitch; //119 - Audio chooser InputItems[InputItemsCount++].IValue = 119; @@ -551,7 +551,7 @@ void ApplyInputs(void) } i++; //16 if (InputItems[i].Valid) { - gSettings.PatchVBios = InputItems[i].BValue; + gSettings.Graphics.PatchVBios = InputItems[i].BValue; } i++; //17 if (InputItems[i].Valid) { @@ -578,23 +578,23 @@ void ApplyInputs(void) i++; //21 if (InputItems[i].Valid) { if (gGraphics[j].Vendor == Ati) { - gSettings.InjectATI = InputItems[i].BValue; + gSettings.Graphics.InjectAsDict.InjectATI = InputItems[i].BValue; } else if (gGraphics[j].Vendor == Nvidia) { - gSettings.InjectNVidia = InputItems[i].BValue; + gSettings.Graphics.InjectAsDict.InjectNVidia = InputItems[i].BValue; } else if (gGraphics[j].Vendor == Intel) { - gSettings.InjectIntel = InputItems[i].BValue; + gSettings.Graphics.InjectAsDict.InjectIntel = InputItems[i].BValue; } } i++; //22 if (InputItems[i].Valid) { if (gGraphics[j].Vendor == Ati) { - gSettings.FBName = InputItems[i].SValue; + gSettings.Graphics.FBName = InputItems[i].SValue; } else if (gGraphics[j].Vendor == Nvidia) { - hex2bin(InputItems[i].SValue, (UINT8*)&gSettings.Dcfg[0], sizeof(gSettings.Dcfg)); + hex2bin(InputItems[i].SValue, (UINT8*)&gSettings.Graphics.Dcfg[0], sizeof(gSettings.Graphics.Dcfg)); } else if (gGraphics[j].Vendor == Intel) { //ig-platform-id for Ivy+ and snb-platform-id for Sandy - gSettings.IgPlatform = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); - DBG("applied *-platform-id=0x%X\n", gSettings.IgPlatform); + gSettings.Graphics.IgPlatform = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); + DBG("applied *-platform-id=0x%X\n", gSettings.Graphics.IgPlatform); } } @@ -611,7 +611,7 @@ void ApplyInputs(void) if (InputItems[i].Valid) { if (gGraphics[j].Vendor == Nvidia) { if ( InputItems[i].SValue.notEmpty() ) { - hex2bin(InputItems[i].SValue, (UINT8*)&gSettings.NVCAP[0], sizeof(gSettings.NVCAP)); + hex2bin(InputItems[i].SValue, (UINT8*)&gSettings.Graphics.NVCAP[0], sizeof(gSettings.Graphics.NVCAP)); } } else { gGraphics[j].Connectors = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); @@ -657,7 +657,7 @@ void ApplyInputs(void) i++; //50 if (InputItems[i].Valid) { - gSettings.RefCLK = (UINT32)StrDecimalToUintn(InputItems[i].SValue.wc_str()); + gSettings.Graphics.RefCLK = (UINT32)StrDecimalToUintn(InputItems[i].SValue.wc_str()); } i++; //51 @@ -667,20 +667,20 @@ void ApplyInputs(void) i++; //52 if (InputItems[i].Valid) { - gSettings.InjectEDID = InputItems[i].BValue; + gSettings.Graphics.EDID.InjectEDID = InputItems[i].BValue; } i++; //53 if (InputItems[i].Valid) { - gSettings.VendorEDID = (UINT16)StrHexToUint64(InputItems[i].SValue.wc_str()); + gSettings.Graphics.EDID.VendorEDID = (UINT16)StrHexToUint64(InputItems[i].SValue.wc_str()); } i++; //54 if (InputItems[i].Valid) { - gSettings.ProductEDID = (UINT16)StrHexToUint64(InputItems[i].SValue.wc_str()); + gSettings.Graphics.EDID.ProductEDID = (UINT16)StrHexToUint64(InputItems[i].SValue.wc_str()); } i++; //55 // ErmaC: NvidiaGeneric bool(Y/N) if (InputItems[i].Valid) { - gSettings.NvidiaGeneric = InputItems[i].BValue; + gSettings.Graphics.NvidiaGeneric = InputItems[i].BValue; } i++; //56 if (InputItems[i].Valid) { @@ -688,7 +688,7 @@ void ApplyInputs(void) } i++; //57 if (InputItems[i].Valid) { - gSettings.ResetHDA = InputItems[i].BValue; + gSettings.Devices.Audio.ResetHDA = InputItems[i].BValue; } i++; //58 if (InputItems[i].Valid) { @@ -728,11 +728,11 @@ void ApplyInputs(void) // CSR i = 65; if (InputItems[i].Valid) { - gSettings.BooterConfig = InputItems[i].IValue & 0x7F; + gSettings.RtVariables.BooterConfig = InputItems[i].IValue & 0x7F; } i++; //66 if (InputItems[i].Valid) { - gSettings.CsrActiveConfig = InputItems[i].IValue; + gSettings.RtVariables.CsrActiveConfig = InputItems[i].IValue; } i++; //67 @@ -967,18 +967,18 @@ void ApplyInputs(void) i++; //109 if (InputItems[i].Valid) { - gSettings.DualLink = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); - DBG("applied DualLink=%X\n", gSettings.DualLink); + gSettings.Graphics.DualLink = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); + DBG("applied DualLink=%X\n", gSettings.Graphics.DualLink); } i++; //110 if (InputItems[i].Valid) { - gSettings.NvidiaNoEFI = InputItems[i].BValue; + gSettings.Graphics.NvidiaNoEFI = InputItems[i].BValue; } i++; //111 if (InputItems[i].Valid) { - gSettings.NvidiaSingle = InputItems[i].BValue; + gSettings.Graphics.NvidiaSingle = InputItems[i].BValue; } i++; //112 if (InputItems[i].Valid) { @@ -990,7 +990,7 @@ void ApplyInputs(void) } i++; //114 if (InputItems[i].Valid) { - gSettings.DeInit = InputItems[i].BValue; + gSettings.Graphics.RadeonDeInit = InputItems[i].BValue; } i++; //115 if (InputItems[i].Valid) { @@ -1010,7 +1010,7 @@ void ApplyInputs(void) } i++; //118 if (InputItems[i].Valid) { - gSettings.BooterCfgStr = InputItems[i].SValue; + gSettings.RtVariables.BooterCfgStr = InputItems[i].SValue; } i++; //119 if (InputItems[i].Valid) { @@ -1550,14 +1550,14 @@ void ModifyTitles(REFIT_ABSTRACT_MENU_ENTRY *ChosenEntry) //MsgLog("@ESC: %ls\n", (*ChosenEntry)->Title); } else if (ChosenEntry->SubScreen->ID == SCREEN_CSR) { // CSR - ChosenEntry->Title.SWPrintf("System Integrity Protection [0x%04x]->", gSettings.CsrActiveConfig); + ChosenEntry->Title.SWPrintf("System Integrity Protection [0x%04x]->", gSettings.RtVariables.CsrActiveConfig); // check for the right booter flag to allow the application // of the new System Integrity Protection configuration. - if (gSettings.CsrActiveConfig != 0 && gSettings.BooterConfig == 0) { - gSettings.BooterConfig = 0x28; + if (gSettings.RtVariables.CsrActiveConfig != 0 && gSettings.RtVariables.BooterConfig == 0) { + gSettings.RtVariables.BooterConfig = 0x28; } } else if (ChosenEntry->SubScreen->ID == SCREEN_BLC) { - ChosenEntry->Title.SWPrintf("boot_args->flags [0x%04hx]->", gSettings.BooterConfig); + ChosenEntry->Title.SWPrintf("boot_args->flags [0x%04hx]->", gSettings.RtVariables.BooterConfig); } } @@ -2369,7 +2369,7 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuBLC() // create the entry in the main menu Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_BLC, NullXString8); -// Entry->Title.SPrintf("boot_args->flags [0x%02hhx]->", gSettings.BooterConfig); +// Entry->Title.SPrintf("boot_args->flags [0x%02hhx]->", gSettings.RtVariables.BooterConfig); // submenu description SubScreen->AddMenuInfoLine_f("Modify flags for boot.efi");