]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Sec/X64/SwitchRam.asm
EmulatorPkg/Sec: Fix various typos
[mirror_edk2.git] / EmulatorPkg / Sec / X64 / SwitchRam.asm
CommitLineData
e148512e 1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
de949fdb 4; Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
e3ba31da 5; SPDX-License-Identifier: BSD-2-Clause-Patent\r
e148512e 6;\r
7;------------------------------------------------------------------------------\r
8\r
9EXTERN CopyMem:PROC\r
10EXTERN ZeroMem:PROC\r
11\r
12 .code\r
13\r
14;------------------------------------------------------------------------------\r
15; EFI_STATUS\r
16; EFIAPI\r
17; SecTemporaryRamSupport (\r
18; IN CONST EFI_PEI_SERVICES **PeiServices, // %rcx\r
19; IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, // %rdx\r
20; IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, // %r8\r
21; IN UINTN CopySize // %r9\r
22; )\r
23;------------------------------------------------------------------------------\r
24SecTemporaryRamSupport PROC\r
25 ; Adjust callers %rbp to account for stack move\r
26 sub rbp, rdx ; Calc offset of %rbp in Temp Memory\r
27 add rbp, r8 ; add in permanent base to offset\r
28\r
29 push rbp ; stack frame is for the debugger\r
30 mov rbp, rsp\r
31\r
32 push rdx ; Save TemporaryMemoryBase\r
33 push r8 ; Save PermanentMemoryBase\r
34 push r9 ; Save CopySize\r
35\r
36 ;\r
37 ; Copy all of temp RAM to permanent memory, including stack\r
38 ;\r
39 ; CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);\r
40 ; %rcx, %rdx, %r8\r
41 mov rcx, r8 ; Shift arguments\r
42 mov r8, r9\r
43 sub rsp, 028h ; Allocate register spill area & 16-byte align stack\r
44 call CopyMem\r
45 ; Temp mem stack now copied to permanent location. %esp still in temp memory\r
46 add rsp, 028h\r
47\r
48 pop r9 ; CopySize (old stack)\r
49 pop r8 ; PermanentMemoryBase (old stack)\r
50 pop rdx ; TemporaryMemoryBase (old stack)\r
51\r
52 mov rcx, rsp ; Move to new stack\r
53 sub rcx, rdx ; Calc offset of stack in Temp Memory\r
54 add rcx, r8 ; Calc PermanentMemoryBase address\r
55 mov rsp, rcx ; Update stack\r
56 ; Stack now points to permanent memory\r
57\r
58 ; ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);\r
59 mov rcx, rdx\r
60 mov rdx, r9\r
61 sub rsp, 028h ; Allocate register spill area & 16-byte align stack\r
62 call ZeroMem\r
63 add rsp, 028h\r
64\r
65 ; This data comes off the NEW stack\r
66 pop rbp\r
67 ret\r
68SecTemporaryRamSupport ENDP\r
69\r
70 END\r