MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / RenameDevices

Function RenameDevices

rEFIt_UEFI/Platform/FixBiosDsdt.cpp:5244–5330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5242}
5243
5244VOID RenameDevices(UINT8* table)
5245{
5246 ACPI_NAME_LIST *List;
5247 ACPI_NAME_LIST *Bridge;
5248 CHAR8 *Replace;
5249 CHAR8 *Find;
5250
5251 INTN i;
5252 INTN k=0; // Cland complain about possible use uninitialised. Not true, but I don't like warnings.
5253 UINTN index;
5254 INTN size;
5255 UINTN len = ((EFI_ACPI_DESCRIPTION_HEADER*)table)->Length;
5256 INTN adr, shift, Num = 0;
5257 BOOLEAN found;
5258 for (index = 0; index < gSettings.DeviceRenameCount; index++) {
5259 List = gSettings.DeviceRename[index].Next;
5260 Replace = gSettings.DeviceRename[index].Name;
5261 Find = List->Name;
5262 Bridge = List->Next;
5263 MsgLog("Name: %s, Bridge: %s, Replace: %s\n", Find, Bridge->Name, Replace);
5264 adr = 0;
5265 do
5266 {
5267
5268 shift = FindBin(table + adr, (UINT32)(len - adr), (const UINT8*)Find, 4); //next occurence
5269 if (shift < 0) {
5270 break; //not found
5271 }
5272 adr += shift;
5273// DBG("found Name @ 0x%X\n", adr);
5274 if (!Bridge || (FindBin(table + adr - 4, 5, (const UINT8*)(Bridge->Name), 4) == 0)) { // long name like "RP02.PXSX"
5275 CopyMem(table + adr, Replace, 4);
5276 adr += 5; //at least, it is impossible to see PXSXPXSX
5277// DBG("replaced\n");
5278 Num++;
5279 continue;
5280 }
5281 //find outer device or scope
5282 i = adr;
5283 while ((i > 0) && isACPI_Char(table[i])) i--; //skip attached name
5284 i -= 6; //skip size and device field
5285 // DBG("search for bridge since %d\n", adr);
5286 while (i > 0x20) { //find devices that previous to adr
5287 found = FALSE;
5288 //check device
5289 if ((table[i] == 0x5B) && (table[i + 1] == 0x82) && !CmpNum(table, (INT32)i, TRUE)) { //device candidate
5290 k = i + 2;
5291 found = TRUE;
5292 }
5293 //check scope
5294
5295 if ((table[i] == 0x10) && !CmpNum(table, (INT32)i, TRUE)) {
5296 k = i + 1;
5297 found = TRUE;
5298 }
5299 if (found) { // i points to Device or Scope
5300 size = get_size(table, (UINT32)(UINTN)k); //k points to size // DBG("found bridge candidate 0x%X size %d\n", table[i], size);
5301 if (size) {

Callers 2

FixBiosDsdtFunction · 0.85
PatchAllTablesFunction · 0.85

Calls 6

FindBinFunction · 0.85
isACPI_CharFunction · 0.85
CmpNumFunction · 0.85
get_sizeFunction · 0.85
CmpFullNameFunction · 0.85
CopyMemFunction · 0.50

Tested by

no test coverage detected