1 #------------------------------------------------------------------------------
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.
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.
13 #------------------------------------------------------------------------------
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
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
32 pushq %rbp // stack frame is for the debugger
35 pushq %rdx // Save TemporaryMemoryBase
36 pushq %r8 // Save PermanentMemoryBase
37 pushq %r9 // Save CopySize
40 // Copy all of temp RAM to permanent memory, including stack
42 // CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);
44 movq %r8, %rcx // Shift arguments
46 subq $0x28, %rsp // Allocate register spill area & 16-byte align stack
48 // Temp mem stack now copied to permanent location. %esp still in temp memory
51 popq %r9 // CopySize (old stack)
52 popq %r8 // PermanentMemoryBase (old stack)
53 popq %rdx // TemporaryMemoryBase (old stack)
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
61 // ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);
64 subq $0x28, %rsp // Allocate register spill area & 16-byte align stack
68 // This data comes off the NEW stack