IntelFsp2Pkg BaseFspSwitchStackLib: Convert Ia32/Stack.asm to NASM
authorLiming Gao <liming.gao@intel.com>
Wed, 8 Jun 2016 09:00:25 +0000 (17:00 +0800)
committerLiming Gao <liming.gao@intel.com>
Tue, 28 Jun 2016 01:52:03 +0000 (09:52 +0800)
The BaseTools/Scripts/ConvertMasmToNasm.py script was used to convert
Ia32/Stack.asm to Ia32/Stack.nasm

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwitchStackLib.inf
IntelFsp2Pkg/Library/BaseFspSwitchStackLib/Ia32/Stack.nasm [new file with mode: 0644]

index bbeeb74..cef8d68 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Instance of BaseFspSwitchStackLib\r
 #\r
-#  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -24,8 +24,9 @@
   FspSwitchStackLib.c\r
 \r
 [Sources.IA32]\r
-  Ia32/Stack.asm | MSFT\r
-  Ia32/Stack.s | GCC\r
+  Ia32/Stack.asm\r
+  Ia32/Stack.s\r
+  Ia32/Stack.nasm\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
diff --git a/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/Ia32/Stack.nasm b/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/Ia32/Stack.nasm
new file mode 100644 (file)
index 0000000..b0d843e
--- /dev/null
@@ -0,0 +1,74 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2016, 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
+; Abstract:\r
+;\r
+;   Switch the stack from temporary memory to permenent memory.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    SECTION .text\r
+\r
+extern ASM_PFX(SwapStack)\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; Pei2LoaderSwitchStack (\r
+;   VOID\r
+;   )\r
+;------------------------------------------------------------------------------\r
+global ASM_PFX(Pei2LoaderSwitchStack)\r
+ASM_PFX(Pei2LoaderSwitchStack):\r
+    xor     eax, eax\r
+    jmp     ASM_PFX(FspSwitchStack)\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; Loader2PeiSwitchStack (\r
+;   VOID\r
+;   )\r
+;------------------------------------------------------------------------------\r
+global ASM_PFX(Loader2PeiSwitchStack)\r
+ASM_PFX(Loader2PeiSwitchStack):\r
+    jmp     ASM_PFX(FspSwitchStack)\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; FspSwitchStack (\r
+;   VOID\r
+;   )\r
+;------------------------------------------------------------------------------\r
+global ASM_PFX(FspSwitchStack)\r
+ASM_PFX(FspSwitchStack):\r
+    ; Save current contexts\r
+    push    eax\r
+    pushfd\r
+    cli\r
+    pushad\r
+    sub     esp, 8\r
+    sidt    [esp]\r
+\r
+    ; Load new stack\r
+    push    esp\r
+    call    ASM_PFX(SwapStack)\r
+    mov     esp, eax\r
+\r
+    ; Restore previous contexts\r
+    lidt    [esp]\r
+    add     esp, 8\r
+    popad\r
+    popfd\r
+    add     esp, 4\r
+    ret\r
+\r