]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Guid/PeiPeCoffLoader.h
Add comments and DoxyGen format for these files.
[mirror_edk2.git] / MdeModulePkg / Include / Guid / PeiPeCoffLoader.h
1 /** @file
2
3 GUID for the PE/COFF Loader APIs 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, ImageAddress, ImageSize, DestinationAddress, CodeView,
33 PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva
34 fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.
35 If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not
36 a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while
37 computing the fields of ImageContext, then the error status is returned in the ImageError field of
38 ImageContext.
39
40 @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.
41 @param ImageContext Pointer to the image context structure that describes the PE/COFF
42 image that needs to be examined by this function.
43
44 @retval RETURN_SUCCESS The information on the PE/COFF image was collected.
45 @retval RETURN_INVALID_PARAMETER ImageContext is NULL.
46 @retval RETURN_UNSUPPORTED The PE/COFF image is not supported.
47
48 **/
49 typedef
50 RETURN_STATUS
51 (EFIAPI *EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO) (
52 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
53 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
54 );
55
56 /**
57 Loads a PE/COFF image into memory.
58
59 Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer
60 specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate
61 the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.
62 The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.
63 If ImageContext is NULL, then ASSERT().
64
65 @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.
66 @param ImageContext Pointer to the image context structure that describes the PE/COFF
67 image that is being loaded.
68
69 @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by
70 the ImageAddress and ImageSize fields of ImageContext.
71 Extended status information is in the ImageError field of ImageContext.
72 @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.
73 Extended status information is in the ImageError field of ImageContext.
74 @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.
75 Extended status information is in the ImageError field of ImageContext.
76 @retval RETURN_INVALID_PARAMETER The image address is invalid.
77 Extended status information is in the ImageError field of ImageContext.
78
79 **/
80 typedef
81 RETURN_STATUS
82 (EFIAPI *EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE) (
83 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
84 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
85 );
86
87 /**
88 Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().
89
90 If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
91 ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
92 of ImageContext as the relocation base address. The caller must allocate the relocation
93 fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
94 If ImageContext is NULL, then ASSERT().
95
96 @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.
97 @param ImageContext Pointer to the image context structure that describes the PE/COFF
98 image that is being relocated.
99
100 @retval RETURN_SUCCESS The PE/COFF image was relocated.
101 Extended status information is in the ImageError field of ImageContext.
102 @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.
103 Extended status information is in the ImageError field of ImageContext.
104 @retval RETURN_UNSUPPORTED A relocation record type is not supported.
105 Extended status information is in the ImageError field of ImageContext.
106
107 **/
108 typedef
109 RETURN_STATUS
110 (EFIAPI *EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE) (
111 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
112 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
113 );
114
115 /**
116 Unloads a loaded PE/COFF image from memory and releases its taken resource.
117
118 For NT32 emulator, the PE/COFF image loaded by system needs to release.
119 For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded,
120 this function can simply return RETURN_SUCCESS.
121
122 @param This Pointer to the EFI_PEI_PE_COFF_LOADER_PROTOCOL instance.
123 @param ImageContext Pointer to the image context structure that describes the PE/COFF
124 image to be unloaded.
125
126 @retval RETURN_SUCCESS The PE/COFF image was unloaded successfully.
127 **/
128 typedef
129 RETURN_STATUS
130 (EFIAPI *EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE) (
131 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
132 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
133 );
134
135 struct _EFI_PEI_PE_COFF_LOADER_PROTOCOL {
136 EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO GetImageInfo;
137 EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE LoadImage;
138 EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE RelocateImage;
139 EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage;
140 };
141
142 extern EFI_GUID gEfiPeiPeCoffLoaderGuid;
143
144 #endif