1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
12 ; Switch the stack from temporary memory to permenent memory.
14 ;------------------------------------------------------------------------------
18 ;------------------------------------------------------------------------------
22 ; UINT32 TemporaryMemoryBase,
23 ; UINT32 PermenentMemoryBase
25 ;------------------------------------------------------------------------------
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 permenent
44 mov rbx, [rsp + 28h] ; Save the first parameter
45 mov rcx, [rsp + 30h] ; Save the second parameter
48 ; Save this function's return address into permenent memory at first.
49 ; Then, Fixup the esp point to permenent memory
54 mov rdx, qword ptr [rsp] ; copy pushed register's value to permenent memory
55 mov qword ptr [rax], rdx
56 mov rdx, qword ptr [rsp + 8]
57 mov qword ptr [rax + 8], rdx
58 mov rdx, qword ptr [rsp + 10h]
59 mov qword ptr [rax + 10h], rdx
60 mov rdx, qword ptr [rsp + 18h]
61 mov qword ptr [rax + 18h], rdx
62 mov rdx, qword ptr [rsp + 20h] ; Update this function's return address into permenent memory
63 mov qword ptr [rax + 20h], rdx
64 mov rsp, rax ; From now, esp is pointed to permenent memory
67 ; Fixup the ebp point to permenent memory
72 mov rbp, rax ; From now, ebp is pointed to permenent memory
81 ;------------------------------------------------------------------------------
85 ; IN SWITCH_STACK_ENTRY_POINT EntryPoint,
86 ; IN VOID *Context1, OPTIONAL
87 ; IN VOID *Context2, OPTIONAL
88 ; IN VOID *Context3, OPTIONAL
91 ;------------------------------------------------------------------------------