]>
Commit | Line | Data |
---|---|---|
62e797a4 A |
1 | /**@file\r |
2 | \r | |
3 | Copyright (c) 2006 - 2009, Intel Corporation\r | |
4 | Portions copyright (c) 2008-2010 Apple Inc. All rights reserved.\r | |
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 | \r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #include <PiDxe.h>\r | |
18 | #include <Library/PeCoffLib.h>\r | |
19 | \r | |
20 | #include <Library/BaseLib.h>\r | |
21 | #include <Library/DebugLib.h>\r | |
22 | #include <Library/BaseMemoryLib.h>\r | |
23 | #include <Library/PeCoffExtraActionLib.h>\r | |
24 | #include <Library/SerialPortLib.h>\r | |
25 | #include <Library/PrintLib.h>\r | |
26 | \r | |
27 | \r | |
28 | VOID\r | |
29 | DeCygwinIfNeeded (\r | |
30 | IN CHAR8 *Name\r | |
31 | )\r | |
32 | {\r | |
33 | CHAR8 *Ptr;\r | |
34 | UINTN Index;\r | |
35 | UINTN Len;\r | |
36 | \r | |
37 | Ptr = AsciiStrStr (Name, "/cygdrive/");\r | |
38 | if (Ptr == NULL) {\r | |
39 | return;\r | |
40 | }\r | |
41 | \r | |
42 | Len = AsciiStrLen (Ptr);\r | |
43 | \r | |
44 | // convert "/cygdrive" to spaces\r | |
45 | for (Index = 0; Index < 9; Index++) {\r | |
46 | Ptr[Index] = ' ';\r | |
47 | }\r | |
48 | \r | |
49 | // convert /c to c:\r | |
50 | Ptr[9] = Ptr[10];\r | |
51 | Ptr[10] = ':';\r | |
52 | \r | |
53 | // switch path seperators\r | |
54 | for (Index = 11; Index < Len; Index++) {\r | |
55 | if (Ptr[Index] == '/') {\r | |
56 | Ptr[Index] = '\\' ;\r | |
57 | }\r | |
58 | }\r | |
59 | }\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 | CHAR8 Buffer[256];\r | |
78 | \r | |
79 | AsciiSPrint (Buffer, sizeof(Buffer), "load /a /ni /np %a &0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));\r | |
80 | DeCygwinIfNeeded (&Buffer[16]);\r | |
81 | \r | |
82 | SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));\r | |
83 | }\r | |
84 | \r | |
85 | \r | |
86 | \r | |
87 | /**\r | |
88 | Performs additional actions just before a PE/COFF image is unloaded. Any resources\r | |
89 | that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r | |
90 | \r | |
91 | If ImageContext is NULL, then ASSERT().\r | |
92 | \r | |
93 | @param ImageContext Pointer to the image context structure that describes the\r | |
94 | PE/COFF image that is being unloaded.\r | |
95 | \r | |
96 | **/\r | |
97 | VOID\r | |
98 | EFIAPI\r | |
99 | PeCoffLoaderUnloadImageExtraAction (\r | |
100 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
101 | )\r | |
102 | {\r | |
103 | CHAR8 Buffer[256];\r | |
104 | \r | |
105 | AsciiSPrint (Buffer, sizeof(Buffer), "unload symbols_only %a", ImageContext->PdbPointer);\r | |
106 | DeCygwinIfNeeded (Buffer);\r | |
107 | \r | |
108 | SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));\r | |
109 | }\r |