OvmfPkg: Split MAINFV into a separate PEI and DXE FVs

By splitting the PEI and DXE phases into separate FVs,
we can only reserve the PEI FV for ACPI S3 support.
This should save about 7MB.

Unfortunately, this all has to happen in a single commit.

DEC:
* Remove PcdOvmfMemFv(Base|Size)
* Add PcdOvmfPeiMemFv(Base|Size)
* Add PcdOvmfDxeMemFv(Base|Size)

FDF:
* Add new PEIFV. Move PEI modules here.
* Remove MAINFV
* Add PEIFV and DXEFV into FVMAIN_COMPACT
   - They are added as 2 sections of a file, and compressed
     together so they should retain good compression
* PcdOvmf(Pei|Dxe)MemFv(Base|Size) are set

SEC:
* Find both the PEI and DXE FVs after decompression.
   - Copy them separately to their memory locations.

Platform PEI driver:
* Fv.c: Publish both FVs as appropriate
* MemDetect.c: PcdOvmfMemFv(Base|Size) =>
                PcdOvmfDxeMemFv(Base|Size)

OVMF.fd before:

  Non-volatile data storage
  FVMAIN_COMPACT                    uncompressed
    FV FFS file                     LZMA compressed
      MAINFV                        uncompressed
        individual PEI modules      uncompressed
        FV FFS file                 compressed with PI_NONE
          DXEFV                     uncompressed
            individual DXE modules  uncompressed
  SECFV                             uncompressed

OVMF.fd after:

  Non-volatile data storage
  FVMAIN_COMPACT                    uncompressed
    FV FFS file                     LZMA compressed
      PEIFV                         uncompressed
        individual PEI modules      uncompressed
      DXEFV                         uncompressed
        individual DXE modules      uncompressed
  SECFV                             uncompressed

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15151 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Jordan Justen 2014-01-21 19:39:13 +00:00 committed by jljusten
parent 4b4b783dbe
commit b36f701d4f
9 changed files with 144 additions and 107 deletions

View File

@ -48,8 +48,10 @@
gBlockMmioProtocolGuid = {0x6b558ce3, 0x69e5, 0x4c67, {0xa6, 0x34, 0xf7, 0xfe, 0x72, 0xad, 0xbe, 0x84}} gBlockMmioProtocolGuid = {0x6b558ce3, 0x69e5, 0x4c67, {0xa6, 0x34, 0xf7, 0xfe, 0x72, 0xad, 0xbe, 0x84}}
[PcdsFixedAtBuild] [PcdsFixedAtBuild]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase|0x0|UINT32|0 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|0x0|UINT32|0
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize|0x0|UINT32|1 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize|0x0|UINT32|1
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|0x0|UINT32|0x15
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize|0x0|UINT32|0x16
## This flag is used to control the destination port for PlatformDebugLibIoPort ## This flag is used to control the destination port for PlatformDebugLibIoPort
gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort|0x402|UINT16|4 gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort|0x402|UINT16|4

View File

