]> git.proxmox.com Git - mirror_edk2.git/blob - InOsEmuPkg/Sec/X64/SwitchRam.S
Clarify the requirements for the Destination parameter of UnicodeStrToAsciiStr.
[mirror_edk2.git] / InOsEmuPkg / Sec / X64 / SwitchRam.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4 # Portitions copyright (c) 2011, Apple Inc. All rights reserved.
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php.
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13 #------------------------------------------------------------------------------
14
15
16
17 // EFI_STATUS
18 // EFIAPI
19 // SecTemporaryRamSupport (
20 // IN CONST EFI_PEI_SERVICES **PeiServices, // %rcx
21 // IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, // %rdx
22 // IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, // %r8
23 // IN UINTN CopySize // %r9
24 // )
25 //
26 ASM_GLOBAL ASM_PFX(SecTemporaryRamSupport)
27 ASM_PFX(SecTemporaryRamSupport):
28 // Adjust callers %rbp to account for stack move
29 subq %rdx, %rbp // Calc offset of %rbp in Temp Memory
30 addq %r8, %rbp // add in permanent base to offset
31
32 pushq %rbp // stack frame is for the debugger
33 movq %rsp, %rbp
34
35 pushq %rdx // Save TemporaryMemoryBase
36 pushq %r8 // Save PermanentMemoryBase
37 pushq %r9 // Save CopySize
38
39 //
40 // Copy all of temp RAM to permanent memory, including stack
41 //
42 // CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);
43 // %rcx, %rdx, %r8
44 movq %r8, %rcx // Shift arguments
45 movq %r9, %r8
46 subq $0x28, %rsp // Allocate register spill area & 16-byte align stack
47 call ASM_PFX(CopyMem)
48 // Temp mem stack now copied to permanent location. %esp still in temp memory
49 addq $0x28, %rsp
50
51 popq %r9 // CopySize (old stack)
52 popq %r8 // PermanentMemoryBase (old stack)
53 popq %rdx // TemporaryMemoryBase (old stack)
54
55 movq %rsp, %rcx // Move to new stack
56 subq %rdx, %rcx // Calc offset of stack in Temp Memory
57 addq %r8, %rcx // Calc PermanentMemoryBase address
58 movq %rcx, %rsp // Update stack
59 // Stack now points to permanent memory
60
61 // ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);
62 movq %rdx, %rcx
63 movq %r9, %rdx
64 subq $0x28, %rsp // Allocate register spill area & 16-byte align stack
65 call ASM_PFX(ZeroMem)
66 addq $0x28, %rsp
67
68 // This data comes off the NEW stack
69 popq %rbp
70 ret
71
72