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>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
---
EmulatorPkg/Win/Host/WinHost.c | 60 ++++++++++++++--------------------
1 file 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;
@@ -457,6 +449,30 @@ Returns:
exit (1);
}
+ //
+ // 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
//
@@ -575,32 +591,6 @@ Returns:
SecPrint ("\n\r");
}
- //
- // 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
//
--
2.37.2.windows.2
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96320): https://edk2.groups.io/g/devel/message/96320
Mute This Topic: https://groups.io/mt/94974520/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2026 Red Hat, Inc.