@ -141,9 +141,13 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.P
0x010000|0x008000 0x010000|0x008000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
0x020000|0x7E0000 0x020000|0x0E0000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
FV = MAINFV FV = PEIFV
0x100000|0x700000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
FV = DXEFV
################################################################################ ################################################################################
@ -170,14 +174,14 @@ READ_LOCK_STATUS = TRUE
# SEC Phase modules # SEC Phase modules
# #
# The code in this FV handles the initial firmware startup, and # The code in this FV handles the initial firmware startup, and
# decompresses the MAINFV which handles the majority of the boot sequence. # decompresses the PEI and DXE FVs which handles the rest of the boot sequence.
# #
INF OvmfPkg/Sec/SecMain.inf INF OvmfPkg/Sec/SecMain.inf
INF RuleOverride=RESET_VECTOR UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf INF RuleOverride=RESET_VECTOR UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf
################################################################################ ################################################################################
[FV.MAINFV] [FV.PEIFV]
BlockSize = 0x10000 BlockSize = 0x10000
FvAlignment = 16 FvAlignment = 16
ERASE_POLARITY = 1 ERASE_POLARITY = 1
@ -196,15 +200,6 @@ READ_STATUS = TRUE
READ_LOCK_CAP = TRUE READ_LOCK_CAP = TRUE
READ_LOCK_STATUS = TRUE READ_LOCK_STATUS = TRUE
#
# Files to be placed in MAIN FV
#
# This firmware volume will have files placed in it uncompressed,
# and then then entire firmware volume will be compressed in a
# single compression operation in order to achieve better
# overall compression.
#
APRIORI PEI { APRIORI PEI {
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
} }
@ -218,12 +213,6 @@ INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
INF OvmfPkg/PlatformPei/PlatformPei.inf INF OvmfPkg/PlatformPei/PlatformPei.inf
INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
FILE FV_IMAGE = A4EF5A93-3F1B-4232-A1C4-F0910E6D1D9C {
SECTION COMPRESS PI_NONE {
SECTION FV_IMAGE = DXEFV
}
}
################################################################################ ################################################################################
[FV.DXEFV] [FV.DXEFV]
@ -400,7 +389,13 @@ READ_LOCK_STATUS = TRUE
FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {
SECTION FV_IMAGE = MAINFV #
# These firmware volumes will have files placed in them uncompressed,
# and then both firmware volumes will be compressed in a single
# compression operation in order to achieve better overall compression.
#
SECTION FV_IMAGE = PEIFV
SECTION FV_IMAGE = DXEFV
} }
} }

View File

@ -141,9 +141,13 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.P
0x010000|0x008000 0x010000|0x008000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
0x020000|0x7E0000 0x020000|0x0E0000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
FV = MAINFV FV = PEIFV
0x100000|0x700000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
FV = DXEFV
################################################################################ ################################################################################
@ -170,14 +174,14 @@ READ_LOCK_STATUS = TRUE
# SEC Phase modules # SEC Phase modules
# #
# The code in this FV handles the initial firmware startup, and # The code in this FV handles the initial firmware startup, and
# decompresses the MAINFV which handles the majority of the boot sequence. # decompresses the PEI and DXE FVs which handles the rest of the boot sequence.
# #
INF OvmfPkg/Sec/SecMain.inf INF OvmfPkg/Sec/SecMain.inf
INF RuleOverride=RESET_VECTOR USE = IA32 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf INF RuleOverride=RESET_VECTOR USE = IA32 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf
################################################################################ ################################################################################
[FV.MAINFV] [FV.PEIFV]
BlockSize = 0x10000 BlockSize = 0x10000
FvAlignment = 16 FvAlignment = 16
ERASE_POLARITY = 1 ERASE_POLARITY = 1
@ -196,15 +200,6 @@ READ_STATUS = TRUE
READ_LOCK_CAP = TRUE READ_LOCK_CAP = TRUE
READ_LOCK_STATUS = TRUE READ_LOCK_STATUS = TRUE
#
# Files to be placed in MAIN FV
#
# This firmware volume will have files placed in it uncompressed,
# and then then entire firmware volume will be compressed in a
# single compression operation in order to achieve better
# overall compression.
#
APRIORI PEI { APRIORI PEI {
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
} }
@ -218,12 +213,6 @@ INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
INF OvmfPkg/PlatformPei/PlatformPei.inf INF OvmfPkg/PlatformPei/PlatformPei.inf
INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
FILE FV_IMAGE = A4EF5A93-3F1B-4232-A1C4-F0910E6D1D9C {
SECTION COMPRESS PI_NONE {
SECTION FV_IMAGE = DXEFV
}
}
################################################################################ ################################################################################
[FV.DXEFV] [FV.DXEFV]
@ -400,7 +389,13 @@ READ_LOCK_STATUS = TRUE
FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {
SECTION FV_IMAGE = MAINFV #
# These firmware volumes will have files placed in them uncompressed,
# and then both firmware volumes will be compressed in a single
# compression operation in order to achieve better overall compression.
#
SECTION FV_IMAGE = PEIFV
SECTION FV_IMAGE = DXEFV
} }
} }

