/* Update or split memory allocation HOB for memory pages allocate and free. */
VOID UpdateOrSplitMemoryAllocationHob(IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob, IN EFI_PHYSICAL_ADDRESS Memory, IN UINT64 Bytes, IN EFI_MEMORY_TYPE MemoryType)
/* Update or split memory allocation HOB for memory pages allocate and free. */
VOID UpdateOrSplitMemoryAllocationHob(IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob, IN EFI_PHYSICAL_ADDRESS Memory, IN UINT64 Bytes, IN EFI_MEMORY_TYPE MemoryType)
{
  if ((Memory + Bytes) <
      (MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress + MemoryAllocationHob->AllocDescriptor.MemoryLength))
  {
    InternalBuildMemoryAllocationHob (
      Memory + Bytes,
      (MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress + MemoryAllocationHob->AllocDescriptor.MemoryLength) - (Memory + Bytes),
      MemoryAllocationHob->AllocDescriptor.MemoryType
      );
  }
  if (Memory > MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress) {
    InternalBuildMemoryAllocationHob (
      MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress,
      Memory - MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress,
      MemoryAllocationHob->AllocDescriptor.MemoryType
      );
  }
  MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress = Memory;
  MemoryAllocationHob->AllocDescriptor.MemoryLength      = Bytes;
  MemoryAllocationHob->AllocDescriptor.MemoryType        = MemoryType;
}