]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Dispatcher / Dispatcher.c
index c4f629dadffe91d1e05f9c54510b1b6cffaf690e..f6bb35a5fe8d4c3726698021cd801501d4be3705 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   EFI PEI Core dispatch services\r
-  \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -44,9 +44,9 @@ DiscoverPeimsAndOrderWithApriori (
   EFI_GUID                            *FileGuid;\r
   EFI_PEI_FIRMWARE_VOLUME_PPI         *FvPpi;\r
   EFI_FV_FILE_INFO                    FileInfo;\r
-  \r
+\r
   FvPpi = CoreFileHandle->FvPpi;\r
-  \r
+\r
   //\r
   // Walk the FV and find all the PEIMs and the Apriori file.\r
   //\r
@@ -182,15 +182,15 @@ DiscoverPeimsAndOrderWithApriori (
 \r
 //\r
 // This is the minimum memory required by DxeCore initialization. When LMFA feature enabled,\r
-// This part of memory still need reserved on the very top of memory so that the DXE Core could  \r
+// This part of memory still need reserved on the very top of memory so that the DXE Core could\r
 // use these memory for data initialization. This macro should be sync with the same marco\r
 // defined in DXE Core.\r
 //\r
 #define MINIMUM_INITIAL_MEMORY_SIZE 0x10000\r
 /**\r
-  This function is to test if the memory range described in resource HOB is available or not. \r
-  \r
-  This function should only be invoked when Loading Module at Fixed Address(LMFA) feature is enabled. Some platform may allocate the \r
+  This function is to test if the memory range described in resource HOB is available or not.\r
+\r
+  This function should only be invoked when Loading Module at Fixed Address(LMFA) feature is enabled. Some platform may allocate the\r
   memory before PeiLoadFixAddressHook in invoked. so this function is to test if the memory range described by the input resource HOB is\r
   available or not.\r
 \r
@@ -203,41 +203,41 @@ PeiLoadFixAddressIsMemoryRangeAvailable (
   IN EFI_HOB_RESOURCE_DESCRIPTOR        *ResourceHob\r
   )\r
 {\r
-       EFI_HOB_MEMORY_ALLOCATION          *MemoryHob;\r
-       BOOLEAN                             IsAvailable;\r
-       EFI_PEI_HOB_POINTERS                Hob;\r
-       \r
+  EFI_HOB_MEMORY_ALLOCATION          *MemoryHob;\r
+  BOOLEAN                             IsAvailable;\r
+  EFI_PEI_HOB_POINTERS                Hob;\r
+\r
   IsAvailable = TRUE;\r
-       if (PrivateData == NULL || ResourceHob == NULL) {\r
-         return FALSE;\r
-       }\r
-       //\r
+  if (PrivateData == NULL || ResourceHob == NULL) {\r
+    return FALSE;\r
+  }\r
+  //\r
   // test if the memory range describe in the HOB is already allocated.\r
   //\r
   for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
-    //                                                              \r
-    // See if this is a memory allocation HOB                     \r
     //\r
-    if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) { \r
+    // See if this is a memory allocation HOB\r
+    //\r
+    if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
       MemoryHob = Hob.MemoryAllocation;\r
-      if(MemoryHob->AllocDescriptor.MemoryBaseAddress == ResourceHob->PhysicalStart && \r
+      if(MemoryHob->AllocDescriptor.MemoryBaseAddress == ResourceHob->PhysicalStart &&\r
          MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength == ResourceHob->PhysicalStart + ResourceHob->ResourceLength) {\r
          IsAvailable = FALSE;\r
-         break;  \r
+         break;\r
        }\r
      }\r
   }\r
-  \r
+\r
   return IsAvailable;\r
-       \r
+\r
 }\r
 /**\r
   Hook function for Loading Module at Fixed Address feature\r
-  \r
+\r
   This function should only be invoked when Loading Module at Fixed Address(LMFA) feature is enabled. When feature is\r
-  configured as Load Modules at Fix Absolute Address, this function is to validate the top address assigned by user. When \r
-  feature is configured as Load Modules at Fixed Offset, the functino is to find the top address which is TOLM-TSEG in general.  \r
-  And also the function will re-install PEI memory. \r
+  configured as Load Modules at Fix Absolute Address, this function is to validate the top address assigned by user. When\r
+  feature is configured as Load Modules at Fixed Offset, the functino is to find the top address which is TOLM-TSEG in general.\r
+  And also the function will re-install PEI memory.\r
 \r
   @param PrivateData         Pointer to the private data passed in from caller\r
 \r
@@ -251,7 +251,7 @@ PeiLoadFixAddressHook(
   UINT64                             PeiMemorySize;\r
   UINT64                             TotalReservedMemorySize;\r
   UINT64                             MemoryRangeEnd;\r
-  EFI_PHYSICAL_ADDRESS               HighAddress; \r
+  EFI_PHYSICAL_ADDRESS               HighAddress;\r
   EFI_HOB_RESOURCE_DESCRIPTOR        *ResourceHob;\r
   EFI_HOB_RESOURCE_DESCRIPTOR        *NextResourceHob;\r
   EFI_HOB_RESOURCE_DESCRIPTOR        *CurrentResourceHob;\r
@@ -273,89 +273,89 @@ PeiLoadFixAddressHook(
   //\r
   // The top reserved memory include 3 parts: the topest range is for DXE core initialization with the size  MINIMUM_INITIAL_MEMORY_SIZE\r
   // then RuntimeCodePage range and Boot time code range.\r
-  //  \r
+  //\r
   TotalReservedMemorySize = MINIMUM_INITIAL_MEMORY_SIZE + EFI_PAGES_TO_SIZE(PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber));\r
-  TotalReservedMemorySize+= EFI_PAGES_TO_SIZE(PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber)) ;  \r
+  TotalReservedMemorySize+= EFI_PAGES_TO_SIZE(PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber)) ;\r
   //\r
   // PEI memory range lies below the top reserved memory\r
-  // \r
+  //\r
   TotalReservedMemorySize += PeiMemorySize;\r
-  \r
+\r
   DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressRuntimeCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber)));\r
   DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressBootTimeCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber)));\r
-  DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressPeiCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressPeiCodePageNumber)));   \r
+  DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressPeiCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressPeiCodePageNumber)));\r
   DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: Total Reserved Memory Size = 0x%lx.\n", TotalReservedMemorySize));\r
   //\r
-  // Loop through the system memory typed hob to merge the adjacent memory range \r
+  // Loop through the system memory typed hob to merge the adjacent memory range\r
   //\r
   for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
-    //                                                              \r
-    // See if this is a resource descriptor HOB                     \r
+    //\r
+    // See if this is a resource descriptor HOB\r
     //\r
     if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
-      \r
-      ResourceHob = Hob.ResourceDescriptor;  \r
+\r
+      ResourceHob = Hob.ResourceDescriptor;\r
       //\r
       // If range described in this hob is not system memory or heigher than MAX_ADDRESS, ignored.\r
       //\r
       if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY ||\r
           ResourceHob->PhysicalStart + ResourceHob->ResourceLength > MAX_ADDRESS)   {\r
         continue;\r
-      }   \r
-      \r
-      for (NextHob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(NextHob); NextHob.Raw = GET_NEXT_HOB(NextHob)) {       \r
+      }\r
+\r
+      for (NextHob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(NextHob); NextHob.Raw = GET_NEXT_HOB(NextHob)) {\r
         if (NextHob.Raw == Hob.Raw){\r
           continue;\r
-        }  \r
+        }\r
         //\r
         // See if this is a resource descriptor HOB\r
         //\r
         if (GET_HOB_TYPE (NextHob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
-      \r
+\r
           NextResourceHob = NextHob.ResourceDescriptor;\r
           //\r
           // test if range described in this NextResourceHob is system memory and have the same attribute.\r
           // Note: Here is a assumption that system memory should always be healthy even without test.\r
-          //    \r
+          //\r
           if (NextResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&\r
              (((NextResourceHob->ResourceAttribute^ResourceHob->ResourceAttribute)&(~EFI_RESOURCE_ATTRIBUTE_TESTED)) == 0)){\r
-              \r
+\r
               //\r
               // See if the memory range described in ResourceHob and NextResourceHob is adjacent\r
               //\r
-              if ((ResourceHob->PhysicalStart <= NextResourceHob->PhysicalStart && \r
-                    ResourceHob->PhysicalStart + ResourceHob->ResourceLength >= NextResourceHob->PhysicalStart)|| \r
+              if ((ResourceHob->PhysicalStart <= NextResourceHob->PhysicalStart &&\r
+                    ResourceHob->PhysicalStart + ResourceHob->ResourceLength >= NextResourceHob->PhysicalStart)||\r
                   (ResourceHob->PhysicalStart >= NextResourceHob->PhysicalStart&&\r
                      ResourceHob->PhysicalStart <= NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength)) {\r
-             \r
+\r
                 MemoryRangeEnd = ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength)>(NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength)) ?\r
                                      (ResourceHob->PhysicalStart + ResourceHob->ResourceLength):(NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength);\r
-          \r
-                ResourceHob->PhysicalStart = (ResourceHob->PhysicalStart < NextResourceHob->PhysicalStart) ? \r
+\r
+                ResourceHob->PhysicalStart = (ResourceHob->PhysicalStart < NextResourceHob->PhysicalStart) ?\r
                                                     ResourceHob->PhysicalStart : NextResourceHob->PhysicalStart;\r
-                \r
-               \r
+\r
+\r
                 ResourceHob->ResourceLength = (MemoryRangeEnd - ResourceHob->PhysicalStart);\r
-                \r
+\r
                 ResourceHob->ResourceAttribute = ResourceHob->ResourceAttribute & (~EFI_RESOURCE_ATTRIBUTE_TESTED);\r
                 //\r
                 // Delete the NextResourceHob by marking it as unused.\r
                 //\r
                 GET_HOB_TYPE (NextHob) = EFI_HOB_TYPE_UNUSED;\r
-                \r
+\r
               }\r
            }\r
-        } \r
+        }\r
       }\r
-    } \r
+    }\r
   }\r
   //\r
   // Some platform is already allocated pages before the HOB re-org. Here to build dedicated resource HOB to describe\r
   //  the allocated memory range\r
   //\r
   for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
-    //                                                              \r
-    // See if this is a memory allocation HOB                     \r
+    //\r
+    // See if this is a memory allocation HOB\r
     //\r
     if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
       MemoryHob = Hob.MemoryAllocation;\r
@@ -364,7 +364,7 @@ PeiLoadFixAddressHook(
         // See if this is a resource descriptor HOB\r
         //\r
         if (GET_HOB_TYPE (NextHob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
-               NextResourceHob = NextHob.ResourceDescriptor;\r
+          NextResourceHob = NextHob.ResourceDescriptor;\r
           //\r
           // If range described in this hob is not system memory or heigher than MAX_ADDRESS, ignored.\r
           //\r
@@ -373,26 +373,26 @@ PeiLoadFixAddressHook(
           }\r
           //\r
           // If the range describe in memory allocation HOB  belongs to the memroy range described by the resource hob\r
-          //          \r
-          if (MemoryHob->AllocDescriptor.MemoryBaseAddress >= NextResourceHob->PhysicalStart && \r
+          //\r
+          if (MemoryHob->AllocDescriptor.MemoryBaseAddress >= NextResourceHob->PhysicalStart &&\r
               MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength <= NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength) {\r
              //\r
              // Build seperate resource hob for this allocated range\r
-             //                     \r
+             //\r
              if (MemoryHob->AllocDescriptor.MemoryBaseAddress > NextResourceHob->PhysicalStart) {\r
                BuildResourceDescriptorHob (\r
-                 EFI_RESOURCE_SYSTEM_MEMORY,                       \r
+                 EFI_RESOURCE_SYSTEM_MEMORY,\r
                  NextResourceHob->ResourceAttribute,\r
-                 NextResourceHob->PhysicalStart,                             \r
-                 (MemoryHob->AllocDescriptor.MemoryBaseAddress - NextResourceHob->PhysicalStart)      \r
+                 NextResourceHob->PhysicalStart,\r
+                 (MemoryHob->AllocDescriptor.MemoryBaseAddress - NextResourceHob->PhysicalStart)\r
                );\r
              }\r
              if (MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength < NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength) {\r
                BuildResourceDescriptorHob (\r
-                 EFI_RESOURCE_SYSTEM_MEMORY,                       \r
+                 EFI_RESOURCE_SYSTEM_MEMORY,\r
                  NextResourceHob->ResourceAttribute,\r
-                 MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength,                            \r
-                 (NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength -(MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength))    \r
+                 MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength,\r
+                 (NextResourceHob->PhysicalStart + NextResourceHob->ResourceLength -(MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength))\r
                );\r
              }\r
              NextResourceHob->PhysicalStart = MemoryHob->AllocDescriptor.MemoryBaseAddress;\r
@@ -406,7 +406,7 @@ PeiLoadFixAddressHook(
 \r
   //\r
   // Try to find and validate the TOP address.\r
-  //  \r
+  //\r
   if ((INT64)PcdGet64(PcdLoadModuleAtFixAddressEnable) > 0 ) {\r
     //\r
     // The LMFA feature is enabled as load module at fixed absolute address.\r
@@ -417,11 +417,11 @@ PeiLoadFixAddressHook(
     // validate the Address. Loop the resource descriptor HOB to make sure the address is in valid memory range\r
     //\r
     if ((TopLoadingAddress & EFI_PAGE_MASK) != 0) {\r
-      DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid since top address should be page align. \n", TopLoadingAddress)); \r
-      ASSERT (FALSE);    \r
+      DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid since top address should be page align. \n", TopLoadingAddress));\r
+      ASSERT (FALSE);\r
     }\r
     //\r
-    // Search for a memory region that is below MAX_ADDRESS and in which TopLoadingAddress lies \r
+    // Search for a memory region that is below MAX_ADDRESS and in which TopLoadingAddress lies\r
     //\r
     for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
       //\r
@@ -432,61 +432,61 @@ PeiLoadFixAddressHook(
         ResourceHob = Hob.ResourceDescriptor;\r
         //\r
         // See if this resource descrior HOB describes tested system memory below MAX_ADDRESS\r
-        //    \r
+        //\r
         if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&\r
             ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MAX_ADDRESS) {\r
             //\r
             // See if Top address specified by user is valid.\r
             //\r
-            if (ResourceHob->PhysicalStart + TotalReservedMemorySize < TopLoadingAddress && \r
-                (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - MINIMUM_INITIAL_MEMORY_SIZE) >= TopLoadingAddress && \r
+            if (ResourceHob->PhysicalStart + TotalReservedMemorySize < TopLoadingAddress &&\r
+                (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - MINIMUM_INITIAL_MEMORY_SIZE) >= TopLoadingAddress &&\r
                 PeiLoadFixAddressIsMemoryRangeAvailable(PrivateData, ResourceHob)) {\r
-              CurrentResourceHob = ResourceHob; \r
+              CurrentResourceHob = ResourceHob;\r
               CurrentHob = Hob;\r
               break;\r
            }\r
         }\r
-      }  \r
-    }  \r
+      }\r
+    }\r
     if (CurrentResourceHob != NULL) {\r
       DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO:Top Address 0x%lx is valid \n",  TopLoadingAddress));\r
-      TopLoadingAddress += MINIMUM_INITIAL_MEMORY_SIZE; \r
+      TopLoadingAddress += MINIMUM_INITIAL_MEMORY_SIZE;\r
     } else {\r
-      DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid \n",  TopLoadingAddress)); \r
-      DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:The recommended Top Address for the platform is: \n")); \r
+      DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid \n",  TopLoadingAddress));\r
+      DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:The recommended Top Address for the platform is: \n"));\r
       //\r
       // Print the recomended Top address range.\r
-      // \r
+      //\r
       for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
         //\r
         // See if this is a resource descriptor HOB\r
         //\r
         if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
-        \r
+\r
           ResourceHob = Hob.ResourceDescriptor;\r
           //\r
           // See if this resource descrior HOB describes tested system memory below MAX_ADDRESS\r
-          //    \r
+          //\r
           if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&\r
               ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MAX_ADDRESS) {\r
               //\r
               // See if Top address specified by user is valid.\r
               //\r
               if (ResourceHob->ResourceLength > TotalReservedMemorySize && PeiLoadFixAddressIsMemoryRangeAvailable(PrivateData, ResourceHob)) {\r
-                 DEBUG ((EFI_D_INFO, "(0x%lx, 0x%lx)\n",  \r
-                          (ResourceHob->PhysicalStart + TotalReservedMemorySize -MINIMUM_INITIAL_MEMORY_SIZE), \r
-                          (ResourceHob->PhysicalStart + ResourceHob->ResourceLength -MINIMUM_INITIAL_MEMORY_SIZE) \r
-                        )); \r
+                 DEBUG ((EFI_D_INFO, "(0x%lx, 0x%lx)\n",\r
+                          (ResourceHob->PhysicalStart + TotalReservedMemorySize -MINIMUM_INITIAL_MEMORY_SIZE),\r
+                          (ResourceHob->PhysicalStart + ResourceHob->ResourceLength -MINIMUM_INITIAL_MEMORY_SIZE)\r
+                        ));\r
               }\r
           }\r
         }\r
-      }  \r
+      }\r
       //\r
-      // Assert here \r
+      // Assert here\r
       //\r
-      ASSERT (FALSE);   \r
-      return;   \r
-    }     \r
+      ASSERT (FALSE);\r
+      return;\r
+    }\r
   } else {\r
     //\r
     // The LMFA feature is enabled as load module at fixed offset relative to TOLM\r
@@ -497,15 +497,15 @@ PeiLoadFixAddressHook(
     //\r
     for (Hob.Raw = PrivateData->HobList.Raw; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
       //\r
-      // See if this is a resource descriptor HOB \r
+      // See if this is a resource descriptor HOB\r
       //\r
       if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
-        \r
-        ResourceHob = Hob.ResourceDescriptor;                                                                                                                                                                                                                               \r
+\r
+        ResourceHob = Hob.ResourceDescriptor;\r
         //\r
         // See if this resource descrior HOB describes tested system memory below MAX_ADDRESS\r
         //\r
-        if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY && \r
+        if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&\r
             ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MAX_ADDRESS &&\r
             ResourceHob->ResourceLength > TotalReservedMemorySize && PeiLoadFixAddressIsMemoryRangeAvailable(PrivateData, ResourceHob)) {\r
           //\r
@@ -517,26 +517,26 @@ PeiLoadFixAddressHook(
              HighAddress = CurrentResourceHob->PhysicalStart;\r
           }\r
         }\r
-      }  \r
+      }\r
     }\r
     if (CurrentResourceHob == NULL) {\r
-      DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:The System Memory is too small\n")); \r
+      DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:The System Memory is too small\n"));\r
       //\r
-      // Assert here \r
+      // Assert here\r
       //\r
       ASSERT (FALSE);\r
-      return;  \r
+      return;\r
     } else {\r
-      TopLoadingAddress = CurrentResourceHob->PhysicalStart + CurrentResourceHob->ResourceLength ; \r
-    }         \r
+      TopLoadingAddress = CurrentResourceHob->PhysicalStart + CurrentResourceHob->ResourceLength ;\r
+    }\r
   }\r
-  \r
+\r
   if (CurrentResourceHob != NULL) {\r
     //\r
     // rebuild resource HOB for PEI memmory and reserved memory\r
     //\r
     BuildResourceDescriptorHob (\r
-      EFI_RESOURCE_SYSTEM_MEMORY,                       \r
+      EFI_RESOURCE_SYSTEM_MEMORY,\r
       (\r
       EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
       EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
@@ -546,15 +546,15 @@ PeiLoadFixAddressHook(
       EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
       EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
       ),\r
-      (TopLoadingAddress - TotalReservedMemorySize),                             \r
-      TotalReservedMemorySize     \r
+      (TopLoadingAddress - TotalReservedMemorySize),\r
+      TotalReservedMemorySize\r
     );\r
     //\r
     // rebuild resource for the remain memory if necessary\r
     //\r
     if (CurrentResourceHob->PhysicalStart < TopLoadingAddress - TotalReservedMemorySize) {\r
       BuildResourceDescriptorHob (\r
-        EFI_RESOURCE_SYSTEM_MEMORY,                       \r
+        EFI_RESOURCE_SYSTEM_MEMORY,\r
         (\r
          EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
          EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
@@ -563,13 +563,13 @@ PeiLoadFixAddressHook(
          EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
          EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
          ),\r
-         CurrentResourceHob->PhysicalStart,                             \r
-         (TopLoadingAddress - TotalReservedMemorySize - CurrentResourceHob->PhysicalStart)      \r
+         CurrentResourceHob->PhysicalStart,\r
+         (TopLoadingAddress - TotalReservedMemorySize - CurrentResourceHob->PhysicalStart)\r
        );\r
     }\r
     if (CurrentResourceHob->PhysicalStart + CurrentResourceHob->ResourceLength  > TopLoadingAddress ) {\r
       BuildResourceDescriptorHob (\r
-        EFI_RESOURCE_SYSTEM_MEMORY,                     \r
+        EFI_RESOURCE_SYSTEM_MEMORY,\r
         (\r
          EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
          EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
@@ -578,21 +578,21 @@ PeiLoadFixAddressHook(
          EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
          EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
          ),\r
-         TopLoadingAddress,                            \r
-         (CurrentResourceHob->PhysicalStart + CurrentResourceHob->ResourceLength  - TopLoadingAddress)     \r
+         TopLoadingAddress,\r
+         (CurrentResourceHob->PhysicalStart + CurrentResourceHob->ResourceLength  - TopLoadingAddress)\r
        );\r
     }\r
     //\r
     // Delete CurrentHob by marking it as unused since the the memory range described by is rebuilt.\r
     //\r
-    GET_HOB_TYPE (CurrentHob) = EFI_HOB_TYPE_UNUSED;         \r
+    GET_HOB_TYPE (CurrentHob) = EFI_HOB_TYPE_UNUSED;\r
   }\r
 \r
   //\r
   // Cache the top address for Loading Module at Fixed Address feature\r
   //\r
   PrivateData->LoadModuleAtFixAddressTopAddress = TopLoadingAddress - MINIMUM_INITIAL_MEMORY_SIZE;\r
-  DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: Top address = 0x%lx\n",  PrivateData->LoadModuleAtFixAddressTopAddress)); \r
+  DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: Top address = 0x%lx\n",  PrivateData->LoadModuleAtFixAddressTopAddress));\r
   //\r
   // reinstall the PEI memory relative to TopLoadingAddress\r
   //\r
@@ -729,7 +729,7 @@ PeiCheckAndSwitchStack (
     ASSERT (NewStackSize >= SecCoreData->StackSize);\r
 \r
     //\r
-    // Calculate stack offset and heap offset between temporary memory and new permement \r
+    // Calculate stack offset and heap offset between temporary memory and new permement\r
     // memory seperately.\r
     //\r
     TopOfOldStack = (UINTN)SecCoreData->StackBase + SecCoreData->StackSize;\r
@@ -796,9 +796,9 @@ PeiCheckAndSwitchStack (
       }\r
 \r
       //\r
-      // Temporary Ram Support PPI is provided by platform, it will copy \r
+      // Temporary Ram Support PPI is provided by platform, it will copy\r
       // temporary memory to permanent memory and do stack switching.\r
-      // After invoking Temporary Ram Support PPI, the following code's \r
+      // After invoking Temporary Ram Support PPI, the following code's\r
       // stack is in permanent memory.\r
       //\r
       TemporaryRamSupportPpi->TemporaryRamMigration (\r
@@ -961,7 +961,7 @@ PeiDispatcher (
   EFI_PEI_FILE_HANDLE                 SaveCurrentFileHandle;\r
   EFI_FV_FILE_INFO                    FvFileInfo;\r
   PEI_CORE_FV_HANDLE                  *CoreFvHandle;\r
-  \r
+\r
   PeiServices = (CONST EFI_PEI_SERVICES **) &Private->Ps;\r
   PeimEntryPoint = NULL;\r
   PeimFileHandle = NULL;\r
@@ -1028,7 +1028,7 @@ PeiDispatcher (
   //\r
   do {\r
     //\r
-    // In case that reenter PeiCore happens, the last pass record is still available.   \r
+    // In case that reenter PeiCore happens, the last pass record is still available.\r
     //\r
     if (!Private->PeimDispatcherReenter) {\r
       Private->PeimNeedingDispatch      = FALSE;\r
@@ -1036,18 +1036,18 @@ PeiDispatcher (
     } else {\r
       Private->PeimDispatcherReenter    = FALSE;\r
     }\r
-    \r
+\r
     for (FvCount = Private->CurrentPeimFvCount; FvCount < Private->FvCount; FvCount++) {\r
       CoreFvHandle = FindNextCoreFvHandle (Private, FvCount);\r
       ASSERT (CoreFvHandle != NULL);\r
-      \r
+\r
       //\r
       // If the FV has corresponding EFI_PEI_FIRMWARE_VOLUME_PPI instance, then dispatch it.\r
       //\r
       if (CoreFvHandle->FvPpi == NULL) {\r
         continue;\r
       }\r
-      \r
+\r
       Private->CurrentPeimFvCount = FvCount;\r
 \r
       if (Private->CurrentPeimCount == 0) {\r
@@ -1297,7 +1297,7 @@ DepexSatisfied (
   } else {\r
     DEBUG ((DEBUG_DISPATCH, "Evaluate PEI DEPEX for FFS(%g)\n", &FileInfo.FileName));\r
   }\r
-  \r
+\r
   if (PeimCount < Private->AprioriCount) {\r
     //\r
     // If its in the A priori file then we set Depex to TRUE\r