Ignore empty if device property value is empty.

Ignore commented device properties in FillDevicePropertiesOld.
Rename Name to acpiName.
This commit is contained in:
jief666 2021-04-05 15:00:17 +03:00
parent 946a6428b5
commit 6545450f02
9 changed files with 74 additions and 161 deletions

View File

@ -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

View File

@ -1,90 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1120"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A92232C2402FD1000483CBA"
BuildableName = "CloverX64TestNewParser UTF16 signed char"
BlueprintName = "CloverX64TestNewParser UTF16 signed char"
ReferencedContainer = "container:CloverX64TestNewParser.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A92232C2402FD1000483CBA"
BuildableName = "CloverX64TestNewParser UTF16 signed char"
BlueprintName = "CloverX64TestNewParser UTF16 signed char"
ReferencedContainer = "container:CloverX64TestNewParser.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
disableMainThreadChecker = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "YES"
customWorkingDirectory = "$PROJECT_DIR"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
migratedStopOnEveryIssue = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A92232C2402FD1000483CBA"
BuildableName = "CloverX64TestNewParser UTF16 signed char"
BlueprintName = "CloverX64TestNewParser UTF16 signed char"
ReferencedContainer = "container:CloverX64TestNewParser.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A92232C2402FD1000483CBA"
BuildableName = "CloverX64TestNewParser UTF16 signed char"
BlueprintName = "CloverX64TestNewParser UTF16 signed char"
ReferencedContainer = "container:CloverX64TestNewParser.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -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);

View File

@ -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];

View File

@ -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("<key>%s\n <value> type %d\n", (*Child)->Key, Prop3->type);
if (value2 && (value2->isString()) && value2->getString()->stringValue().notEmpty()) {

View File

@ -106,6 +106,7 @@ class ACPI_NAME
{
public:
XString8 Name = XString8();
XString8Array getSplittedName() const {
XString8Array splittedName = Split<XString8Array>(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<char*>(SubProp.Key.c_str());
// newSubProp->Key = NULL;
newSubProp->Value = const_cast<unsigned char*>(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;
};

View File

@ -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

View File

@ -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);

View File

@ -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" {