REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3754

1. DxeCore will use ModuleInfo to install LoadedImage protocol for DxeCore.
2. DxeIpl will create the ModuleInfo of UniversalPayload. and
   UniversalPayload will create the ModuleInfo of DxeCore.
3. Only the first ModuleInfo will be used by DxeCore to install
   LoadedImage.
4. So it will create the mismatched ModuleInfo for DxeCore.

Changes:
1. When found the ModuleInfo, update it with DxeCore Info only.
2. Create new ModuleInfo if found no ModuleInfo.

Signed-off-by: Guomin Jiang <[email protected]>
Cc: Guo Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Maurice Ma <[email protected]>
Cc: Benjamin You <[email protected]>
---
 .../Library/PayloadEntryHobLib/Hob.c          | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c 
b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
index 61cd11ba0335..b840e7914f7a 100644
--- a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
+++ b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
@@ -331,6 +331,30 @@ BuildModuleHob (
   ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
           ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
 
+  Hob = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
+  ASSERT (Hob != NULL);
+  while ((Hob = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob)) != NULL) {
+    if (CompareGuid (&Hob->MemoryAllocationHeader.Name, 
&gEfiHobMemoryAllocModuleGuid)) {
+      //
+      // Update Dxe Core HOB.
+      //
+      Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
+      Hob->MemoryAllocationHeader.MemoryLength      = ModuleLength;
+      Hob->MemoryAllocationHeader.MemoryType        = EfiBootServicesCode;
+
+      ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof 
(Hob->MemoryAllocationHeader.Reserved));
+
+      CopyGuid (&Hob->ModuleName, ModuleName);
+      Hob->EntryPoint = EntryPoint;
+
+      //
+      // The Dxe Core HOB should only one. When find it, update and return
+      //
+      return;
+    }
+    Hob = GET_NEXT_HOB (Hob);
+  }
+
   Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof 
(EFI_HOB_MEMORY_ALLOCATION_MODULE));
 
   CopyGuid (&(Hob->MemoryAllocationHeader.Name), 
&gEfiHobMemoryAllocModuleGuid);
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84149): https://edk2.groups.io/g/devel/message/84149
Mute This Topic: https://groups.io/mt/87396410/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to