]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFspPkg/Library/BaseFspSwitchStackLib/Ia32/Stack.s
Add IntelFspPkg to support create FSP bin based on EDKII.
[mirror_edk2.git] / IntelFspPkg / Library / BaseFspSwitchStackLib / Ia32 / Stack.s
diff --git a/IntelFspPkg/Library/BaseFspSwitchStackLib/Ia32/Stack.s b/IntelFspPkg/Library/BaseFspSwitchStackLib/Ia32/Stack.s
new file mode 100644 (file)
index 0000000..6932cd8
--- /dev/null
@@ -0,0 +1,64 @@
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2014, 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
+ASM_GLOBAL ASM_PFX(Pei2LoaderSwitchStack)\r
+ASM_GLOBAL ASM_PFX(Loader2PeiSwitchStack)\r
+\r
+#------------------------------------------------------------------------------\r
+# UINT32\r
+# EFIAPI\r
+# Pei2LoaderSwitchStack (\r
+#   VOID\r
+#   )\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(Pei2LoaderSwitchStack)\r
+ASM_PFX(Pei2LoaderSwitchStack):\r
+    jmp     ASM_PFX(Loader2PeiSwitchStack)\r
+\r
+#------------------------------------------------------------------------------\r
+# UINT32\r
+# EFIAPI\r
+# Loader2PeiSwitchStack (\r
+#   )\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(Loader2PeiSwitchStack)\r
+ASM_PFX(Loader2PeiSwitchStack):\r
+#Save current contexts\r
+    push    $exit\r
+    pushf\r
+    pushf\r
+    cli\r
+    pusha\r
+    push    $0x0\r
+    push    $0x0\r
+    sidt    (%esp)\r
+\r
+    # Load new stack\r
+    push   %esp\r
+    call   ASM_PFX(SwapStack)\r
+    mov    %eax,%esp\r
+\r
+    # Restore previous contexts\r
+    lidt    (%esp)\r
+    add     $8,%esp\r
+    popa\r
+    popf\r
+    popf\r
+exit:\r
+    ret\r
+\r
+\r