Since we marked the FV at PcdOvmfPeiMemFvBase as ACPI NVS memory, we can use it on S3 resume.
The FV at PcdOvmfDxeMemFvBase may have been overwritten by the OS, but we do not use it's contents on S3 resume. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <[email protected]> --- OvmfPkg/Sec/SecMain.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 21c2a36..f79215c 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -469,6 +469,50 @@ FindPeiCoreImageBaseInFv ( return EFI_SUCCESS; } + +/** + Reads 8-bits of CMOS data. + + Reads the 8-bits of CMOS data at the location specified by Index. + The 8-bit read value is returned. + + @param Index The CMOS location to read. + + @return The value read. + +**/ +STATIC +UINT8 +CmosRead8 ( + IN UINTN Index + ) +{ + IoWrite8 (0x70, (UINT8) Index); + return IoRead8 (0x71); +} + + +STATIC +BOOLEAN +IsS3Resume ( + VOID + ) +{ + return (CmosRead8 (0xF) == 0xFE); +} + + +STATIC +EFI_STATUS +GetS3ResumePeiFv ( + IN OUT EFI_FIRMWARE_VOLUME_HEADER **PeiFv + ) +{ + *PeiFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfPeiMemFvBase); + return EFI_SUCCESS; +} + + /** Locates the PEI Core entry point address @@ -488,9 +532,15 @@ FindPeiCoreImageBase ( { *PeiCoreImageBase = 0; - FindMainFv (PeiFv); + if (IsS3Resume ()) { + DEBUG ((EFI_D_VERBOSE, "SEC: S3 resume\n")); + GetS3ResumePeiFv (PeiFv); + } else { + DEBUG ((EFI_D_VERBOSE, "SEC: Normal boot\n")); + FindMainFv (PeiFv); - DecompressMemFvs (PeiFv); + DecompressMemFvs (PeiFv); + } FindPeiCoreImageBaseInFv (*PeiFv, PeiCoreImageBase); } -- 1.8.5.2 ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
