diff options
author | Aaron Li <aaron.li@intel.com> | 2024-03-26 15:57:33 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-04-09 07:03:08 +0000 |
commit | 932db9df0caa26daca4edf133fb2aed7b4a9193e (patch) | |
tree | b238909ec78271f2e3426374685f147789e68c1c /MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | |
parent | b7f8779fe1f60113fdaab3b2f3f17c9f900b0456 (diff) | |
download | edk2-932db9df0caa26daca4edf133fb2aed7b4a9193e.tar.gz edk2-932db9df0caa26daca4edf133fb2aed7b4a9193e.tar.bz2 edk2-932db9df0caa26daca4edf133fb2aed7b4a9193e.zip |
MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory
UEFI spec defined ACPI Tables at boot time can be contained in memory of
type EfiACPIReclaimMemory or EfiAcpiMemoryNVS, although InstallAcpiTable
with AcpiTableProtocol will only allocate memory with type
EfiACPIReclaimMemory (Except FACS).
This patch provides an optional method controlled by PCD to avoid using
EfiACPIReclaimMemory, by setting the PCD PcdNoACPIReclaimMemory to TRUE,
all ACPI allocated memory will use EfiAcpiMemoryNVS instead.
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Liu Yun <yun.y.liu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Aaron Li <aaron.li@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c')
-rw-r--r-- | MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c index e09bc9b704..080768033c 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c @@ -340,6 +340,7 @@ ReallocateAcpiTableBuffer ( EFI_ACPI_TABLE_INSTANCE TempPrivateData;
EFI_STATUS Status;
UINT64 CurrentData;
+ EFI_MEMORY_TYPE AcpiAllocateMemoryType;
CopyMem (&TempPrivateData, AcpiTableInstance, sizeof (EFI_ACPI_TABLE_INSTANCE));
//
@@ -359,6 +360,12 @@ ReallocateAcpiTableBuffer ( NewMaxTableNumber * sizeof (UINT32);
}
+ if (PcdGetBool (PcdNoACPIReclaimMemory)) {
+ AcpiAllocateMemoryType = EfiACPIMemoryNVS;
+ } else {
+ AcpiAllocateMemoryType = EfiACPIReclaimMemory;
+ }
+
if (mAcpiTableAllocType != AllocateAnyPages) {
//
// Allocate memory in the lower 32 bit of address range for
@@ -372,13 +379,13 @@ ReallocateAcpiTableBuffer ( PageAddress = 0xFFFFFFFF;
Status = gBS->AllocatePages (
mAcpiTableAllocType,
- EfiACPIReclaimMemory,
+ AcpiAllocateMemoryType,
EFI_SIZE_TO_PAGES (TotalSize),
&PageAddress
);
} else {
Status = gBS->AllocatePool (
- EfiACPIReclaimMemory,
+ AcpiAllocateMemoryType,
TotalSize,
(VOID **)&Pointer
);
@@ -512,6 +519,7 @@ AddTableToList ( EFI_PHYSICAL_ADDRESS AllocPhysAddress;
UINT64 Buffer64;
BOOLEAN AddToRsdt;
+ EFI_MEMORY_TYPE AcpiAllocateMemoryType;
//
// Check for invalid input parameters
@@ -550,6 +558,12 @@ AddTableToList ( CurrentTableList->TableSize = CurrentTableSize;
CurrentTableList->PoolAllocation = FALSE;
+ if (PcdGetBool (PcdNoACPIReclaimMemory)) {
+ AcpiAllocateMemoryType = EfiACPIMemoryNVS;
+ } else {
+ AcpiAllocateMemoryType = EfiACPIReclaimMemory;
+ }
+
//
// Allocation memory type depends on the type of the table
//
@@ -585,7 +599,7 @@ AddTableToList ( // such as AArch64 that allocate multiples of 64 KB
//
Status = gBS->AllocatePool (
- EfiACPIReclaimMemory,
+ AcpiAllocateMemoryType,
CurrentTableList->TableSize,
(VOID **)&CurrentTableList->Table
);
@@ -596,7 +610,7 @@ AddTableToList ( //
Status = gBS->AllocatePages (
mAcpiTableAllocType,
- EfiACPIReclaimMemory,
+ AcpiAllocateMemoryType,
EFI_SIZE_TO_PAGES (CurrentTableList->TableSize),
&AllocPhysAddress
);
@@ -1944,6 +1958,7 @@ AcpiTableAcpiTableConstructor ( UINTN RsdpTableSize;
UINT8 *Pointer;
EFI_PHYSICAL_ADDRESS PageAddress;
+ EFI_MEMORY_TYPE AcpiAllocateMemoryType;
//
// Check for invalid input parameters
@@ -1978,17 +1993,23 @@ AcpiTableAcpiTableConstructor ( RsdpTableSize += sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER);
}
+ if (PcdGetBool (PcdNoACPIReclaimMemory)) {
+ AcpiAllocateMemoryType = EfiACPIMemoryNVS;
+ } else {
+ AcpiAllocateMemoryType = EfiACPIReclaimMemory;
+ }
+
if (mAcpiTableAllocType != AllocateAnyPages) {
PageAddress = 0xFFFFFFFF;
Status = gBS->AllocatePages (
mAcpiTableAllocType,
- EfiACPIReclaimMemory,
+ AcpiAllocateMemoryType,
EFI_SIZE_TO_PAGES (RsdpTableSize),
&PageAddress
);
} else {
Status = gBS->AllocatePool (
- EfiACPIReclaimMemory,
+ AcpiAllocateMemoryType,
RsdpTableSize,
(VOID **)&Pointer
);
@@ -2037,13 +2058,13 @@ AcpiTableAcpiTableConstructor ( PageAddress = 0xFFFFFFFF;
Status = gBS->AllocatePages (
mAcpiTableAllocType,
- EfiACPIReclaimMemory,
+ AcpiAllocateMemoryType,
EFI_SIZE_TO_PAGES (TotalSize),
&PageAddress
);
} else {
Status = gBS->AllocatePool (
- EfiACPIReclaimMemory,
+ AcpiAllocateMemoryType,
TotalSize,
(VOID **)&Pointer
);
|