1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
4 ; Portions copyright (c) 2011, Apple Inc. All rights reserved.
5 ; SPDX-License-Identifier: BSD-2-Clause-Patent
7 ;------------------------------------------------------------------------------
14 ;------------------------------------------------------------------------------
17 ; SecTemporaryRamSupport (
18 ; IN CONST EFI_PEI_SERVICES **PeiServices, // %rcx
19 ; IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, // %rdx
20 ; IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, // %r8
21 ; IN UINTN CopySize // %r9
23 ;------------------------------------------------------------------------------
24 SecTemporaryRamSupport PROC
25 ; Adjust callers %rbp to account for stack move
26 sub rbp, rdx ; Calc offset of %rbp in Temp Memory
27 add rbp, r8 ; add in permanent base to offset
29 push rbp ; stack frame is for the debugger
32 push rdx ; Save TemporaryMemoryBase
33 push r8 ; Save PermanentMemoryBase
34 push r9 ; Save CopySize
37 ; Copy all of temp RAM to permanent memory, including stack
39 ; CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);
41 mov rcx, r8 ; Shift arguments
43 sub rsp, 028h ; Allocate register spill area & 16-byte align stack
45 ; Temp mem stack now copied to permanent location. %esp still in temp memory
48 pop r9 ; CopySize (old stack)
49 pop r8 ; PermanentMemoryBase (old stack)
50 pop rdx ; TemporaryMemoryBase (old stack)
52 mov rcx, rsp ; Move to new stack
53 sub rcx, rdx ; Calc offset of stack in Temp Memory
54 add rcx, r8 ; Calc PermanentMemoryBase address
55 mov rsp, rcx ; Update stack
56 ; Stack now points to permanent memory
58 ; ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);
61 sub rsp, 028h ; Allocate register spill area & 16-byte align stack
65 ; This data comes off the NEW stack
68 SecTemporaryRamSupport ENDP