3 Copyright (c) 2006 - 2009, Intel Corporation
4 Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 PeiUnixPeCoffExtraActionLib.c
19 Provides services to perform additional actions to relocate and unload
20 PE/Coff image for UNIX environment specific purpose such as souce level debug.
21 This version only works for PEI phase
26 #include <Ppi/UnixThunk.h>
28 #include <Library/PeCoffLib.h>
29 #include <Library/PeiServicesLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/BaseLib.h>
32 #include <Library/PeCoffExtraActionLib.h>
35 // Cache of UnixThunk protocol
37 EFI_UNIX_THUNK_PROTOCOL
*mUnix
= NULL
;
40 The function caches the pointer of the Unix thunk functions
41 It will ASSERT() if Unix thunk ppi is not installed.
43 @retval EFI_SUCCESS WinNT thunk protocol is found and cached.
48 UnixPeCoffGetUnixThunkStucture (
51 PEI_UNIX_THUNK_PPI
*UnixThunkPpi
;
56 // Locate Unix ThunkPpi for retrieving standard output handle
58 Status
= PeiServicesLocatePpi (
59 &gPeiUnixThunkPpiGuid
,
62 (VOID
**) &UnixThunkPpi
65 ASSERT_EFI_ERROR (Status
);
67 mUnix
= (EFI_UNIX_THUNK_PROTOCOL
*) UnixThunkPpi
->UnixThunk ();
73 Performs additional actions after a PE/COFF image has been loaded and relocated.
75 If ImageContext is NULL, then ASSERT().
77 @param ImageContext Pointer to the image context structure that describes the
78 PE/COFF image that has already been loaded and relocated.
83 PeCoffLoaderRelocateImageExtraAction (
84 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
88 UnixPeCoffGetUnixThunkStucture ();
90 mUnix
->PeCoffRelocateImageExtraAction (ImageContext
);
95 Performs additional actions just before a PE/COFF image is unloaded. Any resources
96 that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
98 If ImageContext is NULL, then ASSERT().
100 @param ImageContext Pointer to the image context structure that describes the
101 PE/COFF image that is being unloaded.
106 PeCoffLoaderUnloadImageExtraAction (
107 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
111 UnixPeCoffGetUnixThunkStucture ();
113 mUnix
->PeCoffUnloadImageExtraAction (ImageContext
);