View File

@ -141,9 +141,13 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.P
0x010000|0x008000 0x010000|0x008000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
0x020000|0x7E0000 0x020000|0x0E0000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
FV = MAINFV FV = PEIFV
0x100000|0x700000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
FV = DXEFV
################################################################################ ################################################################################
@ -170,14 +174,14 @@ READ_LOCK_STATUS = TRUE
# SEC Phase modules # SEC Phase modules
# #
# The code in this FV handles the initial firmware startup, and # The code in this FV handles the initial firmware startup, and
# decompresses the MAINFV which handles the majority of the boot sequence. # decompresses the PEI and DXE FVs which handles the rest of the boot sequence.
# #
INF OvmfPkg/Sec/SecMain.inf INF OvmfPkg/Sec/SecMain.inf
INF RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/Bin/ResetVector.inf INF RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/Bin/ResetVector.inf
################################################################################ ################################################################################
[FV.MAINFV] [FV.PEIFV]
BlockSize = 0x10000 BlockSize = 0x10000
FvAlignment = 16 FvAlignment = 16
ERASE_POLARITY = 1 ERASE_POLARITY = 1
@ -196,15 +200,6 @@ READ_STATUS = TRUE
READ_LOCK_CAP = TRUE READ_LOCK_CAP = TRUE
READ_LOCK_STATUS = TRUE READ_LOCK_STATUS = TRUE
#
# Files to be placed in MAIN FV
#
# This firmware volume will have files placed in it uncompressed,
# and then then entire firmware volume will be compressed in a
# single compression operation in order to achieve better
# overall compression.
#
APRIORI PEI { APRIORI PEI {
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
} }
@ -218,12 +213,6 @@ INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
INF OvmfPkg/PlatformPei/PlatformPei.inf INF OvmfPkg/PlatformPei/PlatformPei.inf
INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
FILE FV_IMAGE = A4EF5A93-3F1B-4232-A1C4-F0910E6D1D9C {
SECTION COMPRESS PI_NONE {
SECTION FV_IMAGE = DXEFV
}
}
################################################################################ ################################################################################
[FV.DXEFV] [FV.DXEFV]
@ -400,7 +389,13 @@ READ_LOCK_STATUS = TRUE
FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {
SECTION FV_IMAGE = MAINFV #
# These firmware volumes will have files placed in them uncompressed,
# and then both firmware volumes will be compressed in a single
# compression operation in order to achieve better overall compression.
#
SECTION FV_IMAGE = PEIFV
SECTION FV_IMAGE = DXEFV
} }
} }

View File

