]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Dispatcher.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Dispatcher.c
index 0b3b5924d383be4be8c2a134052213d5db0e272c..7ad0d34178532c2fe95f2ce308e3dd784e484591 100644 (file)
   Depex - Dependency Expresion.\r
 \r
   Copyright (c) 2014, Hewlett-Packard Development Company, L.P.\r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials are licensed and made available \r
-  under the terms and conditions of the BSD License which accompanies this \r
-  distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
 \r
@@ -127,18 +127,18 @@ EFI_SECURITY2_ARCH_PROTOCOL *mSecurity2 = NULL;
 //\r
 // The global variable is defined for Loading modules at fixed address feature to track the SMM code\r
 // memory range usage. It is a bit mapped array in which every bit indicates the corresponding\r
-// memory page available or not. \r
+// memory page available or not.\r
 //\r
 GLOBAL_REMOVE_IF_UNREFERENCED    UINT64                *mSmmCodeMemoryRangeUsageBitMap=NULL;\r
 \r
 /**\r
   To check memory usage bit map array to figure out if the memory range in which the image will be loaded is available or not. If\r
   memory range is available, the function will mark the corresponding bits to 1 which indicates the memory range is used.\r
-  The function is only invoked when load modules at fixed address feature is enabled. \r
-  \r
+  The function is only invoked when load modules at fixed address feature is enabled.\r
+\r
   @param  ImageBase                The base address the image will be loaded at.\r
   @param  ImageSize                The size of the image\r
-  \r
+\r
   @retval EFI_SUCCESS              The memory range the image will be loaded in is available\r
   @retval EFI_NOT_FOUND            The memory range the image will be loaded in is not available\r
 **/\r
@@ -149,7 +149,7 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
   )\r
 {\r
    UINT32                             SmmCodePageNumber;\r
-   UINT64                             SmmCodeSize; \r
+   UINT64                             SmmCodeSize;\r
    EFI_PHYSICAL_ADDRESS               SmmCodeBase;\r
    UINTN                              BaseOffsetPageNumber;\r
    UINTN                              TopOffsetPageNumber;\r
@@ -160,11 +160,11 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
    SmmCodePageNumber = PcdGet32(PcdLoadFixAddressSmmCodePageNumber);\r
    SmmCodeSize = EFI_PAGES_TO_SIZE (SmmCodePageNumber);\r
    SmmCodeBase = gLoadModuleAtFixAddressSmramBase;\r
-   \r
+\r
    //\r
-   // If the memory usage bit map is not initialized,  do it. Every bit in the array \r
+   // If the memory usage bit map is not initialized,  do it. Every bit in the array\r
    // indicate the status of the corresponding memory page, available or not\r
-   // \r
+   //\r
    if (mSmmCodeMemoryRangeUsageBitMap == NULL) {\r
      mSmmCodeMemoryRangeUsageBitMap = AllocateZeroPool(((SmmCodePageNumber / 64) + 1)*sizeof(UINT64));\r
    }\r
@@ -178,11 +178,11 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
    // see if the memory range for loading the image is in the SMM code range.\r
    //\r
    if (SmmCodeBase + SmmCodeSize <  ImageBase + ImageSize || SmmCodeBase >  ImageBase) {\r
-     return EFI_NOT_FOUND;   \r
-   }   \r
+     return EFI_NOT_FOUND;\r
+   }\r
    //\r
    // Test if the memory is avalaible or not.\r
-   // \r
+   //\r
    BaseOffsetPageNumber = EFI_SIZE_TO_PAGES((UINT32)(ImageBase - SmmCodeBase));\r
    TopOffsetPageNumber  = EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - SmmCodeBase));\r
    for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {\r
@@ -190,22 +190,22 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
        //\r
        // This page is already used.\r
        //\r
-       return EFI_NOT_FOUND;  \r
+       return EFI_NOT_FOUND;\r
      }\r
    }\r
