Skip to content

Commit

Permalink
Add step notices for Mobility.HvGcs.
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Dec 12, 2024
1 parent 1878345 commit 6922f94
Showing 1 changed file with 46 additions and 34 deletions.
80 changes: 46 additions & 34 deletions Mobility.HvGcs/Mobility.HvGcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <Mile.Project.Version.h>

#include <Uefi.h>
#include <Protocol/GraphicsOutput.h>
#include <Guid/Acpi.h>
#include <IndustryStandard/Acpi20.h>
#include <IndustryStandard/Acpi30.h>
Expand Down Expand Up @@ -308,7 +307,8 @@ EFI_STATUS EFIAPI UefiMain(
{
::OutputWideString(
SystemTable->ConOut,
L"Yolo!\r\n");
L"Hyper-V Generation 2 Virtual Machine detected, "
L"starting to patch ACPI description tables...\r\n");

MO_ACPI_DESCRIPTION_TABLES DescriptionTables;
::MoAcpiGetDescriptionTables(SystemTable, &DescriptionTables);
Expand All @@ -321,12 +321,10 @@ EFI_STATUS EFIAPI UefiMain(
::MoCalculateChecksum8(
reinterpret_cast<uint8_t*>(DescriptionTables.MadtHeader),
DescriptionTables.MadtHeader->Header.Length);
/*if (!(EFI_ACPI_2_0_PCAT_COMPAT & DescriptionTables.MadtHeader->Flags))
{
::OutputWideString(
SystemTable->ConOut,
L"Not Yolo!\r\n");
}*/

::OutputWideString(
SystemTable->ConOut,
L"ACPI MADT PC-AT Compatibility flags bit is applied.\r\n");
}

if (DescriptionTables.Fadt)
Expand All @@ -338,6 +336,10 @@ EFI_STATUS EFIAPI UefiMain(
{
DescriptionTables.Fadt->Pm1aEvtBlk = static_cast<UINT32>(
DescriptionTables.Fadt->XPm1aEvtBlk.Address);

::OutputWideString(
SystemTable->ConOut,
L"ACPI FADT Pm1aEvtBlk workaround is applied.\r\n");
}
}

Expand All @@ -348,6 +350,10 @@ EFI_STATUS EFIAPI UefiMain(
{
DescriptionTables.Fadt->Pm1bEvtBlk = static_cast<UINT32>(
DescriptionTables.Fadt->XPm1bEvtBlk.Address);

::OutputWideString(
SystemTable->ConOut,
L"ACPI FADT Pm1bEvtBlk workaround is applied.\r\n");
}
}

Expand All @@ -358,6 +364,10 @@ EFI_STATUS EFIAPI UefiMain(
{
DescriptionTables.Fadt->Pm1aCntBlk = static_cast<UINT32>(
DescriptionTables.Fadt->XPm1aCntBlk.Address);

::OutputWideString(
SystemTable->ConOut,
L"ACPI FADT Pm1aCntBlk workaround is applied.\r\n");
}
}

Expand All @@ -368,6 +378,10 @@ EFI_STATUS EFIAPI UefiMain(
{
DescriptionTables.Fadt->Pm1bCntBlk = static_cast<UINT32>(
DescriptionTables.Fadt->XPm1bCntBlk.Address);

::OutputWideString(
SystemTable->ConOut,
L"ACPI FADT Pm1bCntBlk workaround is applied.\r\n");
}
}

Expand All @@ -378,6 +392,10 @@ EFI_STATUS EFIAPI UefiMain(
{
DescriptionTables.Fadt->Pm2CntBlk = static_cast<UINT32>(
DescriptionTables.Fadt->XPm2CntBlk.Address);

::OutputWideString(
SystemTable->ConOut,
L"ACPI FADT Pm2CntBlk workaround is applied.\r\n");
}
}

Expand All @@ -388,6 +406,10 @@ EFI_STATUS EFIAPI UefiMain(
{
DescriptionTables.Fadt->PmTmrBlk = static_cast<UINT32>(
DescriptionTables.Fadt->XPmTmrBlk.Address);

::OutputWideString(
SystemTable->ConOut,
L"ACPI FADT PmTmrBlk workaround is applied.\r\n");
}
}

Expand All @@ -398,6 +420,10 @@ EFI_STATUS EFIAPI UefiMain(
{
DescriptionTables.Fadt->Gpe0Blk = static_cast<UINT32>(
DescriptionTables.Fadt->XGpe0Blk.Address);

::OutputWideString(
SystemTable->ConOut,
L"ACPI FADT Gpe0Blk workaround is applied.\r\n");
}
}

Expand All @@ -408,6 +434,10 @@ EFI_STATUS EFIAPI UefiMain(
{
DescriptionTables.Fadt->Gpe1Blk = static_cast<UINT32>(
DescriptionTables.Fadt->XGpe1Blk.Address);

::OutputWideString(
SystemTable->ConOut,
L"ACPI FADT Gpe1Blk workaround is applied.\r\n");
}
}

Expand Down Expand Up @@ -436,46 +466,28 @@ EFI_STATUS EFIAPI UefiMain(
AddressBase |= CandidateItem->AddressBaseLow;
if (AddressBase >= 0x20000000000ULL)
{
/*CandidateItem->ProximityDomain = 0;
CandidateItem->AddressBaseLow = 0;
CandidateItem->AddressBaseHigh = 0;
CandidateItem->LengthLow = 0;
CandidateItem->LengthHigh = 0;*/
CandidateItem->Flags = 0;
}
}
ProcessedSize += CandidateItem->Length;
CurrentSratItemEntry += CandidateItem->Length;
}

//DescriptionTables.SratHeader->Header.Length = ProcessedSize;
DescriptionTables.SratHeader->Header.Checksum = 0;
DescriptionTables.SratHeader->Header.Checksum =
::MoCalculateChecksum8(
reinterpret_cast<uint8_t*>(DescriptionTables.SratHeader),
DescriptionTables.SratHeader->Header.Length);
}
}

::OutputWideString(
SystemTable->ConOut,
L"Patched!\r\n");

/*::OutputWideString(
SystemTable->ConOut,
L"Hello World!\r\n");
::OutputWideString(
SystemTable->ConOut,
L"ACPI SRAT workaround is applied.\r\n");
}

::OutputWideString(
SystemTable->ConOut,
L"\r\n"
L"Press any key to return to the boot menu...\r\n");
{
UINTN Index = 0;
SystemTable->BootServices->WaitForEvent(
1,
&SystemTable->ConIn->WaitForKey,
&Index);
}*/
::OutputWideString(
SystemTable->ConOut,
L"All needed ACPI description tables are patched.\r\n");
}

return EFI_SUCCESS;
}
Expand Down

0 comments on commit 6922f94

Please sign in to comment.