]>
Commit | Line | Data |
---|---|---|
5b792f1a | 1 | /**@file\r |
2 | \r | |
d6ebcab7 HT |
3 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r |
4 | Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
5b792f1a | 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 | **/\r | |
14 | \r | |
15 | #include <PiDxe.h>\r | |
16 | #include <Library/PeCoffLib.h>\r | |
17 | \r | |
18 | #include <Library/BaseLib.h>\r | |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Library/BaseMemoryLib.h>\r | |
21 | #include <Library/PeCoffExtraActionLib.h>\r | |
22 | #include <Library/PrintLib.h>\r | |
23 | \r | |
24 | \r | |
25 | /**\r | |
26 | If the build is done on cygwin the paths are cygpaths. \r | |
27 | /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert\r | |
28 | them to work with RVD commands\r | |
29 | \r | |
30 | @param Name Path to convert if needed\r | |
31 | \r | |
32 | **/\r | |
33 | CHAR8 *\r | |
34 | DeCygwinPathIfNeeded (\r | |
35 | IN CHAR8 *Name\r | |
36 | )\r | |
37 | {\r | |
38 | CHAR8 *Ptr;\r | |
39 | UINTN Index;\r | |
40 | UINTN Len;\r | |
41 | \r | |
42 | Ptr = AsciiStrStr (Name, "/cygdrive/");\r | |
43 | if (Ptr == NULL) {\r | |
44 | return Name;\r | |
45 | }\r | |
46 | \r | |
47 | Len = AsciiStrLen (Ptr);\r | |
48 | \r | |
49 | // convert "/cygdrive" to spaces\r | |
50 | for (Index = 0; Index < 9; Index++) {\r | |
51 | Ptr[Index] = ' ';\r | |
52 | }\r | |
53 | \r | |
54 | // convert /c to c:\r | |
55 | Ptr[9] = Ptr[10];\r | |
56 | Ptr[10] = ':';\r | |
57 | \r | |
58 | // switch path seperators\r | |
59 | for (Index = 11; Index < Len; Index++) {\r | |
60 | if (Ptr[Index] == '/') {\r | |
61 | Ptr[Index] = '\\' ;\r | |
62 | }\r | |
63 | }\r | |
64 | \r | |
65 | return Name;\r | |
66 | }\r | |
67 | \r | |
68 | \r | |
69 | /**\r | |
70 | Performs additional actions after a PE/COFF image has been loaded and relocated.\r | |
71 | \r | |
72 | If ImageContext is NULL, then ASSERT().\r | |
73 | \r | |
74 | @param ImageContext Pointer to the image context structure that describes the\r | |
75 | PE/COFF image that has already been loaded and relocated.\r | |
76 | \r | |
77 | **/\r | |
78 | VOID\r | |
79 | EFIAPI\r | |
80 | PeCoffLoaderRelocateImageExtraAction (\r | |
81 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
82 | )\r | |
83 | {\r | |
84 | #ifdef __CC_ARM\r | |
85 | // Print out the command for the RVD debugger to load symbols for this image\r | |
86 | DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r | |
87 | #elif __GNUC__\r | |
88 | // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r | |
89 | DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r | |
90 | #else\r | |
91 | DEBUG ((EFI_D_ERROR, "Loading driver at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));\r | |
92 | #endif\r | |
93 | }\r | |
94 | \r | |
95 | \r | |
96 | \r | |
97 | /**\r | |
98 | Performs additional actions just before a PE/COFF image is unloaded. Any resources\r | |
99 | that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r | |
100 | \r | |
101 | If ImageContext is NULL, then ASSERT().\r | |
102 | \r | |
103 | @param ImageContext Pointer to the image context structure that describes the\r | |
104 | PE/COFF image that is being unloaded.\r | |
105 | \r | |
106 | **/\r | |
107 | VOID\r | |
108 | EFIAPI\r | |
109 | PeCoffLoaderUnloadImageExtraAction (\r | |
110 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
111 | )\r | |
112 | {\r | |
113 | #ifdef __CC_ARM\r | |
114 | // Print out the command for the RVD debugger to load symbols for this image\r | |
115 | DEBUG ((EFI_D_ERROR, "unload symbols_only %a", DeCygwinPathIfNeeded (ImageContext->PdbPointer)));\r | |
116 | #elif __GNUC__\r | |
117 | // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r | |
118 | DEBUG ((EFI_D_ERROR, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r | |
119 | #else\r | |
120 | DEBUG ((EFI_D_ERROR, "Unloading %a", ImageContext->PdbPointer));\r | |
121 | #endif\r | |
122 | }\r |