]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.c
Clean up format of comments
[mirror_edk2.git] / ArmPkg / Library / RviPeCoffExtraActionLib / RviPeCoffExtraActionLib.c
1 /**@file
2
3 Copyright (c) 2006 - 2009, Intel Corporation
4 Portions copyright (c) 2008-2010 Apple Inc. All rights reserved.
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14
15 **/
16
17 #include <PiDxe.h>
18 #include <Library/PeCoffLib.h>
19
20 #include <Library/BaseLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/PeCoffExtraActionLib.h>
24 #include <Library/SerialPortLib.h>
25 #include <Library/PrintLib.h>
26
27
28 VOID
29 DeCygwinIfNeeded (
30 IN CHAR8 *Name
31 )
32 {
33 CHAR8 *Ptr;
34 UINTN Index;
35 UINTN Len;
36
37 Ptr = AsciiStrStr (Name, "/cygdrive/");
38 if (Ptr == NULL) {
39 return;
40 }
41
42 Len = AsciiStrLen (Ptr);
43
44 // convert "/cygdrive" to spaces
45 for (Index = 0; Index < 9; Index++) {
46 Ptr[Index] = ' ';
47 }
48
49 // convert /c to c:
50 Ptr[9] = Ptr[10];
51 Ptr[10] = ':';
52
53 // switch path seperators
54 for (Index = 11; Index < Len; Index++) {
55 if (Ptr[Index] == '/') {
56 Ptr[Index] = '\\' ;
57 }
58 }
59 }
60
61
62 /**
63 Performs additional actions after a PE/COFF image has been loaded and relocated.
64
65 If ImageContext is NULL, then ASSERT().
66
67 @param ImageContext Pointer to the image context structure that describes the
68 PE/COFF image that has already been loaded and relocated.
69
70 **/
71 VOID
72 EFIAPI
73 PeCoffLoaderRelocateImageExtraAction (
74 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
75 )
76 {
77 CHAR8 Buffer[256];
78
79 AsciiSPrint (Buffer, sizeof(Buffer), "load /a /ni /np %a &0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
80 DeCygwinIfNeeded (&Buffer[16]);
81
82 SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));
83 }
84
85
86
87 /**
88 Performs additional actions just before a PE/COFF image is unloaded. Any resources
89 that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
90
91 If ImageContext is NULL, then ASSERT().
92
93 @param ImageContext Pointer to the image context structure that describes the
94 PE/COFF image that is being unloaded.
95
96 **/
97 VOID
98 EFIAPI
99 PeCoffLoaderUnloadImageExtraAction (
100 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
101 )
102 {
103 CHAR8 Buffer[256];
104
105 AsciiSPrint (Buffer, sizeof(Buffer), "unload symbols_only %a", ImageContext->PdbPointer);
106 DeCygwinIfNeeded (Buffer);
107
108 SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));
109 }