mirror of https://github.com/acidanthera/audk.git
MdeModulePkg DxeCore: Handle multiple FV images in one FV file
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1131 PI spec and BaseTools support to generate multiple FV images in one FV file. This patch is to update DxeCore to handle the case. Cc: Liming Gao <liming.gao@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
0e042d0ad7
commit
e3b9ab433a
|
@ -184,14 +184,13 @@ CoreAddToDriverList (
|
|||
);
|
||||
|
||||
/**
|
||||
Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.
|
||||
Get Fv image(s) from the FV through file name, and produce FVB protocol for every Fv image(s).
|
||||
|
||||
@param Fv The FIRMWARE_VOLUME protocol installed on the FV.
|
||||
@param FvHandle The handle which FVB protocol installed on.
|
||||
@param DriverName The driver guid specified.
|
||||
@param FileName The file name guid specified.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES No enough memory or other resource.
|
||||
@retval EFI_VOLUME_CORRUPTED Corrupted volume.
|
||||
@retval EFI_SUCCESS Function successfully returned.
|
||||
|
||||
**/
|
||||
|
@ -199,7 +198,7 @@ EFI_STATUS
|
|||
CoreProcessFvImageFile (
|
||||
IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,
|
||||
IN EFI_HANDLE FvHandle,
|
||||
IN EFI_GUID *DriverName
|
||||
IN EFI_GUID *FileName
|
||||
);
|
||||
|
||||
|
||||
|
@ -1004,14 +1003,13 @@ GetFvUsedSize (
|
|||
}
|
||||
|
||||
/**
|
||||
Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.
|
||||
Get Fv image(s) from the FV through file name, and produce FVB protocol for every Fv image(s).
|
||||
|
||||
@param Fv The FIRMWARE_VOLUME protocol installed on the FV.
|
||||
@param FvHandle The handle which FVB protocol installed on.
|
||||
@param DriverName The driver guid specified.
|
||||
@param FileName The file name guid specified.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES No enough memory or other resource.
|
||||
@retval EFI_VOLUME_CORRUPTED Corrupted volume.
|
||||
@retval EFI_SUCCESS Function successfully returned.
|
||||
|
||||
**/
|
||||
|
@ -1019,7 +1017,7 @@ EFI_STATUS
|
|||
CoreProcessFvImageFile (
|
||||
IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,
|
||||
IN EFI_HANDLE FvHandle,
|
||||
IN EFI_GUID *DriverName
|
||||
IN EFI_GUID *FileName
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
@ -1033,11 +1031,15 @@ CoreProcessFvImageFile (
|
|||
EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;
|
||||
UINT32 FvUsedSize;
|
||||
UINT8 EraseByte;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Read the first (and only the first) firmware volume section
|
||||
// Read firmware volume section(s)
|
||||
//
|
||||
SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;
|
||||
|
||||
Index = 0;
|
||||
do {
|
||||
FvHeader = NULL;
|
||||
FvAlignment = 0;
|
||||
Buffer = NULL;
|
||||
|
@ -1045,9 +1047,9 @@ CoreProcessFvImageFile (
|
|||
AlignedBuffer = NULL;
|
||||
Status = Fv->ReadSection (
|
||||
Fv,
|
||||
DriverName,
|
||||
FileName,
|
||||
SectionType,
|
||||
0,
|
||||
Index,
|
||||
&Buffer,
|
||||
&BufferSize,
|
||||
&AuthenticationStatus
|
||||
|
@ -1058,7 +1060,7 @@ CoreProcessFvImageFile (
|
|||
// Security Architectural Protocol
|
||||
//
|
||||
if (gSecurity != NULL) {
|
||||
FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);
|
||||
FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, FileName);
|
||||
Status = gSecurity->FileAuthenticationState (
|
||||
gSecurity,
|
||||
AuthenticationStatus,
|
||||
|
@ -1075,7 +1077,7 @@ CoreProcessFvImageFile (
|
|||
if (Buffer != NULL) {
|
||||
FreePool (Buffer);
|
||||
}
|
||||
return Status;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1118,7 +1120,8 @@ CoreProcessFvImageFile (
|
|||
AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);
|
||||
if (AlignedBuffer == NULL) {
|
||||
FreePool (Buffer);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
break;
|
||||
} else {
|
||||
//
|
||||
// Move FvImage into the aligned buffer and release the original buffer.
|
||||
|
@ -1137,7 +1140,7 @@ CoreProcessFvImageFile (
|
|||
CopyMem (AlignedBuffer, Buffer, BufferSize);
|
||||
}
|
||||
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
|
||||
CoreFreePool (Buffer);
|
||||
FreePool (Buffer);
|
||||
Buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1165,9 +1168,21 @@ CoreProcessFvImageFile (
|
|||
if (AlignedBuffer != NULL) {
|
||||
FreeAlignedPages (AlignedBuffer, EFI_SIZE_TO_PAGES (BufferSize));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
Index++;
|
||||
}
|
||||
} while (TRUE);
|
||||
|
||||
if (Index > 0) {
|
||||
//
|
||||
// At least one FvImage has been processed successfully.
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
} else {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue