Refactor the PeCoffLoader into a library. Add PeiRebase Tool.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@247 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
bbahnsen
2006-05-23 22:00:58 +00:00
parent 51d48c2666
commit 4df60ea54f
10 changed files with 380 additions and 31 deletions

View File

@@ -29,7 +29,6 @@ Abstract:
#include <string.h>
#include "CommonLib.h"
#include "ParseInf.h"
// #include <Guid/PeiPeCoffLoader.h>
#include "FvLib.h"
#include "EfiUtilityMsgs.h"
@@ -38,8 +37,6 @@ Abstract:
#include "PeiRebaseExe.h"
extern PEI_PE_COFF_LOADER_PROTOCOL mPeCoffLoader;
EFI_STATUS
ReadHeader (
IN FILE *InputFile,
@@ -491,7 +488,7 @@ Returns:
--*/
{
EFI_STATUS Status;
EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
UINTN MemoryImagePointer;
UINTN MemoryImagePointerAligned;
EFI_PHYSICAL_ADDRESS ImageAddress;
@@ -570,9 +567,9 @@ Returns:
//
memset (&ImageContext, 0, sizeof (ImageContext));
ImageContext.Handle = (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION));
ImageContext.ImageRead = (EFI_PEI_PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;
ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;
Status = mPeCoffLoader.GetImageInfo (&mPeCoffLoader, &ImageContext);
Status = PeCoffLoaderGetImageInfo (&ImageContext);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 0, "GetImageInfo() call failed on rebase", FileGuidString);
@@ -593,7 +590,7 @@ Returns:
ImageContext.ImageAddress = MemoryImagePointerAligned;
Status = mPeCoffLoader.LoadImage (&mPeCoffLoader, &ImageContext);
Status = PeCoffLoaderLoadImage (&ImageContext);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 0, "LoadImage() call failed on rebase", FileGuidString);
free ((VOID *) MemoryImagePointer);
@@ -601,7 +598,7 @@ Returns:
}
ImageContext.DestinationAddress = NewPe32BaseAddress;
Status = mPeCoffLoader.RelocateImage (&mPeCoffLoader, &ImageContext);
Status = PeCoffLoaderRelocateImage (&ImageContext);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 0, "RelocateImage() call failed on rebase", FileGuidString);
free ((VOID *) MemoryImagePointer);
@@ -802,9 +799,9 @@ Returns:
//
memset (&ImageContext, 0, sizeof (ImageContext));
ImageContext.Handle = (VOID *) TEBuffer;
ImageContext.ImageRead = (EFI_PEI_PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;
ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;
Status = mPeCoffLoader.GetImageInfo (&mPeCoffLoader, &ImageContext);
Status = PeCoffLoaderGetImageInfo (&ImageContext);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 0, "GetImageInfo() call failed on rebase of TE image", FileGuidString);
@@ -825,7 +822,7 @@ Returns:
ImageContext.ImageAddress = MemoryImagePointerAligned;
Status = mPeCoffLoader.LoadImage (&mPeCoffLoader, &ImageContext);
Status = PeCoffLoaderLoadImage (&ImageContext);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 0, "LoadImage() call failed on rebase of TE image", FileGuidString);
free (TEBuffer);
@@ -834,7 +831,7 @@ Returns:
}
ImageContext.DestinationAddress = NewPe32BaseAddress;
Status = mPeCoffLoader.RelocateImage (&mPeCoffLoader, &ImageContext);
Status = PeCoffLoaderRelocateImage (&ImageContext);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 0, "RelocateImage() call failed on rebase of TE image", FileGuidString);
free ((VOID *) MemoryImagePointer);