Modify PatchACPI to assign processorIDs from DSDT

macOS assumes that the first processor from DSDT is always enabled, without checking MADT table
here we're trying to assign first IDs found in DSDT to enabled processors in MADT, such that macOS assumption to be true
This commit is contained in:
Florin9doi 2019-09-14 12:31:25 +03:00
parent ecab494bd2
commit d5021f3f04
4 changed files with 13 additions and 9 deletions

View File

@ -60,7 +60,8 @@ UINTN *XsdtReplaceSizes = NULL;
UINT64 BiosDsdt; UINT64 BiosDsdt;
UINT32 BiosDsdtLen; UINT32 BiosDsdtLen;
UINT8 acpi_cpu_count; UINT8 acpi_cpu_count;
CHAR8* acpi_cpu_name[128]; CHAR8* acpi_cpu_name[acpi_cpu_max];
UINT8 acpi_cpu_processor_id[acpi_cpu_max];
CHAR8* acpi_cpu_score; CHAR8* acpi_cpu_score;
UINT64 machineSignature; UINT64 machineSignature;
@ -2171,13 +2172,14 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion)
DBG("Found subtable in MADT: type=%d\n", *SubTable); DBG("Found subtable in MADT: type=%d\n", *SubTable);
if (*SubTable == EFI_ACPI_4_0_PROCESSOR_LOCAL_APIC) { if (*SubTable == EFI_ACPI_4_0_PROCESSOR_LOCAL_APIC) {
ProcLocalApic = (EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC_STRUCTURE *)SubTable; ProcLocalApic = (EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC_STRUCTURE *)SubTable;
// macOS assumes that the first processor from DSDT is always enabled, without checking MADT table
// here we're trying to assign first IDs found in DSDT to enabled processors in MADT, such that macOS assumption to be true
if (ProcLocalApic->Flags & EFI_ACPI_4_0_LOCAL_APIC_ENABLED) { if (ProcLocalApic->Flags & EFI_ACPI_4_0_LOCAL_APIC_ENABLED) {
if (Index == 0 && ProcLocalApic->AcpiProcessorId > 1) { if (ProcLocalApic->AcpiProcessorId != acpi_cpu_processor_id[Index]) {
DBG("ProcLocalApic changed: %d to %d\n", ProcLocalApic->AcpiProcessorId, 0); DBG("AcpiProcessorId changed: 0x%02x to 0x%02x\n", ProcLocalApic->AcpiProcessorId, acpi_cpu_processor_id[Index]);
ProcLocalApic->AcpiProcessorId = 0; ProcLocalApic->AcpiProcessorId = acpi_cpu_processor_id[Index];
ApicCPUBase = 0;
} else { } else {
DBG("ProcLocalApic: %d\n", ProcLocalApic->AcpiProcessorId); DBG("AcpiProcessorId: 0x%02x\n", ProcLocalApic->AcpiProcessorId);
} }
Index++; Index++;
} }

View File

@ -1036,6 +1036,7 @@ VOID findCPU(UINT8* dsdt, UINT32 length)
if (add_name) { if (add_name) {
acpi_cpu_name[acpi_cpu_count] = AllocateZeroPool(5); acpi_cpu_name[acpi_cpu_count] = AllocateZeroPool(5);
CopyMem(acpi_cpu_name[acpi_cpu_count], dsdt+offset, 4); CopyMem(acpi_cpu_name[acpi_cpu_count], dsdt+offset, 4);
acpi_cpu_processor_id[acpi_cpu_count] = dsdt[offset + 4];
i = offset + 5; i = offset + 5;
//if (acpi_cpu_count == 0) //if (acpi_cpu_count == 0)
@ -1046,7 +1047,7 @@ VOID findCPU(UINT8* dsdt, UINT32 length)
} else { } else {
DBG("| %a ", acpi_cpu_name[acpi_cpu_count]); DBG("| %a ", acpi_cpu_name[acpi_cpu_count]);
} }
if (++acpi_cpu_count == 32) if (++acpi_cpu_count == acpi_cpu_max)
break; break;
} }
} }
@ -1057,6 +1058,7 @@ VOID findCPU(UINT8* dsdt, UINT32 length)
for (i=0; i<15; i++) { for (i=0; i<15; i++) {
acpi_cpu_name[i] = AllocateZeroPool(5); acpi_cpu_name[i] = AllocateZeroPool(5);
AsciiSPrint(acpi_cpu_name[i], 5, "CPU%1x", i); AsciiSPrint(acpi_cpu_name[i], 5, "CPU%1x", i);
acpi_cpu_processor_id[i] = i;
} }
} }
return; return;

View File

@ -1674,8 +1674,10 @@ extern UINT8 DefaultAudioVolume;
//CHAR8* orgBiosDsdt; //CHAR8* orgBiosDsdt;
extern UINT64 BiosDsdt; extern UINT64 BiosDsdt;
extern UINT32 BiosDsdtLen; extern UINT32 BiosDsdtLen;
#define acpi_cpu_max 128
extern UINT8 acpi_cpu_count; extern UINT8 acpi_cpu_count;
extern CHAR8 *acpi_cpu_name[]; extern CHAR8 *acpi_cpu_name[];
extern UINT8 acpi_cpu_processor_id[];
extern CHAR8 *acpi_cpu_score; extern CHAR8 *acpi_cpu_score;
extern BOOLEAN SSSE3; extern BOOLEAN SSSE3;
extern BOOLEAN defDSM; extern BOOLEAN defDSM;

View File

@ -6,8 +6,6 @@
#include "StateGenerator.h" #include "StateGenerator.h"
//CHAR8* acpi_cpu_name[] = {"CPU0", "CPU1", "CPU2", "CPU3", "CPU4", "CPU5", "CPU6", "CPU7", "CPU8", "CPU9"};
CONST UINT8 pss_ssdt_header[] = CONST UINT8 pss_ssdt_header[] =
{ {
0x53, 0x53, 0x44, 0x54, 0x7E, 0x00, 0x00, 0x00, /* SSDT.... */ 0x53, 0x53, 0x44, 0x54, 0x7E, 0x00, 0x00, 0x00, /* SSDT.... */