/* Check whether the provided memory range is covered by a single entry of type EfiGcdSystemMemory in the GCD memory map. */
STATIC BOOLEAN RegionIsSystemMemory(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
/* Check whether the provided memory range is covered by a single entry of type EfiGcdSystemMemory in the GCD memory map. */
STATIC BOOLEAN RegionIsSystemMemory(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
{
  EFI_GCD_MEMORY_SPACE_DESCRIPTOR  GcdDescriptor;
  EFI_PHYSICAL_ADDRESS             GcdEndAddress;
  EFI_STATUS                       Status;
  Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);
  if (EFI_ERROR (Status) ||
      (GcdDescriptor.GcdMemoryType != EfiGcdMemoryTypeSystemMemory))
  {
    return FALSE;
  }
  GcdEndAddress = GcdDescriptor.BaseAddress + GcdDescriptor.Length;
  return GcdEndAddress >= (BaseAddress + Length);
}