+++ /dev/null
-/** @file\r
- Provides services to perform additional actions to relocate and unload\r
- PE/Coff image for Emu environment specific purpose such as souce level debug.\r
- This version only works for DXE phase \r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2008 - 2011, Apple Inc. 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
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/EmuThunk.h>\r
-\r
-#include <Library/PeCoffLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/PeCoffExtraActionLib.h>\r
-\r
-//\r
-// Cache of UnixThunk protocol \r
-//\r
-EMU_THUNK_PROTOCOL *mThunk = NULL;\r
-\r
-\r
-/**\r
- The constructor function gets the pointer of the WinNT thunk functions\r
- It will ASSERT() if Unix thunk protocol is not installed.\r
-\r
- @retval EFI_SUCCESS Unix thunk protocol is found and cached.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DxeEmuPeCoffLibExtraActionConstructor (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_HOB_GUID_TYPE *GuidHob;\r
-\r
- //\r
- // Retrieve EmuThunkProtocol from GUID'ed HOB\r
- //\r
- GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);\r
- ASSERT (GuidHob != NULL);\r
- mThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
- ASSERT (mThunk != NULL);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Performs additional actions after a PE/COFF image has been loaded and relocated.\r
-\r
- If ImageContext is NULL, then ASSERT().\r
-\r
- @param ImageContext Pointer to the image context structure that describes the\r
- PE/COFF image that has already been loaded and relocated.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PeCoffLoaderRelocateImageExtraAction (\r
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
- )\r
-{\r
- if (mThunk != NULL) {\r
- mThunk->PeCoffRelocateImageExtraAction (ImageContext);\r
- }\r
-}\r
-\r
-\r
-\r
-/**\r
- Performs additional actions just before a PE/COFF image is unloaded. Any resources\r
- that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r
- \r
- If ImageContext is NULL, then ASSERT().\r
- \r
- @param ImageContext Pointer to the image context structure that describes the\r
- PE/COFF image that is being unloaded.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PeCoffLoaderUnloadImageExtraAction (\r
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
- )\r
-{\r
- if (mThunk != NULL) {\r
- mThunk->PeCoffUnloadImageExtraAction (ImageContext);\r
- }\r
-}\r