+++ /dev/null
-#------------------------------------------------------------------------------\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
-\r
-#------------------------------------------------------------------------------\r
-# VOID\r
-# EFIAPI\r
-# SecSwitchStack (\r
-# UINT32 TemporaryMemoryBase,\r
-# UINT32 PermanentMemoryBase\r
-# )#\r
-#------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX (SecSwitchStack)\r
-ASM_PFX(SecSwitchStack):\r
- #\r
- # Save standard registers so they can be used to change stack\r
- #\r
- pushl %eax\r
- pushl %ebx\r
- pushl %ecx\r
- pushl %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 permanent\r
- # memory at first!\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 permanent memory at first.\r
- # Then, Fixup the esp point to permanent memory\r
- #\r
- movl %esp, %eax\r
- subl %ebx, %eax\r
- addl %ecx, %eax\r
- movl 0(%esp), %edx # copy pushed register's value to permanent memory\r
- movl %edx, 0(%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 permanent memory\r
- movl %edx, 16(%eax)\r
- movl %eax, %esp # From now, esp is pointed to permanent memory\r
-\r
- #\r
- # Fixup the ebp point to permanent memory\r
- #\r
- movl %ebp, %eax\r
- subl %ebx, %eax\r
- addl %ecx, %eax\r
- movl %eax, %ebp # From now, ebp is pointed to permanent memory\r
-\r
- popl %edx\r
- popl %ecx\r
- popl %ebx\r
- popl %eax\r
- ret\r
-\r