1 /*++ @file
2 Temp RAM PPI
3
4 Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
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 #include <PiPei.h>
16 #include <Library/DebugLib.h>
17 #include <Library/BaseMemoryLib.h>
18
19 #include <Ppi/TemporaryRamSupport.h>
20
21 VOID
22 EFIAPI
23 SecSwitchStack (
24 UINT32 TemporaryMemoryBase,
25 UINT32 PermenentMemoryBase
26 );
27
28
29 EFI_STATUS
30 EFIAPI
SecTemporaryRamSupport(IN CONST EFI_PEI_SERVICES ** PeiServices,IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,IN UINTN CopySize)31 SecTemporaryRamSupport (
32 IN CONST EFI_PEI_SERVICES **PeiServices,
33 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
34 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
35 IN UINTN CopySize
36 )
37 {
38 //
39 // Migrate the whole temporary memory to permanent memory.
40 //
41 CopyMem (
42 (VOID*)(UINTN)PermanentMemoryBase,
43 (VOID*)(UINTN)TemporaryMemoryBase,
44 CopySize
45 );
46
47 //
48 // SecSwitchStack function must be invoked after the memory migration
49 // immediately, also we need fixup the stack change caused by new call into
50 // permanent memory.
51 //
52 SecSwitchStack ((UINT32) TemporaryMemoryBase, (UINT32) PermanentMemoryBase);
53
54 //
55 // We need *not* fix the return address because currently,
56 // The PeiCore is executed in flash.
57 //
58
59 //
60 // Simulate to invalid temporary memory, terminate temporary memory
61 //
62 //ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
63
64 return EFI_SUCCESS;
65 }
66