]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmulatorPkg: Add persistent memory in EmuThunkPpi
authorLiu, Zhiguang <Zhiguang.Liu@intel.com>
Tue, 6 Dec 2022 05:40:52 +0000 (13:40 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 8 Dec 2022 10:44:20 +0000 (10:44 +0000)
The persistent memory is for PEIM to use, and won't lose during cold
or warm reset. PcdPersistentMemorySize is only used by WinHost.c,
other modules can check the persistent memory size using the field
PersistentMemorySize.

Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
EmulatorPkg/EmulatorPkg.dec
EmulatorPkg/Include/Ppi/EmuThunk.h
EmulatorPkg/Unix/Host/Host.c
EmulatorPkg/Unix/Host/Host.inf
EmulatorPkg/Win/Host/WinHost.c
EmulatorPkg/Win/Host/WinHost.inf

index b9c70b63b3ab3f71d90308cdcf89b47df77e21b3..fe81652b0478164583b2eeff973773bf61295700 100644 (file)
@@ -2,7 +2,7 @@
 #\r
 # This is the Emu Emulation Environment Platform\r
 #\r
-# Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
 # (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>\r
 #\r
@@ -86,6 +86,7 @@
   # The user ID and password are fixed as below.\r
   gEmulatorPkgTokenSpaceGuid.PcdRedfishServieUserId|"admin"|VOID*|0x00001022\r
   gEmulatorPkgTokenSpaceGuid.PcdRedfishServiePassword|"pwd123456"|VOID*|0x00001023\r
+  gEmulatorPkgTokenSpaceGuid.PcdPersistentMemorySize|0x4000000|UINT32|0x00001024\r
 \r
 [PcdsFixedAtBuild, PcdsPatchableInModule]\r
   gEmulatorPkgTokenSpaceGuid.PcdEmuBootMode|1|UINT32|0x00001006\r
index c0e2bc6b982bb2b3d95e4034880fa913a403f6b7..cf29cf824c588ead9a453c84cd41dc69995d4b75 100644 (file)
@@ -2,7 +2,7 @@
   Emulator Thunk to abstract OS services from pure EFI code\r
 \r
   Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-\r
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -107,6 +107,8 @@ typedef struct {
   EMU_PEI_AUTOSCAN           MemoryAutoScan;\r
   EMU_PEI_FD_INFORMATION     FirmwareDevices;\r
   EMU_PEI_THUNK_INTERFACE    Thunk;\r
+  UINTN                      PersistentMemorySize;\r
+  UINT8                      PersistentMemory[0];\r
 } EMU_THUNK_PPI;\r
 \r
 extern EFI_GUID  gEmuThunkPpiGuid;\r
index 38c01c84af44d07484a48cdff58a19ed08f9ce01..8d0be5b54be042540efe1e6216c1f8fa38fb1fde 100644 (file)
@@ -1,6 +1,6 @@
 /*++ @file\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -102,6 +102,7 @@ main (
   CHAR16                *FirmwareVolumesStr;\r
   UINTN                 *StackPointer;\r
   FILE                  *GdbTempFile;\r
+  EMU_THUNK_PPI         *SecEmuThunkPpi;\r
 \r
   //\r
   // Xcode does not support sourcing gdb scripts directly, so the Xcode XML\r
@@ -137,7 +138,15 @@ main (
   //\r
   // PPIs pased into PEI_CORE\r
   //\r
-  AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, &mSecEmuThunkPpi);\r
+  SecEmuThunkPpi = AllocateZeroPool (sizeof (EMU_THUNK_PPI) + FixedPcdGet32 (PcdPersistentMemorySize));\r
+  if (SecEmuThunkPpi == NULL) {\r
+    printf ("ERROR : Can not allocate memory for SecEmuThunkPpi.  Exiting.\n");\r
+    exit (1);\r
+  }\r
+\r
+  CopyMem (SecEmuThunkPpi, &mSecEmuThunkPpi, sizeof (EMU_THUNK_PPI));\r
+  SecEmuThunkPpi->PersistentMemorySize = FixedPcdGet32 (PcdPersistentMemorySize);\r
+  AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, SecEmuThunkPpi);\r
 \r
   SecInitThunkProtocol ();\r
 \r
index c479d2b7d02968eb453d8ee14fdbdd934f81db74..f5ebbed683440ea5091be4982821af5c15de4e98 100644 (file)
@@ -2,7 +2,7 @@
 # Entry Point of Emu Emulator\r
 #\r
 # Main executable file of Unix Emulator that loads PEI core after initialization finished.\r
-# Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
 #\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
   gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
   gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
+  gEmulatorPkgTokenSpaceGuid.PcdPersistentMemorySize\r
 \r
 [FeaturePcd]\r
   gEmulatorPkgTokenSpaceGuid.PcdEmulatorLazyLoadSymbols\r
index 084cd4cbd7ec4a7a06802fb51c4312c7bba285eb..19199c648c1532207ec26542a3afb14f8113c751 100644 (file)
@@ -450,6 +450,7 @@ Returns:
   UINTN                SystemAffinityMask;\r
   INT32                LowBit;\r
   UINTN                ResetJumpCode;\r
+  EMU_THUNK_PPI        *SecEmuThunkPpi;\r
 \r
   //\r
   // Enable the privilege so that RTC driver can successfully run SetTime()\r
@@ -491,7 +492,15 @@ Returns:
   //\r
   // PPIs pased into PEI_CORE\r
   //\r
-  AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, &mSecEmuThunkPpi);\r
+  SecEmuThunkPpi = AllocateZeroPool (sizeof (EMU_THUNK_PPI) + FixedPcdGet32 (PcdPersistentMemorySize));\r
+  if (SecEmuThunkPpi == NULL) {\r
+    SecPrint ("ERROR : Can not allocate memory for SecEmuThunkPpi.  Exiting.\n");\r
+    exit (1);\r
+  }\r
+\r
+  CopyMem (SecEmuThunkPpi, &mSecEmuThunkPpi, sizeof (EMU_THUNK_PPI));\r
+  SecEmuThunkPpi->PersistentMemorySize = FixedPcdGet32 (PcdPersistentMemorySize);\r
+  AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, SecEmuThunkPpi);\r
   AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEfiPeiReset2PpiGuid, &mEmuReset2Ppi);\r
 \r
   //\r
index b61901fae294f7bd4445fd8812180b3b42c1752d..4dac6e033e64c7de239d9df6a6128facffaac68a 100644 (file)
@@ -74,7 +74,7 @@
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack\r
-\r
+  gEmulatorPkgTokenSpaceGuid.PcdPersistentMemorySize\r
   gEmulatorPkgTokenSpaceGuid.PcdEmuBootMode\r
   gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareVolume\r
   gEmulatorPkgTokenSpaceGuid.PcdEmuMemorySize\r