diff options
author | Ard Biesheuvel <ard.biesheuvel@arm.com> | 2020-10-16 16:58:01 +0200 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2020-10-30 14:50:33 +0000 |
commit | 8ead7af22bc596de23cdcc46e1f1a8c4e721d6d0 (patch) | |
tree | 1c4fa70b51ce8db9f065f5244e065d9d8667bbd1 /MdeModulePkg/Universal/Acpi | |
parent | cf299745ae66fb56326b386fd6eb6501e4ed33ec (diff) | |
download | edk2-8ead7af22bc596de23cdcc46e1f1a8c4e721d6d0.tar.gz edk2-8ead7af22bc596de23cdcc46e1f1a8c4e721d6d0.tar.bz2 edk2-8ead7af22bc596de23cdcc46e1f1a8c4e721d6d0.zip |
MdeModulePkg/AcpiTableDxe: use pool allocation for RSDP if possible
Use a pool allocation for the RSDP ACPI root pointer structure if no
memory limit is in effect that forces us to use page based allocation,
which may be wasteful if they get rounded up to 64 KB as is the case
on AArch64.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'MdeModulePkg/Universal/Acpi')
-rw-r--r-- | MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c index ae446270fa..5a2afdff27 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c @@ -1745,19 +1745,29 @@ AcpiTableAcpiTableConstructor ( RsdpTableSize += sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER);
}
- PageAddress = 0xFFFFFFFF;
- Status = gBS->AllocatePages (
- mAcpiTableAllocType,
- EfiACPIReclaimMemory,
- EFI_SIZE_TO_PAGES (RsdpTableSize),
- &PageAddress
- );
+ if (mAcpiTableAllocType != AllocateAnyPages) {
+ PageAddress = 0xFFFFFFFF;
+ Status = gBS->AllocatePages (
+ mAcpiTableAllocType,
+ EfiACPIReclaimMemory,
+ EFI_SIZE_TO_PAGES (RsdpTableSize),
+ &PageAddress
+ );
+ } else {
+ Status = gBS->AllocatePool (
+ EfiACPIReclaimMemory,
+ RsdpTableSize,
+ (VOID **)&Pointer
+ );
+ }
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
- Pointer = (UINT8 *) (UINTN) PageAddress;
+ if (mAcpiTableAllocType != AllocateAnyPages) {
+ Pointer = (UINT8 *)(UINTN)PageAddress;
+ }
ZeroMem (Pointer, RsdpTableSize);
AcpiTableInstance->Rsdp1 = (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) Pointer;
@@ -1805,7 +1815,12 @@ AcpiTableAcpiTableConstructor ( }
if (EFI_ERROR (Status)) {
- gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)AcpiTableInstance->Rsdp1, EFI_SIZE_TO_PAGES (RsdpTableSize));
+ if (mAcpiTableAllocType != AllocateAnyPages) {
+ gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)AcpiTableInstance->Rsdp1,
+ EFI_SIZE_TO_PAGES (RsdpTableSize));
+ } else {
+ gBS->FreePool (AcpiTableInstance->Rsdp1);
+ }
return EFI_OUT_OF_RESOURCES;
}
|