+ Padding = *(FreeMemoryTop) & (Granularity - 1);\r
+ if ((UINTN) (*FreeMemoryTop - *FreeMemoryBottom) < Padding) {\r
+ DEBUG ((DEBUG_ERROR, "AllocatePages failed: Out of space after padding.\n"));\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ *(FreeMemoryTop) -= Padding;\r
+ if (Padding >= EFI_PAGE_SIZE) {\r
+ //\r
+ // Create a memory allocation HOB to cover\r
+ // the pages that we will lose to rounding\r
+ //\r
+ BuildMemoryAllocationHob (\r
+ *(FreeMemoryTop),\r
+ Padding & ~(UINTN)EFI_PAGE_MASK,\r
+ EfiConventionalMemory\r
+ );\r
+ }\r