From 1ba1ba6d6cb7984019222d6c29677cb687131cd2 Mon Sep 17 00:00:00 2001 From: SergeySlice Date: Thu, 11 Nov 2021 21:58:28 +0300 Subject: [PATCH] implement ForceOcWriteFlash Signed-off-by: SergeySlice --- .../CloverV2/EFI/CLOVER/config-sample.plist | 2 + .../.settings/language.settings.xml | 69 ++++-------- .../cpp_tests/.settings/language.settings.xml | 102 ++++++------------ rEFIt_UEFI/Platform/Settings.h | 7 +- .../Settings/ConfigPlist/Config_Quirks.h | 7 +- rEFIt_UEFI/refit/main.cpp | 3 + 6 files changed, 73 insertions(+), 117 deletions(-) diff --git a/CloverPackage/CloverV2/EFI/CLOVER/config-sample.plist b/CloverPackage/CloverV2/EFI/CLOVER/config-sample.plist index b79607cb4..8e8f31c8c 100755 --- a/CloverPackage/CloverV2/EFI/CLOVER/config-sample.plist +++ b/CloverPackage/CloverV2/EFI/CLOVER/config-sample.plist @@ -1117,6 +1117,8 @@ ForceExitBootServices + ForceOcWriteFlash + MmioWhitelist diff --git a/Xcode/CloverConfigPlistValidator/.settings/language.settings.xml b/Xcode/CloverConfigPlistValidator/.settings/language.settings.xml index 283ea0745..fa4fb063a 100644 --- a/Xcode/CloverConfigPlistValidator/.settings/language.settings.xml +++ b/Xcode/CloverConfigPlistValidator/.settings/language.settings.xml @@ -1,48 +1,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Xcode/cpp_tests/.settings/language.settings.xml b/Xcode/cpp_tests/.settings/language.settings.xml index 2f0d8bad9..0a9ecc756 100644 --- a/Xcode/cpp_tests/.settings/language.settings.xml +++ b/Xcode/cpp_tests/.settings/language.settings.xml @@ -1,70 +1,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rEFIt_UEFI/Platform/Settings.h b/rEFIt_UEFI/Platform/Settings.h index 600b5edd8..cecb694e0 100755 --- a/rEFIt_UEFI/Platform/Settings.h +++ b/rEFIt_UEFI/Platform/Settings.h @@ -2047,6 +2047,7 @@ printf("%s", ""); XBool PowerTimeoutKernelPanic = false; XBool ThirdPartyDrives = false; XBool XhciPortLimit = false; + #if __cplusplus > 201703L XBool operator == (const OcKernelQuirksClass&) const = default; @@ -2064,6 +2065,7 @@ printf("%s", ""); if ( !(PowerTimeoutKernelPanic == other.PowerTimeoutKernelPanic) ) return false; if ( !(ThirdPartyDrives == other.ThirdPartyDrives) ) return false; if ( !(XhciPortLimit == other.XhciPortLimit) ) return false; + return true; } void takeValueFrom(const ConfigPlistClass::Quirks_Class::OcKernelQuirks_Class& other) @@ -2079,6 +2081,7 @@ printf("%s", ""); PowerTimeoutKernelPanic = other.dgetPowerTimeoutKernelPanic(); ThirdPartyDrives = other.dgetThirdPartyDrives(); XhciPortLimit = other.dgetXhciPortLimit(); + } }; @@ -2103,6 +2106,7 @@ printf("%s", ""); XBool SignalAppleOS = false; XBool SyncRuntimePermissions = false; int8_t ResizeAppleGpuBars = 0; // 0 is NOT the default value if not set in config.plist. Default value if not set is returned by dgetResizeAppleGpuBars() + XBool ForceOcWriteFlash = false; #if __cplusplus > 201703L XBool operator == (const OcBooterQuirksClass&) const = default; @@ -2127,7 +2131,7 @@ printf("%s", ""); if ( !(SetupVirtualMap == other.SetupVirtualMap) ) return false; if ( !(SignalAppleOS == other.SignalAppleOS) ) return false; if ( !(SyncRuntimePermissions == other.SyncRuntimePermissions) ) return false; - + if ( !(ForceOcWriteFlash == other.ForceOcWriteFlash) ) return false; return true; } void takeValueFrom(const ConfigPlistClass::Quirks_Class::OcBooterQuirks_Class& other) @@ -2150,6 +2154,7 @@ printf("%s", ""); SetupVirtualMap = other.dgetSetupVirtualMap(); SignalAppleOS = other.dgetSignalAppleOS(); SyncRuntimePermissions = other.dgetSyncRuntimePermissions(); + ForceOcWriteFlash = other.dgetForceOcWriteFlash(); } }; diff --git a/rEFIt_UEFI/Settings/ConfigPlist/Config_Quirks.h b/rEFIt_UEFI/Settings/ConfigPlist/Config_Quirks.h index 31b62a201..29e9adf2c 100755 --- a/rEFIt_UEFI/Settings/ConfigPlist/Config_Quirks.h +++ b/rEFIt_UEFI/Settings/ConfigPlist/Config_Quirks.h @@ -102,6 +102,7 @@ public: XmlBool SetupVirtualMap = XmlBool(); XmlBool SignalAppleOS = XmlBool(); XmlBool SyncRuntimePermissions = XmlBool(); + XmlBool ForceOcWriteFlash = XmlBool(); XBool dgetAvoidRuntimeDefrag() const { return parent.isDefined() ? AvoidRuntimeDefrag.isDefined() ? AvoidRuntimeDefrag.value() : XBool(true) : XBool(false); }; // TODO: different default value if section is not defined XBool dgetDevirtualiseMmio() const { return DevirtualiseMmio.isDefined() ? DevirtualiseMmio.value() : DevirtualiseMmio.nullValue; }; @@ -121,7 +122,7 @@ public: XBool dgetSignalAppleOS() const { return SignalAppleOS.isDefined() ? SignalAppleOS.value() : SignalAppleOS.nullValue; }; XBool dgetSyncRuntimePermissions() const { return parent.isDefined() ? SyncRuntimePermissions.isDefined() ? SyncRuntimePermissions.value() : XBool(true) : XBool(false); }; // TODO: different default value if section is not defined int8_t dgetResizeAppleGpuBars() const { return parent.isDefined() && ResizeAppleGpuBars.isDefined() ? ResizeAppleGpuBars.value() : -1; }; - + XBool dgetForceOcWriteFlash() const { return ForceOcWriteFlash.isDefined() ? ForceOcWriteFlash.value() : XBool(false); }; OcBooterQuirks_Class(const Quirks_Class& _parent) : parent(_parent) {} }; XmlArray MmioWhitelist = XmlArray(); @@ -133,7 +134,7 @@ public: OcKernelQuirks_Class OcKernelQuirks; OcBooterQuirks_Class OcBooterQuirks; - XmlDictField m_fields[32] = { + XmlDictField m_fields[33] = { {"AvoidRuntimeDefrag", OcBooterQuirks.AvoidRuntimeDefrag}, {"DevirtualiseMmio", OcBooterQuirks.DevirtualiseMmio}, {"DisableSingleUser", OcBooterQuirks.DisableSingleUser}, @@ -142,6 +143,7 @@ public: {"EnableSafeModeSlide", OcBooterQuirks.EnableSafeModeSlide}, {"EnableWriteUnprotector", OcBooterQuirks.EnableWriteUnprotector}, {"ForceExitBootServices", OcBooterQuirks.ForceExitBootServices}, + {"ForceOcWriteFlash", OcBooterQuirks.ForceOcWriteFlash}, {"ProtectMemoryRegions", OcBooterQuirks.ProtectMemoryRegions}, {"ProtectSecureBoot", OcBooterQuirks.ProtectSecureBoot}, {"ProtectUefiServices", OcBooterQuirks.ProtectUefiServices}, @@ -166,6 +168,7 @@ public: {"PowerTimeoutKernelPanic", OcKernelQuirks.PowerTimeoutKernelPanic}, {"ThirdPartyDrives", OcKernelQuirks.ThirdPartyDrives}, {"XhciPortLimit", OcKernelQuirks.XhciPortLimit}, + }; Quirks_Class() : OcKernelQuirks(*this), OcBooterQuirks(*this) {} diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index eeb1bef69..161c333f8 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -980,6 +980,9 @@ void LOADER_ENTRY::StartLoader() #ifdef USE_OC_SECTION_Nvram mOpenCoreConfiguration.Nvram.WriteFlash = true; #endif +#ifndef USE_OC_SECTION_Uefi + mOpenCoreConfiguration.Uefi.Quirks.ForceOcWriteFlash = gSettings.Quirks.OcBooterQuirks.ForceOcWriteFlash; +#endif #ifndef USE_OC_SECTION_Booter