]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Mem/Page.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / Page.c
index 8d5d03a6d90a8d13e5c520dfcd5f18e1a3ddd5e2..3b4cc08e7cec9d60454540443635994440fd26d4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Memory page management functions.\r
 \r
-Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2018, 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
@@ -93,7 +93,7 @@ EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = {
 };\r
 //\r
 // Only used when load module at fixed address feature is enabled. True means the memory is alreay successfully allocated\r
-// and ready to load the module in to specified address.or else, the memory is not ready and module will be loaded at a \r
+// and ready to load the module in to specified address.or else, the memory is not ready and module will be loaded at a\r
 //  address assigned by DXE core.\r
 //\r
 GLOBAL_REMOVE_IF_UNREFERENCED   BOOLEAN       gLoadFixedAddressCodeMemoryReady = FALSE;\r
@@ -178,22 +178,22 @@ CoreAddRange (
   ASSERT_LOCKED (&gMemoryLock);\r
 \r
   DEBUG ((DEBUG_PAGE, "AddRange: %lx-%lx to %d\n", Start, End, Type));\r
-  \r
-  //\r
-  // If memory of type EfiConventionalMemory is being added that includes the page \r
-  // starting at address 0, then zero the page starting at address 0.  This has \r
-  // two benifits.  It helps find NULL pointer bugs and it also maximizes \r
-  // compatibility with operating systems that may evaluate memory in this page \r
-  // for legacy data structures.  If memory of any other type is added starting \r
-  // at address 0, then do not zero the page at address 0 because the page is being \r
+\r
+  //\r
+  // If memory of type EfiConventionalMemory is being added that includes the page\r
+  // starting at address 0, then zero the page starting at address 0.  This has\r
+  // two benifits.  It helps find NULL pointer bugs and it also maximizes\r
+  // compatibility with operating systems that may evaluate memory in this page\r
+  // for legacy data structures.  If memory of any other type is added starting\r
+  // at address 0, then do not zero the page at address 0 because the page is being\r
   // used for other purposes.\r
-  //  \r
+  //\r
   if (Type == EfiConventionalMemory && Start == 0 && (End >= EFI_PAGE_SIZE - 1)) {\r
     if ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT0) == 0) {\r
       SetMem ((VOID *)(UINTN)Start, EFI_PAGE_SIZE, 0);\r
     }\r
   }\r
-  \r
+\r
   //\r
   // Memory map being altered so updated key\r
   //\r
@@ -454,8 +454,8 @@ PromoteMemoryResource (
   return Promoted;\r
 }\r
 /**\r
-  This function try to allocate Runtime code & Boot time code memory range. If LMFA enabled, 2 patchable PCD \r
-  PcdLoadFixAddressRuntimeCodePageNumber & PcdLoadFixAddressBootTimeCodePageNumber which are set by tools will record the \r
+  This function try to allocate Runtime code & Boot time code memory range. If LMFA enabled, 2 patchable PCD\r
+  PcdLoadFixAddressRuntimeCodePageNumber & PcdLoadFixAddressBootTimeCodePageNumber which are set by tools will record the\r
   size of boot time and runtime code.\r
 \r
 **/\r
@@ -473,7 +473,7 @@ CoreLoadingFixedAddressHook (
    //\r
    // Make sure these 2 areas are not initialzied.\r
    //\r
-   if (!gLoadFixedAddressCodeMemoryReady) {   \r
+   if (!gLoadFixedAddressCodeMemoryReady) {\r
      RuntimeCodePageNumber = PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber);\r
      BootTimeCodePageNumber= PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber);\r
      RuntimeCodeBase       = (EFI_PHYSICAL_ADDRESS)(gLoadModuleAtFixAddressConfigurationTable.DxeCodeTopAddress - EFI_PAGES_TO_SIZE (RuntimeCodePageNumber));\r
@@ -489,7 +489,7 @@ CoreLoadingFixedAddressHook (
                        );\r
      if (EFI_ERROR(Status)) {\r
        //\r
-       // Runtime memory allocation failed \r
+       // Runtime memory allocation failed\r
        //\r
        return;\r
      }\r
@@ -504,19 +504,19 @@ CoreLoadingFixedAddressHook (
                        );\r
      if (EFI_ERROR(Status)) {\r
        //\r
-        // boot memory allocation failed. Free Runtime code range and will try the allocation again when \r
-        // new memory range is installed.\r
-        //\r
-        CoreFreePages (\r
+        // boot memory allocation failed. Free Runtime code range and will try the allocation again when\r
+        // new memory range is installed.\r
+        //\r
+        CoreFreePages (\r
               RuntimeCodeBase,\r
               RuntimeCodePageNumber\r
               );\r
        return;\r
      }\r
      gLoadFixedAddressCodeMemoryReady = TRUE;\r
-   } \r
+   }\r
    return;\r
