+\r
+ //\r
+ // Relocate HOB List to an allocated pool buffer.\r
+ // The relocation should be at after all the tested memory resources added\r
+ // (except the memory space that covers HOB List) to the memory services,\r
+ // because the memory resource found in CoreInitializeMemoryServices()\r
+ // may have not enough remaining resource for HOB List.\r
+ //\r
+ NewHobList = AllocateCopyPool (\r
+ (UINTN) PhitHob->EfiFreeMemoryBottom - (UINTN) (*HobStart),\r
+ *HobStart\r
+ );\r
+ ASSERT (NewHobList != NULL);\r
+\r
+ *HobStart = NewHobList;\r
+ gHobList = NewHobList;\r
+\r
+ if (MemorySpaceMapHobList != NULL) {\r
+ //\r
+ // Add and allocate the memory space that covers HOB List to the memory services\r
+ // after HOB List relocation.\r
+ //\r
+ BaseAddress = PageAlignAddress (MemorySpaceMapHobList->BaseAddress);\r
+ Length = PageAlignLength (MemorySpaceMapHobList->BaseAddress + MemorySpaceMapHobList->Length - BaseAddress);\r
+ CoreAddMemoryDescriptor (\r
+ EfiConventionalMemory,\r
+ BaseAddress,\r
+ RShiftU64 (Length, EFI_PAGE_SHIFT),\r
+ MemorySpaceMapHobList->Capabilities & (~EFI_MEMORY_RUNTIME)\r
+ );\r
+ Status = CoreAllocateMemorySpace (\r
+ EfiGcdAllocateAddress,\r
+ MemorySpaceMapHobList->GcdMemoryType,\r
+ 0,\r
+ Length,\r
+ &BaseAddress,\r
+ gDxeCoreImageHandle,\r
+ NULL\r
+ );\r
+ }\r
+\r