## @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
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
--- /dev/null
+;------------------------------------------------------------------------------\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