/* If The cached PEI Services Table pointer is NULL, then ASSERT(). If the permanent memory is allocated failed, then ASSERT().  */
VOID EFIAPI MigratePeiServicesTablePointer(VOID)
/* If The cached PEI Services Table pointer is NULL, then ASSERT(). If the permanent memory is allocated failed, then ASSERT().  */
VOID EFIAPI MigratePeiServicesTablePointer(VOID)
{
  EFI_STATUS              Status;
  IA32_DESCRIPTOR         Idtr;
  EFI_PHYSICAL_ADDRESS    IdtBase;
  CONST EFI_PEI_SERVICES  **PeiServices;
  AsmReadIdtr (&Idtr);
  PeiServices = (CONST EFI_PEI_SERVICES **)(*(UINTN *)(Idtr.Base - sizeof (UINTN)));
  ASSERT (PeiServices != NULL);
  Status = (*PeiServices)->AllocatePages (
                             PeiServices,
                             EfiBootServicesCode,
                             EFI_SIZE_TO_PAGES (Idtr.Limit + 1 + sizeof (UINTN)),
                             &IdtBase
                             );
  ASSERT_EFI_ERROR (Status);
  CopyMem ((VOID *)(UINTN)IdtBase, (VOID *)(Idtr.Base - sizeof (UINTN)), Idtr.Limit + 1 + sizeof (UINTN));
  Idtr.Base = (UINTN)IdtBase + sizeof (UINTN);
  AsmWriteIdtr (&Idtr);
  return;
}