#include "DxeMain.h"\r
#include "Imem.h"\r
\r
-#define EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)\r
-\r
//\r
// Entry for tracking the memory regions for each memory type to coalesce similar memory types\r
//\r
//\r
// The list is empty, to allocate one page to refuel the list\r
//\r
- FreeDescriptorEntries = CoreAllocatePoolPages (EfiBootServicesData, EFI_SIZE_TO_PAGES(DEFAULT_PAGE_ALLOCATION), DEFAULT_PAGE_ALLOCATION);\r
- if(FreeDescriptorEntries != NULL) {\r
+ FreeDescriptorEntries = CoreAllocatePoolPages (EfiBootServicesData,\r
+ EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION_GRANULARITY),\r
+ DEFAULT_PAGE_ALLOCATION_GRANULARITY);\r
+ if (FreeDescriptorEntries != NULL) {\r
//\r
// Enque the free memmory map entries into the list\r
//\r
- for (Index = 0; Index< DEFAULT_PAGE_ALLOCATION / sizeof(MEMORY_MAP); Index++) {\r
+ for (Index = 0; Index < DEFAULT_PAGE_ALLOCATION_GRANULARITY / sizeof(MEMORY_MAP); Index++) {\r
FreeDescriptorEntries[Index].Signature = MEMORY_MAP_SIGNATURE;\r
InsertTailList (&mFreeMemoryMapEntryList, &FreeDescriptorEntries[Index].Link);\r
}\r
return EFI_NOT_FOUND;\r
}\r
\r
+ //\r
+ // If we are converting the type of the range from EfiConventionalMemory to\r
+ // another type, we have to ensure that the entire range is covered by a\r
+ // single entry.\r
+ //\r
+ if (ChangingType && (NewType != EfiConventionalMemory)) {\r
+ if (Entry->End < End) {\r
+ DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: range %lx - %lx covers multiple entries\n", Start, End));\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ }\r
//\r
// Convert range to the end, or to the end of the descriptor\r
// if that's all we've got\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Alignment = EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT;\r
+ Alignment = DEFAULT_PAGE_ALLOCATION_GRANULARITY;\r
\r
if (MemoryType == EfiACPIReclaimMemory ||\r
MemoryType == EfiACPIMemoryNVS ||\r
MemoryType == EfiRuntimeServicesCode ||\r
MemoryType == EfiRuntimeServicesData) {\r
\r
- Alignment = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT;\r
+ Alignment = RUNTIME_PAGE_ALLOCATION_GRANULARITY;\r
}\r
\r
if (Type == AllocateAddress) {\r
goto Done;\r
}\r
\r
- Alignment = EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT;\r
+ Alignment = DEFAULT_PAGE_ALLOCATION_GRANULARITY;\r
\r
ASSERT (Entry != NULL);\r
if (Entry->Type == EfiACPIReclaimMemory ||\r
Entry->Type == EfiRuntimeServicesCode ||\r
Entry->Type == EfiRuntimeServicesData) {\r
\r
- Alignment = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT;\r
+ Alignment = RUNTIME_PAGE_ALLOCATION_GRANULARITY;\r
\r
}\r
\r
if (mMemoryTypeStatistics[Entry->Type].Runtime) {\r
ASSERT (Entry->Type != EfiACPIReclaimMemory);\r
ASSERT (Entry->Type != EfiACPIMemoryNVS);\r
- if ((Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) {\r
+ if ((Entry->Start & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {\r
DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
- if (((Entry->End + 1) & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) {\r
+ if (((Entry->End + 1) & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {\r
DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r