]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Library/DxeUnixPeCoffExtraActionLib/DxeUnixPeCoffExtraActionLib.c
Fix issue with fixing tabs.
[mirror_edk2.git] / UnixPkg / Library / DxeUnixPeCoffExtraActionLib / DxeUnixPeCoffExtraActionLib.c
1 /**@file
2
3 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5 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
9
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.
12
13 Module Name:
14
15 PeiUnixPeCoffExtraActionLib.c
16
17 Abstract:
18
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 DXE phase
22
23
24 **/
25
26 #include <PiDxe.h>
27 #include <UnixDxe.h>
28 #include <Library/PeCoffLib.h>
29
30 #include <Library/BaseLib.h>
31 #include <Library/DebugLib.h>
32 #include <Library/HobLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/PeCoffExtraActionLib.h>
35
36 //
37
38 // Cache of UnixThunk protocol
39
40 //
41
42 EFI_UNIX_THUNK_PROTOCOL *mUnix = NULL;
43
44
45 /**
46 The constructor function gets the pointer of the WinNT thunk functions
47 It will ASSERT() if Unix thunk protocol is not installed.
48
49 @retval EFI_SUCCESS Unix thunk protocol is found and cached.
50
51 **/
52 EFI_STATUS
53 EFIAPI
54 DxeUnixPeCoffLibExtraActionConstructor (
55 IN EFI_HANDLE ImageHandle,
56 IN EFI_SYSTEM_TABLE *SystemTable
57 )
58 {
59 EFI_HOB_GUID_TYPE *GuidHob;
60
61 //
62 // Retrieve UnixThunkProtocol from GUID'ed HOB
63 //
64 GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);
65 ASSERT (GuidHob != NULL);
66 mUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
67 ASSERT (mUnix != NULL);
68
69 return EFI_SUCCESS;
70 }
71
72 /**
73 Performs additional actions after a PE/COFF image has been loaded and relocated.
74
75 If ImageContext is NULL, then ASSERT().
76
77 @param ImageContext Pointer to the image context structure that describes the
78 PE/COFF image that has already been loaded and relocated.
79
80 **/
81 VOID
82 EFIAPI
83 PeCoffLoaderRelocateImageExtraAction (
84 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
85 )
86 {
87 if (mUnix != NULL) {
88 mUnix->PeCoffRelocateImageExtraAction (ImageContext);
89 }
90 }
91
92
93
94 /**
95 Performs additional actions just before a PE/COFF image is unloaded. Any resources
96 that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
97
98 If ImageContext is NULL, then ASSERT().
99
100 @param ImageContext Pointer to the image context structure that describes the
101 PE/COFF image that is being unloaded.
102
103 **/
104 VOID
105 EFIAPI
106 PeCoffLoaderUnloadImageExtraAction (
107 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
108 )
109 {
110 if (mUnix != NULL) {
111 mUnix->PeCoffUnloadImageExtraAction (ImageContext);
112 }
113 }