diff options
author | Ni, Ray <ray.ni@intel.com> | 2022-11-12 12:00:40 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-12-05 05:35:41 +0000 |
commit | d2842bb6ec3e7fa691318c31e71e88b9a9eca545 (patch) | |
tree | 3d15a86110dfd9edf6c7222314bddc6b39be64e6 /EmulatorPkg | |
parent | 735a7496cb35e48ccad51aad0934844a475e3fef (diff) | |
download | edk2-d2842bb6ec3e7fa691318c31e71e88b9a9eca545.tar.gz edk2-d2842bb6ec3e7fa691318c31e71e88b9a9eca545.tar.bz2 edk2-d2842bb6ec3e7fa691318c31e71e88b9a9eca545.zip |
EmulatorPkg/WinHost: pre-allocate "physical" RAM
Move the "physical" RAM allocation from WinPeiAutoScan
to main() entrypoint.
This is to prepare the changes for "reset" support.
Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Diffstat (limited to 'EmulatorPkg')
-rw-r--r-- | EmulatorPkg/Win/Host/WinHost.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index 93247c5043..5b780ca8af 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -8,7 +8,7 @@ This code produces 128 K of temporary memory for the SEC stack by directly
allocate memory space with ReadWrite and Execute attribute.
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016-2020 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -87,14 +87,6 @@ WinPeiAutoScan ( return EFI_UNSUPPORTED;
}
- //
- // Allocate enough memory space for emulator
- //
- gSystemMemory[Index].Memory = (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAlloc (NULL, (SIZE_T)(gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- if (gSystemMemory[Index].Memory == 0) {
- return EFI_OUT_OF_RESOURCES;
- }
-
*MemoryBase = gSystemMemory[Index].Memory;
*MemorySize = gSystemMemory[Index].Size;
@@ -458,6 +450,30 @@ Returns: }
//
+ // Allocate "physical" memory space for emulator. It will be reported out later throuth MemoryAutoScan()
+ //
+ for (Index = 0, Done = FALSE; !Done; Index++) {
+ ASSERT (Index < gSystemMemoryCount);
+ gSystemMemory[Index].Size = ((UINT64)_wtoi (MemorySizeStr)) * ((UINT64)SIZE_1MB);
+ gSystemMemory[Index].Memory = (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAlloc (NULL, (SIZE_T)(gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ if (gSystemMemory[Index].Memory == 0) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Find the next region
+ //
+ for (Index1 = 0; MemorySizeStr[Index1] != '!' && MemorySizeStr[Index1] != 0; Index1++) {
+ }
+
+ if (MemorySizeStr[Index1] == 0) {
+ Done = TRUE;
+ }
+
+ MemorySizeStr = MemorySizeStr + Index1 + 1;
+ }
+
+ //
// Allocate space for gSystemMemory Array
//
gFdInfoCount = CountSeparatorsInString (FirmwareVolumesStr, '!') + 1;
@@ -576,32 +592,6 @@ Returns: }
//
- // Calculate memory regions and store the information in the gSystemMemory
- // global for later use. The autosizing code will use this data to
- // map this memory into the SEC process memory space.
- //
- for (Index = 0, Done = FALSE; !Done; Index++) {
- //
- // Save the size of the memory and make a Unicode filename SystemMemory00, ...
- //
- gSystemMemory[Index].Size = ((UINT64)_wtoi (MemorySizeStr)) * ((UINT64)SIZE_1MB);
-
- //
- // Find the next region
- //
- for (Index1 = 0; MemorySizeStr[Index1] != '!' && MemorySizeStr[Index1] != 0; Index1++) {
- }
-
- if (MemorySizeStr[Index1] == 0) {
- Done = TRUE;
- }
-
- MemorySizeStr = MemorySizeStr + Index1 + 1;
- }
-
- SecPrint ("\n\r");
-
- //
// Hand off to SEC Core
//
SecLoadSecCore ((UINTN)TemporaryRam, TemporaryRamSize, gFdInfo[0].Address, gFdInfo[0].Size, SecFile);
|