1 #------------------------------------------------------------------------------
3 # Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4 # Portitions copyright (c) 2011, Apple Inc. All rights reserved.
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
7 #------------------------------------------------------------------------------
13 // SecTemporaryRamSupport (
14 // IN CONST EFI_PEI_SERVICES **PeiServices, // %rcx
15 // IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, // %rdx
16 // IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, // %r8
17 // IN UINTN CopySize // %r9
20 ASM_GLOBAL ASM_PFX(SecTemporaryRamSupport)
21 ASM_PFX(SecTemporaryRamSupport):
22 // Adjust callers %rbp to account for stack move
23 subq %rdx, %rbp // Calc offset of %rbp in Temp Memory
24 addq %r8, %rbp // add in permanent base to offset
26 pushq %rbp // stack frame is for the debugger
29 pushq %rdx // Save TemporaryMemoryBase
30 pushq %r8 // Save PermanentMemoryBase
31 pushq %r9 // Save CopySize
34 // Copy all of temp RAM to permanent memory, including stack
36 // CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);
38 movq %r8, %rcx // Shift arguments
40 subq $0x28, %rsp // Allocate register spill area & 16-byte align stack
42 // Temp mem stack now copied to permanent location. %esp still in temp memory
45 popq %r9 // CopySize (old stack)
46 popq %r8 // PermanentMemoryBase (old stack)
47 popq %rdx // TemporaryMemoryBase (old stack)
49 movq %rsp, %rcx // Move to new stack
50 subq %rdx, %rcx // Calc offset of stack in Temp Memory
51 addq %r8, %rcx // Calc PermanentMemoryBase address
52 movq %rcx, %rsp // Update stack
53 // Stack now points to permanent memory
55 // ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);
58 subq $0x28, %rsp // Allocate register spill area & 16-byte align stack
62 // This data comes off the NEW stack