12BOOLEAN mRestoreSmmConfigurationInS3 =
FALSE;
17BOOLEAN mSmmS3Flag =
FALSE;
24BOOLEAN mAcpiS3Enable =
TRUE;
42 if (mRestoreSmmConfigurationInS3) {
46 gMmst->
MmStartupThisAp = gSmmCpuPrivate->SmmCoreEntryContext.SmmStartupThisAp;
59 mRestoreSmmConfigurationInS3 =
FALSE;
75 IA32_DESCRIPTOR Ia32Idtr;
76 IA32_DESCRIPTOR X64Idtr;
77 IA32_IDT_GATE_DESCRIPTOR IdtEntryTable[EXCEPTION_VECTOR_NUMBER];
80 DEBUG ((DEBUG_INFO,
"SmmRestoreCpu()\n"));
87 if (mSmmS3ResumeState ==
NULL) {
88 DEBUG ((DEBUG_ERROR,
"No context to return to PEI Phase\n"));
92 SmmS3ResumeState = mSmmS3ResumeState;
93 ASSERT (SmmS3ResumeState !=
NULL);
99 if ((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) && (
FeaturePcdGet (PcdDxeIplSwitchToLongMode) ==
TRUE)) {
108 ZeroMem (IdtEntryTable,
sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32);
109 X64Idtr.Base = (
UINTN)IdtEntryTable;
110 X64Idtr.Limit = (UINT16)(
sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32 - 1);
116 Status = InitializeCpuExceptionHandlers (
NULL);
122 if (mSmmDebugAgentSupport) {
135 mRestoreSmmConfigurationInS3 =
TRUE;
137 DEBUG ((DEBUG_INFO,
"SMM S3 Return CS = %x\n", SmmS3ResumeState->ReturnCs));
138 DEBUG ((DEBUG_INFO,
"SMM S3 Return Entry Point = %x\n", SmmS3ResumeState->ReturnEntryPoint));
139 DEBUG ((DEBUG_INFO,
"SMM S3 Return Context1 = %x\n", SmmS3ResumeState->ReturnContext1));
140 DEBUG ((DEBUG_INFO,
"SMM S3 Return Context2 = %x\n", SmmS3ResumeState->ReturnContext2));
141 DEBUG ((DEBUG_INFO,
"SMM S3 Return Stack Pointer = %x\n", SmmS3ResumeState->ReturnStackPointer));
147 if ((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) || (
FeaturePcdGet (PcdDxeIplSwitchToLongMode) ==
FALSE)) {
148 DEBUG ((DEBUG_INFO,
"Call SwitchStack() to return to S3 Resume in PEI Phase\n"));
152 (VOID *)(
UINTN)SmmS3ResumeState->ReturnContext1,
153 (VOID *)(
UINTN)SmmS3ResumeState->ReturnContext2,
154 (VOID *)(
UINTN)SmmS3ResumeState->ReturnStackPointer
161 if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) {
162 DEBUG ((DEBUG_INFO,
"Call AsmDisablePaging64() to return to S3 Resume in PEI Phase\n"));
172 SmmS3ResumeState->ReturnCs,
173 (UINT32)SmmS3ResumeState->ReturnEntryPoint,
174 (UINT32)SmmS3ResumeState->ReturnContext1,
175 (UINT32)SmmS3ResumeState->ReturnContext2,
176 (UINT32)SmmS3ResumeState->ReturnStackPointer
183 DEBUG ((DEBUG_ERROR,
"No context to return to PEI Phase\n"));
200 if (!mAcpiS3Enable) {
205 if (GuidHob ==
NULL) {
208 "ERROR:%a(): HOB(gEfiAcpiVariableGuid=%g) needed by S3 resume doesn't exist!\n",
210 &gEfiAcpiVariableGuid
216 DEBUG ((DEBUG_INFO,
"SMM S3 SMRAM Structure = %x\n", SmramDescriptor));
217 DEBUG ((DEBUG_INFO,
"SMM S3 Structure = %x\n", SmramDescriptor->
CpuStart));
222 mSmmS3ResumeState = SmmS3ResumeState;
227 SmmS3ResumeState->SmmS3StackSize = SIZE_32KB;
229 if (SmmS3ResumeState->SmmS3StackBase == 0) {
230 SmmS3ResumeState->SmmS3StackSize = 0;
233 SmmS3ResumeState->SmmS3Cr0 = (UINT32)
AsmReadCr0 ();
234 SmmS3ResumeState->SmmS3Cr4 = (UINT32)
AsmReadCr4 ();
236 if (
sizeof (
UINTN) ==
sizeof (UINT64)) {
237 SmmS3ResumeState->Signature = SMM_S3_RESUME_SMM_64;
240 if (
sizeof (
UINTN) ==
sizeof (UINT32)) {
241 SmmS3ResumeState->Signature = SMM_S3_RESUME_SMM_32;
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID EFIAPI SwitchStack(IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL, IN VOID *NewStack,...)
VOID EFIAPI CpuDeadLoop(VOID)
VOID(EFIAPI * SWITCH_STACK_ENTRY_POINT)(IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID InitSmmS3ResumeState(VOID)
VOID EFIAPI SmmRestoreCpu(VOID)
VOID RestoreSmmConfigurationInS3(VOID)
BOOLEAN EFIAPI SaveAndSetDebugTimerInterrupt(IN BOOLEAN EnableStatus)
VOID EFIAPI InitializeDebugAgent(IN UINT32 InitFlag, IN VOID *Context OPTIONAL, IN DEBUG_AGENT_CONTINUE Function OPTIONAL)
UINTN EFIAPI AsmReadCr0(VOID)
UINTN EFIAPI AsmReadCr4(VOID)
VOID InitSmmS3Cr3(OUT UINTN *Cr3)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
VOID EFIAPI SmmCpuFeaturesCompleteSmmReadyToLock(VOID)
#define FeaturePcdGet(TokenName)
VOID ConfigSmmCodeAccessCheck(VOID)
VOID ExecuteFirstSmiInit(VOID)
VOID *EFIAPI AllocatePages(IN UINTN Pages)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)
VOID EFIAPI AsmDisablePaging64(IN UINT16 Cs, IN UINT32 EntryPoint, IN UINT32 Context1 OPTIONAL, IN UINT32 Context2 OPTIONAL, IN UINT32 NewStack)
VOID EFIAPI AsmReadIdtr(OUT IA32_DESCRIPTOR *Idtr)
VOID EFIAPI AsmWriteIdtr(IN CONST IA32_DESCRIPTOR *Idtr)
UINTN CurrentlyExecutingCpu
EFI_MM_STARTUP_THIS_AP MmStartupThisAp
UINTN CurrentlyExecutingCpu
EFI_PHYSICAL_ADDRESS CpuStart