summaryrefslogtreecommitdiff
path: root/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib
diff options
context:
space:
mode:
Diffstat (limited to 'EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib')
-rw-r--r--EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/EdkUnixPeiPeCoffGetEntryPointLib.msa48
-rw-r--r--EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c75
2 files changed, 123 insertions, 0 deletions
diff --git a/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/EdkUnixPeiPeCoffGetEntryPointLib.msa b/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/EdkUnixPeiPeCoffGetEntryPointLib.msa
new file mode 100644
index 0000000000..1c4490047a
--- /dev/null
+++ b/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/EdkUnixPeiPeCoffGetEntryPointLib.msa
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
+ <MsaHeader>
+ <ModuleName>EdkUnixPeiPeCoffGetEntryPointLib</ModuleName>
+ <ModuleType>PEIM</ModuleType>
+ <GuidValue>f3b702e8-8985-11db-9558-0040d02b1835</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Component description file for the EdkNt32PeiPeCoffGetEntryPointLib library.</Abstract>
+ <Description>PeCoffGetEntryPointLib library class for NT32 instance implemented by use NTPeiLoadFile PPI.</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>EdkUnixPeiPeCoffGetEntryPointLib</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">
+ <Keyword>PeCoffGetEntryPointLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>PeCoffGetEntryPoint.c</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+ </PackageDependencies>
+ <PPIs>
+ <Ppi Usage="ALWAYS_CONSUMED">
+ <PpiCName>gUnixPeiLoadFilePpiGuid</PpiCName>
+ </Ppi>
+ </PPIs>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
new file mode 100644
index 0000000000..c0d0a01d3e
--- /dev/null
+++ b/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
@@ -0,0 +1,75 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeCoffGetEntryPoint.c
+
+Abstract:
+
+ Tiano PE/COFF loader
+
+Revision History
+
+--*/
+
+
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderGetEntryPoint (
+ IN VOID *Pe32Data,
+ IN OUT VOID **EntryPoint
+ )
+/*++
+
+Routine Description:
+
+ Loads a PE/COFF image into memory
+
+Arguments:
+
+ Pe32Data - Pointer to a PE/COFF Image
+
+ EntryPoint - Pointer to the entry point of the PE/COFF image
+
+Returns:
+
+ EFI_SUCCESS if the EntryPoint was returned
+ EFI_INVALID_PARAMETER if the EntryPoint could not be found from Pe32Data
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
+ UNIX_PEI_LOAD_FILE_PPI *PeiUnixService;
+ EFI_PHYSICAL_ADDRESS ImageAddress;
+ UINT64 ImageSize;
+ EFI_PHYSICAL_ADDRESS ImageEntryPoint;
+
+ Status = PeiServicesLocatePpi (
+ &gUnixPeiLoadFilePpiGuid,
+ 0,
+ &PpiDescriptor,
+ (void **)&PeiUnixService
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = PeiUnixService->PeiLoadFileService (
+ Pe32Data,
+ &ImageAddress,
+ &ImageSize,
+ &ImageEntryPoint
+ );
+ *EntryPoint = (VOID*)(UINTN)ImageEntryPoint;
+ return Status;
+}