mirror of https://github.com/acidanthera/audk.git
Enable PeiCore to dispatch the encapsulated fv images with depex expression. This feature can process the different fv images in the different boot path, which is useful for boot performance and image size.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4366 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
6ee65722c7
commit
288f9b3824
|
@ -54,7 +54,6 @@ Abstract:
|
||||||
#include <Library/PeCoffLib.h>
|
#include <Library/PeCoffLib.h>
|
||||||
#include <Library/S3Lib.h>
|
#include <Library/S3Lib.h>
|
||||||
#include <Library/RecoveryLib.h>
|
#include <Library/RecoveryLib.h>
|
||||||
#include <Library/PeiPiLib.h>
|
|
||||||
|
|
||||||
#define STACK_SIZE 0x20000
|
#define STACK_SIZE 0x20000
|
||||||
#define BSP_STORE_SIZE 0x4000
|
#define BSP_STORE_SIZE 0x4000
|
||||||
|
@ -73,16 +72,7 @@ PeiLoadFile (
|
||||||
;
|
;
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
DxeIplAddEncapsulatedFirmwareVolumes (
|
DxeIplFindDxeCore (
|
||||||
VOID
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
DxeIplFindFirmwareVolumeInstance (
|
|
||||||
IN OUT UINTN *Instance,
|
|
||||||
IN EFI_FV_FILETYPE SeachType,
|
|
||||||
OUT EFI_PEI_FV_HANDLE *VolumeHandle,
|
|
||||||
OUT EFI_PEI_FILE_HANDLE *FileHandle
|
OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
|
@ -78,13 +78,7 @@
|
||||||
DebugLib
|
DebugLib
|
||||||
S3Lib
|
S3Lib
|
||||||
RecoveryLib
|
RecoveryLib
|
||||||
PeiPiLib
|
PerformanceLib
|
||||||
|
|
||||||
[Protocols]
|
|
||||||
gEfiCustomizedDecompressProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
|
|
||||||
gEfiTianoDecompressProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
|
|
||||||
gEfiDecompressProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
|
|
||||||
|
|
||||||
|
|
||||||
[Ppis]
|
[Ppis]
|
||||||
gEfiPeiSecurityPpiGuid # PPI SOMETIMES_CONSUMED
|
gEfiPeiSecurityPpiGuid # PPI SOMETIMES_CONSUMED
|
||||||
|
|
|
@ -135,11 +135,11 @@ PeimInitializeDxeIpl (
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Install FvFileLoader and DxeIpl PPIs.
|
// Install DxeIpl and Decompress PPIs.
|
||||||
//
|
//
|
||||||
Status = PeiServicesInstallPpi (mPpiList);
|
Status = PeiServicesInstallPpi (mPpiList);
|
||||||
ASSERT_EFI_ERROR(Status);
|
ASSERT_EFI_ERROR(Status);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,9 +167,7 @@ DxeLoadCore (
|
||||||
UINT64 DxeCoreSize;
|
UINT64 DxeCoreSize;
|
||||||
EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint;
|
EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint;
|
||||||
EFI_BOOT_MODE BootMode;
|
EFI_BOOT_MODE BootMode;
|
||||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
|
||||||
EFI_PEI_FILE_HANDLE FileHandle;
|
EFI_PEI_FILE_HANDLE FileHandle;
|
||||||
UINTN Instance;
|
|
||||||
EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;
|
EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;
|
||||||
UINTN DataSize;
|
UINTN DataSize;
|
||||||
EFI_MEMORY_TYPE_INFORMATION MemoryData [EfiMaxMemoryType + 1];
|
EFI_MEMORY_TYPE_INFORMATION MemoryData [EfiMaxMemoryType + 1];
|
||||||
|
@ -194,7 +192,7 @@ DxeLoadCore (
|
||||||
// Now should have a HOB with the DXE core w/ the old HOB destroyed
|
// Now should have a HOB with the DXE core w/ the old HOB destroyed
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = PeiServicesLocatePpi (
|
Status = PeiServicesLocatePpi (
|
||||||
&gEfiPeiReadOnlyVariable2PpiGuid,
|
&gEfiPeiReadOnlyVariable2PpiGuid,
|
||||||
0,
|
0,
|
||||||
|
@ -223,16 +221,12 @@ DxeLoadCore (
|
||||||
DataSize
|
DataSize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// If any FV contains an encapsulated FV extract that FV
|
|
||||||
//
|
|
||||||
DxeIplAddEncapsulatedFirmwareVolumes ();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Look in all the FVs present in PEI and find the DXE Core
|
// Look in all the FVs present in PEI and find the DXE Core
|
||||||
//
|
//
|
||||||
Instance = 0;
|
FileHandle = NULL;
|
||||||
Status = DxeIplFindFirmwareVolumeInstance (&Instance, EFI_FV_FILETYPE_DXE_CORE, &VolumeHandle, &FileHandle);
|
Status = DxeIplFindDxeCore (&FileHandle);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
CopyMem(&DxeCoreFileName, &(((EFI_FFS_FILE_HEADER*)FileHandle)->Name), sizeof (EFI_GUID));
|
CopyMem(&DxeCoreFileName, &(((EFI_FFS_FILE_HEADER*)FileHandle)->Name), sizeof (EFI_GUID));
|
||||||
|
@ -297,171 +291,38 @@ DxeLoadCore (
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STATIC
|
|
||||||
EFI_STATUS
|
|
||||||
GetFvAlignment (
|
|
||||||
IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader,
|
|
||||||
OUT UINT32 *FvAlignment
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Because FvLength in FvHeader is UINT64 type,
|
|
||||||
// so FvHeader must meed at least 8 bytes alignment.
|
|
||||||
// Get the appropriate alignment requirement.
|
|
||||||
//
|
|
||||||
if ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) < EFI_FVB2_ALIGNMENT_8) {
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
*FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Search EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE image and expand
|
Find DxeCore driver from all First Volumes.
|
||||||
as memory FV
|
|
||||||
|
|
||||||
@return EFI_OUT_OF_RESOURCES There are no memory space to exstract FV
|
|
||||||
@return EFI_SUCESS Sucess to find the FV
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
DxeIplAddEncapsulatedFirmwareVolumes (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_STATUS VolumeStatus;
|
|
||||||
UINTN Index;
|
|
||||||
EFI_FV_INFO VolumeInfo;
|
|
||||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
|
||||||
EFI_PEI_FILE_HANDLE FileHandle;
|
|
||||||
UINT32 SectionLength;
|
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
|
|
||||||
EFI_FIRMWARE_VOLUME_IMAGE_SECTION *SectionHeader;
|
|
||||||
VOID *DstBuffer;
|
|
||||||
UINT32 FvAlignment;
|
|
||||||
|
|
||||||
Status = EFI_NOT_FOUND;
|
|
||||||
Index = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
VolumeStatus = DxeIplFindFirmwareVolumeInstance (
|
|
||||||
&Index,
|
|
||||||
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,
|
|
||||||
&VolumeHandle,
|
|
||||||
&FileHandle
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!EFI_ERROR (VolumeStatus)) {
|
|
||||||
Status = PeiServicesFfsFindSectionData (
|
|
||||||
EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
|
|
||||||
(EFI_FFS_FILE_HEADER *)FileHandle,
|
|
||||||
(VOID **)&FvHeader
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
if (FvHeader->Signature == EFI_FVH_SIGNATURE) {
|
|
||||||
//
|
|
||||||
// Because FvLength in FvHeader is UINT64 type,
|
|
||||||
// so FvHeader must meed at least 8 bytes alignment.
|
|
||||||
// If current FvImage base address doesn't meet its alignment,
|
|
||||||
// we need to reload this FvImage to another correct memory address.
|
|
||||||
//
|
|
||||||
Status = GetFvAlignment(FvHeader, &FvAlignment);
|
|
||||||
if (EFI_ERROR(Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
if (((UINTN) FvHeader % FvAlignment) != 0) {
|
|
||||||
SectionHeader = (EFI_FIRMWARE_VOLUME_IMAGE_SECTION*)((UINTN)FvHeader - sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION));
|
|
||||||
SectionLength = *(UINT32 *)SectionHeader->Size & 0x00FFFFFF;
|
|
||||||
|
|
||||||
DstBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINTN) SectionLength - sizeof (EFI_COMMON_SECTION_HEADER)), FvAlignment);
|
|
||||||
if (DstBuffer == NULL) {
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
|
||||||
}
|
|
||||||
CopyMem (DstBuffer, FvHeader, (UINTN) SectionLength - sizeof (EFI_COMMON_SECTION_HEADER));
|
|
||||||
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) DstBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// This new Firmware Volume comes from a firmware file within a firmware volume.
|
|
||||||
// Record the original Firmware Volume Name.
|
|
||||||
//
|
|
||||||
PeiServicesFfsGetVolumeInfo (&VolumeHandle, &VolumeInfo);
|
|
||||||
|
|
||||||
PiLibInstallFvInfoPpi (
|
|
||||||
NULL,
|
|
||||||
FvHeader,
|
|
||||||
(UINT32) FvHeader->FvLength,
|
|
||||||
&(VolumeInfo.FvName),
|
|
||||||
&(((EFI_FFS_FILE_HEADER*)FileHandle)->Name)
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Inform HOB consumer phase, i.e. DXE core, the existance of this FV
|
|
||||||
//
|
|
||||||
BuildFvHob (
|
|
||||||
(EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
|
|
||||||
FvHeader->FvLength
|
|
||||||
);
|
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Makes the encapsulated volume show up in DXE phase to skip processing of
|
|
||||||
// encapsulated file again.
|
|
||||||
//
|
|
||||||
BuildFv2Hob (
|
|
||||||
(EFI_PHYSICAL_ADDRESS)(UINTN)FvHeader,
|
|
||||||
FvHeader->FvLength,
|
|
||||||
&VolumeInfo.FvName,
|
|
||||||
&(((EFI_FFS_FILE_HEADER *)FileHandle)->Name)
|
|
||||||
);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (!EFI_ERROR (VolumeStatus));
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Find the First Volume that contains the first FileType.
|
|
||||||
|
|
||||||
@param Instance The Fv instance.
|
|
||||||
@param SeachType The type of file to search.
|
|
||||||
@param VolumeHandle Pointer to Fv which contains the file to search.
|
|
||||||
@param FileHandle Pointer to FFS file to search.
|
@param FileHandle Pointer to FFS file to search.
|
||||||
|
|
||||||
@return EFI_SUCESS Success to find the FFS in specificed FV
|
@return EFI_SUCESS Success to find the FFS in specificed FV
|
||||||
@return others Fail to find the FFS in specificed FV
|
@return others Fail to find the FFS in specificed FV
|
||||||
*/
|
*/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
DxeIplFindFirmwareVolumeInstance (
|
DxeIplFindDxeCore (
|
||||||
IN OUT UINTN *Instance,
|
|
||||||
IN EFI_FV_FILETYPE SeachType,
|
|
||||||
OUT EFI_PEI_FV_HANDLE *VolumeHandle,
|
|
||||||
OUT EFI_PEI_FILE_HANDLE *FileHandle
|
OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_STATUS VolumeStatus;
|
EFI_STATUS FileStatus;
|
||||||
|
UINTN Instance;
|
||||||
|
EFI_PEI_FV_HANDLE VolumeHandle;
|
||||||
|
|
||||||
|
Instance = 0;
|
||||||
|
*FileHandle = NULL;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
VolumeStatus = PeiServicesFfsFindNextVolume (*Instance, VolumeHandle);
|
Status = PeiServicesFfsFindNextVolume (Instance++, &VolumeHandle);
|
||||||
if (!EFI_ERROR (VolumeStatus)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
*FileHandle = NULL;
|
FileStatus = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, FileHandle);
|
||||||
Status = PeiServicesFfsFindNextFile (SeachType, *VolumeHandle, FileHandle);
|
if (!EFI_ERROR (FileStatus)) {
|
||||||
if (!EFI_ERROR (Status)) {
|
return FileStatus;
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*Instance += 1;
|
} while (!EFI_ERROR (Status));
|
||||||
} while (!EFI_ERROR (VolumeStatus));
|
|
||||||
|
|
||||||
return VolumeStatus;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -646,10 +507,16 @@ CustomGuidedSectionExtract (
|
||||||
//
|
//
|
||||||
// Allocate output buffer
|
// Allocate output buffer
|
||||||
//
|
//
|
||||||
*OutputBuffer = AllocatePages (EFI_SIZE_TO_PAGES (OutputBufferSize));
|
*OutputBuffer = AllocatePages (EFI_SIZE_TO_PAGES (OutputBufferSize) + 1);
|
||||||
if (*OutputBuffer == NULL) {
|
if (*OutputBuffer == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
DEBUG ((EFI_D_INFO, "Customed Guided section Memory Size required is 0x%x and address is 0x%p\n", OutputBufferSize, *OutputBuffer));
|
||||||
|
//
|
||||||
|
// *OutputBuffer still is one section. Adjust *OutputBuffer offset,
|
||||||
|
// skip EFI section header to make section data at page alignment.
|
||||||
|
//
|
||||||
|
*OutputBuffer = (VOID *)((UINT8 *) *OutputBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER));
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = ExtractGuidedSectionDecode (
|
Status = ExtractGuidedSectionDecode (
|
||||||
|
@ -728,13 +595,18 @@ Decompress (
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Allocate destination buffer
|
// Allocate destination buffer, extra one page for adjustment
|
||||||
//
|
//
|
||||||
DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize));
|
DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize) + 1);
|
||||||
if (DstBuffer == NULL) {
|
if (DstBuffer == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
// DstBuffer still is one section. Adjust DstBuffer offset, skip EFI section header
|
||||||
|
// to make section data at page alignment.
|
||||||
|
//
|
||||||
|
DstBuffer = DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER);
|
||||||
|
//
|
||||||
// Call decompress function
|
// Call decompress function
|
||||||
//
|
//
|
||||||
Status = UefiDecompress (
|
Status = UefiDecompress (
|
||||||
|
@ -751,18 +623,21 @@ Decompress (
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// porting note the original branch for customized compress is removed, it should be change to use GUID compress
|
|
||||||
|
|
||||||
case EFI_NOT_COMPRESSED:
|
case EFI_NOT_COMPRESSED:
|
||||||
//
|
//
|
||||||
// Allocate destination buffer
|
// Allocate destination buffer
|
||||||
//
|
//
|
||||||
DstBufferSize = CompressionSection->UncompressedLength;
|
DstBufferSize = CompressionSection->UncompressedLength;
|
||||||
DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize));
|
DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize) + 1);
|
||||||
if (DstBuffer == NULL) {
|
if (DstBuffer == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
// Adjust DstBuffer offset, skip EFI section header
|
||||||
|
// to make section data at page alignment.
|
||||||
|
//
|
||||||
|
DstBuffer = DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER);
|
||||||
|
//
|
||||||
// stream is not actually compressed, just encapsulated. So just copy it.
|
// stream is not actually compressed, just encapsulated. So just copy it.
|
||||||
//
|
//
|
||||||
CopyMem (DstBuffer, CompressionSection + 1, DstBufferSize);
|
CopyMem (DstBuffer, CompressionSection + 1, DstBufferSize);
|
||||||
|
|
|
@ -30,7 +30,6 @@ InvokePeiCore (
|
||||||
VOID *Context2
|
VOID *Context2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
DiscoverPeimsAndOrderWithApriori (
|
DiscoverPeimsAndOrderWithApriori (
|
||||||
IN PEI_CORE_INSTANCE *Private,
|
IN PEI_CORE_INSTANCE *Private,
|
||||||
|
@ -233,11 +232,13 @@ Returns:
|
||||||
VOID *TopOfStack;
|
VOID *TopOfStack;
|
||||||
PEI_CORE_PARAMETERS PeiCoreParameters;
|
PEI_CORE_PARAMETERS PeiCoreParameters;
|
||||||
EFI_DEVICE_HANDLE_EXTENDED_DATA ExtendedData;
|
EFI_DEVICE_HANDLE_EXTENDED_DATA ExtendedData;
|
||||||
|
EFI_FV_FILE_INFO FvFileInfo;
|
||||||
|
|
||||||
|
|
||||||
PeiServices = &Private->PS;
|
PeiServices = &Private->PS;
|
||||||
PeimEntryPoint = NULL;
|
PeimEntryPoint = NULL;
|
||||||
PeimFileHandle = NULL;
|
PeimFileHandle = NULL;
|
||||||
|
EntryPoint = 0;
|
||||||
|
|
||||||
if ((Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
|
if ((Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
|
||||||
//
|
//
|
||||||
|
@ -327,16 +328,28 @@ Returns:
|
||||||
if (!DepexSatisfied (Private, PeimFileHandle, PeimCount)) {
|
if (!DepexSatisfied (Private, PeimFileHandle, PeimCount)) {
|
||||||
PeimNeedingDispatch = TRUE;
|
PeimNeedingDispatch = TRUE;
|
||||||
} else {
|
} else {
|
||||||
Status = PeiLoadImage (
|
Status = PeiFfsGetFileInfo (PeimFileHandle, &FvFileInfo);
|
||||||
PeiServices,
|
ASSERT_EFI_ERROR (Status);
|
||||||
PeimFileHandle,
|
if (FvFileInfo.FileType == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {
|
||||||
&EntryPoint,
|
//
|
||||||
&AuthenticationState
|
// For Fv type file, Produce new FV PPI and FV hob
|
||||||
);
|
//
|
||||||
|
Status = ProcessFvFile (PeiServices, PeimFileHandle, &AuthenticationState);
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// For PEIM driver, Load its entry point
|
||||||
|
//
|
||||||
|
Status = PeiLoadImage (
|
||||||
|
PeiServices,
|
||||||
|
PeimFileHandle,
|
||||||
|
&EntryPoint,
|
||||||
|
&AuthenticationState
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ((Status == EFI_SUCCESS)) {
|
if ((Status == EFI_SUCCESS)) {
|
||||||
//
|
//
|
||||||
// The PEIM has its dependencies satisfied, and its entry point
|
// The PEIM has its dependencies satisfied, and is processed.
|
||||||
// has been found, so invoke it.
|
|
||||||
//
|
//
|
||||||
PERF_START (0, "PEIM", NULL, 0);
|
PERF_START (0, "PEIM", NULL, 0);
|
||||||
|
|
||||||
|
@ -355,12 +368,17 @@ Returns:
|
||||||
// PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED
|
// PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED
|
||||||
//
|
//
|
||||||
Private->Fv[FvCount].PeimState[PeimCount]++;
|
Private->Fv[FvCount].PeimState[PeimCount]++;
|
||||||
|
|
||||||
|
if (FvFileInfo.FileType != EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {
|
||||||
|
//
|
||||||
|
// Call the PEIM entry point for PEIM driver
|
||||||
|
//
|
||||||
|
PeimEntryPoint = (EFI_PEIM_ENTRY_POINT)(UINTN)EntryPoint;
|
||||||
|
PeimEntryPoint (PeimFileHandle, PeiServices);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Call the PEIM entry point
|
// One module has been dispatched.
|
||||||
//
|
//
|
||||||
PeimEntryPoint = (EFI_PEIM_ENTRY_POINT)(UINTN)EntryPoint;
|
|
||||||
PeimEntryPoint (PeimFileHandle, PeiServices);
|
|
||||||
PeimDispatchOnThisPass = TRUE;
|
PeimDispatchOnThisPass = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,8 +590,8 @@ Returns:
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
VOID *DepexData;
|
VOID *DepexData;
|
||||||
|
|
||||||
if (PeimCount < Private->AprioriCount) {
|
if (PeimCount < Private->AprioriCount) {
|
||||||
//
|
//
|
||||||
|
@ -581,8 +599,16 @@ Returns:
|
||||||
//
|
//
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Depex section not in the encapsulated section.
|
||||||
|
//
|
||||||
|
Status = PeiServicesFfsFindSectionData (
|
||||||
|
EFI_SECTION_PEI_DEPEX,
|
||||||
|
FileHandle,
|
||||||
|
(VOID **)&DepexData
|
||||||
|
);
|
||||||
|
|
||||||
Status = PeiServicesFfsFindSectionData (EFI_SECTION_PEI_DEPEX, FileHandle, (VOID **) &DepexData);
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// If there is no DEPEX, assume the module can be executed
|
// If there is no DEPEX, assume the module can be executed
|
||||||
|
@ -675,3 +701,119 @@ InvokePeiCore (
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.
|
||||||
|
|
||||||
|
@param PeiServices Pointer to the PEI Core Services Table.
|
||||||
|
@param FileHandle File handle of a Fv type file.
|
||||||
|
@param AuthenticationState Pointer to attestation authentication state of image.
|
||||||
|
|
||||||
|
|
||||||
|
@retval EFI_NOT_FOUND FV image can't be found.
|
||||||
|
@retval EFI_SUCCESS Successfully to process it.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
ProcessFvFile (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN EFI_PEI_FILE_HANDLE FvFileHandle,
|
||||||
|
OUT UINT32 *AuthenticationState
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_PEI_FV_HANDLE FvImageHandle;
|
||||||
|
EFI_FV_INFO FvImageInfo;
|
||||||
|
UINT32 FvAlignment;
|
||||||
|
VOID *FvBuffer;
|
||||||
|
EFI_PEI_HOB_POINTERS HobFv2;
|
||||||
|
|
||||||
|
FvBuffer = NULL;
|
||||||
|
*AuthenticationState = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already
|
||||||
|
// been extracted.
|
||||||
|
//
|
||||||
|
HobFv2.Raw = GetHobList ();
|
||||||
|
while ((HobFv2.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobFv2.Raw)) != NULL) {
|
||||||
|
if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobFv2.FirmwareVolume2->FileName)) {
|
||||||
|
//
|
||||||
|
// this FILE has been dispatched, it will not be dispatched again.
|
||||||
|
//
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
HobFv2.Raw = GET_NEXT_HOB (HobFv2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Find FvImage in FvFile
|
||||||
|
//
|
||||||
|
Status = PeiFfsFindSectionData (
|
||||||
|
(CONST EFI_PEI_SERVICES **) PeiServices,
|
||||||
|
EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
|
||||||
|
FvFileHandle,
|
||||||
|
(VOID **)&FvImageHandle
|
||||||
|
);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Collect FvImage Info.
|
||||||
|
//
|
||||||
|
Status = PeiFfsGetVolumeInfo (FvImageHandle, &FvImageInfo);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
//
|
||||||
|
// FvAlignment must be more than 8 bytes required by FvHeader structure.
|
||||||
|
//
|
||||||
|
FvAlignment = 1 << ((FvImageInfo.FvAttributes & EFI_FVB2_ALIGNMENT) >> 16);
|
||||||
|
if (FvAlignment < 8) {
|
||||||
|
FvAlignment = 8;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Check FvImage
|
||||||
|
//
|
||||||
|
if ((UINTN) FvImageInfo.FvStart % FvAlignment != 0) {
|
||||||
|
FvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvImageInfo.FvSize), FvAlignment);
|
||||||
|
if (FvBuffer == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
CopyMem (FvBuffer, FvImageInfo.FvStart, (UINTN) FvImageInfo.FvSize);
|
||||||
|
//
|
||||||
|
// Update FvImageInfo after reload FvImage to new aligned memory
|
||||||
|
//
|
||||||
|
PeiFfsGetVolumeInfo ((EFI_PEI_FV_HANDLE) FvBuffer, &FvImageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Install FvPpi and Build FvHob
|
||||||
|
//
|
||||||
|
PiLibInstallFvInfoPpi (
|
||||||
|
NULL,
|
||||||
|
FvImageInfo.FvStart,
|
||||||
|
(UINT32) FvImageInfo.FvSize,
|
||||||
|
&(FvImageInfo.FvName),
|
||||||
|
&(((EFI_FFS_FILE_HEADER*)FvFileHandle)->Name)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inform HOB consumer phase, i.e. DXE core, the existance of this FV
|
||||||
|
//
|
||||||
|
BuildFvHob (
|
||||||
|
(EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,
|
||||||
|
FvImageInfo.FvSize
|
||||||
|
);
|
||||||
|
//
|
||||||
|
// Makes the encapsulated volume show up in DXE phase to skip processing of
|
||||||
|
// encapsulated file again.
|
||||||
|
//
|
||||||
|
BuildFv2Hob (
|
||||||
|
(EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,
|
||||||
|
FvImageInfo.FvSize,
|
||||||
|
&FvImageInfo.FvName,
|
||||||
|
&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name)
|
||||||
|
);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
|
@ -258,7 +258,8 @@ Returns:
|
||||||
}
|
}
|
||||||
} else if (SearchType == PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE) {
|
} else if (SearchType == PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE) {
|
||||||
if ((FfsFileHeader->Type == EFI_FV_FILETYPE_PEIM) ||
|
if ((FfsFileHeader->Type == EFI_FV_FILETYPE_PEIM) ||
|
||||||
(FfsFileHeader->Type == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)) {
|
(FfsFileHeader->Type == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER) ||
|
||||||
|
(FfsFileHeader->Type == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE)) {
|
||||||
|
|
||||||
*FileHeader = FfsFileHeader;
|
*FileHeader = FfsFileHeader;
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -366,8 +367,15 @@ Returns:
|
||||||
UINT8 FvCount;
|
UINT8 FvCount;
|
||||||
EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *Fv;
|
EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *Fv;
|
||||||
PEI_CORE_INSTANCE *PrivateData;
|
PEI_CORE_INSTANCE *PrivateData;
|
||||||
|
EFI_PEI_FILE_HANDLE FileHandle;
|
||||||
|
VOID *DepexData;
|
||||||
|
UINT32 AuthenticationStatus;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
|
FileHandle = NULL;
|
||||||
|
DepexData = NULL;
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
|
||||||
|
|
||||||
if (PrivateData->FvCount >= FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) {
|
if (PrivateData->FvCount >= FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) {
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
|
@ -375,19 +383,53 @@ Returns:
|
||||||
|
|
||||||
Fv = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *)Ppi;
|
Fv = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *)Ppi;
|
||||||
|
|
||||||
if (CompareGuid (&Fv->FvFormat, &gEfiFirmwareFileSystem2Guid)) {
|
if (CompareGuid (&Fv->FvFormat, &gEfiFirmwareFileSystem2Guid)) {
|
||||||
for (FvCount = 0; FvCount < PrivateData->FvCount; FvCount ++) {
|
for (FvCount = 0; FvCount < PrivateData->FvCount; FvCount ++) {
|
||||||
if ((UINTN)PrivateData->Fv[FvCount].FvHeader == (UINTN)Fv->FvInfo) {
|
if ((UINTN)PrivateData->Fv[FvCount].FvHeader == (UINTN)Fv->FvInfo) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrivateData->Fv[PrivateData->FvCount++].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Fv->FvInfo;
|
PrivateData->Fv[PrivateData->FvCount++].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Fv->FvInfo;
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allways add to the All list
|
// Only add FileSystem2 Fv to the All list
|
||||||
//
|
//
|
||||||
PrivateData->AllFv[PrivateData->AllFvCount++] = (EFI_PEI_FV_HANDLE)Fv->FvInfo;
|
PrivateData->AllFv[PrivateData->AllFvCount++] = (EFI_PEI_FV_HANDLE)Fv->FvInfo;
|
||||||
|
|
||||||
|
DEBUG ((EFI_D_INFO, "The %dth FvImage start address is 0x%10p and size is 0x%08x\n", PrivateData->AllFvCount, (VOID *) Fv->FvInfo, Fv->FvInfoSize));
|
||||||
|
//
|
||||||
|
// Preprocess all FV type files in this new FileSystem2 Fv image
|
||||||
|
//
|
||||||
|
do {
|
||||||
|
Status = PeiFindFileEx (
|
||||||
|
(EFI_PEI_FV_HANDLE)Fv->FvInfo,
|
||||||
|
NULL,
|
||||||
|
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,
|
||||||
|
&FileHandle,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Status = PeiFfsFindSectionData (
|
||||||
|
(CONST EFI_PEI_SERVICES **) PeiServices,
|
||||||
|
EFI_SECTION_PEI_DEPEX,
|
||||||
|
FileHandle,
|
||||||
|
(VOID **)&DepexData
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
if (!PeimDispatchReadiness (PeiServices, DepexData)) {
|
||||||
|
//
|
||||||
|
// Dependency is not satisfied.
|
||||||
|
//
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Process FvFile to install FvInfo ppi and build FvHob
|
||||||
|
//
|
||||||
|
ProcessFvFile (PeiServices, FileHandle, &AuthenticationStatus);
|
||||||
|
}
|
||||||
|
} while (FileHandle != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -398,25 +440,21 @@ PeiFfsProcessSection (
|
||||||
IN EFI_SECTION_TYPE SectionType,
|
IN EFI_SECTION_TYPE SectionType,
|
||||||
IN EFI_COMMON_SECTION_HEADER *Section,
|
IN EFI_COMMON_SECTION_HEADER *Section,
|
||||||
IN UINTN SectionSize,
|
IN UINTN SectionSize,
|
||||||
OUT VOID **OutputBuffer,
|
OUT VOID **OutputBuffer
|
||||||
OUT UINTN *OutputSize,
|
|
||||||
OUT UINT32 *Authentication
|
|
||||||
)
|
)
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
|
||||||
Go through the file to search SectionType section,
|
Go through the file to search SectionType section,
|
||||||
when meeting an encapsuled section, search recursively.
|
when meeting an encapsuled section.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
PeiServices - Pointer to the PEI Core Services Table.
|
PeiServices - General purpose services available to every PEIM.
|
||||||
SearchType - Filter to find only section of this type.
|
SearchType - Filter to find only section of this type.
|
||||||
Section - From where to search.
|
Section - From where to search.
|
||||||
SectionSize - The file size to search.
|
SectionSize - The file size to search.
|
||||||
OutputBuffer - Pointer to the section to search.
|
OutputBuffer - Pointer to the section to search.
|
||||||
OutputSize - The size of the section to search.
|
|
||||||
Authentication - Authenticate the section.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -426,57 +464,94 @@ Returns:
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT32 SectionLength;
|
UINT32 SectionLength;
|
||||||
UINT32 ParsedLength;
|
UINT32 ParsedLength;
|
||||||
EFI_GUID_DEFINED_SECTION *GuidSection;
|
|
||||||
EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *GuidSectionPpi;
|
EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *GuidSectionPpi;
|
||||||
EFI_COMPRESSION_SECTION *CompressionSection;
|
|
||||||
EFI_PEI_DECOMPRESS_PPI *DecompressPpi;
|
EFI_PEI_DECOMPRESS_PPI *DecompressPpi;
|
||||||
VOID *PpiOutput;
|
VOID *PpiOutput;
|
||||||
UINTN PpiOutputSize;
|
UINTN PpiOutputSize;
|
||||||
|
UINTN Index;
|
||||||
|
UINT32 Authentication;
|
||||||
|
PEI_CORE_INSTANCE *PrivateData;
|
||||||
|
|
||||||
|
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
|
||||||
*OutputBuffer = NULL;
|
*OutputBuffer = NULL;
|
||||||
ParsedLength = 0;
|
ParsedLength = 0;
|
||||||
|
Index = 0;
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
PpiOutput = NULL;
|
||||||
|
PpiOutputSize = 0;
|
||||||
while (ParsedLength < SectionSize) {
|
while (ParsedLength < SectionSize) {
|
||||||
if (Section->Type == SectionType) {
|
if (Section->Type == SectionType) {
|
||||||
*OutputBuffer = (VOID *)(Section + 1);
|
*OutputBuffer = (VOID *)(Section + 1);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
} else if (Section->Type == EFI_SECTION_GUID_DEFINED) {
|
} else if ((Section->Type == EFI_SECTION_GUID_DEFINED) || (Section->Type == EFI_SECTION_COMPRESSION)) {
|
||||||
GuidSection = (EFI_GUID_DEFINED_SECTION *)Section;
|
//
|
||||||
Status = PeiServicesLocatePpi (&GuidSection->SectionDefinitionGuid, 0, NULL, (VOID **) &GuidSectionPpi);
|
// Check the encapsulated section is extracted into the cache data.
|
||||||
if (!EFI_ERROR (Status)) {
|
//
|
||||||
Status = GuidSectionPpi->ExtractSection (
|
for (Index = 0; Index < PrivateData->CacheSection.AllSectionCount; Index ++) {
|
||||||
GuidSectionPpi,
|
if (Section == PrivateData->CacheSection.Section[Index]) {
|
||||||
Section,
|
PpiOutput = PrivateData->CacheSection.SectionData[Index];
|
||||||
&PpiOutput,
|
PpiOutputSize = PrivateData->CacheSection.SectionSize[Index];
|
||||||
&PpiOutputSize,
|
//
|
||||||
Authentication
|
// Search section directly from the cache data.
|
||||||
);
|
//
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
return PeiFfsProcessSection (
|
return PeiFfsProcessSection (
|
||||||
PeiServices,
|
PeiServices,
|
||||||
SectionType,
|
SectionType,
|
||||||
PpiOutput,
|
PpiOutput,
|
||||||
PpiOutputSize,
|
PpiOutputSize,
|
||||||
OutputBuffer,
|
OutputBuffer
|
||||||
OutputSize,
|
|
||||||
Authentication
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Section->Type == EFI_SECTION_COMPRESSION) {
|
|
||||||
CompressionSection = (EFI_COMPRESSION_SECTION *)Section;
|
Status = EFI_NOT_FOUND;
|
||||||
Status = PeiServicesLocatePpi (&gEfiPeiDecompressPpiGuid, 0, NULL, (VOID **) &DecompressPpi);
|
if (Section->Type == EFI_SECTION_GUID_DEFINED) {
|
||||||
if (!EFI_ERROR (Status)) {
|
Status = PeiServicesLocatePpi (
|
||||||
Status = DecompressPpi->Decompress (
|
&((EFI_GUID_DEFINED_SECTION *)Section)->SectionDefinitionGuid,
|
||||||
DecompressPpi,
|
0,
|
||||||
CompressionSection,
|
NULL,
|
||||||
&PpiOutput,
|
(VOID **) &GuidSectionPpi
|
||||||
&PpiOutputSize
|
);
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
return PeiFfsProcessSection (
|
Status = GuidSectionPpi->ExtractSection (
|
||||||
PeiServices, SectionType, PpiOutput, PpiOutputSize, OutputBuffer, OutputSize, Authentication
|
GuidSectionPpi,
|
||||||
);
|
Section,
|
||||||
|
&PpiOutput,
|
||||||
|
&PpiOutputSize,
|
||||||
|
&Authentication
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
} else if (Section->Type == EFI_SECTION_COMPRESSION) {
|
||||||
|
Status = PeiServicesLocatePpi (&gEfiPeiDecompressPpiGuid, 0, NULL, (VOID **) &DecompressPpi);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Status = DecompressPpi->Decompress (
|
||||||
|
DecompressPpi,
|
||||||
|
(CONST EFI_COMPRESSION_SECTION*) Section,
|
||||||
|
&PpiOutput,
|
||||||
|
&PpiOutputSize
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// Update cache section data.
|
||||||
|
//
|
||||||
|
if (PrivateData->CacheSection.AllSectionCount < CACHE_SETION_MAX_NUMBER) {
|
||||||
|
PrivateData->CacheSection.AllSectionCount ++;
|
||||||
|
}
|
||||||
|
PrivateData->CacheSection.Section [PrivateData->CacheSection.SectionIndex] = Section;
|
||||||
|
PrivateData->CacheSection.SectionData [PrivateData->CacheSection.SectionIndex] = PpiOutput;
|
||||||
|
PrivateData->CacheSection.SectionSize [PrivateData->CacheSection.SectionIndex] = PpiOutputSize;
|
||||||
|
PrivateData->CacheSection.SectionIndex = (PrivateData->CacheSection.SectionIndex + 1)%CACHE_SETION_MAX_NUMBER;
|
||||||
|
|
||||||
|
return PeiFfsProcessSection (
|
||||||
|
PeiServices,
|
||||||
|
SectionType,
|
||||||
|
PpiOutput,
|
||||||
|
PpiOutputSize,
|
||||||
|
OutputBuffer
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,9 +601,6 @@ Returns:
|
||||||
EFI_FFS_FILE_HEADER *FfsFileHeader;
|
EFI_FFS_FILE_HEADER *FfsFileHeader;
|
||||||
UINT32 FileSize;
|
UINT32 FileSize;
|
||||||
EFI_COMMON_SECTION_HEADER *Section;
|
EFI_COMMON_SECTION_HEADER *Section;
|
||||||
UINTN OutputSize;
|
|
||||||
UINT32 AuthenticationStatus;
|
|
||||||
|
|
||||||
|
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)(FileHandle);
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)(FileHandle);
|
||||||
|
|
||||||
|
@ -542,13 +614,11 @@ Returns:
|
||||||
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
|
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
|
||||||
|
|
||||||
return PeiFfsProcessSection (
|
return PeiFfsProcessSection (
|
||||||
PeiServices,
|
PeiServices,
|
||||||
SectionType,
|
SectionType,
|
||||||
Section,
|
Section,
|
||||||
FileSize,
|
FileSize,
|
||||||
SectionData,
|
SectionData
|
||||||
&OutputSize,
|
|
||||||
&AuthenticationStatus
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +671,7 @@ PeiFvFindNextVolume (
|
||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
|
||||||
Return the BFV location
|
Return the firmware volumes.
|
||||||
|
|
||||||
BugBug -- Move this to the location of this code to where the
|
BugBug -- Move this to the location of this code to where the
|
||||||
other FV and FFS support code lives.
|
other FV and FFS support code lives.
|
||||||
|
@ -761,21 +831,32 @@ Returns:
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
EFI_FIRMWARE_VOLUME_HEADER FwVolHeader;
|
||||||
EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
|
EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
|
||||||
|
|
||||||
if (VolumeInfo == NULL) {
|
if (VolumeInfo == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// VolumeHandle may not align at 8 byte,
|
||||||
|
// but FvLength is UINT64 type, which requires FvHeader align at least 8 byte.
|
||||||
|
// So, Copy FvHeader into the local FvHeader structure.
|
||||||
|
//
|
||||||
|
CopyMem (&FwVolHeader, VolumeHandle, sizeof (EFI_FIRMWARE_VOLUME_HEADER));
|
||||||
|
//
|
||||||
|
// Check Fv Image Signature
|
||||||
|
//
|
||||||
|
if (FwVolHeader.Signature != EFI_FVH_SIGNATURE) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
VolumeInfo->FvAttributes = FwVolHeader.Attributes;
|
||||||
|
VolumeInfo->FvStart = (VOID *) VolumeHandle;
|
||||||
|
VolumeInfo->FvSize = FwVolHeader.FvLength;
|
||||||
|
CopyMem (&VolumeInfo->FvFormat, &FwVolHeader.FileSystemGuid, sizeof(EFI_GUID));
|
||||||
|
|
||||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(VolumeHandle);
|
if (FwVolHeader.ExtHeaderOffset != 0) {
|
||||||
VolumeInfo->FvAttributes = FwVolHeader->Attributes;
|
FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER*)(((UINT8 *)VolumeHandle) + FwVolHeader.ExtHeaderOffset);
|
||||||
VolumeInfo->FvStart = FwVolHeader;
|
|
||||||
VolumeInfo->FvSize = FwVolHeader->FvLength;
|
|
||||||
CopyMem (&VolumeInfo->FvFormat, &FwVolHeader->FileSystemGuid,sizeof(EFI_GUID));
|
|
||||||
|
|
||||||
if (FwVolHeader->ExtHeaderOffset != 0) {
|
|
||||||
FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER*)(((UINT8 *)FwVolHeader) + FwVolHeader->ExtHeaderOffset);
|
|
||||||
CopyMem (&VolumeInfo->FvName, &FwVolExHeaderInfo->FvName, sizeof(EFI_GUID));
|
CopyMem (&VolumeInfo->FvName, &FwVolExHeaderInfo->FvName, sizeof(EFI_GUID));
|
||||||
}
|
}
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
|
@ -241,7 +241,7 @@ Returns:
|
||||||
// When Image has no reloc section, it can't be relocated into memory.
|
// When Image has no reloc section, it can't be relocated into memory.
|
||||||
//
|
//
|
||||||
if (ImageContext.RelocationsStripped) {
|
if (ImageContext.RelocationsStripped) {
|
||||||
DEBUG ((EFI_D_ERROR, "The image at 0x%08x without reloc section can't be loaded into memory", (UINTN) Pe32Data));
|
DEBUG ((EFI_D_ERROR, "The image at 0x%08x without reloc section can't be loaded into memory\n", (UINTN) Pe32Data));
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
|
@ -53,6 +53,7 @@ Revision History
|
||||||
#include <IndustryStandard/PeImage.h>
|
#include <IndustryStandard/PeImage.h>
|
||||||
#include <Library/PeiServicesTablePointerLib.h>
|
#include <Library/PeiServicesTablePointerLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/PeiPiLib.h>
|
||||||
#include <Guid/FirmwareFileSystem2.h>
|
#include <Guid/FirmwareFileSystem2.h>
|
||||||
#include <Guid/AprioriFileName.h>
|
#include <Guid/AprioriFileName.h>
|
||||||
|
|
||||||
|
@ -98,6 +99,15 @@ typedef struct {
|
||||||
BOOLEAN ScanFv;
|
BOOLEAN ScanFv;
|
||||||
} PEI_CORE_FV_HANDLE;
|
} PEI_CORE_FV_HANDLE;
|
||||||
|
|
||||||
|
#define CACHE_SETION_MAX_NUMBER 0x10
|
||||||
|
typedef struct {
|
||||||
|
EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];
|
||||||
|
VOID* SectionData[CACHE_SETION_MAX_NUMBER];
|
||||||
|
UINTN SectionSize[CACHE_SETION_MAX_NUMBER];
|
||||||
|
UINTN AllSectionCount;
|
||||||
|
UINTN SectionIndex;
|
||||||
|
} CACHE_SECTION_DATA;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pei Core private data structure instance
|
// Pei Core private data structure instance
|
||||||
//
|
//
|
||||||
|
@ -130,6 +140,7 @@ typedef struct{
|
||||||
UINTN SizeOfCacheAsRam;
|
UINTN SizeOfCacheAsRam;
|
||||||
VOID *MaxTopOfCarHeap;
|
VOID *MaxTopOfCarHeap;
|
||||||
EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;
|
EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;
|
||||||
|
CACHE_SECTION_DATA CacheSection;
|
||||||
} PEI_CORE_INSTANCE;
|
} PEI_CORE_INSTANCE;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1379,4 +1390,23 @@ Returns:
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.
|
||||||
|
|
||||||
|
@param PeiServices Pointer to the PEI Core Services Table.
|
||||||
|
@param FileHandle File handle of a Fv type file.
|
||||||
|
@param AuthenticationState Pointer to attestation authentication state of image.
|
||||||
|
|
||||||
|
|
||||||
|
@retval EFI_NOT_FOUND FV image can't be found.
|
||||||
|
@retval EFI_SUCCESS Successfully to process it.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
ProcessFvFile (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN EFI_PEI_FILE_HANDLE FvFileHandle,
|
||||||
|
OUT UINT32 *AuthenticationState
|
||||||
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
CacheMaintenanceLib
|
CacheMaintenanceLib
|
||||||
PeCoffLib
|
PeCoffLib
|
||||||
|
PeiPiLib
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gPeiAprioriFileNameGuid
|
gPeiAprioriFileNameGuid
|
||||||
|
@ -103,6 +104,3 @@
|
||||||
|
|
||||||
[FeaturePcd.common]
|
[FeaturePcd.common]
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst
|
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue