The library constructor asserts PmGpeEnBase != 0. We derive that field from FADT->Gpe0Blk in ParseAcpiInfo(), and ACPI permits a platform to omit the GPE0 block (Gpe0Blk = 0, Gpe0BlkLen = 0) when it exposes no General Purpose Events, so PmGpeEnBase is legitimately zero there and a DEBUG build does not come up on such a platform.
The only consumer of PmGpeEnBase is ResetShutdown(), which writes zero to the GPE0_EN register to prevent GPI wake events during the S5 transition. On a platform without a GPE0 block there is nothing to disable, so the write can simply be skipped. Drop the constructor assertion and guard the IoWrite16 in ResetShutdown(). In UefiPayloadEntry/AcpiTable.c, report PmGpeEnBase as zero when Gpe0BlkLen is zero instead of the value of Gpe0Blk, which the "upper half of a zero-length register pair" arithmetic would otherwise yield. That way the consumer skips the access instead of clearing status bits. Cc: Benjamin Doron <[email protected]> Cc: Gua Guo <[email protected]> Cc: Guo Dong <[email protected]> Cc: James Lu <[email protected]> Cc: Sean Rhodes <[email protected]> Cc: Shuo Liu <[email protected]> Assisted-by: claude-opus-5 Signed-off-by: Alexander Graf <[email protected]> --- .../Library/ResetSystemLib/ResetSystemLib.c | 5 +++-- UefiPayloadPkg/UefiPayloadEntry/AcpiTable.c | 14 +++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c b/UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c index f252855cfb..c572f4ed9c 100644 --- a/UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c +++ b/UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c @@ -42,7 +42,6 @@ ResetSystemLibConstructor ( ASSERT (mAcpiBoardInfo.ResetRegAddress != 0); ASSERT (mAcpiBoardInfo.ResetValue != 0); - ASSERT (mAcpiBoardInfo.PmGpeEnBase != 0); ASSERT (mAcpiBoardInfo.PmEvtBase != 0); ASSERT (mAcpiBoardInfo.PmCtrlRegBase != 0); @@ -103,7 +102,9 @@ ResetShutdown ( // // GPE0_EN should be disabled to avoid any GPI waking up the system from S5 // - IoWrite16 ((UINTN)mAcpiBoardInfo.PmGpeEnBase, 0); + if (mAcpiBoardInfo.PmGpeEnBase != 0) { + IoWrite16 ((UINTN)mAcpiBoardInfo.PmGpeEnBase, 0); + } // // Clear Power Button Status diff --git a/UefiPayloadPkg/UefiPayloadEntry/AcpiTable.c b/UefiPayloadPkg/UefiPayloadEntry/AcpiTable.c index b50f460bb3..503257efe8 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/AcpiTable.c +++ b/UefiPayloadPkg/UefiPayloadEntry/AcpiTable.c @@ -105,7 +105,19 @@ Done: AcpiBoardInfo->ResetRegAddress = Fadt->ResetReg.Address; AcpiBoardInfo->ResetValue = Fadt->ResetValue; AcpiBoardInfo->PmEvtBase = Fadt->Pm1aEvtBlk; - AcpiBoardInfo->PmGpeEnBase = Fadt->Gpe0Blk + Fadt->Gpe0BlkLen / 2; + + // + // The GPE0 enable register is the upper half of a GPE0 register pair + // that is Gpe0BlkLen bytes long. A FADT reporting a zero length has no + // enable register at all, and adding half of zero would name the GPE0 + // status block instead: report 0 so that consumers skip the access + // rather than clearing status bits. + // + if (Fadt->Gpe0BlkLen != 0) { + AcpiBoardInfo->PmGpeEnBase = Fadt->Gpe0Blk + Fadt->Gpe0BlkLen / 2; + } else { + AcpiBoardInfo->PmGpeEnBase = 0; + } if (MmCfgHdr != NULL) { MmCfgBase = (EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE *)((UINT8 *)MmCfgHdr + sizeof (*MmCfgHdr)); -- 2.47.3 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#122085): https://edk2.groups.io/g/devel/message/122085 Mute This Topic: https://groups.io/mt/120797196/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
