]>
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 | |
4 | This version only works for DXE phase \r | |
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 | |
8 | This program and the accompanying materials\r | |
9 | are licensed and made available under the terms and conditions of the BSD License\r | |
10 | which accompanies this distribution. The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php\r | |
12 | \r | |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
15 | \r | |
16 | **/\r | |
17 | \r | |
18 | #include <PiDxe.h>\r | |
19 | \r | |
20 | #include <Protocol/EmuThunk.h>\r | |
21 | \r | |
22 | #include <Library/PeCoffLib.h>\r | |
23 | #include <Library/BaseLib.h>\r | |
24 | #include <Library/DebugLib.h>\r | |
25 | #include <Library/HobLib.h>\r | |
26 | #include <Library/BaseMemoryLib.h>\r | |
27 | #include <Library/PeCoffExtraActionLib.h>\r | |
28 | \r | |
29 | //\r | |
30 | // Cache of UnixThunk protocol \r | |
31 | //\r | |
32 | EMU_THUNK_PROTOCOL *mThunk = NULL;\r | |
33 | \r | |
34 | \r | |
35 | /**\r | |
36 | The constructor function gets the pointer of the WinNT thunk functions\r | |
37 | It will ASSERT() if Unix thunk protocol is not installed.\r | |
38 | \r | |
39 | @retval EFI_SUCCESS Unix thunk protocol is found and cached.\r | |
40 | \r | |
41 | **/\r | |
42 | EFI_STATUS\r | |
43 | EFIAPI\r | |
44 | DxeEmuPeCoffLibExtraActionConstructor (\r | |
45 | IN EFI_HANDLE ImageHandle,\r | |
46 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
47 | )\r | |
48 | {\r | |
49 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
50 | \r | |
51 | //\r | |
52 | // Retrieve EmuThunkProtocol from GUID'ed HOB\r | |
53 | //\r | |
54 | GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);\r | |
55 | ASSERT (GuidHob != NULL);\r | |
56 | mThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r | |
57 | ASSERT (mThunk != NULL);\r | |
58 | \r | |
59 | return EFI_SUCCESS;\r | |
60 | }\r | |
61 | \r | |
62 | /**\r | |
63 | Performs additional actions after a PE/COFF image has been loaded and relocated.\r | |
64 | \r | |
65 | If ImageContext is NULL, then ASSERT().\r | |
66 | \r | |
67 | @param ImageContext Pointer to the image context structure that describes the\r | |
68 | PE/COFF image that has already been loaded and relocated.\r | |
69 | \r | |
70 | **/\r | |
71 | VOID\r | |
72 | EFIAPI\r | |
73 | PeCoffLoaderRelocateImageExtraAction (\r | |
74 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
75 | )\r | |
76 | {\r | |
77 | if (mThunk != NULL) {\r | |
78 | mThunk->PeCoffRelocateImageExtraAction (ImageContext);\r | |
79 | }\r | |
80 | }\r | |
81 | \r | |
82 | \r | |
83 | \r | |
84 | /**\r | |
85 | Performs additional actions just before a PE/COFF image is unloaded. Any resources\r | |
86 | that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r | |
87 | \r | |
88 | If ImageContext is NULL, then ASSERT().\r | |
89 | \r | |
90 | @param ImageContext Pointer to the image context structure that describes the\r | |
91 | PE/COFF image that is being unloaded.\r | |
92 | \r | |
93 | **/\r | |
94 | VOID\r | |
95 | EFIAPI\r | |
96 | PeCoffLoaderUnloadImageExtraAction (\r | |
97 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
98 | )\r | |
99 | {\r | |
100 | if (mThunk != NULL) {\r | |
101 | mThunk->PeCoffUnloadImageExtraAction (ImageContext);\r | |
102 | }\r | |
103 | }\r |