]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Image/Image.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Image / Image.c
index adeb4bf313a4009f028edb99a8dfc8cebc37725a..eddca140ee1a42647f6e4c7a2fd90349039373f9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Core image handling services to load and unload PeImage.\r
 \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -73,7 +73,7 @@ LOADED_IMAGE_PRIVATE_DATA mCorePrivateImage  = {
 //\r
 // The field is define for Loading modules at fixed address feature to tracker the PEI code\r
 // memory range usage. It is a bit mapped array in which every bit indicates the correspoding memory page\r
-// available or not. \r
+// available or not.\r
 //\r
 GLOBAL_REMOVE_IF_UNREFERENCED    UINT64                *mDxeCodeMemoryRangeUsageBitMap=NULL;\r
 \r
@@ -108,7 +108,7 @@ GetMachineTypeName (
   )\r
 {\r
   UINTN  Index;\r
-  \r
+\r
   for (Index = 0; Index < sizeof(mMachineTypeInfo)/sizeof(mMachineTypeInfo[0]); Index++) {\r
     if (mMachineTypeInfo[Index].MachineType == MachineType) {\r
       return mMachineTypeInfo[Index].MachineTypeName;\r
@@ -138,7 +138,7 @@ CoreInitializeImageServices (
   UINT64                            DxeCoreImageLength;\r
   VOID                              *DxeCoreEntryPoint;\r
   EFI_PEI_HOB_POINTERS              DxeCoreHob;\r
\r
+\r
   //\r
   // Searching for image hob\r
   //\r
@@ -158,7 +158,7 @@ CoreInitializeImageServices (
   DxeCoreImageLength      = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength;\r
   DxeCoreEntryPoint       = (VOID *) (UINTN) DxeCoreHob.MemoryAllocationModule->EntryPoint;\r
   gDxeCoreFileName        = &DxeCoreHob.MemoryAllocationModule->ModuleName;\r
-  \r
+\r
   //\r
   // Initialize the fields for an internal driver\r
   //\r
@@ -263,11 +263,11 @@ CoreReadImageFile (
 /**\r
   To check memory usage bit map array to figure out if the memory range the image will be loaded in 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
@@ -278,23 +278,23 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
   )\r
 {\r
    UINT32                             DxeCodePageNumber;\r
-   UINT64                             DxeCodeSize; \r
+   UINT64                             DxeCodeSize;\r
    EFI_PHYSICAL_ADDRESS               DxeCodeBase;\r
    UINTN                              BaseOffsetPageNumber;\r
    UINTN                              TopOffsetPageNumber;\r
    UINTN                              Index;\r
    //\r
    // The DXE code range includes RuntimeCodePage range and Boot time code range.\r
-   //  \r
+   //\r
    DxeCodePageNumber = PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber);\r
    DxeCodePageNumber += PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber);\r
    DxeCodeSize       = EFI_PAGES_TO_SIZE(DxeCodePageNumber);\r
    DxeCodeBase       =  gLoadModuleAtFixAddressConfigurationTable.DxeCodeTopAddress - DxeCodeSize;\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 (mDxeCodeMemoryRangeUsageBitMap == NULL) {\r
      mDxeCodeMemoryRangeUsageBitMap = AllocateZeroPool(((DxeCodePageNumber/64) + 1)*sizeof(UINT64));\r
    }\r
@@ -309,11 +309,11 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
    //\r
    if (gLoadModuleAtFixAddressConfigurationTable.DxeCodeTopAddress <  ImageBase + ImageSize ||\r
        DxeCodeBase >  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 - DxeCodeBase));\r
    TopOffsetPageNumber  = EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - DxeCodeBase));\r
    for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {\r
@@ -321,17 +321,17 @@ 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
      mDxeCodeMemoryRangeUsageBitMap[Index / 64] |= LShiftU64(1, (Index % 64));\r
    }\r
-   return  EFI_SUCCESS;   \r
+   return  EFI_SUCCESS;\r
 }\r
 /**\r
 \r
@@ -358,10 +358,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
    UINT16                             NumberOfSections;\r
    IMAGE_FILE_HANDLE                  *Handle;\r
    UINT64                             ValueInSectionHeader;\r
-                             \r
+\r
 \r
    Status = EFI_NOT_FOUND;\r
\r
+\r
    //\r
    // Get PeHeader pointer\r
    //\r
@@ -395,30 +395,30 @@ GetPeCoffImageFixLoadingAssignedAddress(
      }\r
 \r
      Status = EFI_NOT_FOUND;\r
-     \r
+\r
      if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_CNT_CODE) == 0) {\r
        //\r
        // Build tool will save the address in PointerToRelocations & PointerToLineNumbers fields in the first section header\r
-       // that doesn't point to code section in image header, as well as ImageBase field of image header. And there is an \r
-       // assumption that when the feature is enabled, if a module is assigned a loading address by tools, PointerToRelocations  \r
+       // that doesn't point to code section in image header, as well as ImageBase field of image header. And there is an\r
+       // assumption that when the feature is enabled, if a module is assigned a loading address by tools, PointerToRelocations\r
        // & PointerToLineNumbers fields should NOT be Zero, or else, these 2 fields should be set to Zero\r
        //\r
        ValueInSectionHeader = ReadUnaligned64((UINT64*)&SectionHeader.PointerToRelocations);\r
        if (ValueInSectionHeader != 0) {\r
          //\r
-         // When the feature is configured as load module at fixed absolute address, the ImageAddress field of ImageContext \r
+         // When the feature is configured as load module at fixed absolute address, the ImageAddress field of ImageContext\r
          // hold the spcified address. If the feature is configured as load module at fixed offset, ImageAddress hold an offset\r
          // relative to top address\r
          //\r
          if ((INT64)PcdGet64(PcdLoadModuleAtFixAddressEnable) < 0) {\r
-                ImageContext->ImageAddress = gLoadModuleAtFixAddressConfigurationTable.DxeCodeTopAddress + (INT64)(INTN)ImageContext->ImageAddress;\r
+            ImageContext->ImageAddress = gLoadModuleAtFixAddressConfigurationTable.DxeCodeTopAddress + (INT64)(INTN)ImageContext->ImageAddress;\r
          }\r
          //\r
          // Check if the memory range is available.\r
          //\r
          Status = CheckAndMarkFixLoadingMemoryUsageBitMap (ImageContext->ImageAddress, (UINTN)(ImageContext->ImageSize + ImageContext->SectionAlignment));\r
        }\r
-       break; \r
+       break;\r
      }\r
      SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
    }\r
@@ -541,17 +541,17 @@ CoreLoadPeImage (
 \r
       if (EFI_ERROR (Status))  {\r
           //\r
-         // If the code memory is not ready, invoke CoreAllocatePage with AllocateAnyPages to load the driver.\r
-         //\r
+          // If the code memory is not ready, invoke CoreAllocatePage with AllocateAnyPages to load the driver.\r
+          //\r
           DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Loading module at fixed address failed since specified memory is not available.\n"));\r
-        \r
+\r
           Status = CoreAllocatePages (\r
                      AllocateAnyPages,\r
                      (EFI_MEMORY_TYPE) (Image->ImageContext.ImageCodeMemoryType),\r
                      Image->NumberOfPages,\r
                      &Image->ImageContext.ImageAddress\r
-                     );         \r
-      } \r
+                     );\r
+      }\r
     } else {\r
       if (Image->ImageContext.ImageAddress >= 0x100000 || Image->ImageContext.RelocationsStripped) {\r
         Status = CoreAllocatePages (\r
@@ -1030,10 +1030,10 @@ CoreUnloadAndCloseImage (
   @retval EFI_LOAD_ERROR          Image was not loaded because the image format was corrupt or not\r
                                   understood.\r
   @retval EFI_DEVICE_ERROR        Image was not loaded because the device returned a read error.\r
-  @retval EFI_ACCESS_DENIED       Image was not loaded because the platform policy prohibits the \r
+  @retval EFI_ACCESS_DENIED       Image was not loaded because the platform policy prohibits the\r
                                   image from being loaded. NULL is returned in *ImageHandle.\r
-  @retval EFI_SECURITY_VIOLATION  Image was loaded and an ImageHandle was created with a \r
-                                  valid EFI_LOADED_IMAGE_PROTOCOL. However, the current \r
+  @retval EFI_SECURITY_VIOLATION  Image was loaded and an ImageHandle was created with a\r
+                                  valid EFI_LOADED_IMAGE_PROTOCOL. However, the current\r
                                   platform policy specifies that the image should not be started.\r
 \r
 **/\r
@@ -1145,7 +1145,7 @@ CoreLoadImageCommon (
     // Get the source file buffer by its device path.\r
     //\r
     FHand.Source = GetFileBufferByFilePath (\r
-                      BootPolicy, \r
+                      BootPolicy,\r
                       FilePath,\r
                       &FHand.SourceSize,\r
                       &AuthenticationStatus\r
@@ -1417,10 +1417,10 @@ Done:
   @retval EFI_LOAD_ERROR          Image was not loaded because the image format was corrupt or not\r
                                   understood.\r
   @retval EFI_DEVICE_ERROR        Image was not loaded because the device returned a read error.\r
-  @retval EFI_ACCESS_DENIED       Image was not loaded because the platform policy prohibits the \r
+  @retval EFI_ACCESS_DENIED       Image was not loaded because the platform policy prohibits the\r
                                   image from being loaded. NULL is returned in *ImageHandle.\r
-  @retval EFI_SECURITY_VIOLATION  Image was loaded and an ImageHandle was created with a \r
-                                  valid EFI_LOADED_IMAGE_PROTOCOL. However, the current \r
+  @retval EFI_SECURITY_VIOLATION  Image was loaded and an ImageHandle was created with a\r
+                                  valid EFI_LOADED_IMAGE_PROTOCOL. However, the current\r
                                   platform policy specifies that the image should not be started.\r
 \r
 **/\r
@@ -1453,10 +1453,10 @@ CoreLoadImage (
              EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION | EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION\r
              );\r
 \r
-  Handle = NULL; \r
+  Handle = NULL;\r
   if (!EFI_ERROR (Status)) {\r
     //\r
-    // ImageHandle will be valid only Status is success. \r
+    // ImageHandle will be valid only Status is success.\r
     //\r
     Handle = *ImageHandle;\r
   }\r
@@ -1498,10 +1498,10 @@ CoreLoadImage (
   @retval EFI_LOAD_ERROR          Image was not loaded because the image format was corrupt or not\r
                                   understood.\r
   @retval EFI_DEVICE_ERROR        Image was not loaded because the device returned a read error.\r
-  @retval EFI_ACCESS_DENIED       Image was not loaded because the platform policy prohibits the \r
+  @retval EFI_ACCESS_DENIED       Image was not loaded because the platform policy prohibits the\r
                                   image from being loaded. NULL is returned in *ImageHandle.\r
-  @retval EFI_SECURITY_VIOLATION  Image was loaded and an ImageHandle was created with a \r
-                                  valid EFI_LOADED_IMAGE_PROTOCOL. However, the current \r
+  @retval EFI_SECURITY_VIOLATION  Image was loaded and an ImageHandle was created with a\r
+                                  valid EFI_LOADED_IMAGE_PROTOCOL. However, the current\r
                                   platform policy specifies that the image should not be started.\r
 \r
 **/\r
@@ -1538,10 +1538,10 @@ CoreLoadImageEx (
            Attribute\r
            );\r
 \r
-  Handle = NULL; \r
+  Handle = NULL;\r
   if (!EFI_ERROR (Status)) {\r
     //\r
-    // ImageHandle will be valid only Status is success. \r
+    // ImageHandle will be valid only Status is success.\r
     //\r
     Handle = *ImageHandle;\r
   }\r