1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
4 ; This program and the accompanying materials
5 ; are licensed and made available under the terms and conditions of the BSD License
6 ; which accompanies this distribution. The full text of the license may be found at
7 ; http://opensource.org/licenses/bsd-license.php.
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 ; Switch the stack from temporary memory to permanent memory.
16 ;------------------------------------------------------------------------------
20 ;------------------------------------------------------------------------------
24 ; UINT32 TemporaryMemoryBase,
25 ; UINT32 PermenentMemoryBase
27 ;------------------------------------------------------------------------------
28 global ASM_PFX(SecSwitchStack)
29 ASM_PFX(SecSwitchStack):
31 ; Save three register: eax, ebx, ecx
39 ; !!CAUTION!! this function address's is pushed into stack after
40 ; migration of whole temporary memory, so need save it to permanent
44 mov ebx, [esp + 20] ; Save the first parameter
45 mov ecx, [esp + 24] ; Save the second parameter
48 ; Save this function's return address into permanent memory at first.
49 ; Then, Fixup the esp point to permanent memory
54 mov edx, dword [esp] ; copy pushed register's value to permanent memory
56 mov edx, dword [esp + 4]
57 mov dword [eax + 4], edx
58 mov edx, dword [esp + 8]
59 mov dword [eax + 8], edx
60 mov edx, dword [esp + 12]
61 mov dword [eax + 12], edx
62 mov edx, dword [esp + 16] ; Update this function's return address into permanent memory
63 mov dword [eax + 16], edx
64 mov esp, eax ; From now, esp is pointed to permanent memory
67 ; Fixup the ebp point to permenent memory
72 mov ebp, eax ; From now, ebp is pointed to permanent memory