Commit | Line | Data |
---|---|---|
504214c4 LG |
1 | /** @file\r |
2 | \r | |
3 | GUID for the PE/COFF Loader APIs shared between SEC, PEI and DXE\r | |
2e19fd0f | 4 | \r |
504214c4 | 5 | Copyright (c) 2006 - 2008, Intel Corporation \r |
2e19fd0f | 6 | All rights reserved. This program and the accompanying materials \r |
7 | are licensed and made available under the terms and conditions of the BSD License \r | |
8 | which accompanies this distribution. The full text of the license may be found at \r | |
9 | http://opensource.org/licenses/bsd-license.php \r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
504214c4 | 12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r |
2e19fd0f | 13 | \r |
504214c4 | 14 | **/\r |
2e19fd0f | 15 | \r |
16 | #ifndef __PEI_PE_COFF_LOADER_H__\r | |
17 | #define __PEI_PE_COFF_LOADER_H__\r | |
18 | \r | |
19 | //\r | |
20 | // MdePkg/Include/Common/PeCoffLoaderImageContext.h\r | |
21 | //\r | |
22 | #include <Library/PeCoffLib.h>\r | |
23 | \r | |
24 | #define EFI_PEI_PE_COFF_LOADER_GUID \\r | |
25 | { 0xd8117cff, 0x94a6, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }\r | |
26 | \r | |
27 | typedef struct _EFI_PEI_PE_COFF_LOADER_PROTOCOL EFI_PEI_PE_COFF_LOADER_PROTOCOL;\r | |
28 | \r | |
504214c4 LG |
29 | /**\r |
30 | Retrieves information about a PE/COFF image.\r | |
31 | \r | |
32 | Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView,\r | |
33 | PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva\r | |
34 | fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.\r | |
35 | If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not\r | |
36 | a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while\r | |
37 | computing the fields of ImageContext, then the error status is returned in the ImageError field of\r | |
38 | ImageContext. \r | |
39 | \r | |
40 | @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.\r | |
41 | @param ImageContext Pointer to the image context structure that describes the PE/COFF\r | |
42 | image that needs to be examined by this function.\r | |
43 | \r | |
44 | @retval RETURN_SUCCESS The information on the PE/COFF image was collected.\r | |
45 | @retval RETURN_INVALID_PARAMETER ImageContext is NULL.\r | |
46 | @retval RETURN_UNSUPPORTED The PE/COFF image is not supported.\r | |
2e19fd0f | 47 | \r |
504214c4 | 48 | **/\r |
2e19fd0f | 49 | typedef \r |
504214c4 | 50 | RETURN_STATUS\r |
2e19fd0f | 51 | (EFIAPI *EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO) (\r |
52 | IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r | |
53 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
54 | );\r | |
55 | \r | |
504214c4 LG |
56 | /**\r |
57 | Loads a PE/COFF image into memory.\r | |
58 | \r | |
59 | Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer\r | |
60 | specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate\r | |
61 | the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.\r | |
62 | The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.\r | |
63 | If ImageContext is NULL, then ASSERT().\r | |
64 | \r | |
65 | @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.\r | |
66 | @param ImageContext Pointer to the image context structure that describes the PE/COFF\r | |
67 | image that is being loaded.\r | |
68 | \r | |
69 | @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by\r | |
70 | the ImageAddress and ImageSize fields of ImageContext.\r | |
71 | Extended status information is in the ImageError field of ImageContext.\r | |
72 | @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.\r | |
73 | Extended status information is in the ImageError field of ImageContext.\r | |
74 | @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.\r | |
75 | Extended status information is in the ImageError field of ImageContext.\r | |
76 | @retval RETURN_INVALID_PARAMETER The image address is invalid.\r | |
77 | Extended status information is in the ImageError field of ImageContext.\r | |
78 | \r | |
79 | **/\r | |
2e19fd0f | 80 | typedef \r |
504214c4 | 81 | RETURN_STATUS\r |
2e19fd0f | 82 | (EFIAPI *EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE) (\r |
83 | IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r | |
84 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
85 | );\r | |
86 | \r | |
504214c4 LG |
87 | /**\r |
88 | Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().\r | |
89 | \r | |
90 | If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of\r | |
91 | ImageContext as the relocation base address. Otherwise, use the DestinationAddress field\r | |
92 | of ImageContext as the relocation base address. The caller must allocate the relocation\r | |
93 | fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function. \r | |
94 | If ImageContext is NULL, then ASSERT().\r | |
95 | \r | |
96 | @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.\r | |
97 | @param ImageContext Pointer to the image context structure that describes the PE/COFF\r | |
98 | image that is being relocated.\r | |
99 | \r | |
100 | @retval RETURN_SUCCESS The PE/COFF image was relocated.\r | |
101 | Extended status information is in the ImageError field of ImageContext.\r | |
102 | @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.\r | |
103 | Extended status information is in the ImageError field of ImageContext.\r | |
104 | @retval RETURN_UNSUPPORTED A relocation record type is not supported.\r | |
105 | Extended status information is in the ImageError field of ImageContext.\r | |
106 | \r | |
107 | **/\r | |
2e19fd0f | 108 | typedef \r |
504214c4 | 109 | RETURN_STATUS\r |
2e19fd0f | 110 | (EFIAPI *EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE) (\r |
111 | IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r | |
112 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
113 | );\r | |
114 | \r | |
504214c4 LG |
115 | /**\r |
116 | Unloads a loaded PE/COFF image from memory and releases its taken resource.\r | |
117 | \r | |
118 | For NT32 emulator, the PE/COFF image loaded by system needs to release.\r | |
119 | For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded, \r | |
120 | this function can simply return RETURN_SUCCESS.\r | |
121 | \r | |
122 | @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.\r | |
123 | @param ImageContext Pointer to the image context structure that describes the PE/COFF\r | |
124 | image to be unloaded.\r | |
125 | \r | |
126 | @retval RETURN_SUCCESS The PE/COFF image was unloaded successfully.\r | |
127 | **/\r | |
2e19fd0f | 128 | typedef \r |
504214c4 | 129 | RETURN_STATUS\r |
2e19fd0f | 130 | (EFIAPI *EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE) (\r |
131 | IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r | |
132 | IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
133 | );\r | |
134 | \r | |
135 | struct _EFI_PEI_PE_COFF_LOADER_PROTOCOL {\r | |
136 | EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO GetImageInfo;\r | |
137 | EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE LoadImage;\r | |
138 | EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE RelocateImage;\r | |
139 | EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage;\r | |
140 | };\r | |
141 | \r | |
142 | extern EFI_GUID gEfiPeiPeCoffLoaderGuid;\r | |
143 | \r | |
144 | #endif\r |