repair RenameDevices

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2021-02-20 21:33:09 +03:00
parent b13a1e5112
commit e1a49a85b9
3 changed files with 27 additions and 29 deletions

View File

@ -5252,12 +5252,11 @@ void RenameDevices(UINT8* table)
INTN i;
INTN k=0; // Clang complain about possible use uninitialised. Not true, but I don't like warnings.
UINTN index;
INTN size;
UINTN len = ((EFI_ACPI_DESCRIPTION_HEADER*)table)->Length;
INTN adr, shift, Num = 0;
BOOLEAN found;
for (index = 0; index < gSettings.ACPI.DeviceRename.size(); index++) {
for (UINTN index = 0; index < gSettings.ACPI.DeviceRename.size(); index++) {
List = gSettings.ACPI.DeviceRename[index].Next;
Replace = gSettings.ACPI.DeviceRename[index].Name;
Find = List->Name;
@ -5266,7 +5265,6 @@ void RenameDevices(UINT8* table)
adr = 0;
do
{
shift = FindBin(table + adr, (UINT32)(len - adr), (const UINT8*)Find, 4); //next occurence
if (shift < 0) {
break; //not found
@ -5315,7 +5313,7 @@ void RenameDevices(UINT8* table)
if (CmpFullName(table + k, len - k, Bridge)) {
CopyMem(table + adr, Replace, 4);
adr += 5;
DBG("found Bridge device begin=%llX end=%llX\n", k, k+size);
DBG("found Bridge device begin=%llX end=%llX\n", k, k+size);
// DBG(" name copied\n");
Num++;
break; //cancel search outer bridge, we found it.

View File

@ -523,7 +523,7 @@ GetSmcKeys (BOOLEAN WriteToSMC)
Status = gAppleSmc->SmcAddKey(gAppleSmc, KeyFromName(Name), (SMC_DATA_SIZE)DataSize, TypeFromName(Name), 0xC0);
if (!EFI_ERROR(Status)) {
Status = gAppleSmc->SmcWriteValue(gAppleSmc, KeyFromName(Name), (SMC_DATA_SIZE)DataSize, Data);
DBG("Write to AppleSMC status=%s\n", efiStrError(Status));
// DBG("Write to AppleSMC status=%s\n", efiStrError(Status));
}
NumKey++;
}
@ -594,8 +594,8 @@ EFI_GUID
/** detailed debug for BootVolumeDevicePathEqual */
//#define DBG_DP(...)
#define DBG_DP(...) DBG(__VA_ARGS__)
#define DBG_DP(...)
//#define DBG_DP(...) DBG(__VA_ARGS__)
/** Returns TRUE if dev paths are equal. Ignores some differences. */
BOOLEAN
@ -617,7 +617,7 @@ BootVolumeDevicePathEqual (
// DBG_DP (" BootVolumeDevicePathEqual:\n %ls\n %ls\n", FileDevicePathToStr (DevicePath1), FileDevicePathToStr (DevicePath2));
DBG_DP (" N1: (Type, Subtype, Len) N2: (Type, Subtype, Len)\n");
// DBG_DP (" N1: (Type, Subtype, Len) N2: (Type, Subtype, Len)\n");
Equal = FALSE;
while (TRUE) {
@ -631,8 +631,8 @@ BootVolumeDevicePathEqual (
ForceEqualNodes = FALSE;
DBG_DP (" N1: (%d, %d, %lld)", Type1, SubType1, Len1);
DBG_DP (" N2: (%d, %d, %lld)", Type2, SubType2, Len2);
// DBG_DP (" N1: (%d, %d, %lld)", Type1, SubType1, Len1);
// DBG_DP (" N2: (%d, %d, %lld)", Type2, SubType2, Len2);
// DBG_DP ("%ls\n", DevicePathToStr (DevicePath1));
// DBG_DP ("%ls\n", DevicePathToStr (DevicePath2));
@ -667,7 +667,7 @@ BootVolumeDevicePathEqual (
if (ForceEqualNodes) {
// assume equal nodes
DBG_DP (" - forcing equal nodes\n");
// DBG_DP (" - forcing equal nodes\n");
DevicePath1 = NextDevicePathNode (DevicePath1);
DevicePath2 = NextDevicePathNode (DevicePath2);
continue;
@ -675,7 +675,7 @@ BootVolumeDevicePathEqual (
if (Type1 != Type2 || SubType1 != SubType2 || Len1 != Len2) {
// Not equal
DBG_DP (" - not equal\n");
// DBG_DP (" - not equal\n");
break;
}
@ -685,7 +685,7 @@ BootVolumeDevicePathEqual (
if (IsDevicePathEnd (DevicePath1)) {
// END node - they are the same
Equal = TRUE;
DBG_DP (" - END = equal\n");
// DBG_DP (" - END = equal\n");
break;
}
@ -700,23 +700,23 @@ BootVolumeDevicePathEqual (
SataNode2 = (SATA_DEVICE_PATH *)DevicePath2;
if (SataNode1->HBAPortNumber != SataNode2->HBAPortNumber) {
// not equal
DBG_DP (" - not equal SataNode.HBAPortNumber\n");
// DBG_DP (" - not equal SataNode.HBAPortNumber\n");
break;
}
if (SataNode1->Lun != SataNode2->Lun) {
// not equal
DBG_DP (" - not equal SataNode.Lun\n");
// DBG_DP (" - not equal SataNode.Lun\n");
break;
}
DBG_DP (" - forcing equal nodes");
// DBG_DP (" - forcing equal nodes");
} else if (CompareMem (DevicePath1, DevicePath2, DevicePathNodeLength (DevicePath1)) != 0) {
// Not equal
DBG_DP (" - not equal\n");
// DBG_DP (" - not equal\n");
break;
}
DBG_DP ("\n");
// DBG_DP ("\n");
//
// Advance to next node
//
@ -1097,23 +1097,23 @@ PutNvramPlistToRtVars ()
// <string> element
Value = (void*)valueTag->getString()->stringValue().c_str();
Size = valueTag->getString()->stringValue().length();
if (!gSettings.Boot.DebugLog) {
// if (!gSettings.Boot.DebugLog) {
DBG("String: Size = %llu, Val = '%s'\n", Size, valueTag->getString()->stringValue().c_str());
}
// }
} else if (valueTag->isData()) {
// <data> element
Size = valueTag->getData()->dataLenValue();
Value = valueTag->getData()->dataValue();
// if (gSettings.Boot.DebugLog) {
// if (gSettings.Boot.DebugLog) {
// DBG("Size = %llu, Data: ", Size);
// for ( i = 0; i < Size; i++) {
// DBG("%02hhX ", *(((UINT8*)Value) + i));
// }
// }
// if (!gSettings.Boot.DebugLog) {
// DBG("\n");
//
// }
// if (!gSettings.Boot.DebugLog) {
DBG("\n");
//
} else {
DBG("ERROR: Unsupported tag type: %s\n", valueTag->getTypeAsXString8().c_str());
continue;

View File

@ -3923,19 +3923,19 @@ static void getACPISettings(const TagDict *CfgDict)
const TagDict* RenameDevicesDict = ACPIDict->dictPropertyForKey("RenameDevices"); // dict of key/string
if ( RenameDevicesDict ) {
INTN i;
INTN Count = RenameDevicesDict->dictKeyCount();
if (Count > 0) {
gSettings.ACPI.DeviceRename.setEmpty();
DBG("Devices to rename %lld\n", Count);
for (i = 0; i < Count; i++) {
for (INTN i = 0; i < Count; i++) {
const TagKey* key;
const TagStruct* value;
if ( !EFI_ERROR(RenameDevicesDict->getKeyAndValueAtIndex(i, &key, &value)) ) {
ACPI_NAME_LIST* List = ParseACPIName(key->keyStringValue());
ACPI_NAME_LIST* List2 = List;
ACPI_NAME_LIST* List2 = (__typeof__(List2))AllocateZeroPool(sizeof(ACPI_NAME_LIST));
List2->Next = List;
// gSettings.ACPI.DeviceRename[gSettings.ACPI.DeviceRename.size()].Next = List;
gSettings.ACPI.DeviceRename.AddReference(List, false);
gSettings.ACPI.DeviceRename.AddReference(List2, false);
while (List) {
DBG("%s:", List->Name);
List = List->Next;