]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Gcd/Gcd.c
Switch DxeCore to use DxeCoreMemoryAllocationLib for NT32 platform.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Gcd / Gcd.c
index a2c9b0e73aac064ee2d78354f7b51eb361a8d6a8..2e7afb33c3a1566fedcf30e3a938a3ef64f3a9cc 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
   The file contains the GCD related services in the EFI Boot Services Table.\r
-  The GCD services are used to manage the memory and I/O regions that \r
+  The GCD services are used to manage the memory and I/O regions that\r
   are accessible to the CPU that is executing the DXE core.\r
 \r
 Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
@@ -26,7 +26,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
                                        EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \\r
                                        EFI_RESOURCE_ATTRIBUTE_16_BIT_IO           | \\r
                                        EFI_RESOURCE_ATTRIBUTE_32_BIT_IO           | \\r
-                                       EFI_RESOURCE_ATTRIBUTE_64_BIT_IO           ) \r
+                                       EFI_RESOURCE_ATTRIBUTE_64_BIT_IO           )\r
 \r
 #define TESTED_MEMORY_ATTRIBUTES      (EFI_RESOURCE_ATTRIBUTE_PRESENT     | \\r
                                        EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \\r
@@ -49,7 +49,7 @@ LIST_ENTRY         mGcdIoSpaceMap      = INITIALIZE_LIST_HEAD_VARIABLE (mGcdIoSp
 \r
 EFI_GCD_MAP_ENTRY mGcdMemorySpaceMapEntryTemplate = {\r
   EFI_GCD_MAP_SIGNATURE,\r
-  { \r
+  {\r
     NULL,\r
     NULL\r
   },\r
@@ -81,7 +81,7 @@ EFI_GCD_MAP_ENTRY mGcdIoSpaceMapEntryTemplate = {
 \r
 GCD_ATTRIBUTE_CONVERSION_ENTRY mAttributeConversionTable[] = {\r
   { EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE,             EFI_MEMORY_UC,          TRUE  },\r
-  { EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED,       EFI_MEMORY_UCE,         TRUE  },   \r
+  { EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED,       EFI_MEMORY_UCE,         TRUE  },\r
   { EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE,       EFI_MEMORY_WC,          TRUE  },\r
   { EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE, EFI_MEMORY_WT,          TRUE  },\r
   { EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE,    EFI_MEMORY_WB,          TRUE  },\r
@@ -156,11 +156,11 @@ CoreReleaseGcdIoLock (
 /**\r
   Aligns a value to the specified boundary.\r
 \r
-  @param  Value                  64 bit value to align \r
-  @param  Alignment              Log base 2 of the boundary to align Value to \r
-  @param  RoundUp                TRUE if Value is to be rounded up to the nearest \r
-                                 aligned boundary.  FALSE is Value is to be \r
-                                 rounded down to the nearest aligned boundary. \r
+  @param  Value                  64 bit value to align\r
+  @param  Alignment              Log base 2 of the boundary to align Value to\r
+  @param  RoundUp                TRUE if Value is to be rounded up to the nearest\r
+                                 aligned boundary.  FALSE is Value is to be\r
+                                 rounded down to the nearest aligned boundary.\r
 \r
   @return A 64 bit value is the aligned to the value nearest Value with an alignment by Alignment.\r
 \r
@@ -185,7 +185,7 @@ AlignValue (
 /**\r
   Aligns address to the page boundary.\r
 \r
-  @param  Value                  64 bit address to align \r
+  @param  Value                  64 bit address to align\r
 \r
   @return A 64 bit value is the aligned to the value nearest Value with an alignment by Alignment.\r
 \r
@@ -202,7 +202,7 @@ PageAlignAddress (
 /**\r
   Aligns length to the page boundary.\r
 \r
-  @param  Value                  64 bit length to align \r
+  @param  Value                  64 bit length to align\r
 \r
   @return A 64 bit value is the aligned to the value nearest Value with an alignment by Alignment.\r
 \r
@@ -222,10 +222,10 @@ PageAlignLength (
 /**\r
   Allocate pool for two entries.\r
 \r
-  @param  TopEntry               An entry of GCD map \r
-  @param  BottomEntry            An entry of GCD map \r
+  @param  TopEntry               An entry of GCD map\r
+  @param  BottomEntry            An entry of GCD map\r
 \r
-  @retval EFI_OUT_OF_RESOURCES   No enough buffer to be allocated. \r
+  @retval EFI_OUT_OF_RESOURCES   No enough buffer to be allocated.\r
   @retval EFI_SUCCESS            Both entries successfully allocated.\r
 \r
 **/\r
@@ -253,13 +253,13 @@ CoreAllocateGcdMapEntry (
 /**\r
   Internal function.  Inserts a new descriptor into a sorted list\r
 \r
-  @param  Link                   The linked list to insert the range BaseAddress \r
-                                 and Length into \r
-  @param  Entry                  A pointer to the entry that is inserted \r
-  @param  BaseAddress            The base address of the new range \r
-  @param  Length                 The length of the new range in bytes \r
-  @param  TopEntry               Top pad entry to insert if needed. \r
-  @param  BottomEntry            Bottom pad entry to insert if needed. \r
+  @param  Link                   The linked list to insert the range BaseAddress\r
+                                 and Length into\r
+  @param  Entry                  A pointer to the entry that is inserted\r
+  @param  BaseAddress            The base address of the new range\r
+  @param  Length                 The length of the new range in bytes\r
+  @param  TopEntry               Top pad entry to insert if needed.\r
+  @param  BottomEntry            Bottom pad entry to insert if needed.\r
 \r
   @retval EFI_SUCCESS            The new range was inserted into the linked list\r
 \r
@@ -283,7 +283,7 @@ CoreInsertGcdMapEntry (
     Entry->BaseAddress      = BaseAddress;\r
     BottomEntry->EndAddress = BaseAddress - 1;\r
     InsertTailList (Link, &BottomEntry->Link);\r
-  } \r
+  }\r
 \r
   if ((BaseAddress + Length - 1) < Entry->EndAddress) {\r
     CopyMem (TopEntry, Entry, sizeof (EFI_GCD_MAP_ENTRY));\r
@@ -299,12 +299,12 @@ CoreInsertGcdMapEntry (
 /**\r
   Merge the Gcd region specified by Link and its adjacent entry.\r
 \r
-  @param  Link                   Specify the entry to be merged (with its \r
-                                 adjacent entry). \r
-  @param  Forward                Direction (forward or backward). \r
-  @param  Map                    Boundary. \r
+  @param  Link                   Specify the entry to be merged (with its\r
+                                 adjacent entry).\r
+  @param  Forward                Direction (forward or backward).\r
+  @param  Map                    Boundary.\r
 \r
-  @retval EFI_SUCCESS            Successfully returned. \r
+  @retval EFI_SUCCESS            Successfully returned.\r
   @retval EFI_UNSUPPORTED        These adjacent regions could not merge.\r
 \r
 **/\r
@@ -372,11 +372,11 @@ CoreMergeGcdMapEntry (
 /**\r
   Merge adjacent entries on total chain.\r
 \r
-  @param  TopEntry               Top entry of GCD map. \r
-  @param  BottomEntry            Bottom entry of GCD map. \r
-  @param  StartLink              Start link of the list for this loop. \r
-  @param  EndLink                End link of the list for this loop. \r
-  @param  Map                    Boundary. \r
+  @param  TopEntry               Top entry of GCD map.\r
+  @param  BottomEntry            Bottom entry of GCD map.\r
+  @param  StartLink              Start link of the list for this loop.\r
+  @param  EndLink                End link of the list for this loop.\r
+  @param  Map                    Boundary.\r
 \r
   @retval EFI_SUCCESS            GCD map successfully cleaned up.\r
 \r
@@ -413,15 +413,15 @@ CoreCleanupGcdMapEntry (
 /**\r
   Search a segment of memory space in GCD map. The result is a range of GCD entry list.\r
 \r
-  @param  BaseAddress            The start address of the segment. \r
-  @param  Length                 The length of the segment. \r
-  @param  StartLink              The first GCD entry involves this segment of \r
-                                 memory space. \r
-  @param  EndLink                The first GCD entry involves this segment of \r
-                                 memory space. \r
-  @param  Map                    Points to the start entry to search. \r
+  @param  BaseAddress            The start address of the segment.\r
+  @param  Length                 The length of the segment.\r
+  @param  StartLink              The first GCD entry involves this segment of\r
+                                 memory space.\r
+  @param  EndLink                The first GCD entry involves this segment of\r
+                                 memory space.\r
+  @param  Map                    Points to the start entry to search.\r
 \r
-  @retval EFI_SUCCESS            Successfully found the entry. \r
+  @retval EFI_SUCCESS            Successfully found the entry.\r
   @retval EFI_NOT_FOUND          Not found.\r
 \r
 **/\r
@@ -449,7 +449,7 @@ CoreSearchGcdMapEntry (
       *StartLink = Link;\r
     }\r
     if (*StartLink != NULL) {\r
-      if ((BaseAddress + Length - 1) >= Entry->BaseAddress && \r
+      if ((BaseAddress + Length - 1) >= Entry->BaseAddress &&\r
           (BaseAddress + Length - 1) <= Entry->EndAddress     ) {\r
         *EndLink = Link;\r
         return EFI_SUCCESS;\r
@@ -465,7 +465,7 @@ CoreSearchGcdMapEntry (
 /**\r
   Count the amount of GCD map entries.\r
 \r
-  @param  Map                    Points to the start entry to do the count loop. \r
+  @param  Map                    Points to the start entry to do the count loop.\r
 \r
   @return The count.\r
 \r
@@ -484,7 +484,7 @@ CoreCountGcdMapEntry (
     Count++;\r
     Link = Link->ForwardLink;\r
   }\r
-  \r
+\r
   return Count;\r
 }\r
 \r
@@ -493,7 +493,7 @@ CoreCountGcdMapEntry (
 /**\r
   Return the memory attribute specified by Attributes\r
 \r
-  @param  Attributes             A num with some attribute bits on. \r
+  @param  Attributes             A num with some attribute bits on.\r
 \r
   @return The enum value of memory attribute.\r
 \r
@@ -531,23 +531,23 @@ ConverToCpuArchAttributes (
 /**\r
   Do operation on a segment of memory space specified (add, free, remove, change attribute ...).\r
 \r
-  @param  Operation              The type of the operation \r
-  @param  GcdMemoryType          Additional information for the operation \r
-  @param  GcdIoType              Additional information for the operation \r
-  @param  BaseAddress            Start address of the segment \r
-  @param  Length                 length of the segment \r
-  @param  Capabilities           The alterable attributes of a newly added entry \r
-  @param  Attributes             The attributes needs to be set \r
-\r
-  @retval EFI_INVALID_PARAMETER  Length is 0 or address (length) not aligned when \r
-                                 setting attribute. \r
-  @retval EFI_SUCCESS            Action successfully done. \r
-  @retval EFI_UNSUPPORTED        Could not find the proper descriptor on this \r
-                                 segment or  set an upsupported attribute. \r
-  @retval EFI_ACCESS_DENIED      Operate on an space non-exist or is used for an \r
-                                 image. \r
-  @retval EFI_NOT_FOUND          Free a non-using space or remove a non-exist \r
-                                 space, and so on. \r
+  @param  Operation              The type of the operation\r
+  @param  GcdMemoryType          Additional information for the operation\r
+  @param  GcdIoType              Additional information for the operation\r
+  @param  BaseAddress            Start address of the segment\r
+  @param  Length                 length of the segment\r
+  @param  Capabilities           The alterable attributes of a newly added entry\r
+  @param  Attributes             The attributes needs to be set\r
+\r
+  @retval EFI_INVALID_PARAMETER  Length is 0 or address (length) not aligned when\r
+                                 setting attribute.\r
+  @retval EFI_SUCCESS            Action successfully done.\r
+  @retval EFI_UNSUPPORTED        Could not find the proper descriptor on this\r
+                                 segment or  set an upsupported attribute.\r
+  @retval EFI_ACCESS_DENIED      Operate on an space non-exist or is used for an\r
+                                 image.\r
+  @retval EFI_NOT_FOUND          Free a non-using space or remove a non-exist\r
+                                 space, and so on.\r
   @retval EFI_OUT_OF_RESOURCES   No buffer could be allocated.\r
 \r
 **/\r
@@ -570,7 +570,7 @@ CoreConvertSpace (
   EFI_GCD_MAP_ENTRY  *BottomEntry;\r
   LIST_ENTRY         *StartLink;\r
   LIST_ENTRY         *EndLink;\r
-  \r
+\r
   EFI_CPU_ARCH_PROTOCOL           *CpuArch;\r
   UINT64                          CpuArchAttributes;\r
 \r
@@ -778,15 +778,15 @@ Done:
 /**\r
   Check whether an entry could be used to allocate space.\r
 \r
-  @param  Operation              Allocate memory or IO \r
-  @param  Entry                  The entry to be tested \r
-  @param  GcdMemoryType          The desired memory type \r
-  @param  GcdIoType              The desired IO type \r
+  @param  Operation              Allocate memory or IO\r
+  @param  Entry                  The entry to be tested\r
+  @param  GcdMemoryType          The desired memory type\r
+  @param  GcdIoType              The desired IO type\r
 \r
-  @retval EFI_NOT_FOUND          The memory type does not match or there's an \r
-                                 image handle on the entry. \r
-  @retval EFI_UNSUPPORTED        The operation unsupported. \r
-  @retval EFI_SUCCESS            It's ok for this entry to be used to allocate \r
+  @retval EFI_NOT_FOUND          The memory type does not match or there's an\r
+                                 image handle on the entry.\r
+  @retval EFI_UNSUPPORTED        The operation unsupported.\r
+  @retval EFI_SUCCESS            It's ok for this entry to be used to allocate\r
                                  space.\r
 \r
 **/\r
@@ -822,18 +822,18 @@ CoreAllocateSpaceCheckEntry (
 /**\r
   Allocate space on specified address and length.\r
 \r
-  @param  Operation              The type of operation (memory or IO) \r
-  @param  GcdAllocateType        The type of allocate operation \r
-  @param  GcdMemoryType          The desired memory type \r
-  @param  GcdIoType              The desired IO type \r
-  @param  Alignment              Align with 2^Alignment \r
-  @param  Length                 Length to allocate \r
-  @param  BaseAddress            Base address to allocate \r
-  @param  ImageHandle            The image handle consume the allocated space. \r
-  @param  DeviceHandle           The device handle consume the allocated space. \r
-\r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter. \r
-  @retval EFI_NOT_FOUND          No descriptor for the desired space exists. \r
+  @param  Operation              The type of operation (memory or IO)\r
+  @param  GcdAllocateType        The type of allocate operation\r
+  @param  GcdMemoryType          The desired memory type\r
+  @param  GcdIoType              The desired IO type\r
+  @param  Alignment              Align with 2^Alignment\r
+  @param  Length                 Length to allocate\r
+  @param  BaseAddress            Base address to allocate\r
+  @param  ImageHandle            The image handle consume the allocated space.\r
+  @param  DeviceHandle           The device handle consume the allocated space.\r
+\r
+  @retval EFI_INVALID_PARAMETER  Invalid parameter.\r
+  @retval EFI_NOT_FOUND          No descriptor for the desired space exists.\r
   @retval EFI_SUCCESS            Space successfully allocated.\r
 \r
 **/\r
@@ -1074,12 +1074,12 @@ Done:
 /**\r
   Add a segment of memory to GCD map.\r
 \r
-  @param  GcdMemoryType          Memory type of the segment. \r
-  @param  BaseAddress            Base address of the segment. \r
-  @param  Length                 Length of the segment. \r
-  @param  Capabilities           alterable attributes of the segment. \r
+  @param  GcdMemoryType          Memory type of the segment.\r
+  @param  BaseAddress            Base address of the segment.\r
+  @param  Length                 Length of the segment.\r
+  @param  Capabilities           alterable attributes of the segment.\r
 \r
-  @retval EFI_INVALID_PARAMETER  Invalid parameters. \r
+  @retval EFI_INVALID_PARAMETER  Invalid parameters.\r
   @retval EFI_SUCCESS            Successfully add a segment of memory space.\r
 \r
 **/\r
@@ -1109,16 +1109,16 @@ CoreInternalAddMemorySpace (
   Allocates nonexistent memory, reserved memory, system memory, or memorymapped\r
   I/O resources from the global coherency domain of the processor.\r
 \r
-  @param  GcdAllocateType        The type of allocate operation \r
-  @param  GcdMemoryType          The desired memory type \r
-  @param  Alignment              Align with 2^Alignment \r
-  @param  Length                 Length to allocate \r
-  @param  BaseAddress            Base address to allocate \r
-  @param  ImageHandle            The image handle consume the allocated space. \r
-  @param  DeviceHandle           The device handle consume the allocated space. \r
+  @param  GcdAllocateType        The type of allocate operation\r
+  @param  GcdMemoryType          The desired memory type\r
+  @param  Alignment              Align with 2^Alignment\r
+  @param  Length                 Length to allocate\r
+  @param  BaseAddress            Base address to allocate\r
+  @param  ImageHandle            The image handle consume the allocated space.\r
+  @param  DeviceHandle           The device handle consume the allocated space.\r
 \r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter. \r
-  @retval EFI_NOT_FOUND          No descriptor contains the desired space. \r
+  @retval EFI_INVALID_PARAMETER  Invalid parameter.\r
+  @retval EFI_NOT_FOUND          No descriptor contains the desired space.\r
   @retval EFI_SUCCESS            Memory space successfully allocated.\r
 \r
 **/\r
@@ -1134,14 +1134,14 @@ CoreAllocateMemorySpace (
   )\r
 {\r
   return CoreAllocateSpace (\r
-           GCD_ALLOCATE_MEMORY_OPERATION, \r
-           GcdAllocateType, \r
-           GcdMemoryType, \r
-           (EFI_GCD_IO_TYPE) 0, \r
-           Alignment, \r
-           Length, \r
-           BaseAddress, \r
-           ImageHandle, \r
+           GCD_ALLOCATE_MEMORY_OPERATION,\r
+           GcdAllocateType,\r
+           GcdMemoryType,\r
+           (EFI_GCD_IO_TYPE) 0,\r
+           Alignment,\r
+           Length,\r
+           BaseAddress,\r
+           ImageHandle,\r
            DeviceHandle\r
            );\r
 }\r
@@ -1151,10 +1151,10 @@ CoreAllocateMemorySpace (
   Adds reserved memory, system memory, or memory-mapped I/O resources to the\r
   global coherency domain of the processor.\r
 \r
-  @param  GcdMemoryType          Memory type of the memory space. \r
-  @param  BaseAddress            Base address of the memory space. \r
-  @param  Length                 Length of the memory space. \r
-  @param  Capabilities           alterable attributes of the memory space. \r
+  @param  GcdMemoryType          Memory type of the memory space.\r
+  @param  BaseAddress            Base address of the memory space.\r
+  @param  Length                 Length of the memory space.\r
+  @param  Capabilities           alterable attributes of the memory space.\r
 \r
   @retval EFI_SUCCESS            Merged this memory space into GCD map.\r
 \r
@@ -1181,7 +1181,7 @@ CoreAddMemorySpace (
     Status = CoreAllocateMemorySpace (\r
                EfiGcdAllocateAddress,\r
                GcdMemoryType,\r
-               EFI_PAGE_SHIFT,         \r
+               EFI_PAGE_SHIFT,\r
                PageLength,\r
                &PageBaseAddress,\r
                gDxeCoreImageHandle,\r
@@ -1200,7 +1200,7 @@ CoreAddMemorySpace (
         Status = CoreAllocateMemorySpace (\r
                    EfiGcdAllocateAddress,\r
                    GcdMemoryType,\r
-                   EFI_PAGE_SHIFT,         \r
+                   EFI_PAGE_SHIFT,\r
                    EFI_PAGE_SIZE,\r
                    &PageBaseAddress,\r
                    gDxeCoreImageHandle,\r
@@ -1226,8 +1226,8 @@ CoreAddMemorySpace (
   Frees nonexistent memory, reserved memory, system memory, or memory-mapped\r
   I/O resources from the global coherency domain of the processor.\r
 \r
-  @param  BaseAddress            Base address of the memory space. \r
-  @param  Length                 Length of the memory space. \r
+  @param  BaseAddress            Base address of the memory space.\r
+  @param  Length                 Length of the memory space.\r
 \r
   @retval EFI_SUCCESS            Space successfully freed.\r
 \r
@@ -1246,8 +1246,8 @@ CoreFreeMemorySpace (
   Removes reserved memory, system memory, or memory-mapped I/O resources from\r
   the global coherency domain of the processor.\r
 \r
-  @param  BaseAddress            Base address of the memory space. \r
-  @param  Length                 Length of the memory space. \r
+  @param  BaseAddress            Base address of the memory space.\r
+  @param  Length                 Length of the memory space.\r
 \r
   @retval EFI_SUCCESS            Successfully remove a segment of memory space.\r
 \r
@@ -1265,7 +1265,7 @@ CoreRemoveMemorySpace (
 /**\r
   Build a memory descriptor according to an entry.\r
 \r
-  @param  Descriptor             The descriptor to be built \r
+  @param  Descriptor             The descriptor to be built\r
   @param  Entry                  According to this entry\r
 \r
 **/\r
@@ -1288,10 +1288,10 @@ BuildMemoryDescriptor (
 /**\r
   Retrieves the descriptor for a memory region containing a specified address.\r
 \r
-  @param  BaseAddress            Specified start address \r
-  @param  Descriptor             Specified length \r
+  @param  BaseAddress            Specified start address\r
+  @param  Descriptor             Specified length\r
 \r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter \r
+  @retval EFI_INVALID_PARAMETER  Invalid parameter\r
   @retval EFI_SUCCESS            Successfully get memory space descriptor.\r
 \r
 **/\r
@@ -1316,7 +1316,7 @@ CoreGetMemorySpaceDescriptor (
   CoreAcquireGcdMemoryLock ();\r
 \r
   //\r
-  // Search for the list of descriptors that contain BaseAddress \r
+  // Search for the list of descriptors that contain BaseAddress\r
   //\r
   Status = CoreSearchGcdMapEntry (BaseAddress, 1, &StartLink, &EndLink, &mGcdMemorySpaceMap);\r
   if (EFI_ERROR (Status)) {\r
@@ -1339,11 +1339,11 @@ CoreGetMemorySpaceDescriptor (
   Modifies the attributes for a memory region in the global coherency domain of the\r
   processor.\r
 \r
-  @param  BaseAddress            Specified start address \r
-  @param  Length                 Specified length \r
-  @param  Attributes             Specified attributes \r
+  @param  BaseAddress            Specified start address\r
+  @param  Length                 Specified length\r
+  @param  Attributes             Specified attributes\r
 \r
-  @retval EFI_SUCCESS            Successfully set attribute of a segment of \r
+  @retval EFI_SUCCESS            Successfully set attribute of a segment of\r
                                  memory space.\r
 \r
 **/\r
@@ -1362,11 +1362,11 @@ CoreSetMemorySpaceAttributes (
   Returns a map of the memory resources in the global coherency domain of the\r
   processor.\r
 \r
-  @param  NumberOfDescriptors    Number of descriptors. \r
-  @param  MemorySpaceMap         Descriptor array \r
+  @param  NumberOfDescriptors    Number of descriptors.\r
+  @param  MemorySpaceMap         Descriptor array\r
 \r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter \r
-  @retval EFI_OUT_OF_RESOURCES   No enough buffer to allocate \r
+  @retval EFI_INVALID_PARAMETER  Invalid parameter\r
+  @retval EFI_OUT_OF_RESOURCES   No enough buffer to allocate\r
   @retval EFI_SUCCESS            Successfully get memory space map.\r
 \r
 **/\r
@@ -1429,11 +1429,11 @@ Done:
 /**\r
   Adds reserved I/O or I/O resources to the global coherency domain of the processor.\r
 \r
-  @param  GcdIoType              IO type of the segment. \r
-  @param  BaseAddress            Base address of the segment. \r
-  @param  Length                 Length of the segment. \r
+  @param  GcdIoType              IO type of the segment.\r
+  @param  BaseAddress            Base address of the segment.\r
+  @param  Length                 Length of the segment.\r
 \r
-  @retval EFI_SUCCESS            Merged this segment into GCD map. \r
+  @retval EFI_SUCCESS            Merged this segment into GCD map.\r
   @retval EFI_INVALID_PARAMETER  Parameter not valid\r
 \r
 **/\r
@@ -1458,16 +1458,16 @@ CoreAddIoSpace (
   Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency\r
   domain of the processor.\r
 \r
-  @param  GcdAllocateType        The type of allocate operation \r
-  @param  GcdIoType              The desired IO type \r
-  @param  Alignment              Align with 2^Alignment \r
-  @param  Length                 Length to allocate \r
-  @param  BaseAddress            Base address to allocate \r
-  @param  ImageHandle            The image handle consume the allocated space. \r
-  @param  DeviceHandle           The device handle consume the allocated space. \r
+  @param  GcdAllocateType        The type of allocate operation\r
+  @param  GcdIoType              The desired IO type\r
+  @param  Alignment              Align with 2^Alignment\r
+  @param  Length                 Length to allocate\r
+  @param  BaseAddress            Base address to allocate\r
+  @param  ImageHandle            The image handle consume the allocated space.\r
+  @param  DeviceHandle           The device handle consume the allocated space.\r
 \r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter. \r
-  @retval EFI_NOT_FOUND          No descriptor contains the desired space. \r
+  @retval EFI_INVALID_PARAMETER  Invalid parameter.\r
+  @retval EFI_NOT_FOUND          No descriptor contains the desired space.\r
   @retval EFI_SUCCESS            IO space successfully allocated.\r
 \r
 **/\r
@@ -1483,14 +1483,14 @@ CoreAllocateIoSpace (
   )\r
 {\r
   return CoreAllocateSpace (\r
-           GCD_ALLOCATE_IO_OPERATION, \r
-           GcdAllocateType, \r
-           (EFI_GCD_MEMORY_TYPE) 0, \r
-           GcdIoType, \r
-           Alignment, \r
-           Length, \r
-           BaseAddress, \r
-           ImageHandle, \r
+           GCD_ALLOCATE_IO_OPERATION,\r
+           GcdAllocateType,\r
+           (EFI_GCD_MEMORY_TYPE) 0,\r
+           GcdIoType,\r
+           Alignment,\r
+           Length,\r
+           BaseAddress,\r
+           ImageHandle,\r
            DeviceHandle\r
            );\r
 }\r
@@ -1500,8 +1500,8 @@ CoreAllocateIoSpace (
   Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency\r
   domain of the processor.\r
 \r
-  @param  BaseAddress            Base address of the segment. \r
-  @param  Length                 Length of the segment. \r
+  @param  BaseAddress            Base address of the segment.\r
+  @param  Length                 Length of the segment.\r
 \r
   @retval EFI_SUCCESS            Space successfully freed.\r
 \r
@@ -1520,8 +1520,8 @@ CoreFreeIoSpace (
   Removes reserved I/O or I/O resources from the global coherency domain of the\r
   processor.\r
 \r
-  @param  BaseAddress            Base address of the segment. \r
-  @param  Length                 Length of the segment. \r
+  @param  BaseAddress            Base address of the segment.\r
+  @param  Length                 Length of the segment.\r
 \r
   @retval EFI_SUCCESS            Successfully removed a segment of IO space.\r
 \r
@@ -1539,7 +1539,7 @@ CoreRemoveIoSpace (
 /**\r
   Build a IO descriptor according to an entry.\r
 \r
-  @param  Descriptor             The descriptor to be built \r
+  @param  Descriptor             The descriptor to be built\r
   @param  Entry                  According to this entry\r
 \r
 **/\r
@@ -1560,10 +1560,10 @@ BuildIoDescriptor (
 /**\r
   Retrieves the descriptor for an I/O region containing a specified address.\r
 \r
-  @param  BaseAddress            Specified start address \r
-  @param  Descriptor             Specified length \r
+  @param  BaseAddress            Specified start address\r
+  @param  Descriptor             Specified length\r
 \r
-  @retval EFI_INVALID_PARAMETER  Descriptor is NULL. \r
+  @retval EFI_INVALID_PARAMETER  Descriptor is NULL.\r
   @retval EFI_SUCCESS            Successfully get the IO space descriptor.\r
 \r
 **/\r
@@ -1588,7 +1588,7 @@ CoreGetIoSpaceDescriptor (
   CoreAcquireGcdIoLock ();\r
 \r
   //\r
-  // Search for the list of descriptors that contain BaseAddress \r
+  // Search for the list of descriptors that contain BaseAddress\r
   //\r
   Status = CoreSearchGcdMapEntry (BaseAddress, 1, &StartLink, &EndLink, &mGcdIoSpaceMap);\r
   if (EFI_ERROR (Status)) {\r
@@ -1610,11 +1610,11 @@ CoreGetIoSpaceDescriptor (
 /**\r
   Returns a map of the I/O resources in the global coherency domain of the processor.\r
 \r
-  @param  NumberOfDescriptors    Number of descriptors. \r
-  @param  IoSpaceMap             Descriptor array \r
+  @param  NumberOfDescriptors    Number of descriptors.\r
+  @param  IoSpaceMap             Descriptor array\r
 \r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter \r
-  @retval EFI_OUT_OF_RESOURCES   No enough buffer to allocate \r
+  @retval EFI_INVALID_PARAMETER  Invalid parameter\r
+  @retval EFI_OUT_OF_RESOURCES   No enough buffer to allocate\r
   @retval EFI_SUCCESS            Successfully get IO space map.\r
 \r
 **/\r
@@ -1671,16 +1671,16 @@ CoreGetIoSpaceMap (
 Done:\r
   CoreReleaseGcdIoLock ();\r
   return Status;\r
-}  \r
+}\r
 \r
 \r
 /**\r
   Converts a Resource Descriptor HOB attributes mask to an EFI Memory Descriptor\r
   capabilities mask\r
 \r
-  @param  GcdMemoryType          Type of resource in the GCD memory map. \r
-  @param  Attributes             The attribute mask in the Resource Descriptor \r
-                                 HOB. \r
+  @param  GcdMemoryType          Type of resource in the GCD memory map.\r
+  @param  Attributes             The attribute mask in the Resource Descriptor\r
+                                 HOB.\r
 \r
   @return The capabilities mask for an EFI Memory Descriptor.\r
 \r
@@ -1693,7 +1693,7 @@ CoreConvertResourceDescriptorHobAttributesToCapabilities (
 {\r
   UINT64                          Capabilities;\r
   GCD_ATTRIBUTE_CONVERSION_ENTRY  *Conversion;\r
-  \r
+\r
   //\r
   // Convert the Resource HOB Attributes to an EFI Memory Capabilities mask\r
   //\r
@@ -1704,7 +1704,7 @@ CoreConvertResourceDescriptorHobAttributesToCapabilities (
       }\r
     }\r
   }\r
-  \r
+\r
   return Capabilities;\r
 }\r
 \r
@@ -1717,10 +1717,10 @@ CoreConvertResourceDescriptorHobAttributesToCapabilities (
   memory descriptor is provided to the memory services.  Then the memory services\r
   can be used to intialize the GCD map.\r
 \r
-  @param  HobStart               The start address of the HOB. \r
-  @param  MemoryBaseAddress      Start address of memory region found to init DXE \r
-                                 core. \r
-  @param  MemoryLength           Length of memory region found to init DXE core. \r
+  @param  HobStart               The start address of the HOB.\r
+  @param  MemoryBaseAddress      Start address of memory region found to init DXE\r
+                                 core.\r
+  @param  MemoryLength           Length of memory region found to init DXE core.\r
 \r
   @retval EFI_SUCCESS            Memory services successfully initialized.\r
 \r
@@ -1807,7 +1807,7 @@ CoreInitializeMemoryServices (
       if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY                                       &&\r
           (ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES    ) {\r
 \r
-        if (PhitHob->EfiFreeMemoryBottom >= ResourceHob->PhysicalStart                         && \r
+        if (PhitHob->EfiFreeMemoryBottom >= ResourceHob->PhysicalStart                         &&\r
             PhitHob->EfiFreeMemoryTop    <= (ResourceHob->PhysicalStart + ResourceHob->ResourceLength)    ) {\r
 \r
           //\r
@@ -1931,10 +1931,10 @@ CoreInitializeMemoryServices (
   can be used to intialize the GCD map. The HobStart will be relocated to a pool\r
   buffer.\r
 \r
-  @param  HobStart               The start address of the HOB \r
-  @param  MemoryBaseAddress      Start address of memory region found to init DXE \r
-                                 core. \r
-  @param  MemoryLength           Length of memory region found to init DXE core. \r
+  @param  HobStart               The start address of the HOB\r
+  @param  MemoryBaseAddress      Start address of memory region found to init DXE\r
+                                 core.\r
+  @param  MemoryLength           Length of memory region found to init DXE core.\r
 \r
   @retval EFI_SUCCESS            GCD services successfully initialized.\r
 \r
@@ -1979,7 +1979,7 @@ CoreInitializeGcdServices (
   ASSERT (CpuHob != NULL);\r
   SizeOfMemorySpace = CpuHob->SizeOfMemorySpace;\r
   SizeOfIoSpace     = CpuHob->SizeOfIoSpace;\r
\r
+\r
   //\r
   // Initialize the GCD Memory Space Map\r
   //\r
@@ -2001,7 +2001,7 @@ CoreInitializeGcdServices (
   InsertHeadList (&mGcdIoSpaceMap, &Entry->Link);\r
 \r
   //\r
-  // Walk the HOB list and add all resource descriptors to the GCD \r
+  // Walk the HOB list and add all resource descriptors to the GCD\r
   //\r
   for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
 \r
@@ -2092,7 +2092,7 @@ CoreInitializeGcdServices (
       if (!EFI_ERROR (Status)) {\r
         Status = CoreAllocateMemorySpace (\r
                    EfiGcdAllocateAddress,\r
-                   Descriptor.GcdMemoryType, \r
+                   Descriptor.GcdMemoryType,\r
                    0,\r
                    MemoryHob->AllocDescriptor.MemoryLength,\r
                    &BaseAddress,\r
@@ -2115,7 +2115,7 @@ CoreInitializeGcdServices (
       BaseAddress = FirmwareVolumeHob->BaseAddress;\r
       Status = CoreAllocateMemorySpace (\r
                  EfiGcdAllocateAddress,\r
-                 EfiGcdMemoryTypeMemoryMappedIo, \r
+                 EfiGcdMemoryTypeMemoryMappedIo,\r
                  0,\r
                  FirmwareVolumeHob->Length,\r
                  &BaseAddress,\r
@@ -2129,7 +2129,7 @@ CoreInitializeGcdServices (
   // Relocate HOB List to an allocated pool buffer.\r
   //\r
   NewHobList = CoreAllocateCopyPool (\r
-                 (UINTN)PhitHob->EfiFreeMemoryBottom - (UINTN)(*HobStart), \r
+                 (UINTN)PhitHob->EfiFreeMemoryBottom - (UINTN)(*HobStart),\r
                  *HobStart\r
                  );\r
   ASSERT (NewHobList != NULL);\r