@ -1,7 +1,7 @@
/** @file /** @file
Build FV related hobs for platform. Build FV related hobs for platform.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -20,10 +20,8 @@
/** /**
Perform a call-back into the SEC simulator to get address of the Firmware Hub Publish PEI & DXE (Decompressed) Memory based FVs to let PEI
and DXE know about them.
@param FfsHeader Ffs Header availible to every PEIM
@param PeiServices General purpose services available to every PEIM.
@retval EFI_SUCCESS Platform PEI FVs were initialized successfully. @retval EFI_SUCCESS Platform PEI FVs were initialized successfully.
@ -33,26 +31,44 @@ PeiFvInitialization (
VOID VOID
) )
{ {
DEBUG ((EFI_D_ERROR, "Platform PEI Firmware Volume Initialization\n")); DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));
DEBUG (
(EFI_D_ERROR, "Firmware Volume HOB: 0x%x 0x%x\n",
PcdGet32 (PcdOvmfMemFvBase),
PcdGet32 (PcdOvmfMemFvSize)
)
);
BuildFvHob (PcdGet32 (PcdOvmfMemFvBase), PcdGet32 (PcdOvmfMemFvSize));
// //
// Create a memory allocation HOB. // Create a memory allocation HOB for the PEI FV.
//
// This is marked as ACPI NVS so it will still be available on S3 resume.
// //
BuildMemoryAllocationHob ( BuildMemoryAllocationHob (
PcdGet32 (PcdOvmfMemFvBase), PcdGet32 (PcdOvmfPeiMemFvBase),
PcdGet32 (PcdOvmfMemFvSize), PcdGet32 (PcdOvmfPeiMemFvSize),
EfiACPIMemoryNVS
);
//
// Let DXE know about the DXE FV
//
BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
//
// Create a memory allocation HOB for the DXE FV.
//
BuildMemoryAllocationHob (
PcdGet32 (PcdOvmfDxeMemFvBase),
PcdGet32 (PcdOvmfDxeMemFvSize),
EfiBootServicesData EfiBootServicesData
); );
//
// Let PEI know about the DXE FV so it can find the DXE Core
//
PeiServicesInstallFvInfoPpi (
NULL,
(VOID *)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase),
PcdGet32 (PcdOvmfDxeMemFvSize),
NULL,
NULL
);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -1,7 +1,7 @@
/**@file /**@file
Memory Detection for Virtual Machines. Memory Detection for Virtual Machines.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -104,7 +104,7 @@ PublishPeiMemory (
// //
// Determine the range of memory to use during PEI // Determine the range of memory to use during PEI
// //
MemoryBase = PcdGet32 (PcdOvmfMemFvBase) + PcdGet32 (PcdOvmfMemFvSize); MemoryBase = PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize);
MemorySize = LowerMemorySize - MemoryBase; MemorySize = LowerMemorySize - MemoryBase;
if (MemorySize > SIZE_64MB) { if (MemorySize > SIZE_64MB) {
MemoryBase = LowerMemorySize - SIZE_64MB; MemoryBase = LowerMemorySize - SIZE_64MB;

View File

@ -2,7 +2,7 @@
# Platform PEI driver # Platform PEI driver
# #
# This module provides platform specific function to detect boot mode. # This module provides platform specific function to detect boot mode.
# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -58,8 +58,10 @@
PcdLib PcdLib
[Pcd] [Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress
gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize

View File

@ -311,7 +311,7 @@ FindFfsFileAndSection (
Locates the compressed main firmware volume and decompresses it. Locates the compressed main firmware volume and decompresses it.
@param[in,out] Fv On input, the firmware volume to search @param[in,out] Fv On input, the firmware volume to search
On output, the decompressed main FV On output, the decompressed BOOT/PEI FV
@retval EFI_SUCCESS The file and section was found @retval EFI_SUCCESS The file and section was found
@retval EFI_NOT_FOUND The file and section was not found @retval EFI_NOT_FOUND The file and section was not found
@ -319,7 +319,7 @@ FindFfsFileAndSection (
**/ **/
EFI_STATUS EFI_STATUS
DecompressGuidedFv ( DecompressMemFvs (
IN OUT EFI_FIRMWARE_VOLUME_HEADER **Fv IN OUT EFI_FIRMWARE_VOLUME_HEADER **Fv
) )
{ {
@ -331,10 +331,11 @@ DecompressGuidedFv (
UINT32 AuthenticationStatus; UINT32 AuthenticationStatus;
VOID *OutputBuffer; VOID *OutputBuffer;
VOID *ScratchBuffer; VOID *ScratchBuffer;
EFI_FIRMWARE_VOLUME_IMAGE_SECTION *NewFvSection; EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FvSection;
EFI_FIRMWARE_VOLUME_HEADER *NewFv; EFI_FIRMWARE_VOLUME_HEADER *PeiMemFv;
EFI_FIRMWARE_VOLUME_HEADER *DxeMemFv;
NewFvSection = (EFI_FIRMWARE_VOLUME_IMAGE_SECTION*) NULL; FvSection = (EFI_FIRMWARE_VOLUME_IMAGE_SECTION*) NULL;
Status = FindFfsFileAndSection ( Status = FindFfsFileAndSection (
*Fv, *Fv,
@ -358,8 +359,7 @@ DecompressGuidedFv (
return Status; return Status;
} }
//PcdGet32 (PcdOvmfMemFvBase), PcdGet32 (PcdOvmfMemFvSize) OutputBuffer = (VOID*) ((UINT8*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase) + SIZE_1MB);
OutputBuffer = (VOID*) ((UINT8*)(UINTN) PcdGet32 (PcdOvmfMemFvBase) + SIZE_1MB);
ScratchBuffer = ALIGN_POINTER ((UINT8*) OutputBuffer + OutputBufferSize, SIZE_1MB); ScratchBuffer = ALIGN_POINTER ((UINT8*) OutputBuffer + OutputBufferSize, SIZE_1MB);
Status = ExtractGuidedSectionDecode ( Status = ExtractGuidedSectionDecode (
Section, Section,
@ -372,27 +372,57 @@ DecompressGuidedFv (
return Status; return Status;
} }
Status = FindFfsSectionInSections ( Status = FindFfsSectionInstance (
OutputBuffer, OutputBuffer,
OutputBufferSize, OutputBufferSize,
EFI_SECTION_FIRMWARE_VOLUME_IMAGE, EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
(EFI_COMMON_SECTION_HEADER**) &NewFvSection 0,
(EFI_COMMON_SECTION_HEADER**) &FvSection
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "Unable to find FV image in extracted data\n")); DEBUG ((EFI_D_ERROR, "Unable to find PEI FV section\n"));
return Status; return Status;
} }
NewFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfMemFvBase); ASSERT (SECTION_SIZE (FvSection) ==
CopyMem (NewFv, (VOID*) (NewFvSection + 1), PcdGet32 (PcdOvmfMemFvSize)); (PcdGet32 (PcdOvmfPeiMemFvSize) + sizeof (*FvSection)));
ASSERT (FvSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE);
if (NewFv->Signature != EFI_FVH_SIGNATURE) { PeiMemFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfPeiMemFvBase);
DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", NewFv)); CopyMem (PeiMemFv, (VOID*) (FvSection + 1), PcdGet32 (PcdOvmfPeiMemFvSize));
if (PeiMemFv->Signature != EFI_FVH_SIGNATURE) {
DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", PeiMemFv));
CpuDeadLoop (); CpuDeadLoop ();
return EFI_VOLUME_CORRUPTED; return EFI_VOLUME_CORRUPTED;
} }
*Fv = NewFv; Status = FindFfsSectionInstance (
OutputBuffer,
OutputBufferSize,
EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
1,
(EFI_COMMON_SECTION_HEADER**) &FvSection
);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "Unable to find DXE FV section\n"));
return Status;
}
ASSERT (FvSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE);
ASSERT (SECTION_SIZE (FvSection) ==
(PcdGet32 (PcdOvmfDxeMemFvSize) + sizeof (*FvSection)));
DxeMemFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase);
CopyMem (DxeMemFv, (VOID*) (FvSection + 1), PcdGet32 (PcdOvmfDxeMemFvSize));
if (DxeMemFv->Signature != EFI_FVH_SIGNATURE) {
DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", DxeMemFv));
CpuDeadLoop ();
return EFI_VOLUME_CORRUPTED;
}
*Fv = PeiMemFv;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -460,7 +490,7 @@ FindPeiCoreImageBase (
FindMainFv (BootFv); FindMainFv (BootFv);
DecompressGuidedFv (BootFv); DecompressMemFvs (BootFv);
FindPeiCoreImageBaseInFv (*BootFv, PeiCoreImageBase); FindPeiCoreImageBaseInFv (*BootFv, PeiCoreImageBase);
} }

View File

@ -1,7 +1,7 @@
## @file ## @file
# SEC Driver # SEC Driver
# #
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -64,8 +64,10 @@
gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED
[Pcd] [Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize