/* Retrieve corresponding bits in bitmap table according to given memory range. */
UINT64 GetGuardedMemoryBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfPages)
/* Retrieve corresponding bits in bitmap table according to given memory range. */
UINT64 GetGuardedMemoryBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfPages)
{
  UINT64  *BitMap;
  UINTN   Bits;
  UINT64  Result;
  UINTN   Shift;
  UINTN   BitsToUnitEnd;
  ASSERT (NumberOfPages <= GUARDED_HEAP_MAP_ENTRY_BITS);
  Result = 0;
  Shift  = 0;
  while (NumberOfPages > 0) {
    BitsToUnitEnd = FindGuardedMemoryMap (Address, FALSE, &BitMap);
    if (NumberOfPages > BitsToUnitEnd) {
      Bits = BitsToUnitEnd;
    } else {
      Bits = NumberOfPages;
    }
    if (BitMap != NULL) {
      Result |= LShiftU64 (GetBits (Address, Bits, BitMap), Shift);
    }
    Shift         += Bits;
    NumberOfPages -= Bits;
    Address       += EFI_PAGES_TO_SIZE (Bits);
  }
  return Result;
}