]>
Commit | Line | Data |
---|---|---|
bac49e77 | 1 | /**@file\r |
2 | \r | |
f9b8ab56 HT |
3 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r |
4 | Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
bac49e77 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | Module Name:\r | |
14 | \r | |
15 | PeiUnixPeCoffExtraActionLib.c\r | |
16 | \r | |
17 | Abstract:\r | |
18 | \r | |
19 | Provides services to perform additional actions to relocate and unload\r | |
20 | PE/Coff image for Unix environment specific purpose such as souce level debug.\r | |
21 | This version only works for DXE phase \r | |
22 | \r | |
23 | \r | |
24 | **/\r | |
25 | \r | |
ccd55824 | 26 | #include <PiDxe.h>\r |
bac49e77 | 27 | #include <UnixDxe.h>\r |
28 | #include <Library/PeCoffLib.h>\r | |
3980a850 | 29 | \r |
bac49e77 | 30 | #include <Library/BaseLib.h>\r |
31 | #include <Library/DebugLib.h>\r | |
32 | #include <Library/HobLib.h>\r | |
33 | #include <Library/BaseMemoryLib.h>\r | |
34 | #include <Library/PeCoffExtraActionLib.h>\r | |
35 | \r | |
398b646f | 36 | //\r |
ccd55824 | 37 | \r |
398b646f | 38 | // Cache of UnixThunk protocol \r |
ccd55824 | 39 | \r |
398b646f | 40 | //\r |
ccd55824 | 41 | \r |
42 | EFI_UNIX_THUNK_PROTOCOL *mUnix = NULL;\r | |
bac49e77 | 43 | \r |
44 | \r | |
45 | /**\r | |
46 | The constructor function gets the pointer of the WinNT thunk functions\r | |
47 | It will ASSERT() if Unix thunk protocol is not installed.\r | |
48 | \r | |
49 | @retval EFI_SUCCESS Unix thunk protocol is found and cached.\r | |
50 | \r | |
51 | **/\r | |
52 | EFI_STATUS\r | |
53 | EFIAPI\r | |
54 | DxeUnixPeCoffLibExtraActionConstructor (\r | |
55 | IN EFI_HANDLE ImageHandle,\r | |
56 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
57 | )\r | |
58 | {\r | |
2ac288f9 | 59 | EFI_HOB_GUID_TYPE *GuidHob;\r |
398b646f | 60 | \r |
61 | //\r | |
62 | // Retrieve UnixThunkProtocol from GUID'ed HOB\r | |
63 | //\r | |
64 | GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);\r | |
65 | ASSERT (GuidHob != NULL);\r | |
66 | mUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r | |
67 | ASSERT (mUnix != NULL);\r | |
68 | \r | |
bac49e77 | 69 | return EFI_SUCCESS;\r |
70 | }\r | |
71 | \r | |
72 | /**\r | |
6cb6f078 | 73 | Performs additional actions after a PE/COFF image has been loaded and relocated.\r |
74 | \r | |
75 | If ImageContext is NULL, then ASSERT().\r | |
76 | \r | |
77 | @param ImageContext Pointer to the image context structure that describes the\r | |
78 | PE/COFF image that has already been loaded and relocated.\r | |
bac49e77 | 79 | \r |
80 | **/\r | |
81 | VOID\r | |
82 | EFIAPI\r | |
83 | PeCoffLoaderRelocateImageExtraAction (\r | |
84 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
85 | )\r | |
86 | {\r | |
c0351cfe | 87 | if (mUnix != NULL) {\r |
88 | mUnix->PeCoffRelocateImageExtraAction (ImageContext);\r | |
398b646f | 89 | }\r |
c0351cfe | 90 | }\r |
398b646f | 91 | \r |
92 | \r | |
bac49e77 | 93 | \r |
94 | /**\r | |
6cb6f078 | 95 | Performs additional actions just before a PE/COFF image is unloaded. Any resources\r |
96 | that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r | |
97 | \r | |
98 | If ImageContext is NULL, then ASSERT().\r | |
99 | \r | |
100 | @param ImageContext Pointer to the image context structure that describes the\r | |
101 | PE/COFF image that is being unloaded.\r | |
bac49e77 | 102 | \r |
103 | **/\r | |
104 | VOID\r | |
105 | EFIAPI\r | |
106 | PeCoffLoaderUnloadImageExtraAction (\r | |
107 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
108 | )\r | |
109 | {\r | |
c0351cfe | 110 | if (mUnix != NULL) {\r |
111 | mUnix->PeCoffUnloadImageExtraAction (ImageContext);\r | |
112 | }\r | |
bac49e77 | 113 | }\r |