]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Image/Image.c
Move registration of DXE Core with PeCoffExtraActionLib after the lib constructors...
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Image / Image.c
index 7752fab70dc5f8880aa3f61cf9e132df17664326..2ffd6af9b6949afd9a606e6f182bc18b69cdfe97 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Core image handling services to load and unload PeImage.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2010, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -97,6 +97,7 @@ CoreInitializeImageServices (
   UINT64                            DxeCoreImageLength;\r
   VOID                              *DxeCoreEntryPoint;\r
   EFI_PEI_HOB_POINTERS              DxeCoreHob;\r
\r
   //\r
   // Searching for image hob\r
   //\r
@@ -116,6 +117,7 @@ CoreInitializeImageServices (
   DxeCoreImageLength      = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength;\r
   DxeCoreEntryPoint       = (VOID *) (UINTN) DxeCoreHob.MemoryAllocationModule->EntryPoint;\r
   gDxeCoreFileName        = &DxeCoreHob.MemoryAllocationModule->ModuleName;\r
+  \r
   //\r
   // Initialize the fields for an internal driver\r
   //\r
@@ -153,11 +155,11 @@ CoreInitializeImageServices (
     // Export DXE Core PE Loader functionality for backward compatibility.\r
     //\r
     Status = CoreInstallProtocolInterface (\r
-      &mLoadPe32PrivateData.Handle,\r
-      &gEfiLoadPeImageProtocolGuid,\r
-      EFI_NATIVE_INTERFACE,\r
-      &mLoadPe32PrivateData.Pe32Image\r
-      );\r
+               &mLoadPe32PrivateData.Handle,\r
+               &gEfiLoadPeImageProtocolGuid,\r
+               EFI_NATIVE_INTERFACE,\r
+               &mLoadPe32PrivateData.Pe32Image\r
+               );\r
   }\r
 \r
   return Status;\r
@@ -355,8 +357,8 @@ GetPeCoffImageFixLoadingAssignedAddress(
          // 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)FixedPcdGet64(PcdLoadModuleAtFixAddressEnable) < 0) {\r
-                ImageContext->ImageAddress = gLoadModuleAtFixAddressConfigurationTable.DxeCodeTopAddress + (INT64)ImageContext->ImageAddress;\r
+         if ((INT64)PcdGet64(PcdLoadModuleAtFixAddressEnable) < 0) {\r
+                ImageContext->ImageAddress = gLoadModuleAtFixAddressConfigurationTable.DxeCodeTopAddress + (INT64)(INTN)ImageContext->ImageAddress;\r
          }\r
          //\r
          // Check if the memory range is avaliable.\r
@@ -367,7 +369,7 @@ GetPeCoffImageFixLoadingAssignedAddress(
      }\r
      SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
    }\r
-   DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x. Status = %r \n", ImageContext->ImageAddress, Status));\r
+   DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address 0x%11p. Status = %r \n", (VOID *)(UINTN)(ImageContext->ImageAddress), Status));\r
    return Status;\r
 }\r
 /**\r
@@ -479,7 +481,7 @@ CoreLoadPeImage (
     // If Loading Module At Fixed Address feature is enabled, the module should be loaded to\r
     // a specified address.\r
     //\r
-    if (FixedPcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 ) {\r
+    if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 ) {\r
       Status = GetPeCoffImageFixLoadingAssignedAddress (&(Image->ImageContext));\r
 \r
       if (EFI_ERROR (Status))  {\r
@@ -603,7 +605,7 @@ CoreLoadPeImage (
     // Locate the EBC interpreter protocol\r
     //\r
     Status = CoreLocateProtocol (&gEfiEbcProtocolGuid, NULL, (VOID **)&Image->Ebc);\r
-    if (EFI_ERROR(Status)) {\r
+    if (EFI_ERROR(Status) || Image->Ebc == NULL) {\r
       DEBUG ((DEBUG_LOAD | DEBUG_ERROR, "CoreLoadPeImage: There is no EBC interpreter for an EBC image.\n"));\r
       goto Done;\r
     }\r
@@ -1095,12 +1097,13 @@ CoreLoadImageCommon (
   // Pull out just the file portion of the DevicePath for the LoadedImage FilePath\r
   //\r
   FilePath = OriginalFilePath;\r
-  Status = CoreHandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath);\r
-  if (!EFI_ERROR (Status)) {\r
-    FilePathSize = GetDevicePathSize (HandleFilePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);\r
-    FilePath = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *)FilePath) + FilePathSize );\r
+  if (DeviceHandle != NULL) {\r
+    Status = CoreHandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath);\r
+    if (!EFI_ERROR (Status)) {\r
+      FilePathSize = GetDevicePathSize (HandleFilePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);\r
+      FilePath = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *)FilePath) + FilePathSize );\r
+    }\r
   }\r
-\r
   //\r
   // Initialize the fields for an internal driver\r
   //\r