summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-03-05 09:18:28 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-03-05 09:18:28 +0000
commit27b2d249d57f9bde599af477d3b82acc3c62dfac (patch)
tree79ae97de8054ad0c2be70ec862ed60a2f89ab5b2 /MdePkg
parent92650d219962b8acf81ed434e1db92739a50ba85 (diff)
Remove PeRemove PeiPeCoffLoader.h and gPeiPeCoffLoaderGuid, and Add PeCoffExtraActionLib class and instances.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7811 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/Library/PeCoffExtraActionLib.h56
-rw-r--r--MdePkg/Library/BasePeCoffLib/BasePeCoff.c11
-rw-r--r--MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf1
-rw-r--r--MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h1
-rw-r--r--MdePkg/Library/PeCoffExtraActionLibNull/PeCoffExtraActionLib.c57
-rw-r--r--MdePkg/Library/PeCoffExtraActionLibNull/PeCoffExtraActionLibNull.inf35
-rw-r--r--MdePkg/MdePkg.dec3
-rw-r--r--MdePkg/MdePkg.dsc1
8 files changed, 165 insertions, 0 deletions
diff --git a/MdePkg/Include/Library/PeCoffExtraActionLib.h b/MdePkg/Include/Library/PeCoffExtraActionLib.h
new file mode 100644
index 000000000..b1396dee4
--- /dev/null
+++ b/MdePkg/Include/Library/PeCoffExtraActionLib.h
@@ -0,0 +1,56 @@
+/** @file
+ Provides services to perform additional actions to relocate and unload
+ PE/Coff image for some environment specific purpose say for souce level debug.
+
+ Copyright (c) 2006 - 2008, Intel Corporation<BR>
+ 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.
+
+**/
+
+#ifndef __PE_COFF_EXTRA_ACTION_LIB_H__
+#define __PE_COFF_EXTRA_ACTION_LIB_H__
+#include <Library/PeCoffLib.h>
+/**
+ Applies additional actions to relocate fixups to a PE/COFF image.
+
+ Generally this function is called after sucessfully Applying relocation fixups
+ to a PE/COFF image for some specicial purpose.
+ As a example, For NT32 emulator, the function should be implemented and called
+ to support source level debug.
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image that is being relocated.
+
+**/
+VOID
+EFIAPI
+PeCoffLoaderRelocateImageExtraAction (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+/**
+ Unloads a loaded PE/COFF image from memory and releases its taken resource.
+
+ Releases any environment specific resources that were allocated when the image
+ specified by ImageContext was loaded using PeCoffLoaderLoadImage().
+ For NT32 emulator, the PE/COFF image loaded by system needs to release.
+ For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded,
+
+ If ImageContext is NULL, then ASSERT().
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image to be unloaded.
+
+**/
+VOID
+EFIAPI
+PeCoffLoaderUnloadImageExtraAction (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+#endif
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index 91df24e09..9274f31aa 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -540,6 +540,9 @@ PeCoffLoaderRelocateImage (
// If there are no relocation entries, then we are done
//
if (ImageContext->RelocationsStripped) {
+ // Applies additional environment specific actions to relocate fixups
+ // to a PE/COFF image if needed
+ PeCoffLoaderRelocateImageExtraAction (ImageContext);
return RETURN_SUCCESS;
}
@@ -736,6 +739,11 @@ PeCoffLoaderRelocateImage (
ImageContext->EntryPoint -= (UINT64) ImageContext->ImageAddress;
ImageContext->EntryPoint += (UINT64) ImageContext->DestinationAddress;
}
+
+ // Applies additional environment specific actions to relocate fixups
+ // to a PE/COFF image if needed
+ PeCoffLoaderRelocateImageExtraAction (ImageContext);
+
return RETURN_SUCCESS;
}
@@ -1411,5 +1419,8 @@ PeCoffLoaderUnloadImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
+ // Applies additional environment specific actions to unload a
+ // PE/COFF image if needed
+ PeCoffLoaderUnloadImageExtraAction (ImageContext);
return RETURN_SUCCESS;
}
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
index 28e942cb7..534b78ec2 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
@@ -41,5 +41,6 @@
[LibraryClasses]
DebugLib
+ PeCoffExtraActionLib
BaseMemoryLib
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h b/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h
index c8f95a11f..864337b0c 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h
@@ -19,6 +19,7 @@
#include <Library/PeCoffLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#include <Library/PeCoffExtraActionLib.h>
#include <IndustryStandard/PeImage.h>
diff --git a/MdePkg/Library/PeCoffExtraActionLibNull/PeCoffExtraActionLib.c b/MdePkg/Library/PeCoffExtraActionLibNull/PeCoffExtraActionLib.c
new file mode 100644
index 000000000..00ec9d24c
--- /dev/null
+++ b/MdePkg/Library/PeCoffExtraActionLibNull/PeCoffExtraActionLib.c
@@ -0,0 +1,57 @@
+/** @file
+ Null PE/Coff Extra Action library instances with empty functions.
+
+ Copyright (c) 2006 - 2008, Intel Corporation<BR>
+ 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.
+
+**/
+
+#include <Base.h>
+#include <Library/PeCoffExtraActionLib.h>
+/**
+ Applies additional actions to relocate fixups to a PE/COFF image.
+
+ Generally this function is called after sucessfully Applying relocation fixups
+ to a PE/COFF image for some specicial purpose.
+ As a example, For NT32 emulator, the function should be implemented and called
+ to support source level debug.
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image that is being relocated.
+
+**/
+VOID
+EFIAPI
+PeCoffLoaderRelocateImageExtraAction (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+}
+
+/**
+ Unloads a loaded PE/COFF image from memory and releases its taken resource.
+
+ Releases any environment specific resources that were allocated when the image
+ specified by ImageContext was loaded using PeCoffLoaderLoadImage().
+ For NT32 emulator, the PE/COFF image loaded by system needs to release.
+ For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded,
+
+ If ImageContext is NULL, then ASSERT().
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image to be unloaded.
+
+**/
+VOID
+EFIAPI
+PeCoffLoaderUnloadImageExtraAction (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+} \ No newline at end of file
diff --git a/MdePkg/Library/PeCoffExtraActionLibNull/PeCoffExtraActionLibNull.inf b/MdePkg/Library/PeCoffExtraActionLibNull/PeCoffExtraActionLibNull.inf
new file mode 100644
index 000000000..995a92f8a
--- /dev/null
+++ b/MdePkg/Library/PeCoffExtraActionLibNull/PeCoffExtraActionLibNull.inf
@@ -0,0 +1,35 @@
+#/** @file
+# Debug Library with empty functions.
+#
+# Copyright (c) 2007 - 2008, 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.
+#
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeCoffExtraActionLibNull
+ FILE_GUID = 0EB84DA1-267A-40b4-8347-1F48694C8B47
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PeCoffExtraActionLib
+
+
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources.common]
+ PeCoffExtraActionLib.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 569ad2bf2..56ff115ec 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -114,6 +114,9 @@
## @libraryclass Provides services to load and relocate a PE/COFF image.
PeCoffLib|Include/Library/PeCoffLib.h
+ ## @libraryclass Provides extra action services for unloading and relocating a PE/COFF image on some specific platform such
+ ## as NT32 emulator.
+ PeCoffExtraActionLib|Include/Library/PeCoffExtraActionLib.h
## @libraryclass Provides a service to retrieve the PE/COFF entry point from a PE/COFF image.
PeCoffGetEntryPointLib|Include/Library/PeCoffGetEntryPointLib.h
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 92cd4d353..24786b52e 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -83,6 +83,7 @@
MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+ MdePkg/Library/PeCoffExtraActionLibNull/PeCoffExtraActionLibNull.inf
MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
MdePkg/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf
MdePkg/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf