--- /dev/null
+#------------------------------------------------------------------------------\r
+#*\r
+#* Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+#* This program and the accompanying materials\r
+#* are licensed and made available under the terms and conditions of the BSD License\r
+#* which accompanies this distribution. The full text of the license may be found at\r
+#* http://opensource.org/licenses/bsd-license.php\r
+#*\r
+#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#*\r
+#* AsmFuncs.S\r
+#*\r
+#* Abstract:\r
+#*\r
+#* Assembly function to set segment selectors.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+.text\r
+\r
+#------------------------------------------------------------------------------\r
+# \r
+# VOID\r
+# EFIAPI\r
+# AsmSetDataSelectors (\r
+# IN UINT16 SelectorValue\r
+# );\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(AsmSetDataSelectors)\r
+ASM_PFX(AsmSetDataSelectors):\r
+ movl 4(%esp), %eax\r
+ movw %ax, %ss\r
+ movw %ax, %ds\r
+ movw %ax, %es\r
+ movw %ax, %fs\r
+ movw %ax, %gs \r
+ ret\r
--- /dev/null
+;------------------------------------------------------------------------------ ;\r
+; Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+; This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php.\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; AsmFuncs.Asm\r
+;\r
+; Abstract:\r
+;\r
+; Assembly function to set segment selectors.\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+.686\r
+.model flat,C\r
+\r
+.code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmSetDataSelectors (\r
+; IN UINT16 SelectorValue\r
+; );\r
+;------------------------------------------------------------------------------\r
+AsmSetDataSelectors PROC near public\r
+ mov eax, [esp + 4]\r
+ mov ds, ax\r
+ mov es, ax\r
+ mov fs, ax\r
+ mov gs, ax\r
+ mov ss, ax \r
+ ret\r
+AsmSetDataSelectors ENDP\r
+\r
+END\r
IN EFI_PEI_S3_RESUME2_PPI *This\r
);\r
\r
+/**\r
+ Set data segment selectors value including DS/ES/FS/GS/SS.\r
+\r
+ @param[in] SelectorValue Segment selector value to be set.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmSetDataSelectors (\r
+ IN UINT16 SelectorValue\r
+ );\r
+\r
//\r
// Globals\r
//\r
/* 0x40 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},\r
};\r
\r
+#define DATA_SEGEMENT_SELECTOR 0x18\r
+\r
//\r
// IA32 Gdt register\r
//\r
IA32_DESCRIPTOR *IdtDescriptor;\r
VOID *IdtBuffer;\r
PEI_S3_RESUME_STATE *PeiS3ResumeState;\r
+ BOOLEAN InterruptStatus;\r
\r
DEBUG ((EFI_D_ERROR, "S3ResumeExecuteBootScript()\n"));\r
\r
*(UINTN*)(IdtDescriptor->Base - sizeof(UINTN)) = (UINTN)GetPeiServicesTablePointer ();\r
}\r
\r
+ InterruptStatus = SaveAndDisableInterrupts ();\r
//\r
// Need to make sure the GDT is loaded with values that support long mode and real mode.\r
//\r
AsmWriteGdtr (&mGdt);\r
+ //\r
+ // update segment selectors per the new GDT.\r
+ //\r
+ AsmSetDataSelectors (DATA_SEGEMENT_SELECTOR);\r
+ //\r
+ // Restore interrupt state.\r
+ //\r
+ SetInterruptState (InterruptStatus);\r
\r
//\r
// Prepare data for return back\r
SMM_S3_RESUME_STATE *SmmS3ResumeState;\r
VOID *GuidHob;\r
BOOLEAN Build4GPageTableOnly;\r
+ BOOLEAN InterruptStatus;\r
\r
TempAcpiS3Context = 0;\r
TempEfiBootScriptExecutorVariable = 0;\r
// Switch to long mode to complete resume.\r
//\r
\r
+ InterruptStatus = SaveAndDisableInterrupts ();\r
//\r
// Need to make sure the GDT is loaded with values that support long mode and real mode.\r
//\r
AsmWriteGdtr (&mGdt);\r
+ //\r
+ // update segment selectors per the new GDT.\r
+ // \r
+ AsmSetDataSelectors (DATA_SEGEMENT_SELECTOR);\r
+ //\r
+ // Restore interrupt state.\r
+ //\r
+ SetInterruptState (InterruptStatus);\r
+\r
AsmWriteCr3 ((UINTN)SmmS3ResumeState->SmmS3Cr3);\r
AsmEnablePaging64 (\r
0x38,\r
[Sources]\r
S3Resume.c\r
\r
+[Sources.IA32]\r
+ Ia32/AsmFuncs.asm | MSFT\r
+ Ia32/AsmFuncs.S | GCC\r
+\r
+[Sources.X64]\r
+ X64/AsmFuncs.asm | MSFT\r
+ X64/AsmFuncs.S | GCC\r
+\r
[Packages]\r
MdePkg/MdePkg.dec\r
MdeModulePkg/MdeModulePkg.dec\r
--- /dev/null
+#------------------------------------------------------------------------------\r
+#*\r
+#* Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+#* This program and the accompanying materials\r
+#* are licensed and made available under the terms and conditions of the BSD License\r
+#* which accompanies this distribution. The full text of the license may be found at\r
+#* http://opensource.org/licenses/bsd-license.php\r
+#*\r
+#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#*\r
+#* AsmFuncs.S\r
+#*\r
+#* Abstract:\r
+#*\r
+#* Assembly function to set segment selectors.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+.text\r
+\r
+#------------------------------------------------------------------------------\r
+# \r
+# VOID\r
+# EFIAPI\r
+# AsmSetDataSelectors (\r
+# IN UINT16 SelectorValue\r
+# );\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(AsmSetDataSelectors)\r
+ASM_PFX(AsmSetDataSelectors):\r
+ movw %cx, %ss\r
+ movw %cx, %ds\r
+ movw %cx, %es\r
+ movw %cx, %fs\r
+ movw %cx, %gs \r
+ ret\r
--- /dev/null
+;------------------------------------------------------------------------------ ;\r
+; Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+; This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php.\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; AsmFuncs.Asm\r
+;\r
+; Abstract:\r
+;\r
+; Assembly function to set segment selectors.\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+.code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmSetDataSelectors (\r
+; IN UINT16 SelectorValue\r
+; );\r
+;------------------------------------------------------------------------------\r
+AsmSetDataSelectors PROC\r
+ mov ds, cx\r
+ mov es, cx\r
+ mov fs, cx\r
+ mov gs, cx\r
+ mov ss, cx \r
+ ret\r
+AsmSetDataSelectors ENDP\r
+\r
+END\r