1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
8 ; Switch the stack from temporary memory to permanent memory.
10 ;------------------------------------------------------------------------------
14 ;------------------------------------------------------------------------------
18 ; UINT32 TemporaryMemoryBase,
19 ; UINT32 PermenentMemoryBase
21 ;------------------------------------------------------------------------------
22 global ASM_PFX(SecSwitchStack)
23 ASM_PFX(SecSwitchStack):
25 ; Save three register: eax, ebx, ecx
33 ; !!CAUTION!! this function address's is pushed into stack after
34 ; migration of whole temporary memory, so need save it to permanent
38 mov ebx, [esp + 20] ; Save the first parameter
39 mov ecx, [esp + 24] ; Save the second parameter
42 ; Save this function's return address into permanent memory at first.
43 ; Then, Fixup the esp point to permanent memory
48 mov edx, dword [esp] ; copy pushed register's value to permanent memory
50 mov edx, dword [esp + 4]
51 mov dword [eax + 4], edx
52 mov edx, dword [esp + 8]
53 mov dword [eax + 8], edx
54 mov edx, dword [esp + 12]
55 mov dword [eax + 12], edx
56 mov edx, dword [esp + 16] ; Update this function's return address into permanent memory
57 mov dword [eax + 16], edx
58 mov esp, eax ; From now, esp is pointed to permanent memory
61 ; Fixup the ebp point to permanent memory
66 mov ebp, eax ; From now, ebp is pointed to permanent memory