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