From 6545450f02dab70bc18e804b4e0d9e628bd39436 Mon Sep 17 00:00:00 2001 From: jief666 Date: Mon, 5 Apr 2021 15:00:17 +0300 Subject: [PATCH] Ignore empty if device property value is empty. Ignore commented device properties in FillDevicePropertiesOld. Rename Name to acpiName. --- PosixCompilation/xcode_utf_fixed.cpp | 2 +- ...64TestNewParser UTF16 signed char.xcscheme | 90 ------------------- rEFIt_UEFI/Platform/BootLog.h | 6 ++ rEFIt_UEFI/Platform/FixBiosDsdt.cpp | 2 +- rEFIt_UEFI/Platform/Settings.cpp | 34 +++---- rEFIt_UEFI/Platform/Settings.h | 59 ++++++------ rEFIt_UEFI/PlatformEFI/include/Platform.h | 7 -- rEFIt_UEFI/PlatformPOSIX/BootLog.cpp | 10 ++- rEFIt_UEFI/PlatformPOSIX/include/Platform.h | 25 +++--- 9 files changed, 74 insertions(+), 161 deletions(-) delete mode 100644 Xcode/CloverX64TestNewParser/CloverX64TestNewParser.xcodeproj/xcshareddata/xcschemes/CloverX64TestNewParser UTF16 signed char.xcscheme diff --git a/PosixCompilation/xcode_utf_fixed.cpp b/PosixCompilation/xcode_utf_fixed.cpp index 15d5d9439..885e1b6eb 100644 --- a/PosixCompilation/xcode_utf_fixed.cpp +++ b/PosixCompilation/xcode_utf_fixed.cpp @@ -175,7 +175,7 @@ int wcsncmp_fixed(const wchar_t *s1, const wchar_t * s2, size_t n) #ifdef _LIBCPP_WCHAR_H wchar_t* wcsstr_fixed(const wchar_t* haystack, const wchar_t* needle) #else -const wchar_t* wcsstr_fixed(const wchar_t* haystack, const wchar_t* needle) +wchar_t* wcsstr_fixed(const wchar_t* haystack, const wchar_t* needle) #endif { #if __WCHAR_MAX__ >= 0x10000 diff --git a/Xcode/CloverX64TestNewParser/CloverX64TestNewParser.xcodeproj/xcshareddata/xcschemes/CloverX64TestNewParser UTF16 signed char.xcscheme b/Xcode/CloverX64TestNewParser/CloverX64TestNewParser.xcodeproj/xcshareddata/xcschemes/CloverX64TestNewParser UTF16 signed char.xcscheme deleted file mode 100644 index a632b5b07..000000000 --- a/Xcode/CloverX64TestNewParser/CloverX64TestNewParser.xcodeproj/xcshareddata/xcschemes/CloverX64TestNewParser UTF16 signed char.xcscheme +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rEFIt_UEFI/Platform/BootLog.h b/rEFIt_UEFI/Platform/BootLog.h index f10a2199d..303966b7a 100755 --- a/rEFIt_UEFI/Platform/BootLog.h +++ b/rEFIt_UEFI/Platform/BootLog.h @@ -24,6 +24,12 @@ extern "C" { //#define PREWAKE_LOG L"misc\\prewake.log" +#ifndef DEBUG_ALL +#define MsgLog(...) DebugLog(1, __VA_ARGS__) +#else +#define MsgLog(...) DebugLog(DEBUG_ALL, __VA_ARGS__) +#endif + void InitBooterLog (void); diff --git a/rEFIt_UEFI/Platform/FixBiosDsdt.cpp b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp index afc6f3857..169155f4b 100755 --- a/rEFIt_UEFI/Platform/FixBiosDsdt.cpp +++ b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp @@ -5260,7 +5260,7 @@ DBG("RenameDevices %zu\n", gSettings.ACPI.DeviceRename.size()); BOOLEAN found; for (UINTN index = 0; index < gSettings.ACPI.DeviceRename.size(); index++) { const ACPI_RENAME_DEVICE& deviceRename = gSettings.ACPI.DeviceRename[index]; - XString8Array FindList = deviceRename.Name.getSplittedName(); + XString8Array FindList = deviceRename.acpiName.getSplittedName(); XString8 Replace = deviceRename.getRenameTo(); XString8 LastComponentFind; if( FindList.notEmpty() ) LastComponentFind = FindList[0]; diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 90dc51af0..02480a9a2 100755 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -4380,16 +4380,13 @@ static void getACPISettings(const TagDict *CfgDict, SETTINGS_DATA& gSettings) const TagKey* key; const TagStruct* value; if ( !EFI_ERROR(RenameDevicesDict->getKeyAndValueAtIndex(j, &key, &value)) ) { - if (value->isString()) { + if ( value->isString() && value->getString()->stringValue().notEmpty() ) { ACPI_RENAME_DEVICE* List2 = new ACPI_RENAME_DEVICE(); - List2->Name.Name = key->keyStringValue(); + List2->acpiName.Name = key->keyStringValue(); List2->renameTo = value->getString()->stringValue(); - DBG("->will be renamed to %s\n", List2->renameTo.c_str()); gSettings.ACPI.DeviceRename.AddReference(List2, false); - const XString8Array List2Name = List2->Name.getSplittedName(); - for (size_t idx = 0 ; idx < List2Name.size() ; ++idx ) { - DBG("%s:", List2Name[idx].c_str()); - } + // Debug print. We use getSplittedName() and then ConcatAll because getSplittedName() format components (trim or expand to 4 chars). + DBG("'%s' -> will be renamed to '%s'\n", List2->acpiName.getSplittedName().ConcatAll(":").c_str(), List2->renameTo.c_str()); } } } //for j < dict size @@ -4468,24 +4465,29 @@ if (key->keyStringValue().startWithOrEqualTo("#")) { // DBG("Add %d properties:\n", PropCount); for (INTN j = 0; j < PropCount; j++) { DevProps = *Child; - *Child = new DEV_PROPERTY; - // *Child = new (__typeof_am__(**Child))(); - (*Child)->Next = DevProps; const TagKey* key2; const TagStruct* value2; if (EFI_ERROR(valueDict->getKeyAndValueAtIndex(j, &key2, &value2))) { continue; } - if (key2->keyStringValue()[0] != '#') { + if (key2->keyStringValue().isEmpty()) { continue; + } + if (key2->keyStringValue()[0] == '#') { + continue; + } + + *Child = new DEV_PROPERTY; + (*Child)->Next = DevProps; +// if (key2->keyStringValue()[0] != '#') { (*Child)->MenuItem.BValue = TRUE; (*Child)->Key = S8Printf("%s", key2->keyStringValue().c_str()).forgetDataWithoutFreeing(); - } - else { - (*Child)->MenuItem.BValue = FALSE; - (*Child)->Key = S8Printf("%s", key2->keyStringValue().c_str() + 1).forgetDataWithoutFreeing(); - } +// } +// else { +// (*Child)->MenuItem.BValue = FALSE; +// (*Child)->Key = S8Printf("%s", key2->keyStringValue().c_str() + 1).forgetDataWithoutFreeing(); +// } // DBG("%s\n type %d\n", (*Child)->Key, Prop3->type); if (value2 && (value2->isString()) && value2->getString()->stringValue().notEmpty()) { diff --git a/rEFIt_UEFI/Platform/Settings.h b/rEFIt_UEFI/Platform/Settings.h index eee6366d0..a8e78ac7d 100644 --- a/rEFIt_UEFI/Platform/Settings.h +++ b/rEFIt_UEFI/Platform/Settings.h @@ -106,6 +106,7 @@ class ACPI_NAME { public: XString8 Name = XString8(); + XString8Array getSplittedName() const { XString8Array splittedName = Split(Name, "."); for ( size_t idx = 0 ; idx < splittedName.size() ; ++idx) { @@ -123,8 +124,9 @@ public: class ACPI_RENAME_DEVICE { public: - ACPI_NAME Name = ACPI_NAME(); + ACPI_NAME acpiName = ACPI_NAME(); XString8 renameTo = XString8(); + XString8 getRenameTo() const { if ( renameTo.length() == 4 ) return renameTo; XString8 newName = renameTo; @@ -867,66 +869,66 @@ public: public: void FillDevicePropertiesOld(SETTINGS_DATA& gSettings, const TagDict* DevicesDict); - bool compareDevProperty(const XString8& label, const DEV_PROPERTY& devProp, const DEV_PROPERTY& newDev) const + bool compareDevProperty(const XString8& label, const DEV_PROPERTY& oldProp, const DEV_PROPERTY& newProp) const { - if ( newDev.Device != devProp.Device ) + if ( newProp.Device != oldProp.Device ) { - printf("%s.Device\n", label.c_str()); + printf("%s.Device !=\n", label.c_str()); return false; } - if ( newDev.Key || devProp.Key ) { - if ( !newDev.Key || !devProp.Key ) { - printf("%s.Key\n", label.c_str()); + if ( newProp.Key || oldProp.Key ) { + if ( !newProp.Key || !oldProp.Key ) { + printf("%s.Key !=\n", label.c_str()); return false; } #ifdef JIEF_DEBUG -if ( strcmp(devProp.Key, "10") == 0 ) { +if ( strcmp(oldProp.Key, "10") == 0 ) { printf("%s", ""); } #endif - if ( strcmp(newDev.Key, devProp.Key) != 0 ) + if ( strcmp(newProp.Key, oldProp.Key) != 0 ) { - printf("%s.Key\n", label.c_str()); + printf("%s.Key !=\n", label.c_str()); return false; } } - if ( newDev.ValueLen != devProp.ValueLen ) + if ( newProp.ValueLen != oldProp.ValueLen ) { - printf("%s.Value.ValueLen\n", label.c_str()); + printf("%s.Value.ValueLen %lld != %lld\n", label.c_str(), oldProp.ValueLen, newProp.ValueLen); return false; } else { - if ( newDev.ValueLen > 0 ) { - if ( memcmp(newDev.Value, devProp.Value, devProp.ValueLen) != 0 ) + if ( newProp.ValueLen > 0 ) { + if ( memcmp(newProp.Value, oldProp.Value, oldProp.ValueLen) != 0 ) { - printf("%s.Value\n", label.c_str()); + printf("%s.Value !=\n", label.c_str()); return false; } } } - if ( newDev.ValueType != devProp.ValueType ) + if ( newProp.ValueType != oldProp.ValueType ) { - printf("%s.ValueType\n", label.c_str()); + printf("%s.ValueType !=\n", label.c_str()); return false; } - if ( newDev.Label || devProp.Label ) { - if ( !newDev.Label || !devProp.Label ) { - printf("%s.Label\n", label.c_str()); + if ( newProp.Label || oldProp.Label ) { + if ( !newProp.Label || !oldProp.Label ) { + printf("%s.Label !=\n", label.c_str()); return false; } - if ( strcmp(newDev.Label, devProp.Label) != 0 ) + if ( strcmp(newProp.Label, oldProp.Label) != 0 ) { - printf("%s.Label : old:%s new:%s\n", label.c_str(), devProp.Label, newDev.Label); + printf("%s.Label != : old:%s new:%s\n", label.c_str(), oldProp.Label, newProp.Label); return false; } } - if ( newDev.MenuItem.BValue != devProp.MenuItem.BValue ) + if ( newProp.MenuItem.BValue != oldProp.MenuItem.BValue ) { - printf("%s.MenuItem.BValue\n", label.c_str()); + printf("%s.MenuItem.BValue !=\n", label.c_str()); return false; } - DEV_PROPERTY *oldChild = devProp.Child; - DEV_PROPERTY *newChild = newDev.Child; + DEV_PROPERTY *oldChild = oldProp.Child; + DEV_PROPERTY *newChild = newProp.Child; size_t jdx = 0; while ( oldChild && newChild ) { @@ -1008,10 +1010,11 @@ printf("%s", ""); DEV_PROPERTY* newSubProp = new DEV_PROPERTY(); newSubProp->Device = 0; newSubProp->Key = const_cast(SubProp.Key.c_str()); +// newSubProp->Key = NULL; newSubProp->Value = const_cast(SubProp.Value.data()); newSubProp->ValueLen = SubProp.Value.size(); newSubProp->ValueType = SubProp.ValueType; - newSubProp->MenuItem.BValue = SubProp.MenuItem.BValue; + newSubProp->MenuItem.BValue = true; if ( newProp->Child ) { DEV_PROPERTY* childs; for ( childs = newProp->Child ; childs->Next ; childs = childs->Next ); @@ -1021,7 +1024,7 @@ printf("%s", ""); } } arb.AddReference(newProp, true); -// printf("Add prop %s at index %zu\n", newProp->Key.c_str(), arb.size()-1); +// MsgLog("Add prop %s at index %zu\n", newProp->Label, arb.size()-1); } return arb; }; diff --git a/rEFIt_UEFI/PlatformEFI/include/Platform.h b/rEFIt_UEFI/PlatformEFI/include/Platform.h index fbf43a2c1..e8330d11f 100755 --- a/rEFIt_UEFI/PlatformEFI/include/Platform.h +++ b/rEFIt_UEFI/PlatformEFI/include/Platform.h @@ -38,13 +38,6 @@ Headers collection for procedures #endif -#ifndef DEBUG_ALL -#define MsgLog(...) DebugLog(1, __VA_ARGS__) -#else -#define MsgLog(...) DebugLog(DEBUG_ALL, __VA_ARGS__) -#endif - - // Jief : temporary rename #define AllocateZeroPool AllocateZeroPool diff --git a/rEFIt_UEFI/PlatformPOSIX/BootLog.cpp b/rEFIt_UEFI/PlatformPOSIX/BootLog.cpp index dd260fc91..bdde985d1 100644 --- a/rEFIt_UEFI/PlatformPOSIX/BootLog.cpp +++ b/rEFIt_UEFI/PlatformPOSIX/BootLog.cpp @@ -52,6 +52,8 @@ PrintBytes(IN void *Bytes, IN UINTN Number) } } +bool disabledLog = false; + // Changed MsgLog(...) it now calls this function // with DebugMode == 0. - apianti // DebugMode==0 Prints to msg log, only output to log on SaveBooterLog @@ -59,16 +61,16 @@ PrintBytes(IN void *Bytes, IN UINTN Number) // DebugMode==2 Prints to msg log, DEBUG_LOG and display console void EFIAPI DebugLog(IN INTN DebugMode, IN CONST CHAR8 *FormatString, ...) { -// VA_LIST Marker; - va_list Marker; + if ( disabledLog ) return; + + VA_LIST Marker; // Make sure the buffer is intact for writing if (FormatString == NULL || DebugMode < 0) { return; } // Print message to log buffer -// VA_START(Marker, FormatString); - va_start(Marker, FormatString); + VA_START(Marker, FormatString); #if __WCHAR_MAX__ < 0xffff #else vprintf(FormatString, Marker); diff --git a/rEFIt_UEFI/PlatformPOSIX/include/Platform.h b/rEFIt_UEFI/PlatformPOSIX/include/Platform.h index da93424d7..82358967c 100644 --- a/rEFIt_UEFI/PlatformPOSIX/include/Platform.h +++ b/rEFIt_UEFI/PlatformPOSIX/include/Platform.h @@ -62,27 +62,24 @@ typedef unsigned long long uintptr_t; #ifdef __cplusplus #include "../../../rEFIt_UEFI/cpp_foundation/XString.h" +#include "../../../rEFIt_UEFI/cpp_foundation/XArray.h" #include "../../../rEFIt_UEFI/cpp_foundation/XObjArray.h" +#include "../include/remove_ref.h" +#include "../cpp_lib/undefinable.h" + +#include "../include/OneLinerMacros.h" + #include "../../../rEFIt_UEFI/entry_scan/common.h" #include "../../../rEFIt_UEFI/libeg/BmLib.h" -#endif +#include "../Platform/BootLog.h" +#include "../Platform/BasicIO.h" +#include "../Platform/VersionString.h" +#include "../Platform/Utils.h" #include "../../../rEFIt_UEFI/Platform/Utils.h" -//#include "../../../../../cpp_tests/Include/xcode_utf_fixed.h" +#endif -void CpuDeadLoop(void); - -void PauseForKey(const wchar_t* msg); - -const char* efiStrError(EFI_STATUS Status); - - -//#define DEBUG_VERBOSE 0 -//#define DEBUG( expression ) - -#define MsgLog ::printf - // to be able to compile AutoGen.c #ifdef __cplusplus extern "C" {