Updated to support passing PE/COFF and LZMA decompress up via HOBS. Currently turned off.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9887 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish
2010-01-31 01:39:20 +00:00
parent 3370d33e8d
commit ca3ad58bfa
13 changed files with 75 additions and 67 deletions

View File

@@ -21,6 +21,9 @@
#include <Protocol/PeCoffLoader.h>
PE_COFF_LOADER_PROTOCOL *gPeCoffLoader = NULL;
/**
Retrieves information about a PE/COFF image.
@@ -167,11 +170,11 @@ PeCoffLoaderImageReadFromMemory (
OUT VOID *Buffer
)
{
return gPeCoffLoader->RelocateImageForRuntime (
*FileHandle,
return gPeCoffLoader->ReadFromMemory (
FileHandle,
FileOffset,
*ReadSize,
*Buffer
ReadSize,
Buffer
);
}
@@ -214,7 +217,7 @@ PeCoffLoaderRelocateImageForRuntime (
ImageBase,
VirtImageBase,
ImageSize,
*RelocationData
RelocationData
);
}
@@ -244,27 +247,42 @@ PeCoffLoaderUnloadImage (
return gPeCoffLoader->UnloadImage (ImageContext);
}
typedef struct {
EFI_HOB_GUID_TYPE Hob;
VOID *Interface;
} PROTOCOL_HOB;
/**
Register LzmaDecompress and LzmaDecompressGetInfo handlers with LzmaCustomerDecompressGuid.
The constructor function caches the pointer of DXE Services Table.
The constructor function caches the pointer of DXE Services Table.
It will ASSERT() if that operation fails.
It will ASSERT() if the pointer of DXE Services Table is NULL.
It will always return EFI_SUCCESS.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
@retval RETURN_SUCCESS Register successfully.
@retval RETURN_OUT_OF_RESOURCES No enough memory to store this handler.
**/
EFI_STATUS
EFIAPI
DxeHobPeCoffLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
PROTOCOL_HOB *Hob;
Hob = GetFirstGuidHob (&gPeCoffLoaderProtocolGuid);
if (Hob == NULL) {
return EFI_NOT_FOUND;
}
gPeCoffLoader = Hob->Interface;
return EFI_SUCCESS;
}

View File

@@ -16,7 +16,7 @@
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BasePeCoffLib
BASE_NAME = DxeHobPeCoffLib
FILE_GUID = 671C6FD7-99FB-4EE3-B640-4B1D463BC3B5
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
@@ -34,7 +34,11 @@
[Packages]
MdePkg/MdePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
[LibraryClasses]
DebugLib
HobLib
[Protocols]
gPeCoffLoaderProtocolGuid

View File

@@ -44,7 +44,7 @@ LzmaDecompressLibConstructor (
return ExtractGuidedSectionRegisterHandlers (
&gLzmaCustomDecompressGuid,
Hob->SectionGetInfo,
Hob->SectionExtraction
Hob->Data.SectionGetInfo,
Hob->Data.SectionExtraction
);
}

View File

@@ -818,11 +818,11 @@ BuildExtractSectionHob (
IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction
)
{
EXTRACT_SECTION_HOB Hob;
EXTRACT_SECTION_DATA Data;
Hob.SectionGetInfo = SectionGetInfo;
Hob.SectionExtraction = SectionExtraction;
BuildGuidDataHob (Guid, &Hob, sizeof (EXTRACT_SECTION_HOB));
Data.SectionGetInfo = SectionGetInfo;
Data.SectionExtraction = SectionExtraction;
BuildGuidDataHob (Guid, &Data, sizeof (Data));
}
PE_COFF_LOADER_PROTOCOL gPeCoffProtocol = {
@@ -834,22 +834,18 @@ PE_COFF_LOADER_PROTOCOL gPeCoffProtocol = {
PeCoffLoaderUnloadImage
};
typedef struct {
EFI_HOB_GUID_TYPE Hob;
VOID *Interface;
} PROTOCOL_HOB;
VOID
EFIAPI
BuildPeCoffLoaderHob (
VOID
)
{
PROTOCOL_HOB Hob;
VOID *Ptr;
Hob.Interface = &gPeCoffProtocol;
BuildGuidDataHob (&gPeCoffLoaderProtocolGuid, &Hob, sizeof (PROTOCOL_HOB));
Ptr = &gPeCoffProtocol;
BuildGuidDataHob (&gPeCoffLoaderProtocolGuid, &Ptr, sizeof (VOID *));
}