]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Guid/PeiPeCoffLoader.h
Code Clean for Driver PlatformDriOverrideDxe and PlatOverMngr application. And Clean...
[mirror_edk2.git] / MdeModulePkg / Include / Guid / PeiPeCoffLoader.h
CommitLineData
504214c4 1/** @file\r
5f597758
LG
2 This file defines PeCoffLoader guid for PeCoffLoader entry in the HOB list.\r
3 It also defines PE/COFF Loader APIs in PeCoffLoader Hob entry shared between SEC, PEI and DXE\r
2e19fd0f 4\r
504214c4 5Copyright (c) 2006 - 2008, Intel Corporation \r
2e19fd0f 6All rights reserved. This program and the accompanying materials \r
7are licensed and made available under the terms and conditions of the BSD License \r
8which accompanies this distribution. The full text of the license may be found at \r
9http://opensource.org/licenses/bsd-license.php \r
10 \r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
504214c4 12WITHOUT 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
27typedef 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
ebafc55b
LG
32 Computes the PeCoffHeaderOffset, IsTeImage, ImageType, ImageAddress, ImageSize, \r
33 DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and \r
34 DebugDirectoryEntryRva fields of the ImageContext structure. \r
35 If ImageContext is NULL, then return RETURN_INVALID_PARAMETER. \r
36 If the PE/COFF image accessed through the ImageRead service in the ImageContext \r
37 structure is not a supported PE/COFF image type, then return RETURN_UNSUPPORTED. \r
38 If any errors occur while computing the fields of ImageContext, \r
39 then the error status is returned in the ImageError field of ImageContext. \r
40 If the image is a TE image, then SectionAlignment is set to 0.\r
41 The ImageRead and Handle fields of ImageContext structure must be valid prior \r
42 to invoking this service. \r
504214c4
LG
43\r
44 @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.\r
45 @param ImageContext Pointer to the image context structure that describes the PE/COFF\r
46 image that needs to be examined by this function.\r
47\r
48 @retval RETURN_SUCCESS The information on the PE/COFF image was collected.\r
49 @retval RETURN_INVALID_PARAMETER ImageContext is NULL.\r
50 @retval RETURN_UNSUPPORTED The PE/COFF image is not supported.\r
2e19fd0f 51\r
504214c4 52**/\r
2e19fd0f 53typedef \r
504214c4 54RETURN_STATUS\r
7d839888 55(EFIAPI *EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO)(\r
2e19fd0f 56 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r
57 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
58 );\r
59\r
504214c4
LG
60/**\r
61 Loads a PE/COFF image into memory.\r
62\r
63 Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer\r
64 specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate\r
65 the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.\r
66 The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.\r
ebafc55b
LG
67 The ImageRead, Handle, PeCoffHeaderOffset, IsTeImage, Machine, ImageType, ImageAddress, ImageSize, \r
68 DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva \r
69 fields of the ImageContext structure must be valid prior to invoking this service.\r
504214c4
LG
70\r
71 @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.\r
72 @param ImageContext Pointer to the image context structure that describes the PE/COFF\r
73 image that is being loaded.\r
74\r
75 @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by\r
76 the ImageAddress and ImageSize fields of ImageContext.\r
77 Extended status information is in the ImageError field of ImageContext.\r
78 @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.\r
79 Extended status information is in the ImageError field of ImageContext.\r
80 @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.\r
81 Extended status information is in the ImageError field of ImageContext.\r
82 @retval RETURN_INVALID_PARAMETER The image address is invalid.\r
83 Extended status information is in the ImageError field of ImageContext.\r
84\r
85**/\r
2e19fd0f 86typedef \r
504214c4 87RETURN_STATUS\r
7d839888 88(EFIAPI *EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE)(\r
2e19fd0f 89 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r
90 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
91 );\r
92\r
504214c4
LG
93/**\r
94 Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().\r
95\r
96 If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of\r
97 ImageContext as the relocation base address. Otherwise, use the DestinationAddress field\r
98 of ImageContext as the relocation base address. The caller must allocate the relocation\r
ebafc55b
LG
99 fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.\r
100 \r
101 The ImageRead, Handle, PeCoffHeaderOffset, IsTeImage, Machine, ImageType, ImageAddress, \r
102 ImageSize, DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, \r
103 DebugDirectoryEntryRva, EntryPoint, FixupDataSize, CodeView, PdbPointer, and FixupData of \r
104 the ImageContext structure must be valid prior to invoking this service.\r
105\r
504214c4
LG
106 If ImageContext is NULL, then ASSERT().\r
107\r
108 @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.\r
109 @param ImageContext Pointer to the image context structure that describes the PE/COFF\r
110 image that is being relocated.\r
111\r
112 @retval RETURN_SUCCESS The PE/COFF image was relocated.\r
113 Extended status information is in the ImageError field of ImageContext.\r
114 @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.\r
115 Extended status information is in the ImageError field of ImageContext.\r
116 @retval RETURN_UNSUPPORTED A relocation record type is not supported.\r
117 Extended status information is in the ImageError field of ImageContext.\r
118\r
119**/\r
2e19fd0f 120typedef \r
504214c4 121RETURN_STATUS\r
7d839888 122(EFIAPI *EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE)(\r
2e19fd0f 123 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r
124 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
125 );\r
126\r
504214c4
LG
127/**\r
128 Unloads a loaded PE/COFF image from memory and releases its taken resource.\r
ebafc55b
LG
129 Releases any environment specific resources that were allocated when the image \r
130 specified by ImageContext was loaded using PeCoffLoaderLoadImage(). \r
131 \r
504214c4
LG
132 For NT32 emulator, the PE/COFF image loaded by system needs to release.\r
133 For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded, \r
134 this function can simply return RETURN_SUCCESS.\r
135\r
136 @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.\r
137 @param ImageContext Pointer to the image context structure that describes the PE/COFF\r
138 image to be unloaded.\r
139\r
140 @retval RETURN_SUCCESS The PE/COFF image was unloaded successfully.\r
141**/\r
2e19fd0f 142typedef \r
504214c4 143RETURN_STATUS\r
7d839888 144(EFIAPI *EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE)(\r
5f597758 145 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r
2e19fd0f 146 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
147 );\r
148\r
149struct _EFI_PEI_PE_COFF_LOADER_PROTOCOL {\r
150 EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO GetImageInfo;\r
151 EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE LoadImage;\r
152 EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE RelocateImage;\r
153 EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage;\r
154};\r
155\r
156extern EFI_GUID gEfiPeiPeCoffLoaderGuid;\r
157\r
158#endif\r