TempRam.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*++ @file
  2. Temp RAM PPI
  3. Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiPei.h>
  7. #include <Library/DebugLib.h>
  8. #include <Library/BaseMemoryLib.h>
  9. #include <Ppi/TemporaryRamSupport.h>
  10. VOID
  11. EFIAPI
  12. SecSwitchStack (
  13. UINT32 TemporaryMemoryBase,
  14. UINT32 PermenentMemoryBase
  15. );
  16. EFI_STATUS
  17. EFIAPI
  18. SecTemporaryRamSupport (
  19. IN CONST EFI_PEI_SERVICES **PeiServices,
  20. IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
  21. IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
  22. IN UINTN CopySize
  23. )
  24. {
  25. //
  26. // Migrate the whole temporary memory to permanent memory.
  27. //
  28. CopyMem (
  29. (VOID *)(UINTN)PermanentMemoryBase,
  30. (VOID *)(UINTN)TemporaryMemoryBase,
  31. CopySize
  32. );
  33. //
  34. // SecSwitchStack function must be invoked after the memory migration
  35. // immediately, also we need fixup the stack change caused by new call into
  36. // permanent memory.
  37. //
  38. SecSwitchStack ((UINT32)TemporaryMemoryBase, (UINT32)PermanentMemoryBase);
  39. //
  40. // We need *not* fix the return address because currently,
  41. // The PeiCore is executed in flash.
  42. //
  43. //
  44. // Simulate to invalid temporary memory, terminate temporary memory
  45. //
  46. // ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
  47. return EFI_SUCCESS;
  48. }