-   \r
+\r
    //\r
    // Being here means the memory range is available.  So mark the bits for the memory range\r
-   // \r
+   //\r
    for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {\r
      mSmmCodeMemoryRangeUsageBitMap[Index / 64] |= LShiftU64(1, (Index % 64));\r
    }\r
-   return  EFI_SUCCESS;   \r
+   return  EFI_SUCCESS;\r
 }\r
 /**\r
   Get the fixed loading address from image header assigned by build tool. This function only be called\r
   when Loading module at Fixed address feature enabled.\r
-  \r
+\r
   @param  ImageContext              Pointer to the image context structure that describes the PE/COFF\r
                                     image that needs to be examined by this function.\r
   @retval EFI_SUCCESS               An fixed loading address is assigned to this image by build tools .\r
@@ -398,7 +398,7 @@ SmmLoadImage (
                   &AuthenticationStatus\r
                   );\r
   }\r
-  \r
+\r
   if (EFI_ERROR (Status)) {\r
     if (Buffer != NULL) {\r
       gBS->FreePool (Buffer);\r
@@ -422,7 +422,7 @@ SmmLoadImage (
   //\r
   // Verify the Authentication Status through the Security Architectural Protocol\r
   // Only on images that have been read using Firmware Volume protocol.\r
-  // All SMM images are from FV protocol. \r
+  // All SMM images are from FV protocol.\r
   //\r
   if (!EFI_ERROR (SecurityStatus) && (mSecurity != NULL)) {\r
     SecurityStatus = mSecurity->FileAuthenticationState (\r
@@ -436,7 +436,7 @@ SmmLoadImage (
     Status = SecurityStatus;\r
     return Status;\r
   }\r
-  \r
+\r
   //\r
   // Initialize ImageContext\r
   //\r
@@ -468,7 +468,7 @@ SmmLoadImage (
       // following statements is to bypass SmmFreePages\r
       //\r
       PageCount = 0;\r
-      DstBuffer = (UINTN)gLoadModuleAtFixAddressSmramBase;   \r
+      DstBuffer = (UINTN)gLoadModuleAtFixAddressSmramBase;\r
     } else {\r
        DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Failed to load module at fixed address. \n"));\r
        //\r
@@ -476,7 +476,7 @@ SmmLoadImage (
        //\r
        PageCount = (UINTN)EFI_SIZE_TO_PAGES((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);\r
        DstBuffer = (UINTN)(-1);\r
-     \r
+\r
        Status = SmmAllocatePages (\r
                    AllocateMaxAddress,\r
                    EfiRuntimeServicesCode,\r
@@ -486,15 +486,15 @@ SmmLoadImage (
        if (EFI_ERROR (Status)) {\r
          if (Buffer != NULL) {\r
            gBS->FreePool (Buffer);\r
-         } \r
+         }\r
          return Status;\r
-       }     \r
+       }\r
       ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)DstBuffer;\r
     }\r
   } else {\r
      PageCount = (UINTN)EFI_SIZE_TO_PAGES((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);\r
      DstBuffer = (UINTN)(-1);\r
-     \r
+\r
      Status = SmmAllocatePages (\r
                   AllocateMaxAddress,\r
                   EfiRuntimeServicesCode,\r
@@ -507,7 +507,7 @@ SmmLoadImage (
        }\r
        return Status;\r
      }\r
-     \r
+\r
      ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)DstBuffer;\r
   }\r
   //\r
@@ -549,7 +549,7 @@ SmmLoadImage (
   // Save Image EntryPoint in DriverEntry\r
   //\r
   DriverEntry->ImageEntryPoint  = ImageContext.EntryPoint;\r
-  DriverEntry->ImageBuffer      = DstBuffer; \r
+  DriverEntry->ImageBuffer      = DstBuffer;\r
   DriverEntry->NumberOfPage     = PageCount;\r
 \r
   //\r
@@ -698,20 +698,20 @@ SmmLoadImage (
   //\r
   // Free buffer allocated by Fv->ReadSection.\r
   //\r
-  // The UEFI Boot Services FreePool() function must be used because Fv->ReadSection \r
+  // The UEFI Boot Services FreePool() function must be used because Fv->ReadSection\r
   // used the UEFI Boot Services AllocatePool() function\r
   //\r
   Status = gBS->FreePool(Buffer);\r
   if (!EFI_ERROR (Status) && EFI_ERROR (SecurityStatus)) {\r
     Status = SecurityStatus;\r
   }\r
-  return Status;  \r
+  return Status;\r
 }\r
 \r
 /**\r
   Preprocess dependency expression and update DriverEntry to reflect the\r
   state of  Before and After dependencies. If DriverEntry->Before\r
-  or DriverEntry->After is set it will never be cleared. \r
+  or DriverEntry->After is set it will never be cleared.\r
 \r
   @param  DriverEntry           DriverEntry element to update .\r
 \r
@@ -810,7 +810,7 @@ SmmGetDepexSectionAndPreProccess (
   drivers to run. Drain the mScheduledQueue and load and start a PE\r
   image for each driver. Search the mDiscoveredList to see if any driver can\r
   be placed on the mScheduledQueue. If no drivers are placed on the\r
-  mScheduledQueue exit the function. \r
+  mScheduledQueue exit the function.\r
 \r
   @retval EFI_SUCCESS           All of the SMM Drivers that could be dispatched\r
                                 have been run and the SMM Entry Point has been\r
@@ -945,11 +945,11 @@ SmmDispatcher (
 \r
       if (!PreviousSmmEntryPointRegistered && gSmmCorePrivate->SmmEntryPointRegistered) {\r
         //\r
-        // Return immediately if the SMM Entry Point was registered by the SMM \r
+        // Return immediately if the SMM Entry Point was registered by the SMM\r
         // Driver that was just dispatched.  The SMM IPL will reinvoke the SMM\r
-        // Core Dispatcher.  This is required so SMM Mode may be enabled as soon \r
-        // as all the dependent SMM Drivers for SMM Mode have been dispatched.  \r
-        // Once the SMM Entry Point has been registered, then SMM Mode will be \r
+        // Core Dispatcher.  This is required so SMM Mode may be enabled as soon\r
+        // as all the dependent SMM Drivers for SMM Mode have been dispatched.\r
+        // Once the SMM Entry Point has been registered, then SMM Mode will be\r
         // used.\r
         //\r
         gRequestDispatch = TRUE;\r
@@ -1437,14 +1437,14 @@ SmmDriverDispatchHandler (
     //\r
     // Free data allocated by Fv->ReadSection ()\r
     //\r
-    // The UEFI Boot Services FreePool() function must be used because Fv->ReadSection \r
+    // The UEFI Boot Services FreePool() function must be used because Fv->ReadSection\r
     // used the UEFI Boot Services AllocatePool() function\r
     //\r
     gBS->FreePool (AprioriFile);\r
   }\r
 \r
   //\r
-  // Execute the SMM Dispatcher on any newly discovered FVs and previously \r
+  // Execute the SMM Dispatcher on any newly discovered FVs and previously\r
   // discovered SMM drivers that have been discovered but not dispatched.\r
   //\r
   Status = SmmDispatcher ();\r
@@ -1456,7 +1456,7 @@ SmmDriverDispatchHandler (
     if (*CommBufferSize > 0) {\r
       if (Status == EFI_NOT_READY) {\r
         //\r
-        // If a the SMM Core Entry Point was just registered, then set flag to \r
+        // If a the SMM Core Entry Point was just registered, then set flag to\r
         // request the SMM Dispatcher to be restarted.\r
         //\r
         *(UINT8 *)CommBuffer = COMM_BUFFER_SMM_DISPATCH_RESTART;\r