1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2006 - 2012, 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 ;------------------------------------------------------------------------------
20 ;------------------------------------------------------------------------------
23 ; SecTemporaryRamSupport (
24 ; IN CONST EFI_PEI_SERVICES **PeiServices, // %rcx
25 ; IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, // %rdx
26 ; IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, // %r8
27 ; IN UINTN CopySize // %r9
29 ;------------------------------------------------------------------------------
30 SecTemporaryRamSupport PROC
31 ; Adjust callers %rbp to account for stack move
32 sub rbp, rdx ; Calc offset of %rbp in Temp Memory
33 add rbp, r8 ; add in permanent base to offset
35 push rbp ; stack frame is for the debugger
38 push rdx ; Save TemporaryMemoryBase
39 push r8 ; Save PermanentMemoryBase
40 push r9 ; Save CopySize
43 ; Copy all of temp RAM to permanent memory, including stack
45 ; CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);
47 mov rcx, r8 ; Shift arguments
49 sub rsp, 028h ; Allocate register spill area & 16-byte align stack
51 ; Temp mem stack now copied to permanent location. %esp still in temp memory
54 pop r9 ; CopySize (old stack)
55 pop r8 ; PermanentMemoryBase (old stack)
56 pop rdx ; TemporaryMemoryBase (old stack)
58 mov rcx, rsp ; Move to new stack
59 sub rcx, rdx ; Calc offset of stack in Temp Memory
60 add rcx, r8 ; Calc PermanentMemoryBase address
61 mov rsp, rcx ; Update stack
62 ; Stack now points to permanent memory
64 ; ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);
67 sub rsp, 028h ; Allocate register spill area & 16-byte align stack
71 ; This data comes off the NEW stack
74 SecTemporaryRamSupport ENDP