-}  \r
+}\r
 \r
 /**\r
   Called to initialize the memory map and add descriptors to\r
@@ -545,7 +545,7 @@ CoreAddMemoryDescriptor (
   EFI_STATUS                  Status;\r
   UINTN                       Index;\r
   UINTN                       FreeIndex;\r
-  \r
+\r
   if ((Start & EFI_PAGE_MASK) != 0) {\r
     return;\r
   }\r
@@ -568,7 +568,7 @@ CoreAddMemoryDescriptor (
   if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {\r
     CoreLoadingFixedAddressHook();\r
   }\r
-  \r
+\r
   //\r
   // Check to see if the statistics for the different memory types have already been established\r
   //\r
@@ -576,7 +576,7 @@ CoreAddMemoryDescriptor (
     return;\r
   }\r
 \r
-  \r
+\r
   //\r
   // Loop through each memory type in the order specified by the gMemoryTypeInformation[] array\r
   //\r
@@ -1163,10 +1163,10 @@ FindFreePages (
   //\r
   if ((UINT32)NewType < EfiMaxMemoryType && MaxAddress >= mMemoryTypeStatistics[NewType].MaximumAddress) {\r
     Start = CoreFindFreePagesI (\r
-              mMemoryTypeStatistics[NewType].MaximumAddress, \r
-              mMemoryTypeStatistics[NewType].BaseAddress, \r
-              NoPages, \r
-              NewType, \r
+              mMemoryTypeStatistics[NewType].MaximumAddress,\r
+              mMemoryTypeStatistics[NewType].BaseAddress,\r
+              NoPages,\r
+              NewType,\r
               Alignment,\r
               NeedGuard\r
               );\r
@@ -1190,9 +1190,9 @@ FindFreePages (
   }\r
 \r
   //\r
-  // The allocation did not succeed in any of the prefered bins even after \r
-  // promoting resources. Attempt to find free pages anywhere is the requested \r
-  // address range.  If this allocation fails, then there are not enough \r
+  // The allocation did not succeed in any of the prefered bins even after\r
+  // promoting resources. Attempt to find free pages anywhere is the requested\r
+  // address range.  If this allocation fails, then there are not enough\r
   // resources anywhere to satisfy the request.\r
   //\r
   Start = CoreFindFreePagesI (MaxAddress, 0, NoPages, NewType, Alignment,\r
@@ -1311,7 +1311,7 @@ CoreInternalAllocatePages (
     End = Start + NumberOfBytes - 1;\r
 \r
     if ((Start >= End) ||\r
-        (Start > MaxAddress) || \r
+        (Start > MaxAddress) ||\r
         (End > MaxAddress)) {\r
       return EFI_NOT_FOUND;\r
     }\r
@@ -1571,7 +1571,7 @@ MergeMemoryMapDescriptor (
     //\r
     // Check to see if MemoryMapDescriptor is immediately above MemoryMap\r
     //\r
-    if (MemoryMap->PhysicalStart + EFI_PAGES_TO_SIZE ((UINTN)MemoryMap->NumberOfPages) == MemoryMapDescriptor->PhysicalStart) { \r
+    if (MemoryMap->PhysicalStart + EFI_PAGES_TO_SIZE ((UINTN)MemoryMap->NumberOfPages) == MemoryMapDescriptor->PhysicalStart) {\r
       //\r
       // Merge MemoryMapDescriptor into MemoryMap\r
       //\r
@@ -1604,7 +1604,7 @@ MergeMemoryMapDescriptor (
   //\r
   // MemoryMapDescrtiptor could not be merged with any descriptors in MemoryMap.\r
   //\r
-  // Return the slot immediately after MemoryMapDescriptor as the next available \r
+  // Return the slot immediately after MemoryMapDescriptor as the next available\r
   // slot in the MemoryMap array\r
   //\r
   return NEXT_MEMORY_DESCRIPTOR (MemoryMapDescriptor, DescriptorSize);\r
@@ -1678,7 +1678,7 @@ CoreGetMemoryMap (
   NumberOfEntries = 0;\r
   for (Link = mGcdMemorySpaceMap.ForwardLink; Link != &mGcdMemorySpaceMap; Link = Link->ForwardLink) {\r
     GcdMapEntry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);\r
-    if ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypePersistent) || \r
+    if ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypePersistent) ||\r
         (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) ||\r
         ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) &&\r
         ((GcdMapEntry->Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME))) {\r
@@ -1764,13 +1764,13 @@ CoreGetMemoryMap (
     }\r
 \r
     //\r
-    // Check to see if the new Memory Map Descriptor can be merged with an \r
+    // Check to see if the new Memory Map Descriptor can be merged with an\r
     // existing descriptor if they are adjacent and have the same attributes\r
     //\r
     MemoryMap = MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, Size);\r
   }\r
 \r
\r
+\r
   ZeroMem (&MergeGcdMapEntry, sizeof (MergeGcdMapEntry));\r
   GcdMapEntry = NULL;\r
   for (Link = mGcdMemorySpaceMap.ForwardLink; ; Link = Link->ForwardLink) {\r
@@ -1779,8 +1779,8 @@ CoreGetMemoryMap (
       // Merge adjacent same type and attribute GCD memory range\r
       //\r
       GcdMapEntry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);\r
-  \r
-      if ((MergeGcdMapEntry.Capabilities == GcdMapEntry->Capabilities) && \r
+\r
+      if ((MergeGcdMapEntry.Capabilities == GcdMapEntry->Capabilities) &&\r
           (MergeGcdMapEntry.Attributes == GcdMapEntry->Attributes) &&\r
           (MergeGcdMapEntry.GcdMemoryType == GcdMapEntry->GcdMemoryType) &&\r
           (MergeGcdMapEntry.GcdIoType == GcdMapEntry->GcdIoType)) {\r
@@ -1793,19 +1793,19 @@ CoreGetMemoryMap (
         ((MergeGcdMapEntry.GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) &&\r
         ((MergeGcdMapEntry.Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME))) {\r
       //\r
-      // Page Align GCD range is required. When it is converted to EFI_MEMORY_DESCRIPTOR, \r
-      // it will be recorded as page PhysicalStart and NumberOfPages. \r
+      // Page Align GCD range is required. When it is converted to EFI_MEMORY_DESCRIPTOR,\r
+      // it will be recorded as page PhysicalStart and NumberOfPages.\r
       //\r
       ASSERT ((MergeGcdMapEntry.BaseAddress & EFI_PAGE_MASK) == 0);\r
       ASSERT (((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress + 1) & EFI_PAGE_MASK) == 0);\r
-      \r
-      // \r
+\r
+      //\r
       // Create EFI_MEMORY_DESCRIPTOR for every Reserved and runtime MMIO GCD entries\r
       //\r
       MemoryMap->PhysicalStart = MergeGcdMapEntry.BaseAddress;\r
       MemoryMap->VirtualStart  = 0;\r
       MemoryMap->NumberOfPages = RShiftU64 ((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress + 1), EFI_PAGE_SHIFT);\r
-      MemoryMap->Attribute     = (MergeGcdMapEntry.Attributes & ~EFI_MEMORY_PORT_IO) | \r
+      MemoryMap->Attribute     = (MergeGcdMapEntry.Attributes & ~EFI_MEMORY_PORT_IO) |\r
                                 (MergeGcdMapEntry.Capabilities & (EFI_MEMORY_RP | EFI_MEMORY_WP | EFI_MEMORY_XP | EFI_MEMORY_RO |\r
                                 EFI_MEMORY_UC | EFI_MEMORY_UCE | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB));\r
 \r
@@ -1820,33 +1820,33 @@ CoreGetMemoryMap (
       }\r
 \r
       //\r
-      // Check to see if the new Memory Map Descriptor can be merged with an \r
+      // Check to see if the new Memory Map Descriptor can be merged with an\r
       // existing descriptor if they are adjacent and have the same attributes\r
       //\r
       MemoryMap = MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, Size);\r
     }\r
-    \r
+\r
     if (MergeGcdMapEntry.GcdMemoryType == EfiGcdMemoryTypePersistent) {\r
       //\r
-      // Page Align GCD range is required. When it is converted to EFI_MEMORY_DESCRIPTOR, \r
-      // it will be recorded as page PhysicalStart and NumberOfPages. \r
+      // Page Align GCD range is required. When it is converted to EFI_MEMORY_DESCRIPTOR,\r
+      // it will be recorded as page PhysicalStart and NumberOfPages.\r
       //\r
       ASSERT ((MergeGcdMapEntry.BaseAddress & EFI_PAGE_MASK) == 0);\r
       ASSERT (((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress + 1) & EFI_PAGE_MASK) == 0);\r
 \r
-      // \r
+      //\r
       // Create EFI_MEMORY_DESCRIPTOR for every Persistent GCD entries\r
       //\r
       MemoryMap->PhysicalStart = MergeGcdMapEntry.BaseAddress;\r
       MemoryMap->VirtualStart  = 0;\r
       MemoryMap->NumberOfPages = RShiftU64 ((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress + 1), EFI_PAGE_SHIFT);\r
-      MemoryMap->Attribute     = MergeGcdMapEntry.Attributes | EFI_MEMORY_NV | \r
+      MemoryMap->Attribute     = MergeGcdMapEntry.Attributes | EFI_MEMORY_NV |\r
                                 (MergeGcdMapEntry.Capabilities & (EFI_MEMORY_RP | EFI_MEMORY_WP | EFI_MEMORY_XP | EFI_MEMORY_RO |\r
                                 EFI_MEMORY_UC | EFI_MEMORY_UCE | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB));\r
       MemoryMap->Type          = EfiPersistentMemory;\r
-      \r
+\r
       //\r
-      // Check to see if the new Memory Map Descriptor can be merged with an \r
+      // Check to see if the new Memory Map Descriptor can be merged with an\r
       // existing descriptor if they are adjacent and have the same attributes\r
       //\r
       MemoryMap = MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, Size);\r