]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFspPkg/FspSecCore/Ia32/Stacks.s
Add IntelFspPkg to support create FSP bin based on EDKII.
[mirror_edk2.git] / IntelFspPkg / FspSecCore / Ia32 / Stacks.s
diff --git a/IntelFspPkg/FspSecCore/Ia32/Stacks.s b/IntelFspPkg/FspSecCore/Ia32/Stacks.s
new file mode 100644 (file)
index 0000000..6c36c25
--- /dev/null
@@ -0,0 +1,88 @@
+#------------------------------------------------------------------------------\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(SecSwitchStack)\r
+\r
+#------------------------------------------------------------------------------\r
+# VOID\r
+# EFIAPI\r
+# SecSwitchStack (\r
+#   UINT32   TemporaryMemoryBase,\r
+#   UINT32   PermenentMemoryBase\r
+#   )\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
+ASM_PFX(SecSwitchStack):\r
+#\r
+# Save three register: eax, ebx, ecx\r
+#\r
+    push  %eax\r
+    push  %ebx\r
+    push  %ecx\r
+    push  %edx\r
+\r
+#\r
+# !!CAUTION!! this function address's is pushed into stack after\r
+# migration of whole temporary memory, so need save it to permenent\r
+# memory at first!\r
+#\r
+\r
+    movl  20(%esp), %ebx            # Save the first parameter\r
+    movl  24(%esp), %ecx            # Save the second parameter\r
+\r
+#\r
+# Save this function's return address into permenent memory at first.\r
+# Then, Fixup the esp point to permenent memory\r
+#\r
+\r
+    movl  %esp, %eax\r
+    subl  %ebx, %eax\r
+    addl  %ecx, %eax\r
+    movl  (%esp), %edx                 # copy pushed register's value to permenent memory\r
+    movl  %edx, (%eax)\r
+    movl  4(%esp), %edx\r
+    movl  %edx, 4(%eax)\r
+    movl  8(%esp), %edx\r
+    movl  %edx, 8(%eax)\r
+    movl  12(%esp), %edx\r
+    movl  %edx, 12(%eax)\r
+    movl  16(%esp), %edx               # Update this function's return address into permenent memory\r
+    movl  %edx, 16(%eax)\r
+    movl  %eax, %esp                   # From now, esp is pointed to permenent memory\r
+\r
+#\r
+# Fixup the ebp point to permenent memory\r
+#\r
+\r
+    movl   %ebp, %eax\r
+    subl   %ebx, %eax\r
+    addl   %ecx, %eax\r
+    movl   %eax, %ebp                  # From now, ebp is pointed to permenent memory\r
+\r
+#\r
+# Fixup callee's ebp point for PeiDispatch\r
+#\r
+    movl   %ebp, %eax\r
+    subl   %ebx, %eax\r
+    addl   %ecx, %eax\r
+    movl   %eax, %ebp                #  From now, ebp is pointed to permenent memory\r
+\r
+    pop   %edx\r
+    pop   %ecx\r
+    pop   %ebx\r
+    pop   %eax\r
+    ret
\ No newline at end of file