]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenFv/GenFvInternalLib.c
Sync BaseTools Branch (version r2321) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / C / GenFv / GenFvInternalLib.c
index 7368bbbf9c2dca06517c0ff0280100e699fda662..d86909b4df63e15df65eeabec1a4de3a35a0c9ba 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 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
@@ -809,6 +809,10 @@ Returns:
   }\r
 \r
   if (FfsFile->Type != EFI_FV_FILETYPE_SECURITY_CORE && pImageContext->Machine == EFI_IMAGE_MACHINE_IA64) {\r
+    //\r
+    // Process IPF PLABEL to get the real address after the image has been rebased. \r
+    // PLABEL structure is got by AddressOfEntryPoint offset to ImageBuffer stored in pImageContext->Handle.\r
+    //\r
     fprintf (FvMapFile, "EntryPoint=0x%010llx", (unsigned long long) (*(UINT64 *)((UINTN) pImageContext->Handle + (UINTN) AddressOfEntryPoint)));\r
   } else {\r
     fprintf (FvMapFile, "EntryPoint=0x%010llx", (unsigned long long) (ImageBaseAddress + AddressOfEntryPoint));\r
@@ -1081,7 +1085,11 @@ Returns:
       // Rebase the PE or TE image in FileBuffer of FFS file for XIP \r
       // Rebase for the debug genfvmap tool\r
       //\r
-      FfsRebase (FvInfo, FvInfo->FvFiles[Index], (EFI_FFS_FILE_HEADER *) FileBuffer, (UINTN) *VtfFileImage - (UINTN) FvImage->FileImage, FvMapFile);\r
+      Status = FfsRebase (FvInfo, FvInfo->FvFiles[Index], (EFI_FFS_FILE_HEADER *) FileBuffer, (UINTN) *VtfFileImage - (UINTN) FvImage->FileImage, FvMapFile);\r
+      if (EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 3000, "Invalid", "Could not rebase %s.", FvInfo->FvFiles[Index]);\r
+        return Status;\r
+      }          \r
       //\r
       // copy VTF File\r
       //\r
@@ -1120,7 +1128,11 @@ Returns:
     // Rebase the PE or TE image in FileBuffer of FFS file for XIP. \r
     // Rebase Bs and Rt drivers for the debug genfvmap tool.\r
     //\r
-    FfsRebase (FvInfo, FvInfo->FvFiles[Index], (EFI_FFS_FILE_HEADER *) FileBuffer, (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage, FvMapFile);\r
+    Status = FfsRebase (FvInfo, FvInfo->FvFiles[Index], (EFI_FFS_FILE_HEADER *) FileBuffer, (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage, FvMapFile);\r
+       if (EFI_ERROR (Status)) {\r
+         Error (NULL, 0, 3000, "Invalid", "Could not rebase %s.", FvInfo->FvFiles[Index]);\r
+         return Status;\r
+       }               \r
     //\r
     // Copy the file\r
     //\r
@@ -1819,7 +1831,7 @@ Returns:
   }\r
   \r
   // Add opcode for an uncondional branch with no link. AKA B SecEntryPoint\r
-  ResetVector[0] |= 0xEA000000;\r
+  ResetVector[0] |= 0xEB000000;\r
   \r
   \r
   // Address of PEI Core, if we have one\r
@@ -3016,7 +3028,7 @@ Returns:
       return EFI_OUT_OF_RESOURCES;\r
     }\r
     memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);\r
-    ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((INT64)ImageContext.SectionAlignment - 1));\r
+    ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((UINTN) ImageContext.SectionAlignment - 1));\r
     \r
     Status =  PeCoffLoaderLoadImage (&ImageContext);\r
     if (EFI_ERROR (Status)) {\r
@@ -3243,7 +3255,7 @@ Returns:
       return EFI_OUT_OF_RESOURCES;\r
     }\r
     memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);\r
-    ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~(ImageContext.SectionAlignment - 1));\r
+    ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((UINTN) ImageContext.SectionAlignment - 1));\r
 \r
     Status =  PeCoffLoaderLoadImage (&ImageContext);\r
     if (EFI_ERROR (Status)) {\r