mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-22 21:24:35 +02:00
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>
This commit is contained in:
parent
735a7496cb
commit
d2842bb6ec
@ -8,7 +8,7 @@
|
|||||||
This code produces 128 K of temporary memory for the SEC stack by directly
|
This code produces 128 K of temporary memory for the SEC stack by directly
|
||||||
allocate memory space with ReadWrite and Execute attribute.
|
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>
|
(C) Copyright 2016-2020 Hewlett Packard Enterprise Development LP<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
**/
|
**/
|
||||||
@ -87,14 +87,6 @@ WinPeiAutoScan (
|
|||||||
return EFI_UNSUPPORTED;
|
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;
|
*MemoryBase = gSystemMemory[Index].Memory;
|
||||||
*MemorySize = gSystemMemory[Index].Size;
|
*MemorySize = gSystemMemory[Index].Size;
|
||||||
|
|
||||||
@ -457,6 +449,30 @@ Returns:
|
|||||||
exit (1);
|
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
|
// Allocate space for gSystemMemory Array
|
||||||
//
|
//
|
||||||
@ -575,32 +591,6 @@ Returns:
|
|||||||
SecPrint ("\n\r");
|
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
|
// Hand off to SEC Core
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user