/* Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM Save State Map. */
RETURN_STATUS EFIAPI MemEncryptSevLocateInitialSmramSaveStateMapPages(OUT UINTN *BaseAddress, OUT UINTN *NumberOfPages)
/* Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM Save State Map. */
RETURN_STATUS EFIAPI MemEncryptSevLocateInitialSmramSaveStateMapPages(OUT UINTN *BaseAddress, OUT UINTN *NumberOfPages)
{
  UINTN  MapStart;
  UINTN  MapEnd;
  UINTN  MapPagesStart;
  UINTN  MapPagesEnd;
  UINTN  MapPagesSize;
  if (!FeaturePcdGet (PcdSmmSmramRequire)) {
    return RETURN_UNSUPPORTED;
  }
  MapStart      = SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET;
  MapEnd        = MapStart + sizeof (AMD_SMRAM_SAVE_STATE_MAP);
  MapPagesStart = MapStart & ~(UINTN)EFI_PAGE_MASK;
  MapPagesEnd   = ALIGN_VALUE (MapEnd, EFI_PAGE_SIZE);
  MapPagesSize  = MapPagesEnd - MapPagesStart;
  ASSERT ((MapPagesSize & EFI_PAGE_MASK) == 0);
  *BaseAddress   = MapPagesStart;
  *NumberOfPages = MapPagesSize >> EFI_PAGE_SHIFT;
  return RETURN_SUCCESS;
}