MdeModulePkg/DxeCore: switch to MdePkg allocation granularity macros

Remove the local definitions for the default and runtime page allocation
granularity macros, and switch to the new MdePkg versions.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Ard Biesheuvel 2017-03-03 15:11:32 +00:00
parent 08855193ca
commit d4731a98a3
6 changed files with 22 additions and 47 deletions

View File

@ -123,31 +123,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/// ///
#define DEPEX_STACK_SIZE_INCREMENT 0x1000 #define DEPEX_STACK_SIZE_INCREMENT 0x1000
#if defined (MDE_CPU_IPF)
///
/// For Itanium machines make the default allocations 8K aligned
///
#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)
#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)
#elif defined (MDE_CPU_AARCH64)
///
/// 64-bit ARM systems allow the OS to execute with 64 KB page size,
/// so for improved interoperability with the firmware, align the
/// runtime regions to 64 KB as well
///
#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (SIZE_64KB)
#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
#else
///
/// For generic EFI machines make the default allocations 4K aligned
///
#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
#endif
typedef struct { typedef struct {
EFI_GUID *ProtocolGuid; EFI_GUID *ProtocolGuid;
VOID **Protocol; VOID **Protocol;

View File

@ -15,8 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "DxeMain.h" #include "DxeMain.h"
#include "Imem.h" #include "Imem.h"
#define EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
// //
// Entry for tracking the memory regions for each memory type to coalesce similar memory types // Entry for tracking the memory regions for each memory type to coalesce similar memory types
// //
@ -287,12 +285,14 @@ AllocateMemoryMapEntry (
// //
// The list is empty, to allocate one page to refuel the list // The list is empty, to allocate one page to refuel the list
// //
FreeDescriptorEntries = CoreAllocatePoolPages (EfiBootServicesData, EFI_SIZE_TO_PAGES(DEFAULT_PAGE_ALLOCATION), DEFAULT_PAGE_ALLOCATION); FreeDescriptorEntries = CoreAllocatePoolPages (EfiBootServicesData,
if(FreeDescriptorEntries != NULL) { EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION_GRANULARITY),
DEFAULT_PAGE_ALLOCATION_GRANULARITY);
if (FreeDescriptorEntries != NULL) {
// //
// Enque the free memmory map entries into the list // Enque the free memmory map entries into the list
// //
for (Index = 0; Index< DEFAULT_PAGE_ALLOCATION / sizeof(MEMORY_MAP); Index++) { for (Index = 0; Index < DEFAULT_PAGE_ALLOCATION_GRANULARITY / sizeof(MEMORY_MAP); Index++) {
FreeDescriptorEntries[Index].Signature = MEMORY_MAP_SIGNATURE; FreeDescriptorEntries[Index].Signature = MEMORY_MAP_SIGNATURE;
InsertTailList (&mFreeMemoryMapEntryList, &FreeDescriptorEntries[Index].Link); InsertTailList (&mFreeMemoryMapEntryList, &FreeDescriptorEntries[Index].Link);
} }
@ -1222,14 +1222,14 @@ CoreInternalAllocatePages (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Alignment = EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT; Alignment = DEFAULT_PAGE_ALLOCATION_GRANULARITY;
if (MemoryType == EfiACPIReclaimMemory || if (MemoryType == EfiACPIReclaimMemory ||
MemoryType == EfiACPIMemoryNVS || MemoryType == EfiACPIMemoryNVS ||
MemoryType == EfiRuntimeServicesCode || MemoryType == EfiRuntimeServicesCode ||
MemoryType == EfiRuntimeServicesData) { MemoryType == EfiRuntimeServicesData) {
Alignment = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; Alignment = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
} }
if (Type == AllocateAddress) { if (Type == AllocateAddress) {
@ -1398,7 +1398,7 @@ CoreInternalFreePages (
goto Done; goto Done;
} }
Alignment = EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT; Alignment = DEFAULT_PAGE_ALLOCATION_GRANULARITY;
ASSERT (Entry != NULL); ASSERT (Entry != NULL);
if (Entry->Type == EfiACPIReclaimMemory || if (Entry->Type == EfiACPIReclaimMemory ||
@ -1406,7 +1406,7 @@ CoreInternalFreePages (
Entry->Type == EfiRuntimeServicesCode || Entry->Type == EfiRuntimeServicesCode ||
Entry->Type == EfiRuntimeServicesData) { Entry->Type == EfiRuntimeServicesData) {
Alignment = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; Alignment = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
} }
@ -1925,12 +1925,12 @@ CoreTerminateMemoryMap (
if (mMemoryTypeStatistics[Entry->Type].Runtime) { if (mMemoryTypeStatistics[Entry->Type].Runtime) {
ASSERT (Entry->Type != EfiACPIReclaimMemory); ASSERT (Entry->Type != EfiACPIReclaimMemory);
ASSERT (Entry->Type != EfiACPIMemoryNVS); ASSERT (Entry->Type != EfiACPIMemoryNVS);
if ((Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) { if ((Entry->Start & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {
DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n")); DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
if (((Entry->End + 1) & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) { if (((Entry->End + 1) & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {
DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n")); DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;

View File

@ -352,9 +352,9 @@ CoreAllocatePoolI (
PoolType == EfiRuntimeServicesCode || PoolType == EfiRuntimeServicesCode ||
PoolType == EfiRuntimeServicesData) { PoolType == EfiRuntimeServicesData) {
Granularity = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; Granularity = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
} else { } else {
Granularity = DEFAULT_PAGE_ALLOCATION; Granularity = DEFAULT_PAGE_ALLOCATION_GRANULARITY;
} }
// //
@ -643,9 +643,9 @@ CoreFreePoolI (
Head->Type == EfiRuntimeServicesCode || Head->Type == EfiRuntimeServicesCode ||
Head->Type == EfiRuntimeServicesData) { Head->Type == EfiRuntimeServicesData) {
Granularity = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; Granularity = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
} else { } else {
Granularity = DEFAULT_PAGE_ALLOCATION; Granularity = DEFAULT_PAGE_ALLOCATION_GRANULARITY;
} }
if (PoolType != NULL) { if (PoolType != NULL) {

View File

@ -104,7 +104,7 @@ InstallMemoryAttributesTable (
if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) { if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {
DEBUG ((EFI_D_VERBOSE, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, ")); DEBUG ((EFI_D_VERBOSE, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, "));
DEBUG ((EFI_D_VERBOSE, "because Runtime Driver Section Alignment is not %dK.\n", EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10)); DEBUG ((EFI_D_VERBOSE, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));
return ; return ;
} }

View File

@ -344,12 +344,12 @@ IsMemoryProtectionSectionAligned (
switch (MemoryType) { switch (MemoryType) {
case EfiRuntimeServicesCode: case EfiRuntimeServicesCode:
case EfiACPIMemoryNVS: case EfiACPIMemoryNVS:
PageAlignment = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; PageAlignment = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
break; break;
case EfiRuntimeServicesData: case EfiRuntimeServicesData:
case EfiACPIReclaimMemory: case EfiACPIReclaimMemory:
ASSERT (FALSE); ASSERT (FALSE);
PageAlignment = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT; PageAlignment = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
break; break;
case EfiBootServicesCode: case EfiBootServicesCode:
case EfiLoaderCode: case EfiLoaderCode:

View File

@ -804,7 +804,7 @@ SetPropertiesTableSectionAlignment (
IN UINT32 SectionAlignment IN UINT32 SectionAlignment
) )
{ {
if (((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) && if (((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) &&
((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) != 0)) { ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) != 0)) {
DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n")); DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n"));
mPropertiesTable.MemoryProtectionAttribute &= ~((UINT64)EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA); mPropertiesTable.MemoryProtectionAttribute &= ~((UINT64)EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA);
@ -1136,9 +1136,9 @@ InsertImageRecord (
} }
SetPropertiesTableSectionAlignment (SectionAlignment); SetPropertiesTableSectionAlignment (SectionAlignment);
if ((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) { if ((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {
DEBUG ((EFI_D_WARN, "!!!!!!!! InsertImageRecord - Section Alignment(0x%x) is not %dK !!!!!!!!\n", DEBUG ((EFI_D_WARN, "!!!!!!!! InsertImageRecord - Section Alignment(0x%x) is not %dK !!!!!!!!\n",
SectionAlignment, EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10)); SectionAlignment, RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));
PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress); PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
if (PdbPointer != NULL) { if (PdbPointer != NULL) {
DEBUG ((EFI_D_WARN, "!!!!!!!! Image - %a !!!!!!!!\n", PdbPointer)); DEBUG ((EFI_D_WARN, "!!!!!!!! Image - %a !!!!!!!!\n", PdbPointer));
@ -1338,7 +1338,7 @@ InstallPropertiesTable (
DEBUG ((EFI_D_INFO, "MemoryProtectionAttribute - 0x%016lx\n", mPropertiesTable.MemoryProtectionAttribute)); DEBUG ((EFI_D_INFO, "MemoryProtectionAttribute - 0x%016lx\n", mPropertiesTable.MemoryProtectionAttribute));
if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) { if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {
DEBUG ((EFI_D_ERROR, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, ")); DEBUG ((EFI_D_ERROR, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, "));
DEBUG ((EFI_D_ERROR, "because Runtime Driver Section Alignment is not %dK.\n", EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10)); DEBUG ((EFI_D_ERROR, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));
return ; return ;
} }