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

Function GetBiosRegions

rEFIt_UEFI/Platform/FixBiosDsdt.cpp:5096–5151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5094}
5095
5096VOID GetBiosRegions(UINT8 *buffer)
5097{
5098 EFI_ACPI_DESCRIPTION_HEADER *TableHeader;
5099// UINT8 *buffer = NULL;
5100 UINT32 bufferLen = 0;
5101 UINTN i, j;
5102 INTN shift, shift2;
5103 CHAR8 Name[8];
5104 CHAR8 NameAdr[8];
5105
5106 if (!buffer) {
5107 return;
5108 }
5109
5110// gRegions = NULL;
5111// buffer = (UINT8*)(UINTN)fadt->Dsdt;
5112 TableHeader = (EFI_ACPI_DESCRIPTION_HEADER*)buffer;
5113 bufferLen = TableHeader->Length;
5114
5115 for (i=0x24; bufferLen >= 15 && i < bufferLen - 15; i++) {
5116 if ((buffer[i] == 0x5B) && (buffer[i+1] == 0x80) &&
5117 GetName(buffer, (INT32)(i+2), &Name[0], &shift)) {
5118 if (buffer[i+6+shift] == 0) {
5119 //this is SystemMemory region. Write to bios regions tables
5120 OPER_REGION tmp;
5121 tmp.Address = 0;
5122 CopyMem(&tmp.Name[0], &buffer[i+2+shift], 4);
5123 tmp.Name[4] = 0;
5124 if (buffer[i+7+shift] == 0x0C) {
5125 CopyMem(&tmp.Address, &buffer[i+8+shift], 4);
5126 } else if (buffer[i+7+shift] == 0x0B) {
5127 CopyMem(&tmp.Address, &buffer[i+8+shift], 2);
5128 } else if (GetName(buffer, (INT32)(i+7+shift), &NameAdr[0], &shift2)) {
5129 j = FindName(buffer, bufferLen, &NameAdr[0]);
5130 if (j > 0) {
5131 if (buffer[j+4] == 0x0C) {
5132 CopyMem(&tmp.Address, &buffer[j+5], 4);
5133 } else if (buffer[j+4] == 0x0B) {
5134 CopyMem(&tmp.Address, &buffer[j+5], 2);
5135 }
5136 }
5137 }
5138 if (tmp.Address) {
5139 OPER_REGION *newRegion = (__typeof__(newRegion))AllocateZeroPool(sizeof(OPER_REGION));
5140 MsgLog("Found OperationRegion(%s, SystemMemory, %X, ...)\n", tmp.Name, tmp.Address);
5141 *newRegion = tmp;
5142 newRegion->next = gRegions;
5143 gRegions = newRegion;
5144 } else {
5145 // ignore OperationRegion where the address cannot be determined
5146 //DBG("Unable to determine address for OperationRegion(%s, SystemMemory, ...) skipping\n", tmp.Name);
5147 }
5148 }
5149 }
5150 }
5151}
5152
5153// RehabMan: Fix Mutex with non-zero SyncLevel (change to zero)

Callers 2

PatchAllTablesFunction · 0.85
PatchACPIFunction · 0.85

Calls 4

GetNameFunction · 0.85
FindNameFunction · 0.85
CopyMemFunction · 0.50
AllocateZeroPoolFunction · 0.50

Tested by

no test coverage detected