mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
repair RenameDevices
Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
parent
b13a1e5112
commit
e1a49a85b9
@ -5252,12 +5252,11 @@ void RenameDevices(UINT8* table)
|
|||||||
|
|
||||||
INTN i;
|
INTN i;
|
||||||
INTN k=0; // Clang complain about possible use uninitialised. Not true, but I don't like warnings.
|
INTN k=0; // Clang complain about possible use uninitialised. Not true, but I don't like warnings.
|
||||||
UINTN index;
|
|
||||||
INTN size;
|
INTN size;
|
||||||
UINTN len = ((EFI_ACPI_DESCRIPTION_HEADER*)table)->Length;
|
UINTN len = ((EFI_ACPI_DESCRIPTION_HEADER*)table)->Length;
|
||||||
INTN adr, shift, Num = 0;
|
INTN adr, shift, Num = 0;
|
||||||
BOOLEAN found;
|
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;
|
List = gSettings.ACPI.DeviceRename[index].Next;
|
||||||
Replace = gSettings.ACPI.DeviceRename[index].Name;
|
Replace = gSettings.ACPI.DeviceRename[index].Name;
|
||||||
Find = List->Name;
|
Find = List->Name;
|
||||||
@ -5266,7 +5265,6 @@ void RenameDevices(UINT8* table)
|
|||||||
adr = 0;
|
adr = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
||||||
shift = FindBin(table + adr, (UINT32)(len - adr), (const UINT8*)Find, 4); //next occurence
|
shift = FindBin(table + adr, (UINT32)(len - adr), (const UINT8*)Find, 4); //next occurence
|
||||||
if (shift < 0) {
|
if (shift < 0) {
|
||||||
break; //not found
|
break; //not found
|
||||||
@ -5315,7 +5313,7 @@ void RenameDevices(UINT8* table)
|
|||||||
if (CmpFullName(table + k, len - k, Bridge)) {
|
if (CmpFullName(table + k, len - k, Bridge)) {
|
||||||
CopyMem(table + adr, Replace, 4);
|
CopyMem(table + adr, Replace, 4);
|
||||||
adr += 5;
|
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");
|
// DBG(" name copied\n");
|
||||||
Num++;
|
Num++;
|
||||||
break; //cancel search outer bridge, we found it.
|
break; //cancel search outer bridge, we found it.
|
||||||
|
@ -523,7 +523,7 @@ GetSmcKeys (BOOLEAN WriteToSMC)
|
|||||||
Status = gAppleSmc->SmcAddKey(gAppleSmc, KeyFromName(Name), (SMC_DATA_SIZE)DataSize, TypeFromName(Name), 0xC0);
|
Status = gAppleSmc->SmcAddKey(gAppleSmc, KeyFromName(Name), (SMC_DATA_SIZE)DataSize, TypeFromName(Name), 0xC0);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
Status = gAppleSmc->SmcWriteValue(gAppleSmc, KeyFromName(Name), (SMC_DATA_SIZE)DataSize, Data);
|
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++;
|
NumKey++;
|
||||||
}
|
}
|
||||||
@ -594,8 +594,8 @@ EFI_GUID
|
|||||||
|
|
||||||
|
|
||||||
/** detailed debug for BootVolumeDevicePathEqual */
|
/** detailed debug for BootVolumeDevicePathEqual */
|
||||||
//#define DBG_DP(...)
|
#define DBG_DP(...)
|
||||||
#define DBG_DP(...) DBG(__VA_ARGS__)
|
//#define DBG_DP(...) DBG(__VA_ARGS__)
|
||||||
|
|
||||||
/** Returns TRUE if dev paths are equal. Ignores some differences. */
|
/** Returns TRUE if dev paths are equal. Ignores some differences. */
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
@ -617,7 +617,7 @@ BootVolumeDevicePathEqual (
|
|||||||
|
|
||||||
|
|
||||||
// DBG_DP (" BootVolumeDevicePathEqual:\n %ls\n %ls\n", FileDevicePathToStr (DevicePath1), FileDevicePathToStr (DevicePath2));
|
// 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;
|
Equal = FALSE;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@ -631,8 +631,8 @@ BootVolumeDevicePathEqual (
|
|||||||
|
|
||||||
ForceEqualNodes = FALSE;
|
ForceEqualNodes = FALSE;
|
||||||
|
|
||||||
DBG_DP (" N1: (%d, %d, %lld)", Type1, SubType1, Len1);
|
// DBG_DP (" N1: (%d, %d, %lld)", Type1, SubType1, Len1);
|
||||||
DBG_DP (" N2: (%d, %d, %lld)", Type2, SubType2, Len2);
|
// DBG_DP (" N2: (%d, %d, %lld)", Type2, SubType2, Len2);
|
||||||
|
|
||||||
// DBG_DP ("%ls\n", DevicePathToStr (DevicePath1));
|
// DBG_DP ("%ls\n", DevicePathToStr (DevicePath1));
|
||||||
// DBG_DP ("%ls\n", DevicePathToStr (DevicePath2));
|
// DBG_DP ("%ls\n", DevicePathToStr (DevicePath2));
|
||||||
@ -667,7 +667,7 @@ BootVolumeDevicePathEqual (
|
|||||||
|
|
||||||
if (ForceEqualNodes) {
|
if (ForceEqualNodes) {
|
||||||
// assume equal nodes
|
// assume equal nodes
|
||||||
DBG_DP (" - forcing equal nodes\n");
|
// DBG_DP (" - forcing equal nodes\n");
|
||||||
DevicePath1 = NextDevicePathNode (DevicePath1);
|
DevicePath1 = NextDevicePathNode (DevicePath1);
|
||||||
DevicePath2 = NextDevicePathNode (DevicePath2);
|
DevicePath2 = NextDevicePathNode (DevicePath2);
|
||||||
continue;
|
continue;
|
||||||
@ -675,7 +675,7 @@ BootVolumeDevicePathEqual (
|
|||||||
|
|
||||||
if (Type1 != Type2 || SubType1 != SubType2 || Len1 != Len2) {
|
if (Type1 != Type2 || SubType1 != SubType2 || Len1 != Len2) {
|
||||||
// Not equal
|
// Not equal
|
||||||
DBG_DP (" - not equal\n");
|
// DBG_DP (" - not equal\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,7 +685,7 @@ BootVolumeDevicePathEqual (
|
|||||||
if (IsDevicePathEnd (DevicePath1)) {
|
if (IsDevicePathEnd (DevicePath1)) {
|
||||||
// END node - they are the same
|
// END node - they are the same
|
||||||
Equal = TRUE;
|
Equal = TRUE;
|
||||||
DBG_DP (" - END = equal\n");
|
// DBG_DP (" - END = equal\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,23 +700,23 @@ BootVolumeDevicePathEqual (
|
|||||||
SataNode2 = (SATA_DEVICE_PATH *)DevicePath2;
|
SataNode2 = (SATA_DEVICE_PATH *)DevicePath2;
|
||||||
if (SataNode1->HBAPortNumber != SataNode2->HBAPortNumber) {
|
if (SataNode1->HBAPortNumber != SataNode2->HBAPortNumber) {
|
||||||
// not equal
|
// not equal
|
||||||
DBG_DP (" - not equal SataNode.HBAPortNumber\n");
|
// DBG_DP (" - not equal SataNode.HBAPortNumber\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SataNode1->Lun != SataNode2->Lun) {
|
if (SataNode1->Lun != SataNode2->Lun) {
|
||||||
// not equal
|
// not equal
|
||||||
DBG_DP (" - not equal SataNode.Lun\n");
|
// DBG_DP (" - not equal SataNode.Lun\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DBG_DP (" - forcing equal nodes");
|
// DBG_DP (" - forcing equal nodes");
|
||||||
} else if (CompareMem (DevicePath1, DevicePath2, DevicePathNodeLength (DevicePath1)) != 0) {
|
} else if (CompareMem (DevicePath1, DevicePath2, DevicePathNodeLength (DevicePath1)) != 0) {
|
||||||
// Not equal
|
// Not equal
|
||||||
DBG_DP (" - not equal\n");
|
// DBG_DP (" - not equal\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG_DP ("\n");
|
// DBG_DP ("\n");
|
||||||
//
|
//
|
||||||
// Advance to next node
|
// Advance to next node
|
||||||
//
|
//
|
||||||
@ -1097,23 +1097,23 @@ PutNvramPlistToRtVars ()
|
|||||||
// <string> element
|
// <string> element
|
||||||
Value = (void*)valueTag->getString()->stringValue().c_str();
|
Value = (void*)valueTag->getString()->stringValue().c_str();
|
||||||
Size = valueTag->getString()->stringValue().length();
|
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());
|
DBG("String: Size = %llu, Val = '%s'\n", Size, valueTag->getString()->stringValue().c_str());
|
||||||
}
|
// }
|
||||||
} else if (valueTag->isData()) {
|
} else if (valueTag->isData()) {
|
||||||
|
|
||||||
// <data> element
|
// <data> element
|
||||||
Size = valueTag->getData()->dataLenValue();
|
Size = valueTag->getData()->dataLenValue();
|
||||||
Value = valueTag->getData()->dataValue();
|
Value = valueTag->getData()->dataValue();
|
||||||
// if (gSettings.Boot.DebugLog) {
|
// if (gSettings.Boot.DebugLog) {
|
||||||
// DBG("Size = %llu, Data: ", Size);
|
// DBG("Size = %llu, Data: ", Size);
|
||||||
// for ( i = 0; i < Size; i++) {
|
// for ( i = 0; i < Size; i++) {
|
||||||
// DBG("%02hhX ", *(((UINT8*)Value) + i));
|
// DBG("%02hhX ", *(((UINT8*)Value) + i));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// if (!gSettings.Boot.DebugLog) {
|
// if (!gSettings.Boot.DebugLog) {
|
||||||
// DBG("\n");
|
DBG("\n");
|
||||||
//
|
//
|
||||||
} else {
|
} else {
|
||||||
DBG("ERROR: Unsupported tag type: %s\n", valueTag->getTypeAsXString8().c_str());
|
DBG("ERROR: Unsupported tag type: %s\n", valueTag->getTypeAsXString8().c_str());
|
||||||
continue;
|
continue;
|
||||||
|
@ -3923,19 +3923,19 @@ static void getACPISettings(const TagDict *CfgDict)
|
|||||||
|
|
||||||
const TagDict* RenameDevicesDict = ACPIDict->dictPropertyForKey("RenameDevices"); // dict of key/string
|
const TagDict* RenameDevicesDict = ACPIDict->dictPropertyForKey("RenameDevices"); // dict of key/string
|
||||||
if ( RenameDevicesDict ) {
|
if ( RenameDevicesDict ) {
|
||||||
INTN i;
|
|
||||||
INTN Count = RenameDevicesDict->dictKeyCount();
|
INTN Count = RenameDevicesDict->dictKeyCount();
|
||||||
if (Count > 0) {
|
if (Count > 0) {
|
||||||
gSettings.ACPI.DeviceRename.setEmpty();
|
gSettings.ACPI.DeviceRename.setEmpty();
|
||||||
DBG("Devices to rename %lld\n", Count);
|
DBG("Devices to rename %lld\n", Count);
|
||||||
for (i = 0; i < Count; i++) {
|
for (INTN i = 0; i < Count; i++) {
|
||||||
const TagKey* key;
|
const TagKey* key;
|
||||||
const TagStruct* value;
|
const TagStruct* value;
|
||||||
if ( !EFI_ERROR(RenameDevicesDict->getKeyAndValueAtIndex(i, &key, &value)) ) {
|
if ( !EFI_ERROR(RenameDevicesDict->getKeyAndValueAtIndex(i, &key, &value)) ) {
|
||||||
ACPI_NAME_LIST* List = ParseACPIName(key->keyStringValue());
|
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[gSettings.ACPI.DeviceRename.size()].Next = List;
|
||||||
gSettings.ACPI.DeviceRename.AddReference(List, false);
|
gSettings.ACPI.DeviceRename.AddReference(List2, false);
|
||||||
while (List) {
|
while (List) {
|
||||||
DBG("%s:", List->Name);
|
DBG("%s:", List->Name);
|
||||||
List = List->Next;
|
List = List->Next;
|
||||||
|
Loading…
Reference in New Issue
Block a user