]>
Commit | Line | Data |
---|---|---|
2ddf8375 | 1 | /**@file\r |
2 | \r | |
3 | Copyright (c) 2006 - 2009, Intel Corporation\r | |
ccd55824 | 4 | Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.\r |
2ddf8375 | 5 | All rights reserved. This program and the accompanying materials\r |
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 PEI phase\r | |
22 | \r | |
23 | \r | |
24 | **/\r | |
25 | #include <PiPei.h>\r | |
26 | #include <Ppi/UnixThunk.h>\r | |
27 | \r | |
28 | #include <Library/PeCoffLib.h>\r | |
29 | #include <Library/PeiServicesLib.h>\r | |
30 | #include <Library/DebugLib.h>\r | |
31 | #include <Library/BaseLib.h>\r | |
32 | #include <Library/PeCoffExtraActionLib.h>\r | |
33 | \r | |
34 | //\r | |
35 | // Cache of UnixThunk protocol \r | |
36 | //\r | |
37 | EFI_UNIX_THUNK_PROTOCOL *mUnix = NULL;\r | |
38 | \r | |
39 | /**\r | |
ccd55824 | 40 | The function caches the pointer of the Unix thunk functions\r |
2ddf8375 | 41 | It will ASSERT() if Unix thunk ppi is not installed.\r |
42 | \r | |
43 | @retval EFI_SUCCESS WinNT thunk protocol is found and cached.\r | |
44 | \r | |
45 | **/\r | |
46 | EFI_STATUS\r | |
47 | EFIAPI\r | |
48 | UnixPeCoffGetUnixThunkStucture (\r | |
49 | )\r | |
50 | {\r | |
51 | PEI_UNIX_THUNK_PPI *UnixThunkPpi;\r | |
52 | EFI_STATUS Status;\r | |
53 | \r | |
54 | \r | |
55 | //\r | |
56 | // Locate Unix ThunkPpi for retrieving standard output handle\r | |
57 | //\r | |
58 | Status = PeiServicesLocatePpi (\r | |
59 | &gPeiUnixThunkPpiGuid,\r | |
60 | 0,\r | |
61 | NULL,\r | |
62 | (VOID **) &UnixThunkPpi\r | |
63 | );\r | |
64 | \r | |
65 | ASSERT_EFI_ERROR (Status);\r | |
66 | \r | |
67 | mUnix = (EFI_UNIX_THUNK_PROTOCOL *) UnixThunkPpi->UnixThunk ();\r | |
68 | \r | |
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 | |
2ddf8375 | 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 | |
2ddf8375 | 87 | if (mUnix == NULL) {\r |
88 | UnixPeCoffGetUnixThunkStucture ();\r | |
89 | }\r | |
ccd55824 | 90 | mUnix->PeCoffRelocateImageExtraAction (ImageContext);\r |
398b646f | 91 | }\r |
398b646f | 92 | \r |
2ddf8375 | 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 | |
2ddf8375 | 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 | |
ccd55824 | 110 | if (mUnix == NULL) {\r |
111 | UnixPeCoffGetUnixThunkStucture ();\r | |
112 | }\r | |
113 | mUnix->PeCoffUnloadImageExtraAction (ImageContext);\r | |
2ddf8375 | 114 | }\r |