+++ /dev/null
-/**@file\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2008 - 2009, 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
-Module Name:\r
-\r
- PeiUnixPeCoffExtraActionLib.c\r
-\r
-Abstract:\r
-\r
- Provides services to perform additional actions to relocate and unload\r
- PE/Coff image for Unix environment specific purpose such as souce level debug.\r
- This version only works for DXE phase \r
-\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <UnixDxe.h>\r
-#include <Library/PeCoffLib.h>\r
-\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
-\r
-// Cache of UnixThunk protocol \r
-\r
-//\r
-\r
-EFI_UNIX_THUNK_PROTOCOL *mUnix = 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
-DxeUnixPeCoffLibExtraActionConstructor (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_HOB_GUID_TYPE *GuidHob;\r
-\r
- //\r
- // Retrieve UnixThunkProtocol from GUID'ed HOB\r
- //\r
- GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);\r
- ASSERT (GuidHob != NULL);\r
- mUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
- ASSERT (mUnix != 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 (mUnix != NULL) {\r
- mUnix->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 (mUnix != NULL) {\r
- mUnix->PeCoffUnloadImageExtraAction (ImageContext);\r
- }\r
-}\r