]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Sec/SecMain.c
OvmfPkg/Sec: Don't decompress the FV on S3 resume
[mirror_edk2.git] / OvmfPkg / Sec / SecMain.c
index 0edc4f9af3cfbfee0f73c4d78f105a5ed0e7d939..670ad8d763aab0dc3a5f8215ee57c96a3cf7c6dd 100644 (file)
@@ -469,6 +469,50 @@ FindPeiCoreImageBaseInFv (
   return EFI_SUCCESS;\r
 }\r
 \r
+\r
+/**\r
+  Reads 8-bits of CMOS data.\r
+\r
+  Reads the 8-bits of CMOS data at the location specified by Index.\r
+  The 8-bit read value is returned.\r
+\r
+  @param  Index  The CMOS location to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+STATIC\r
+UINT8\r
+CmosRead8 (\r
+  IN      UINTN                     Index\r
+  )\r
+{\r
+  IoWrite8 (0x70, (UINT8) Index);\r
+  return IoRead8 (0x71);\r
+}\r
+\r
+\r
+STATIC\r
+BOOLEAN\r
+IsS3Resume (\r
+  VOID\r
+  )\r
+{\r
+  return (CmosRead8 (0xF) == 0xFE);\r
+}\r
+\r
+\r
+STATIC\r
+EFI_STATUS\r
+GetS3ResumePeiFv (\r
+  IN OUT EFI_FIRMWARE_VOLUME_HEADER       **PeiFv\r
+  )\r
+{\r
+  *PeiFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfPeiMemFvBase);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
 /**\r
   Locates the PEI Core entry point address\r
 \r
@@ -488,9 +532,15 @@ FindPeiCoreImageBase (
 {\r
   *PeiCoreImageBase = 0;\r
 \r
-  FindMainFv (BootFv);\r
+  if (IsS3Resume ()) {\r
+    DEBUG ((EFI_D_VERBOSE, "SEC: S3 resume\n"));\r
+    GetS3ResumePeiFv (BootFv);\r
+  } else {\r
+    DEBUG ((EFI_D_VERBOSE, "SEC: Normal boot\n"));\r
+    FindMainFv (BootFv);\r
 \r
-  DecompressMemFvs (BootFv);\r
+    DecompressMemFvs (BootFv);\r
+  }\r
 \r
   FindPeiCoreImageBaseInFv (*BootFv, PeiCoreImageBase);\r
 }\r