/* Set corresponding bits in bitmap table to 1 according to given memory range. */
VOID EFIAPI SetGuardedMemoryBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfPages)
/* Set corresponding bits in bitmap table to 1 according to given memory range. */
VOID EFIAPI SetGuardedMemoryBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfPages)
{
  UINT64  *BitMap;
  UINTN   Bits;
  UINTN   BitsToUnitEnd;
  while (NumberOfPages > 0) {
    BitsToUnitEnd = FindGuardedMemoryMap (Address, TRUE, &BitMap);
    ASSERT (BitMap != NULL);
    if (NumberOfPages > BitsToUnitEnd) {
      Bits = BitsToUnitEnd;
    } else {
      Bits = NumberOfPages;
    }
    SetBits (Address, Bits, BitMap);
    NumberOfPages -= Bits;
    Address       += EFI_PAGES_TO_SIZE (Bits);
  }
}