]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Sec/SecMain.c
UefiCpuPkg/PiSmmCpuDxeSmm: TransferApToSafeState() use UINTN params
[mirror_edk2.git] / OvmfPkg / Sec / SecMain.c
index a12e6768ae26c28447a5c80e314e7c76fffa6b64..e1993ec347b54d6d83254485718995baae9efff1 100644 (file)
@@ -2,6 +2,7 @@
   Main SEC phase code.  Transitions to PEI.\r
 \r
   Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -332,11 +333,13 @@ DecompressMemFvs (
   UINT32                            AuthenticationStatus;\r
   VOID                              *OutputBuffer;\r
   VOID                              *ScratchBuffer;\r
-  EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FvSection;\r
+  EFI_COMMON_SECTION_HEADER         *FvSection;\r
   EFI_FIRMWARE_VOLUME_HEADER        *PeiMemFv;\r
   EFI_FIRMWARE_VOLUME_HEADER        *DxeMemFv;\r
+  UINT32                            FvHeaderSize;\r
+  UINT32                            FvSectionSize;\r
 \r
-  FvSection = (EFI_FIRMWARE_VOLUME_IMAGE_SECTION*) NULL;\r
+  FvSection = (EFI_COMMON_SECTION_HEADER*) NULL;\r
 \r
   Status = FindFfsFileAndSection (\r
              *Fv,\r
@@ -386,7 +389,7 @@ DecompressMemFvs (
              OutputBufferSize,\r
              EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r
              0,\r
-             (EFI_COMMON_SECTION_HEADER**) &FvSection\r
+             &FvSection\r
              );\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((EFI_D_ERROR, "Unable to find PEI FV section\n"));\r
@@ -411,7 +414,7 @@ DecompressMemFvs (
              OutputBufferSize,\r
              EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r
              1,\r
-             (EFI_COMMON_SECTION_HEADER**) &FvSection\r
+             &FvSection\r
              );\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((EFI_D_ERROR, "Unable to find DXE FV section\n"));\r
@@ -419,11 +422,19 @@ DecompressMemFvs (
   }\r
 \r
   ASSERT (FvSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE);\r
-  ASSERT (SECTION_SIZE (FvSection) ==\r
-          (PcdGet32 (PcdOvmfDxeMemFvSize) + sizeof (*FvSection)));\r
+\r
+  if (IS_SECTION2 (FvSection)) {\r
+    FvSectionSize = SECTION2_SIZE (FvSection);\r
+    FvHeaderSize = sizeof (EFI_COMMON_SECTION_HEADER2);\r
+  } else {\r
+    FvSectionSize = SECTION_SIZE (FvSection);\r
+    FvHeaderSize = sizeof (EFI_COMMON_SECTION_HEADER);\r
+  }\r
+\r
+  ASSERT (FvSectionSize == (PcdGet32 (PcdOvmfDxeMemFvSize) + FvHeaderSize));\r
 \r
   DxeMemFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase);\r
-  CopyMem (DxeMemFv, (VOID*) (FvSection + 1), PcdGet32 (PcdOvmfDxeMemFvSize));\r
+  CopyMem (DxeMemFv, (VOID*) ((UINTN)FvSection + FvHeaderSize), PcdGet32 (PcdOvmfDxeMemFvSize));\r
 \r
   if (DxeMemFv->Signature != EFI_FVH_SIGNATURE) {\r
     DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", DxeMemFv));\r
@@ -658,7 +669,7 @@ FindImageBase (
 /*\r
   Find and return Pei Core entry point.\r
 \r
-  It also find SEC and PEI Core file debug inforamtion. It will report them if\r
+  It also find SEC and PEI Core file debug information. It will report them if\r
   remote debug is enabled.\r
 \r
 **/\r