]>
Commit | Line | Data |
---|---|---|
949f388f | 1 | /** @file\r |
2 | Provides services to perform additional actions to relocate and unload\r | |
3 | PE/Coff image for Emu environment specific purpose such as souce level debug.\r | |
d18d8a1d | 4 | This version only works for DXE phase\r |
949f388f | 5 | \r |
6 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r | |
7 | Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r | |
e3ba31da | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
949f388f | 9 | \r |
10 | **/\r | |
11 | \r | |
12 | #include <PiDxe.h>\r | |
13 | \r | |
14 | #include <Protocol/EmuThunk.h>\r | |
15 | \r | |
16 | #include <Library/PeCoffLib.h>\r | |
17 | #include <Library/BaseLib.h>\r | |
18 | #include <Library/DebugLib.h>\r | |
19 | #include <Library/HobLib.h>\r | |
20 | #include <Library/BaseMemoryLib.h>\r | |
21 | #include <Library/PeCoffExtraActionLib.h>\r | |
22 | \r | |
23 | //\r | |
d18d8a1d | 24 | // Cache of UnixThunk protocol\r |
949f388f | 25 | //\r |
a550d468 | 26 | EMU_THUNK_PROTOCOL *mThunk = NULL;\r |
949f388f | 27 | \r |
28 | /**\r | |
29 | The constructor function gets the pointer of the WinNT thunk functions\r | |
30 | It will ASSERT() if Unix thunk protocol is not installed.\r | |
31 | \r | |
32 | @retval EFI_SUCCESS Unix thunk protocol is found and cached.\r | |
33 | \r | |
34 | **/\r | |
35 | EFI_STATUS\r | |
36 | EFIAPI\r | |
37 | DxeEmuPeCoffLibExtraActionConstructor (\r | |
38 | IN EFI_HANDLE ImageHandle,\r | |
39 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
40 | )\r | |
41 | {\r | |
a550d468 | 42 | EFI_HOB_GUID_TYPE *GuidHob;\r |
949f388f | 43 | \r |
44 | //\r | |
45 | // Retrieve EmuThunkProtocol from GUID'ed HOB\r | |
46 | //\r | |
47 | GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);\r | |
48 | ASSERT (GuidHob != NULL);\r | |
49 | mThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r | |
50 | ASSERT (mThunk != NULL);\r | |
51 | \r | |
52 | return EFI_SUCCESS;\r | |
53 | }\r | |
54 | \r | |
55 | /**\r | |
56 | Performs additional actions after a PE/COFF image has been loaded and relocated.\r | |
57 | \r | |
58 | If ImageContext is NULL, then ASSERT().\r | |
59 | \r | |
60 | @param ImageContext Pointer to the image context structure that describes the\r | |
61 | PE/COFF image that has already been loaded and relocated.\r | |
62 | \r | |
63 | **/\r | |
64 | VOID\r | |
65 | EFIAPI\r | |
66 | PeCoffLoaderRelocateImageExtraAction (\r | |
67 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
68 | )\r | |
69 | {\r | |
70 | if (mThunk != NULL) {\r | |
71 | mThunk->PeCoffRelocateImageExtraAction (ImageContext);\r | |
72 | }\r | |
73 | }\r | |
74 | \r | |
949f388f | 75 | /**\r |
76 | Performs additional actions just before a PE/COFF image is unloaded. Any resources\r | |
77 | that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r | |
d18d8a1d | 78 | \r |
949f388f | 79 | If ImageContext is NULL, then ASSERT().\r |
d18d8a1d | 80 | \r |
949f388f | 81 | @param ImageContext Pointer to the image context structure that describes the\r |
82 | PE/COFF image that is being unloaded.\r | |
83 | \r | |
84 | **/\r | |
85 | VOID\r | |
86 | EFIAPI\r | |
87 | PeCoffLoaderUnloadImageExtraAction (\r | |
88 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
89 | )\r | |
90 | {\r | |
91 | if (mThunk != NULL) {\r | |
92 | mThunk->PeCoffUnloadImageExtraAction (ImageContext);\r | |
93 | }\r | |
94 | }\r |