summaryrefslogtreecommitdiffstats
path: root/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
diff options
context:
space:
mode:
authorZhiguang Liu <zhiguang.liu@intel.com>2021-05-07 15:41:59 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-06-24 09:16:22 +0000
commitb208d37c73a71be20e007ca4917b3a25c732b605 (patch)
tree66d0b6bf6f4df422c28c22ad44f860c00b6e8d80 /UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
parent0ff6de93583652b09f450148b71d4c2def66bd38 (diff)
downloadedk2-b208d37c73a71be20e007ca4917b3a25c732b605.tar.gz
edk2-b208d37c73a71be20e007ca4917b3a25c732b605.tar.bz2
edk2-b208d37c73a71be20e007ca4917b3a25c732b605.zip
UefiPayloadPkg: Get and enter DxeCore for Universal Payload
From gUniversalPayloadExtraDataGuid Guid Hob, get the Dxe FV information, and get the Dxe Core from the FV. Also, make sure if there are muliple FV hob, the FV hob pointing to this FV will be the first in the hob list. Cc: Maurice Ma <maurice.ma@intel.com> Cc: Guo Dong <guo.dong@intel.com> Cc: Benjamin You <benjamin.you@intel.com> Reviewed-by: Guo Dong <guo.dong@intel.com> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Diffstat (limited to 'UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c')
-rw-r--r--UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
index de9dbb0b0e..f5d70c59f8 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
@@ -305,3 +305,50 @@ LoadDxeCore (
return EFI_SUCCESS;
}
+
+/**
+ Find DXE core from FV and build DXE core HOBs.
+
+ @param[in] DxeFv The FV where to find the DXE core.
+ @param[out] DxeCoreEntryPoint DXE core entry point
+
+ @retval EFI_SUCCESS If it completed successfully.
+ @retval EFI_NOT_FOUND If it failed to load DXE FV.
+**/
+EFI_STATUS
+UniversalLoadDxeCore (
+ IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
+ OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint
+ )
+{
+ EFI_STATUS Status;
+ EFI_FFS_FILE_HEADER *FileHeader;
+ VOID *PeCoffImage;
+ EFI_PHYSICAL_ADDRESS ImageAddress;
+ UINT64 ImageSize;
+
+ //
+ // Find DXE core file from DXE FV
+ //
+ Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = FileFindSection (FileHeader, EFI_SECTION_PE32, (VOID **)&PeCoffImage);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Get DXE core info
+ //
+ Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, DxeCoreEntryPoint);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ BuildModuleHob (&FileHeader->Name, ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, *DxeCoreEntryPoint);
+
+ return EFI_SUCCESS;
+}