/* Check if AP wakeup buffer is overlapped with existing allocated buffer. */
BOOLEAN CheckOverlapWithAllocatedBuffer(IN UINT64 WakeupBufferStart, IN UINT64 WakeupBufferEnd)
/* Check if AP wakeup buffer is overlapped with existing allocated buffer. */
BOOLEAN CheckOverlapWithAllocatedBuffer(IN UINT64 WakeupBufferStart, IN UINT64 WakeupBufferEnd)
{
  EFI_PEI_HOB_POINTERS       Hob;
  EFI_HOB_MEMORY_ALLOCATION  *MemoryHob;
  BOOLEAN                    Overlapped;
  UINT64                     MemoryStart;
  UINT64                     MemoryEnd;
  Overlapped = FALSE;
  Hob.Raw = GetHobList ();
  while (!END_OF_HOB_LIST (Hob)) {
    if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
      MemoryHob   = Hob.MemoryAllocation;
      MemoryStart = MemoryHob->AllocDescriptor.MemoryBaseAddress;
      MemoryEnd   = MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength;
      if (!((WakeupBufferStart >= MemoryEnd) || (WakeupBufferEnd <= MemoryStart))) {
        Overlapped = TRUE;
        break;
      }
    }
    Hob.Raw = GET_NEXT_HOB (Hob);
  }
  return Overlapped;
}