/* Helper function of memory free with Guard pages. */
EFI_STATUS SmmInternalFreePagesExWithGuard(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages, IN BOOLEAN AddRegion)
/* Helper function of memory free with Guard pages. */
EFI_STATUS SmmInternalFreePagesExWithGuard(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages, IN BOOLEAN AddRegion)
{
  EFI_PHYSICAL_ADDRESS  MemoryToFree;
  UINTN                 PagesToFree;
  if (((Memory & EFI_PAGE_MASK) != 0) || (Memory == 0) || (NumberOfPages == 0)) {
    return EFI_INVALID_PARAMETER;
  }
  MemoryToFree = Memory;
  PagesToFree  = NumberOfPages;
  AdjustMemoryF (&MemoryToFree, &PagesToFree);
  UnsetGuardForMemory (Memory, NumberOfPages);
  if (PagesToFree == 0) {
    return EFI_SUCCESS;
  }
  return SmmInternalFreePagesEx (MemoryToFree, PagesToFree, AddRegion);
}