summaryrefslogtreecommitdiffstats
path: root/EmulatorPkg
diff options
context:
space:
mode:
authorNi, Ray <ray.ni@intel.com>2022-11-12 12:00:41 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-12-05 05:35:41 +0000
commita121165e35b50a8bfc1253c9be156c1c123ff688 (patch)
tree8b255aef071ed837d2b4a7a821aeac52d86366f4 /EmulatorPkg
parentd2842bb6ec3e7fa691318c31e71e88b9a9eca545 (diff)
downloadedk2-a121165e35b50a8bfc1253c9be156c1c123ff688.tar.gz
edk2-a121165e35b50a8bfc1253c9be156c1c123ff688.tar.bz2
edk2-a121165e35b50a8bfc1253c9be156c1c123ff688.zip
EmulatorPkg/WinHost: XIP for SEC and PEI_CORE
In EmulatorPkg/Win, SEC and PEI_CORE are loaded to memory allocated through VirtualAlloc. Though the corresponding DLL files are loaded and the entry points in DLL files are executed. The loading to memory allocated through VirtualAlloc is for the case when the DLL files can not be loaded. Actually some PEIMs like PcdPeim which are loaded before "physical" RAM is discovered, they are executing in the original location (FV) like XIP module in real platform. The SEC and PEI_CORE can follow the same mechanism. So, the VirtualAlloc call is removed. This is to prepare the "reset" support to avoid additional OS memory consumption when reset happens. Signed-off-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com> Cc: Andrew Fish <afish@apple.com
Diffstat (limited to 'EmulatorPkg')
-rw-r--r--EmulatorPkg/Win/Host/WinHost.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 5b780ca8af..9b10290ff3 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -718,19 +718,9 @@ SecPeCoffGetEntryPoint (
}
//
- // Allocate space in NT (not emulator) memory with ReadWrite and Execute attribute.
- // Extra space is for alignment
+ // XIP for SEC and PEI_CORE
//
- ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAlloc (NULL, (SIZE_T)(ImageContext.ImageSize + (ImageContext.SectionAlignment * 2)), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- if (ImageContext.ImageAddress == 0) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Align buffer on section boundary
- //
- ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;
- ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 1);
+ ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Pe32Data;
Status = PeCoffLoaderLoadImage (&ImageContext);
if (EFI_ERROR (Status)) {