]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
remove member context from _EFI_MTFTP4_TOKEN structure.
[mirror_edk2.git] / MdeModulePkg / Core / DxeIplPeim / DxeLoad.c
index 82382111e6010b7ee45471dfcac4d87a5f048c3a..d593e30c74b99710135b3e7e25601b4807788ec0 100644 (file)
@@ -130,7 +130,7 @@ PeimInitializeDxeIpl (
        }\r
       }\r
     } else {\r
-      ASSERT_EFI_ERROR (FALSE);\r
+      ASSERT (FALSE);\r
     }\r
   }\r
   \r
@@ -207,7 +207,7 @@ DxeLoadCore (
   CopyMem(&DxeCoreFileName, &(((EFI_FFS_FILE_HEADER*)FileHandle)->Name), sizeof (EFI_GUID));\r
 \r
   //\r
-  // Load the DXE Core from a Firmware Volume\r
+  // Load the DXE Core from a Firmware Volume, may use LoadFile ppi to do this for save code size.\r
   //\r
   Status = PeiLoadFile (\r
             FileHandle,\r
@@ -224,7 +224,7 @@ DxeLoadCore (
   BuildModuleHob (\r
     &DxeCoreFileName,\r
     DxeCoreAddress,\r
-    DxeCoreSize,\r
+    EFI_SIZE_TO_PAGES ((UINT32) DxeCoreSize) * EFI_PAGE_SIZE,\r
     DxeCoreEntryPoint\r
     );\r
 \r
@@ -236,11 +236,25 @@ DxeLoadCore (
     EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT\r
     );\r
 \r
+  DEBUG_CODE_BEGIN ();\r
+\r
+    EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION       PtrPeImage;\r
+    PtrPeImage.Pe32 = (EFI_IMAGE_NT_HEADERS32 *) ((UINTN) DxeCoreAddress + ((EFI_IMAGE_DOS_HEADER *) (UINTN) DxeCoreAddress)->e_lfanew);\r
+    \r
+    if (PtrPeImage.Pe32->FileHeader.Machine != IMAGE_FILE_MACHINE_IA64) {\r
+      DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading DXE CORE at 0x%10p EntryPoint=0x%10p\n", (VOID *)(UINTN)DxeCoreAddress, (VOID *)(UINTN)DxeCoreEntryPoint));\r
+    } else {\r
+      //\r
+      // For IPF Image, the real entry point should be print.\r
+      //\r
+      DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading DXE CORE at 0x%10p EntryPoint=0x%10p\n", (VOID *)(UINTN)DxeCoreAddress, (VOID *)(UINTN)(*(UINT64 *)(UINTN)DxeCoreEntryPoint)));\r
+    }\r
+\r
+  DEBUG_CODE_END ();\r
   //\r
   // Transfer control to the DXE Core\r
   // The handoff state is simply a pointer to the HOB list\r
   //\r
-  DEBUG ((EFI_D_INFO, "DXE Core Entry Point 0x%08x\n", (UINTN) DxeCoreEntryPoint));\r
   HandOffToDxeCore (DxeCoreEntryPoint, HobList, &mPpiSignal);\r
   //\r
   // If we get here, then the DXE Core returned.  This is an error\r
@@ -443,21 +457,13 @@ PeiLoadFile (
   PE_COFF_LOADER_IMAGE_CONTEXT      ImageContext;\r
   VOID                              *Pe32Data;\r
   //\r
-  // First try to find the required section in this ffs file.\r
+  // First try to find the PE32 section in this ffs file.\r
   //\r
   Status = PeiServicesFfsFindSectionData (\r
              EFI_SECTION_PE32,\r
              FileHandle,\r
              &Pe32Data\r
              );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    Status = PeiServicesFfsFindSectionData (\r
-               EFI_SECTION_TE,\r
-               FileHandle,\r
-               &Pe32Data\r
-               );\r
-  }\r
   \r
   if (EFI_ERROR (Status)) {\r
     //\r
@@ -745,3 +751,33 @@ Decompress (
   return EFI_SUCCESS;\r
 }\r
 \r
+VOID\r
+UpdateStackHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS           Hob;\r
+\r
+  Hob.Raw = GetHobList ();\r
+  while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) {\r
+    if (CompareGuid (&gEfiHobMemoryAllocStackGuid, &(Hob.MemoryAllocationStack->AllocDescriptor.Name))) {\r
+      //\r
+      // Build a new memory allocation HOB with old stack info with EfiConventionalMemory type\r
+      // to be reclaimed by DXE core.\r
+      //\r
+      BuildMemoryAllocationHob (\r
+        Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress,\r
+        Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength,\r
+        EfiConventionalMemory\r
+        );\r
+      //\r
+      // Update the BSP Stack Hob to reflect the new stack info.\r
+      //\r
+      Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
+      Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length;\r
+      break;\r
+    }\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+  }\r
+}\r