]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Mem/Page.c
Code Scrub for Dxe Core.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / Page.c
index 2bf457267a99b8e338a7cb5491811f5596eeb15c..3159fbd3b36a499dc0d4756864eda79f3329efc6 100644 (file)
@@ -103,12 +103,12 @@ PromoteMemoryResource (
   Internal function.  Adds a ranges to the memory map.\r
   The range must not already exist in the map.\r
 \r
-  @param  Type                   The type of memory range to add \r
-  @param  Start                  The starting address in the memory range Must be \r
-                                 paged aligned \r
-  @param  End                    The last address in the range Must be the last \r
-                                 byte of a page \r
-  @param  Attribute              The attributes of the memory range to add \r
+  @param  Type                   The type of memory range to add\r
+  @param  Start                  The starting address in the memory range Must be\r
+                                 paged aligned\r
+  @param  End                    The last address in the range Must be the last\r
+                                 byte of a page\r
+  @param  Attribute              The attributes of the memory range to add\r
 \r
 **/\r
 VOID\r
@@ -133,15 +133,15 @@ CoreFreeMemoryMapStack (
   Internal function.  Converts a memory range to the specified type.\r
   The range must exist in the memory map.\r
 \r
-  @param  Start                  The first address of the range Must be page \r
-                                 aligned \r
-  @param  NumberOfPages          The number of pages to convert \r
-  @param  NewType                The new type for the memory range \r
+  @param  Start                  The first address of the range Must be page\r
+                                 aligned\r
+  @param  NumberOfPages          The number of pages to convert\r
+  @param  NewType                The new type for the memory 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
+  @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 type.\r
 \r
 **/\r
@@ -160,9 +160,9 @@ CoreConvertPages (
 **/\r
 VOID\r
 RemoveMemoryMapEntry (\r
-  MEMORY_MAP      *Entry\r
+  IN OUT MEMORY_MAP      *Entry\r
   );\r
-  \r
+\r
 /**\r
   Internal function.  Deque a descriptor entry from the mFreeMemoryMapEntryList.\r
   If the list is emtry, then allocate a new page to refuel the list.\r
@@ -180,7 +180,7 @@ MEMORY_MAP *
 AllocateMemoryMapEntry (\r
   VOID\r
   );\r
\r
+\r
 \r
 /**\r
   Enter critical section by gaining lock on gMemoryLock.\r
@@ -222,9 +222,9 @@ PromoteMemoryResource (
   EFI_GCD_MAP_ENTRY                *Entry;\r
 \r
   DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "Promote the memory resource\n"));\r
-  \r
+\r
   CoreAcquireGcdMemoryLock ();\r
-  \r
+\r
   Link = mGcdMemorySpaceMap.ForwardLink;\r
   while (Link != &mGcdMemorySpaceMap) {\r
 \r
@@ -244,23 +244,23 @@ PromoteMemoryResource (
 \r
       //\r
       // Add to allocable system memory resource\r
-      //      \r
+      //\r
 \r
       CoreAddRange (\r
-        EfiConventionalMemory, \r
-        Entry->BaseAddress, \r
-        Entry->EndAddress, \r
+        EfiConventionalMemory,\r
+        Entry->BaseAddress,\r
+        Entry->EndAddress,\r
         Entry->Capabilities & ~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)\r
         );\r
       CoreFreeMemoryMapStack ();\r
-      \r
+\r
     }\r
 \r
     Link = Link->ForwardLink;\r
   }\r
-  \r
+\r
   CoreReleaseGcdMemoryLock ();\r
-  \r
+\r
   return;\r
 }\r
 \r
@@ -271,11 +271,11 @@ PromoteMemoryResource (
   The first descriptor that is added must be general usable\r
   memory as the addition allocates heap.\r
 \r
-  @param  Type                   The type of memory to add \r
-  @param  Start                  The starting address in the memory range Must be \r
-                                 page aligned \r
-  @param  NumberOfPages          The number of pages in the range \r
-  @param  Attribute              Attributes of the memory to add \r
+  @param  Type                   The type of memory to add\r
+  @param  Start                  The starting address in the memory range Must be\r
+                                 page aligned\r
+  @param  NumberOfPages          The number of pages in the range\r
+  @param  Attribute              Attributes of the memory to add\r
 \r
   @return None.  The range is added to the memory map\r
 \r
@@ -300,7 +300,7 @@ CoreAddMemoryDescriptor (
   if (Type >= EfiMaxMemoryType && Type <= 0x7fffffff) {\r
     return;\r
   }\r
-  \r
+\r
   CoreAcquireMemoryLock ();\r
   End = Start + LShiftU64 (NumberOfPages, EFI_PAGE_SHIFT) - 1;\r
   CoreAddRange (Type, Start, End, Attribute);\r
@@ -338,7 +338,7 @@ CoreAddMemoryDescriptor (
                  );\r
       if (EFI_ERROR (Status)) {\r
         //\r
-        // If an error occurs allocating the pages for the current memory type, then \r
+        // If an error occurs allocating the pages for the current memory type, then\r
         // free all the pages allocates for the previous memory types and return.  This\r
         // operation with be retied when/if more memory is added to the system\r
         //\r
@@ -353,7 +353,7 @@ CoreAddMemoryDescriptor (
 \r
           if (gMemoryTypeInformation[FreeIndex].NumberOfPages != 0) {\r
             CoreFreePages (\r
-              mMemoryTypeStatistics[Type].BaseAddress, \r
+              mMemoryTypeStatistics[Type].BaseAddress,\r
               gMemoryTypeInformation[FreeIndex].NumberOfPages\r
               );\r
             mMemoryTypeStatistics[Type].BaseAddress    = 0;\r
@@ -366,12 +366,12 @@ CoreAddMemoryDescriptor (
       //\r
       // Compute the address at the top of the current statistics\r
       //\r
-      mMemoryTypeStatistics[Type].MaximumAddress = \r
-        mMemoryTypeStatistics[Type].BaseAddress + \r
+      mMemoryTypeStatistics[Type].MaximumAddress =\r
+        mMemoryTypeStatistics[Type].BaseAddress +\r
         LShiftU64 (gMemoryTypeInformation[Index].NumberOfPages, EFI_PAGE_SHIFT) - 1;\r
 \r
       //\r
-      // If the current base address is the lowest address so far, then update the default \r
+      // If the current base address is the lowest address so far, then update the default\r
       // maximum address\r
       //\r
       if (mMemoryTypeStatistics[Type].BaseAddress < mDefaultMaximumAddress) {\r
@@ -396,7 +396,7 @@ CoreAddMemoryDescriptor (
 \r
     if (gMemoryTypeInformation[Index].NumberOfPages != 0) {\r
       CoreFreePages (\r
-        mMemoryTypeStatistics[Type].BaseAddress, \r
+        mMemoryTypeStatistics[Type].BaseAddress,\r
         gMemoryTypeInformation[Index].NumberOfPages\r
         );\r
       mMemoryTypeStatistics[Type].NumberOfPages   = gMemoryTypeInformation[Index].NumberOfPages;\r
@@ -429,14 +429,12 @@ CoreAddMemoryDescriptor (
   Internal function.  Adds a ranges to the memory map.\r
   The range must not already exist in the map.\r
 \r
-  @param  Type                   The type of memory range to add \r
-  @param  Start                  The starting address in the memory range Must be \r
-                                 paged aligned \r
-  @param  End                    The last address in the range Must be the last \r
-                                 byte of a page \r
-  @param  Attribute              The attributes of the memory range to add \r
-\r
-  @return None.  The range is added to the memory map\r
+  @param  Type                   The type of memory range to add\r
+  @param  Start                  The starting address in the memory range Must be\r
+                                 paged aligned\r
+  @param  End                    The last address in the range Must be the last\r
+                                 byte of a page\r
+  @param  Attribute              The attributes of the memory range to add\r
 \r
 **/\r
 VOID\r
@@ -454,7 +452,7 @@ CoreAddRange (
   ASSERT (End > Start) ;\r
 \r
   ASSERT_LOCKED (&gMemoryLock);\r
-  \r
+\r
   DEBUG ((DEBUG_PAGE, "AddRange: %lx-%lx to %d\n", Start, End, Type));\r
 \r
   //\r
@@ -465,9 +463,9 @@ CoreAddRange (
   //\r
   // UEFI 2.0 added an event group for notificaiton on memory map changes.\r
   // So we need to signal this Event Group every time the memory map changes.\r
-  // If we are in EFI 1.10 compatability mode no event groups will be \r
+  // If we are in EFI 1.10 compatability mode no event groups will be\r
   // found and nothing will happen we we call this function. These events\r
-  // will get signaled but since a lock is held around the call to this \r
+  // will get signaled but since a lock is held around the call to this\r
   // function the notificaiton events will only be called after this funciton\r
   // returns and the lock is released.\r
   //\r
@@ -476,7 +474,7 @@ CoreAddRange (
   //\r
   // Look for adjoining memory descriptor\r
   //\r
-  \r
+\r
   // Two memory descriptors can only be merged if they have the same Type\r
   // and the same Attribute\r
   //\r
@@ -495,19 +493,19 @@ CoreAddRange (
     }\r
 \r
     if (Entry->End + 1 == Start) {\r
-      \r
+\r
       Start = Entry->Start;\r
       RemoveMemoryMapEntry (Entry);\r
 \r
     } else if (Entry->Start == End + 1) {\r
-      \r
+\r
       End = Entry->End;\r
       RemoveMemoryMapEntry (Entry);\r
     }\r
   }\r
 \r
   //\r
-  // Add descriptor \r
+  // Add descriptor\r
   //\r
 \r
   mMapStack[mMapDepth].Signature     = MEMORY_MAP_SIGNATURE;\r
@@ -556,10 +554,10 @@ CoreFreeMemoryMapStack (
 \r
   while (mMapDepth != 0) {\r
     //\r
-    // Deque an memory map entry from mFreeMemoryMapEntryList \r
+    // Deque an memory map entry from mFreeMemoryMapEntryList\r
     //\r
     Entry = AllocateMemoryMapEntry ();\r
-    \r
+\r
     ASSERT (Entry);\r
 \r
     //\r
@@ -591,7 +589,7 @@ CoreFreeMemoryMapStack (
       InsertTailList (Link2, &Entry->Link);\r
 \r
     } else {\r
-      // \r
+      //\r
       // This item of mMapStack[mMapDepth] has already been dequeued from gMemoryMap list,\r
       // so here no need to move it to memory.\r
       //\r
@@ -647,9 +645,9 @@ AllocateMemoryMapEntry (
   MEMORY_MAP*            FreeDescriptorEntries;\r
   MEMORY_MAP*            Entry;\r
   UINTN                  Index;\r
-  \r
+\r
   if (IsListEmpty (&mFreeMemoryMapEntryList)) {\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
@@ -660,7 +658,7 @@ AllocateMemoryMapEntry (
       for (Index = 0; Index< DEFAULT_PAGE_ALLOCATION / sizeof(MEMORY_MAP); Index++) {\r
         FreeDescriptorEntries[Index].Signature = MEMORY_MAP_SIGNATURE;\r
         InsertTailList (&mFreeMemoryMapEntryList, &FreeDescriptorEntries[Index].Link);\r
-      }     \r
+      }\r
     } else {\r
       return NULL;\r
     }\r
@@ -670,24 +668,24 @@ AllocateMemoryMapEntry (
   //\r
   Entry = CR (mFreeMemoryMapEntryList.ForwardLink, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);\r
   RemoveEntryList (&Entry->Link);\r
-  \r
+\r
   return Entry;\r
-}    \r
+}\r
 \r
 \r
 /**\r
   Internal function.  Converts a memory range to the specified type.\r
   The range must exist in the memory map.\r
 \r
-  @param  Start                  The first address of the range Must be page \r
-                                 aligned \r
-  @param  NumberOfPages          The number of pages to convert \r
-  @param  NewType                The new type for the memory range \r
+  @param  Start                  The first address of the range Must be page\r
+                                 aligned\r
+  @param  NumberOfPages          The number of pages to convert\r
+  @param  NewType                The new type for the memory 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
+  @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 type.\r
 \r
 **/\r
@@ -758,13 +756,13 @@ CoreConvertPages (
     if (!(NewType == EfiConventionalMemory ? 1 : 0) ^ (Entry->Type == EfiConventionalMemory ? 1 : 0)) {\r
       DEBUG ((DEBUG_ERROR , "ConvertPages: Incompatible memory types\n"));\r
       return EFI_NOT_FOUND;\r
-    }  \r
+    }\r
 \r
     //\r
     // Update counters for the number of pages allocated to each memory type\r
     //\r
     if (Entry->Type >= 0 && Entry->Type < EfiMaxMemoryType) {\r
-      if (Start >= mMemoryTypeStatistics[Entry->Type].BaseAddress && \r
+      if (Start >= mMemoryTypeStatistics[Entry->Type].BaseAddress &&\r
           Start <= mMemoryTypeStatistics[Entry->Type].MaximumAddress) {\r
         if (NumberOfPages > mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages) {\r
           mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages = 0;\r
@@ -777,7 +775,7 @@ CoreConvertPages (
     if (NewType >= 0 && NewType < EfiMaxMemoryType) {\r
       if (Start >= mMemoryTypeStatistics[NewType].BaseAddress && Start <= mMemoryTypeStatistics[NewType].MaximumAddress) {\r
         mMemoryTypeStatistics[NewType].CurrentNumberOfPages += NumberOfPages;\r
-        if (mMemoryTypeStatistics[NewType].CurrentNumberOfPages > \r
+        if (mMemoryTypeStatistics[NewType].CurrentNumberOfPages >\r
             gMemoryTypeInformation[mMemoryTypeStatistics[NewType].InformationIndex].NumberOfPages) {\r
           gMemoryTypeInformation[mMemoryTypeStatistics[NewType].InformationIndex].NumberOfPages = (UINT32)mMemoryTypeStatistics[NewType].CurrentNumberOfPages;\r
         }\r
@@ -788,14 +786,14 @@ CoreConvertPages (
     // Pull range out of descriptor\r
     //\r
     if (Entry->Start == Start) {\r
-      \r
+\r
       //\r
       // Clip start\r
       //\r
       Entry->Start = RangeEnd + 1;\r
 \r
     } else if (Entry->End == RangeEnd) {\r
-      \r
+\r
       //\r
       // Clip end\r
       //\r
@@ -806,7 +804,7 @@ CoreConvertPages (
       //\r
       // Pull it out of the center, clip current\r
       //\r
-      \r
+\r
       //\r
       // Add a new one\r
       //\r
@@ -832,7 +830,7 @@ CoreConvertPages (
     }\r
 \r
     //\r
-    // The new range inherits the same Attribute as the Entry \r
+    // The new range inherits the same Attribute as the Entry\r
     //it is being cut out of\r
     //\r
     Attribute = Entry->Attribute;\r
@@ -844,7 +842,7 @@ CoreConvertPages (
       RemoveMemoryMapEntry (Entry);\r
       Entry = NULL;\r
     }\r
-    \r
+\r
     //\r
     // Add our new range in\r
     //\r
@@ -874,11 +872,11 @@ CoreConvertPages (
   Internal function. Finds a consecutive free page range below\r
   the requested address.\r
 \r
-  @param  MaxAddress             The address that the range must be below \r
-  @param  NumberOfPages          Number of pages needed \r
-  @param  NewType                The type of memory the range is going to be \r
-                                 turned into \r
-  @param  Alignment              Bits to align with \r
+  @param  MaxAddress             The address that the range must be below\r
+  @param  NumberOfPages          Number of pages needed\r
+  @param  NewType                The type of memory the range is going to be\r
+                                 turned into\r
+  @param  Alignment              Bits to align with\r
 \r
   @return The base address of the range, or 0 if the range was not found\r
 \r
@@ -904,21 +902,21 @@ CoreFindFreePagesI (
   }\r
 \r
   if ((MaxAddress & EFI_PAGE_MASK) != EFI_PAGE_MASK) {\r
-    \r
+\r
     //\r
     // If MaxAddress is not aligned to the end of a page\r
     //\r
-    \r
+\r
     //\r
     // Change MaxAddress to be 1 page lower\r
     //\r
     MaxAddress -= (EFI_PAGE_MASK + 1);\r
-    \r
+\r
     //\r
     // Set MaxAddress to a page boundary\r
     //\r
     MaxAddress &= ~EFI_PAGE_MASK;\r
-    \r
+\r
     //\r
     // Set MaxAddress to end of the page\r
     //\r
@@ -930,7 +928,7 @@ CoreFindFreePagesI (
 \r
   for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {\r
     Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);\r
-  \r
+\r
     //\r
     // If it's not a free entry, don't bother with it\r
     //\r
@@ -958,7 +956,7 @@ CoreFindFreePagesI (
     DescEnd = ((DescEnd + 1) & (~(Alignment - 1))) - 1;\r
 \r
     //\r
-    // Compute the number of bytes we can used from this \r
+    // Compute the number of bytes we can used from this\r
     // descriptor, and see it's enough to satisfy the request\r
     //\r
     DescNumberOfBytes = DescEnd - DescStart + 1;\r
@@ -972,7 +970,7 @@ CoreFindFreePagesI (
         Target = DescEnd;\r
       }\r
     }\r
-  }          \r
+  }\r
 \r
   //\r
   // If this is a grow down, adjust target to be the allocation base\r
@@ -994,11 +992,11 @@ CoreFindFreePagesI (
   Internal function.  Finds a consecutive free page range below\r
   the requested address\r
 \r
-  @param  MaxAddress             The address that the range must be below \r
-  @param  NoPages                Number of pages needed \r
-  @param  NewType                The type of memory the range is going to be \r
-                                 turned into \r
-  @param  Alignment              Bits to align with \r
+  @param  MaxAddress             The address that the range must be below\r
+  @param  NoPages                Number of pages needed\r
+  @param  NewType                The type of memory the range is going to be\r
+                                 turned into\r
+  @param  Alignment              Bits to align with\r
 \r
   @return The base address of the range, or 0 if the range was not found.\r
 \r
@@ -1049,18 +1047,18 @@ FindFreePages (
 /**\r
   Allocates pages from the memory map.\r
 \r
-  @param  Type                   The type of allocation to perform \r
-  @param  MemoryType             The type of memory to turn the allocated pages \r
-                                 into \r
-  @param  NumberOfPages          The number of pages to allocate \r
-  @param  Memory                 A pointer to receive the base allocated memory \r
-                                 address \r
+  @param  Type                   The type of allocation to perform\r
+  @param  MemoryType             The type of memory to turn the allocated pages\r
+                                 into\r
+  @param  NumberOfPages          The number of pages to allocate\r
+  @param  Memory                 A pointer to receive the base allocated memory\r
+                                 address\r
 \r
   @return Status. On success, Memory is filled in with the base address allocated\r
-  @retval EFI_INVALID_PARAMETER  Parameters violate checking rules defined in \r
-                                 spec. \r
-  @retval EFI_NOT_FOUND          Could not allocate pages match the requirement. \r
-  @retval EFI_OUT_OF_RESOURCES   No enough pages to allocate. \r
+  @retval EFI_INVALID_PARAMETER  Parameters violate checking rules defined in\r
+                                 spec.\r
+  @retval EFI_NOT_FOUND          Could not allocate pages match the requirement.\r
+  @retval EFI_OUT_OF_RESOURCES   No enough pages to allocate.\r
   @retval EFI_SUCCESS            Pages successfully allocated.\r
 \r
 **/\r
@@ -1107,21 +1105,21 @@ CoreAllocatePages (
   NumberOfPages &= ~(EFI_SIZE_TO_PAGES (Alignment) - 1);\r
 \r
   //\r
-  // If this is for below a particular address, then \r
+  // If this is for below a particular address, then\r
   //\r
   Start = *Memory;\r
-  \r
+\r
   //\r
   // The max address is the max natively addressable address for the processor\r
   //\r
   MaxAddress = EFI_MAX_ADDRESS;\r
-  \r
+\r
   if (Type == AllocateMaxAddress) {\r
     MaxAddress = Start;\r
   }\r
 \r
   CoreAcquireMemoryLock ();\r
-  \r
+\r
   //\r
   // If not a specific address, then find an address to allocate\r
   //\r
@@ -1152,15 +1150,15 @@ Done:
 /**\r
   Frees previous allocated pages.\r
 \r
-  @param  Memory                 Base address of memory being freed \r
-  @param  NumberOfPages          The number of pages to free \r
+  @param  Memory                 Base address of memory being freed\r
+  @param  NumberOfPages          The number of pages to free\r
 \r
-  @retval EFI_NOT_FOUND          Could not find the entry that covers the range \r
-  @retval EFI_INVALID_PARAMETER  Address not aligned \r
+  @retval EFI_NOT_FOUND          Could not find the entry that covers the range\r
+  @retval EFI_INVALID_PARAMETER  Address not aligned\r
   @return EFI_SUCCESS         -Pages successfully freed.\r
 \r
 **/\r
-EFI_STATUS \r
+EFI_STATUS\r
 EFIAPI\r
 CoreFreePages (\r
   IN EFI_PHYSICAL_ADDRESS   Memory,\r
@@ -1225,7 +1223,7 @@ CoreFreePages (
   if (Memory < EFI_MAX_ADDRESS) {\r
     DEBUG_CLEAR_MEMORY ((VOID *)(UINTN)Memory, NumberOfPages << EFI_PAGE_SHIFT);\r
   }\r
-  \r
+\r
   return Status;\r
 }\r
 \r
@@ -1234,29 +1232,29 @@ CoreFreePages (
   This function returns a copy of the current memory map. The map is an array of\r
   memory descriptors, each of which describes a contiguous block of memory.\r
 \r
-  @param  MemoryMapSize          A pointer to the size, in bytes, of the \r
-                                 MemoryMap buffer. On input, this is the size of \r
-                                 the buffer allocated by the caller.  On output, \r
-                                 it is the size of the buffer returned by the \r
-                                 firmware  if the buffer was large enough, or the \r
-                                 size of the buffer needed  to contain the map if \r
-                                 the buffer was too small. \r
-  @param  MemoryMap              A pointer to the buffer in which firmware places \r
-                                 the current memory map. \r
-  @param  MapKey                 A pointer to the location in which firmware \r
-                                 returns the key for the current memory map. \r
-  @param  DescriptorSize         A pointer to the location in which firmware \r
-                                 returns the size, in bytes, of an individual \r
-                                 EFI_MEMORY_DESCRIPTOR. \r
-  @param  DescriptorVersion      A pointer to the location in which firmware \r
-                                 returns the version number associated with the \r
-                                 EFI_MEMORY_DESCRIPTOR. \r
-\r
-  @retval EFI_SUCCESS            The memory map was returned in the MemoryMap \r
-                                 buffer. \r
-  @retval EFI_BUFFER_TOO_SMALL   The MemoryMap buffer was too small. The current \r
-                                 buffer size needed to hold the memory map is \r
-                                 returned in MemoryMapSize. \r
+  @param  MemoryMapSize          A pointer to the size, in bytes, of the\r
+                                 MemoryMap buffer. On input, this is the size of\r
+                                 the buffer allocated by the caller.  On output,\r
+                                 it is the size of the buffer returned by the\r
+                                 firmware  if the buffer was large enough, or the\r
+                                 size of the buffer needed  to contain the map if\r
+                                 the buffer was too small.\r
+  @param  MemoryMap              A pointer to the buffer in which firmware places\r
+                                 the current memory map.\r
+  @param  MapKey                 A pointer to the location in which firmware\r
+                                 returns the key for the current memory map.\r
+  @param  DescriptorSize         A pointer to the location in which firmware\r
+                                 returns the size, in bytes, of an individual\r
+                                 EFI_MEMORY_DESCRIPTOR.\r
+  @param  DescriptorVersion      A pointer to the location in which firmware\r
+                                 returns the version number associated with the\r
+                                 EFI_MEMORY_DESCRIPTOR.\r
+\r
+  @retval EFI_SUCCESS            The memory map was returned in the MemoryMap\r
+                                 buffer.\r
+  @retval EFI_BUFFER_TOO_SMALL   The MemoryMap buffer was too small. The current\r
+                                 buffer size needed to hold the memory map is\r
+                                 returned in MemoryMapSize.\r
   @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value.\r
 \r
 **/\r
@@ -1271,12 +1269,12 @@ CoreGetMemoryMap (
   )\r
 {\r
   EFI_STATUS                        Status;\r
-  UINTN                             Size;  \r
-  UINTN                             BufferSize;  \r
+  UINTN                             Size;\r
+  UINTN                             BufferSize;\r
   UINTN                             NumberOfRuntimeEntries;\r
   LIST_ENTRY                        *Link;\r
-  MEMORY_MAP                        *Entry;  \r
-  EFI_GCD_MAP_ENTRY                 *GcdMapEntry;  \r
+  MEMORY_MAP                        *Entry;\r
+  EFI_GCD_MAP_ENTRY                 *GcdMapEntry;\r
   EFI_MEMORY_TYPE                   Type;\r
 \r
   //\r
@@ -1285,9 +1283,9 @@ CoreGetMemoryMap (
   if (MemoryMapSize == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   CoreAcquireGcdMemoryLock ();\r
-  \r
+\r
   //\r
   // Count the number of Reserved and MMIO entries that are marked for runtime use\r
   //\r
@@ -1314,7 +1312,7 @@ CoreGetMemoryMap (
   if (DescriptorSize != NULL) {\r
     *DescriptorSize = Size;\r
   }\r
-  \r
+\r
   if (DescriptorVersion != NULL) {\r
     *DescriptorVersion = EFI_MEMORY_DESCRIPTOR_VERSION;\r
   }\r
@@ -1356,8 +1354,8 @@ CoreGetMemoryMap (
     MemoryMap->NumberOfPages  = RShiftU64 (Entry->End - Entry->Start + 1, EFI_PAGE_SHIFT);\r
     //\r
     // If the memory type is EfiConventionalMemory, then determine if the range is part of a\r
-    // memory type bin and needs to be converted to the same memory type as the rest of the \r
-    // memory type bin in order to minimize EFI Memory Map changes across reboots.  This \r
+    // memory type bin and needs to be converted to the same memory type as the rest of the\r
+    // memory type bin in order to minimize EFI Memory Map changes across reboots.  This\r
     // improves the chances for a successful S4 resume in the presence of minor page allocation\r
     // differences across reboots.\r
     //\r
@@ -1375,7 +1373,7 @@ CoreGetMemoryMap (
     if (mMemoryTypeStatistics[MemoryMap->Type].Runtime) {\r
       MemoryMap->Attribute |= EFI_MEMORY_RUNTIME;\r
     }\r
-    \r
+\r
     MemoryMap = NextMemoryDescriptor (MemoryMap, Size);\r
   }\r
 \r
@@ -1384,7 +1382,7 @@ CoreGetMemoryMap (
     if ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) ||\r
         (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo)) {\r
       if ((GcdMapEntry->Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {\r
-        \r
+\r
         MemoryMap->PhysicalStart = GcdMapEntry->BaseAddress;\r
         MemoryMap->VirtualStart  = 0;\r
         MemoryMap->NumberOfPages = RShiftU64 ((GcdMapEntry->EndAddress - GcdMapEntry->BaseAddress + 1), EFI_PAGE_SHIFT);\r
@@ -1404,24 +1402,24 @@ CoreGetMemoryMap (
       }\r
     }\r
   }\r
-  \r
+\r
   Status = EFI_SUCCESS;\r
 \r
 Done:\r
 \r
   CoreReleaseMemoryLock ();\r
-  \r
+\r
   CoreReleaseGcdMemoryLock ();\r
-  \r
-  // \r
-  // Update the map key finally \r
-  // \r
+\r
+  //\r
+  // Update the map key finally\r
+  //\r
   if (MapKey != NULL) {\r
     *MapKey = mMemoryMapKey;\r
   }\r
-  \r
+\r
   *MemoryMapSize = BufferSize;\r
-  \r
+\r
   return Status;\r
 }\r
 \r
@@ -1430,9 +1428,9 @@ Done:
   Internal function.  Used by the pool functions to allocate pages\r
   to back pool allocation requests.\r
 \r
-  @param  PoolType               The type of memory for the new pool pages \r
-  @param  NumberOfPages          No of pages to allocate \r
-  @param  Alignment              Bits to align. \r
+  @param  PoolType               The type of memory for the new pool pages\r
+  @param  NumberOfPages          No of pages to allocate\r
+  @param  Alignment              Bits to align.\r
 \r
   @return The allocated memory, or NULL\r
 \r
@@ -1467,7 +1465,7 @@ CoreAllocatePoolPages (
 /**\r
   Internal function.  Frees pool pages allocated via AllocatePoolPages ()\r
 \r
-  @param  Memory                 The base address to free \r
+  @param  Memory                 The base address to free\r
   @param  NumberOfPages          The number of pages to free\r
 \r
 **/\r
@@ -1486,10 +1484,10 @@ CoreFreePoolPages (
   Make sure the memory map is following all the construction rules,\r
   it is the last time to check memory map error before exit boot services.\r
 \r
-  @param  MapKey                 Memory map key \r
+  @param  MapKey                 Memory map key\r
 \r
-  @retval EFI_INVALID_PARAMETER  Memory map not consistent with construction \r
-                                 rules. \r
+  @retval EFI_INVALID_PARAMETER  Memory map not consistent with construction\r
+                                 rules.\r
   @retval EFI_SUCCESS            Valid memory map.\r
 \r
 **/\r
@@ -1516,7 +1514,7 @@ CoreTerminateMemoryMap (
 \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) { \r
+      if (Entry->Attribute & EFI_MEMORY_RUNTIME) {\r
         if (Entry->Type == EfiACPIReclaimMemory || Entry->Type == EfiACPIMemoryNVS) {\r
           DEBUG((DEBUG_ERROR, "ExitBootServices: ACPI memory entry has RUNTIME attribute set.\n"));\r
           CoreReleaseMemoryLock ();\r