/** @file\r
UEFI Memory page management functions.\r
\r
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
@param NumberOfPages The number of pages to convert\r
@param NewAttributes The new attributes value for the range.\r
\r
- @retval EFI_INVALID_PARAMETER Invalid parameter\r
- @retval EFI_NOT_FOUND Could not find a descriptor cover the specified\r
- range or convertion not allowed.\r
- @retval EFI_SUCCESS Successfully converts the memory range to the\r
- specified attributes.\r
-\r
**/\r
VOID\r
CoreUpdateMemoryAttributes (\r
)\r
{\r
EFI_STATUS Status;\r
-
- Status = CoreInternalFreePages (Memory, NumberOfPages);
- if (!EFI_ERROR (Status)) {
- CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePages, (EFI_MEMORY_TYPE) 0, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) Memory);
- }
- return Status;
-}
+\r
+ Status = CoreInternalFreePages (Memory, NumberOfPages);\r
+ if (!EFI_ERROR (Status)) {\r
+ CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePages, (EFI_MEMORY_TYPE) 0, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) Memory);\r
+ }\r
+ return Status;\r
+}\r
\r
/**\r
This function checks to see if the last memory map descriptor in a memory map\r
\r
for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {\r
Entry = CR(Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);\r
- if ((Entry->Attribute & EFI_MEMORY_RUNTIME) != 0) {\r
- if (Entry->Type == EfiACPIReclaimMemory || Entry->Type == EfiACPIMemoryNVS) {\r
- DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: ACPI memory entry has RUNTIME attribute set.\n"));\r
- Status = EFI_INVALID_PARAMETER;\r
- goto Done;\r
- }\r
- if ((Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 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
- 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
+ if (Entry->Type < EfiMaxMemoryType) {\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
+ 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
+ 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
}\r
}\r
}\r