1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2013, 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.
18 ; Switch the stack from temporary memory to permenent memory.
20 ;------------------------------------------------------------------------------
24 ;------------------------------------------------------------------------------
28 ; UINT32 TemporaryMemoryBase,
29 ; UINT32 PermenentMemoryBase
31 ;------------------------------------------------------------------------------
37 ; Save three register: eax, ebx, ecx
45 ; !!CAUTION!! this function address's is pushed into stack after
46 ; migration of whole temporary memory, so need save it to permenent
50 mov rbx, [rsp + 28h] ; Save the first parameter
51 mov rcx, [rsp + 30h] ; Save the second parameter
54 ; Save this function's return address into permenent memory at first.
55 ; Then, Fixup the esp point to permenent memory
60 mov rdx, qword ptr [rsp] ; copy pushed register's value to permenent memory
61 mov qword ptr [rax], rdx
62 mov rdx, qword ptr [rsp + 8]
63 mov qword ptr [rax + 8], rdx
64 mov rdx, qword ptr [rsp + 10h]
65 mov qword ptr [rax + 10h], rdx
66 mov rdx, qword ptr [rsp + 18h]
67 mov qword ptr [rax + 18h], rdx
68 mov rdx, qword ptr [rsp + 20h] ; Update this function's return address into permenent memory
69 mov qword ptr [rax + 20h], rdx
70 mov rsp, rax ; From now, esp is pointed to permenent memory
73 ; Fixup the ebp point to permenent memory
78 mov rbp, rax ; From now, ebp is pointed to permenent memory
87 ;------------------------------------------------------------------------------
91 ; IN SWITCH_STACK_ENTRY_POINT EntryPoint,
92 ; IN VOID *Context1, OPTIONAL
93 ; IN VOID *Context2, OPTIONAL
94 ; IN VOID *Context3, OPTIONAL
97 ;------------------------------------------------------------------------------