Merge branch of PI tree to main trunk

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3918 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2
2007-09-24 11:38:43 +00:00
parent f6203b7192
commit b0d803fe3e
34 changed files with 2893 additions and 1393 deletions

View File

@ -1,6 +1,6 @@
/*++
Copyright (c) 2006, Intel Corporation
Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
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
@ -21,7 +21,14 @@ Abstract:
#include <PeiMain.h>
#define GETOCCUPIEDSIZE(ActualSize, Alignment) \
STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = {
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiFirmwareVolumeInfoPpiGuid,
FirmwareVolmeInfoPpiNotifyCallback
};
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
STATIC
@ -121,12 +128,37 @@ Bugbug: For PEI performance reason, we comments this code at this time.
}
STATIC
BOOLEAN
EFIAPI
PeiFileHandleToVolume (
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_PEI_FV_HANDLE *VolumeHandle
)
{
UINTN Index;
PEI_CORE_INSTANCE *PrivateData;
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());
for (Index = 0; Index < PrivateData->FvCount; Index++) {
FwVolHeader = PrivateData->Fv[Index].FvHeader;
if (((UINT64) FileHandle > (UINT64) FwVolHeader ) && \
((UINT64) FileHandle <= ((UINT64) FwVolHeader + FwVolHeader->FvLength - 1))) {
*VolumeHandle = (EFI_PEI_FV_HANDLE)FwVolHeader;
return TRUE;
}
}
return FALSE;
}
EFI_STATUS
PeiFfsFindNextFileEx (
IN EFI_FV_FILETYPE SearchType,
IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
IN OUT EFI_FFS_FILE_HEADER **FileHeader,
IN BOOLEAN Flag
PeiFindFileEx (
IN CONST EFI_PEI_FV_HANDLE FvHandle,
IN CONST EFI_GUID *FileName, OPTIONAL
IN EFI_FV_FILETYPE SearchType,
IN OUT EFI_PEI_FILE_HANDLE *FileHandle,
IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL
)
/*++
@ -144,53 +176,63 @@ Arguments:
FileHeader - Pointer to the current file from which to begin searching.
This pointer will be updated upon return to reflect the file found.
Flag - Indicator for if this is for PEI Dispath search
Returns:
EFI_NOT_FOUND - No files matching the search criteria were found
EFI_SUCCESS
--*/
{
EFI_FFS_FILE_HEADER *FfsFileHeader;
UINT32 FileLength;
UINT32 FileOccupiedSize;
UINT32 FileOffset;
UINT64 FvLength;
UINT8 ErasePolarity;
UINT8 FileState;
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
EFI_FFS_FILE_HEADER **FileHeader;
EFI_FFS_FILE_HEADER *FfsFileHeader;
EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
UINT32 FileLength;
UINT32 FileOccupiedSize;
UINT32 FileOffset;
UINT64 FvLength;
UINT8 ErasePolarity;
UINT8 FileState;
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvHandle;
FileHeader = (EFI_FFS_FILE_HEADER **)FileHandle;
FvLength = FwVolHeader->FvLength;
if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
if (FwVolHeader->Attributes & EFI_FVB_ERASE_POLARITY) {
ErasePolarity = 1;
} else {
ErasePolarity = 0;
}
//
// If FileHeader is not specified (NULL) start with the first file in the
// firmware volume. Otherwise, start from the FileHeader.
// If FileHeader is not specified (NULL) or FileName is not NULL,
// start with the first file in the firmware volume. Otherwise,
// start from the FileHeader.
//
if (*FileHeader == NULL) {
if ((*FileHeader == NULL) || (FileName != NULL)) {
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);
if (FwVolHeader->ExtHeaderOffset != 0) {
FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)(((UINT8 *)FwVolHeader) + FwVolHeader->ExtHeaderOffset);
FfsFileHeader = (EFI_FFS_FILE_HEADER *)(((UINT8 *)FwVolExHeaderInfo) + FwVolExHeaderInfo->ExtHeaderSize);
}
} else {
//
// Length is 24 bits wide so mask upper 8 bits
// FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
//
FileLength = *(UINT32 *)(*FileHeader)->Size & 0x00FFFFFF;
FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)*FileHeader + FileOccupiedSize);
}
FileOffset = (UINT32) ((UINT8 *)FfsFileHeader - (UINT8 *)FwVolHeader);
ASSERT (FileOffset <= 0xFFFFFFFF);
while (FileOffset < (FvLength - sizeof(EFI_FFS_FILE_HEADER))) {
while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
//
// Get FileState which is the highest bit of the State
//
FileState = GetFileState (ErasePolarity, FfsFileHeader);
switch (FileState) {
case EFI_FILE_HEADER_INVALID:
@ -200,40 +242,44 @@ Returns:
case EFI_FILE_DATA_VALID:
case EFI_FILE_MARKED_FOR_UPDATE:
if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);
if (Flag) {
if ((FfsFileHeader->Type == EFI_FV_FILETYPE_PEIM) ||
(FfsFileHeader->Type == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)) {
*FileHeader = FfsFileHeader;
return EFI_SUCCESS;
}
} else {
if ((SearchType == FfsFileHeader->Type) ||
(SearchType == EFI_FV_FILETYPE_ALL)) {
*FileHeader = FfsFileHeader;
return EFI_SUCCESS;
}
}
FileOffset += FileOccupiedSize;
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
} else {
if (CalculateHeaderChecksum (FfsFileHeader) != 0) {
ASSERT (FALSE);
return EFI_NOT_FOUND;
}
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
if (FileName != NULL) {
if (CompareGuid (&FfsFileHeader->Name, (EFI_GUID*)FileName)) {
*FileHeader = FfsFileHeader;
return EFI_SUCCESS;
}
} else if (SearchType == PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE) {
if ((FfsFileHeader->Type == EFI_FV_FILETYPE_PEIM) ||
(FfsFileHeader->Type == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)) {
*FileHeader = FfsFileHeader;
return EFI_SUCCESS;
} else if (AprioriFile != NULL) {
if (FfsFileHeader->Type == EFI_FV_FILETYPE_FREEFORM) {
if (CompareGuid (&FfsFileHeader->Name, &gPeiAprioriFileNameGuid)) {
*AprioriFile = FfsFileHeader;
}
}
}
} else if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
*FileHeader = FfsFileHeader;
return EFI_SUCCESS;
}
FileOffset += FileOccupiedSize;
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
break;
case EFI_FILE_DELETED:
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);
FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
FileOffset += FileOccupiedSize;
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
break;
@ -247,6 +293,206 @@ Returns:
return EFI_NOT_FOUND;
}
VOID
PeiInitializeFv (
IN PEI_CORE_INSTANCE *PrivateData,
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
)
/*++
Routine Description:
Initialize PeiCore Fv List.
Arguments:
PrivateData - Pointer to PEI_CORE_INSTANCE.
SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.
Returns:
NONE
--*/
{
EFI_STATUS Status;
//
// The BFV must be the first entry. The Core FV support is stateless
// The AllFV list has a single entry per FV in PEI.
// The Fv list only includes FV that PEIMs will be dispatched from and
// its File System Format is PI 1.0 definition.
//
PrivateData->FvCount = 1;
PrivateData->Fv[0].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)SecCoreData->BootFirmwareVolumeBase;
PrivateData->AllFvCount = 1;
PrivateData->AllFv[0] = (EFI_PEI_FV_HANDLE)PrivateData->Fv[0].FvHeader;
//
// Post a call-back for the FvInfoPPI services to expose
// additional Fvs to PeiCore.
//
Status = PeiServicesNotifyPpi (&mNotifyOnFvInfoList);
ASSERT_EFI_ERROR (Status);
}
EFI_STATUS
EFIAPI
FirmwareVolmeInfoPpiNotifyCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
)
/*++
Routine Description:
Process Firmware Volum Information once FvInfoPPI install.
Arguments:
PeiServices - General purpose services available to every PEIM.
Returns:
Status - EFI_SUCCESS if the interface could be successfully
installed
--*/
{
UINT8 FvCount;
EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *Fv;
PEI_CORE_INSTANCE *PrivateData;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
if (PrivateData->FvCount >= PEI_CORE_MAX_FV_SUPPORTED) {
ASSERT (FALSE);
}
Fv = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *)Ppi;
if (CompareGuid (&Fv->FvFormat, &gEfiFirmwareFileSystem2Guid)) {
for (FvCount = 0; FvCount < PrivateData->FvCount; FvCount ++) {
if ((UINTN)PrivateData->Fv[FvCount].FvHeader == (UINTN)Fv->FvInfo) {
return EFI_SUCCESS;
}
}
PrivateData->Fv[PrivateData->FvCount++].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Fv->FvInfo;
BuildFvHob ((EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo, (UINT64) Fv->FvInfoSize);
}
//
// Allways add to the All list
//
PrivateData->AllFv[PrivateData->AllFvCount++] = (EFI_PEI_FV_HANDLE)Fv->FvInfo;
return EFI_SUCCESS;
}
EFI_STATUS
PeiFfsProcessSection (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_SECTION_TYPE SectionType,
IN EFI_COMMON_SECTION_HEADER *Section,
IN UINTN SectionSize,
OUT VOID **OutputBuffer,
OUT UINTN *OutputSize,
OUT UINT32 *Authentication
)
/*++
Routine Description:
Go through the file to search SectionType section,
when meeting an encapsuled section, search recursively.
Arguments:
PeiServices - Pointer to the PEI Core Services Table.
SearchType - Filter to find only section of this type.
Section - From where to search.
SectionSize - The file size to search.
OutputBuffer - Pointer to the section to search.
OutputSize - The size of the section to search.
Authentication - Authenticate the section.
Returns:
EFI_STATUS
--*/
{
EFI_STATUS Status;
UINT32 SectionLength;
UINT32 ParsedLength;
EFI_GUID_DEFINED_SECTION *GuidSection;
EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *GuidSectionPpi;
EFI_COMPRESSION_SECTION *CompressionSection;
EFI_PEI_DECOMPRESS_PPI *DecompressPpi;
VOID *PpiOutput;
UINTN PpiOutputSize;
*OutputBuffer = NULL;
ParsedLength = 0;
while (ParsedLength < SectionSize) {
if (Section->Type == SectionType) {
*OutputBuffer = (VOID *)(Section + 1);
return EFI_SUCCESS;
} else if (Section->Type == EFI_SECTION_GUID_DEFINED) {
GuidSection = (EFI_GUID_DEFINED_SECTION *)Section;
Status = PeiServicesLocatePpi (&GuidSection->SectionDefinitionGuid, 0, NULL, (VOID **) &GuidSectionPpi);
if (!EFI_ERROR (Status)) {
Status = GuidSectionPpi->ExtractSection (
GuidSectionPpi,
Section,
&PpiOutput,
&PpiOutputSize,
Authentication
);
if (!EFI_ERROR (Status)) {
return PeiFfsProcessSection (
PeiServices,
SectionType,
PpiOutput,
PpiOutputSize,
OutputBuffer,
OutputSize,
Authentication
);
}
}
} else if (Section->Type == EFI_SECTION_COMPRESSION) {
CompressionSection = (EFI_COMPRESSION_SECTION *)Section;
Status = PeiServicesLocatePpi (&gEfiPeiDecompressPpiGuid, 0, NULL, (VOID **) &DecompressPpi);
if (!EFI_ERROR (Status)) {
Status = DecompressPpi->Decompress (
DecompressPpi,
CompressionSection,
&PpiOutput,
&PpiOutputSize
);
if (!EFI_ERROR (Status)) {
return PeiFfsProcessSection (
PeiServices, SectionType, PpiOutput, PpiOutputSize, OutputBuffer, OutputSize, Authentication
);
}
}
}
//
// Size is 24 bits wide so mask upper 8 bits.
// SectionLength is adjusted it is 4 byte aligned.
// Go to the next section
//
SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
ASSERT (SectionLength != 0);
ParsedLength += SectionLength;
Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
}
return EFI_NOT_FOUND;
}
EFI_STATUS
EFIAPI
@ -275,46 +521,33 @@ Returns:
--*/
{
UINT32 FileSize;
EFI_COMMON_SECTION_HEADER *Section;
UINT32 SectionLength;
UINT32 ParsedLength;
EFI_FFS_FILE_HEADER *FfsFileHeader;
EFI_FFS_FILE_HEADER *FfsFileHeader;
UINT32 FileSize;
EFI_COMMON_SECTION_HEADER *Section;
UINTN OutputSize;
UINT32 AuthenticationStatus;
FfsFileHeader = (EFI_FFS_FILE_HEADER *)(FileHandle);
FfsFileHeader = (EFI_FFS_FILE_HEADER *) FileHandle;
//
// Size is 24 bits wide so mask upper 8 bits.
// Does not include FfsFileHeader header size
// Does not include FfsFileHeader header size
// FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
//
Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);
FileSize = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileSize -= sizeof(EFI_FFS_FILE_HEADER);
*SectionData = NULL;
ParsedLength = 0;
while (ParsedLength < FileSize) {
if (Section->Type == SectionType) {
*SectionData = (VOID *)(Section + 1);
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
return EFI_SUCCESS;
}
//
// Size is 24 bits wide so mask upper 8 bits.
// SectionLength is adjusted it is 4 byte aligned.
// Go to the next section
//
SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;
SectionLength = GETOCCUPIEDSIZE (SectionLength, 4);
ASSERT (SectionLength != 0);
ParsedLength += SectionLength;
Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
}
return EFI_NOT_FOUND;
return PeiFfsProcessSection (
PeiServices,
SectionType,
Section,
FileSize,
SectionData,
&OutputSize,
&AuthenticationStatus
);
}
@ -346,11 +579,12 @@ Returns:
--*/
{
return PeiFfsFindNextFileEx (
0,
FwVolHeader,
PeimFileHeader,
TRUE
return PeiFindFileEx (
(EFI_PEI_FV_HANDLE) FwVolHeader,
NULL,
EFI_FV_FILETYPE_PEIM,
(EFI_PEI_FILE_HANDLE *)PeimFileHeader,
NULL
);
}
@ -387,20 +621,10 @@ Returns:
--*/
{
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
EFI_FFS_FILE_HEADER **FileHeader;
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)VolumeHandle;
FileHeader = (EFI_FFS_FILE_HEADER **) FileHandle;
return PeiFfsFindNextFileEx (
SearchType,
FwVolHeader,
FileHeader,
FALSE
);
return PeiFindFileEx (VolumeHandle, NULL, SearchType, FileHandle, NULL);
}
EFI_STATUS
EFIAPI
PeiFvFindNextVolume (
@ -433,52 +657,162 @@ Returns:
--*/
{
PEI_CORE_INSTANCE *PrivateData;
EFI_STATUS Status;
EFI_PEI_FIND_FV_PPI *FindFvPpi;
UINT8 LocalInstance;
EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader;
PEI_CORE_INSTANCE *Private;
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER **) VolumeHandle;
Private = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
if (VolumeHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
LocalInstance = (UINT8) Instance;
Status = EFI_SUCCESS;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
if (FwVolHeader == NULL) {
return EFI_INVALID_PARAMETER;
if (Instance >= Private->AllFvCount) {
VolumeHandle = NULL;
return EFI_NOT_FOUND;
}
if (Instance == 0) {
*FwVolHeader = PrivateData->DispatchData.BootFvAddress;
*VolumeHandle = Private->AllFv[Instance];
return EFI_SUCCESS;
}
return Status;
} else {
//
// Locate all instances of FindFV
// Alternately, could use FV HOBs, but the PPI is cleaner
//
Status = PeiServicesLocatePpi (
&gEfiFindFvPpiGuid,
0,
NULL,
(VOID **)&FindFvPpi
);
EFI_STATUS
EFIAPI
PeiFfsFindFileByName (
IN CONST EFI_GUID *FileName,
IN EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_PEI_FILE_HANDLE *FileHandle
)
/*++
if (Status != EFI_SUCCESS) {
Status = EFI_NOT_FOUND;
} else {
Status = FindFvPpi->FindFv (
FindFvPpi,
(EFI_PEI_SERVICES **)PeiServices,
&LocalInstance,
FwVolHeader
);
Routine Description:
}
Given the input VolumeHandle, search for the next matching name file.
Arguments:
FileName - File name to search.
VolumeHandle - The current FV to search.
FileHandle - Pointer to the file matching name in VolumeHandle.
- NULL if file not found
Returns:
EFI_STATUS
--*/
{
EFI_STATUS Status;
if ((VolumeHandle == NULL) || (FileName == NULL) || (FileHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
Status = PeiFindFileEx (VolumeHandle, FileName, 0, FileHandle, NULL);
if (Status == EFI_NOT_FOUND) {
*FileHandle = NULL;
}
return Status;
}
EFI_STATUS
EFIAPI
PeiFfsGetFileInfo (
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_FV_FILE_INFO *FileInfo
)
/*++
Routine Description:
Collect information of given file.
Arguments:
FileHandle - The handle to file.
FileInfo - Pointer to the file information.
Returns:
EFI_STATUS
--*/
{
UINT8 FileState;
UINT8 ErasePolarity;
EFI_FFS_FILE_HEADER *FileHeader;
EFI_PEI_FV_HANDLE VolumeHandle;
if ((FileHandle == NULL) || (FileInfo == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
// Retrieve the FirmwareVolume which the file resides in.
//
if (!PeiFileHandleToVolume(FileHandle, &VolumeHandle)) {
return EFI_INVALID_PARAMETER;
}
if (((EFI_FIRMWARE_VOLUME_HEADER*)VolumeHandle)->Attributes & EFI_FVB_ERASE_POLARITY) {
ErasePolarity = 1;
} else {
ErasePolarity = 0;
}
//
// Get FileState which is the highest bit of the State
//
FileState = GetFileState (ErasePolarity, (EFI_FFS_FILE_HEADER*)FileHandle);
switch (FileState) {
case EFI_FILE_DATA_VALID:
case EFI_FILE_MARKED_FOR_UPDATE:
break;
default:
return EFI_INVALID_PARAMETER;
}
FileHeader = (EFI_FFS_FILE_HEADER *)FileHandle;
CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));
FileInfo->FileType = FileHeader->Type;
FileInfo->FileAttributes = FileHeader->Attributes;
FileInfo->BufferSize = ((*(UINT32 *)FileHeader->Size) & 0x00FFFFFF) - sizeof (EFI_FFS_FILE_HEADER);
FileInfo->Buffer = (FileHeader + 1);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
PeiFfsGetVolumeInfo (
IN EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_FV_INFO *VolumeInfo
)
/*++
Routine Description:
Collect information of given Fv Volume.
Arguments:
VolumeHandle - The handle to Fv Volume.
VolumeInfo - The pointer to volume information.
Returns:
EFI_STATUS
--*/
{
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
if (VolumeInfo == NULL) {
return EFI_INVALID_PARAMETER;
}
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(VolumeHandle);
VolumeInfo->FvAttributes = FwVolHeader->Attributes;
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));
}
return EFI_SUCCESS;
}