]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/ExtractGuidedSectionLib.h
MdePkg/BaseLib: add PatchInstructionX86()
[mirror_edk2.git] / MdePkg / Include / Library / ExtractGuidedSectionLib.h
CommitLineData
18fd8d65 1/** @file\r
50a64e5b 2 This library provides common functions to process the different guided section data. \r
3e5c3238 3 \r
4 This library provides functions to process GUIDed sections of FFS files. Handlers may \r
5 be registered to decode GUIDed sections of FFS files. Services are provided to determine \r
6 the set of supported section GUIDs, collection information about a specific GUIDed section, \r
7 and decode a specific GUIDed section. \r
8 \r
9 A library instance that produces this library class may be used to produce a \r
10 EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI or a EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL \r
11 providing a simple method to extend the number of GUIDed sections types a platform supports.\r
18fd8d65 12\r
9be899c5 13Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
9df063a0 14This program and the accompanying materials\r
50a64e5b 15are licensed and made available under the terms and conditions of the BSD License\r
16which accompanies this distribution. The full text of the license may be found at\r
17http://opensource.org/licenses/bsd-license.php\r
18fd8d65 18\r
50a64e5b 19THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
20WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
18fd8d65 21\r
18fd8d65
LG
22**/\r
23#ifndef __EXTRACT_GUIDED_SECTION_H__\r
24#define __EXTRACT_GUIDED_SECTION_H__\r
25\r
98c39c6b 26/**\r
f1db45f8 27 Examines a GUIDed section and returns the size of the decoded buffer and the\r
28 size of an optional scratch buffer required to actually decode the data in a GUIDed section.\r
29\r
30 Examines a GUIDed section specified by InputSection. \r
31 If GUID for InputSection does not match the GUID that this handler supports,\r
32 then RETURN_UNSUPPORTED is returned. \r
33 If the required information can not be retrieved from InputSection,\r
34 then RETURN_INVALID_PARAMETER is returned.\r
35 If the GUID of InputSection does match the GUID that this handler supports,\r
36 then the size required to hold the decoded buffer is returned in OututBufferSize,\r
37 the size of an optional scratch buffer is returned in ScratchSize, and the Attributes field\r
38 from EFI_GUID_DEFINED_SECTION header of InputSection is returned in SectionAttribute.\r
3e5c3238 39 \r
f1db45f8 40 If InputSection is NULL, then ASSERT().\r
41 If OutputBufferSize is NULL, then ASSERT().\r
42 If ScratchBufferSize is NULL, then ASSERT().\r
43 If SectionAttribute is NULL, then ASSERT().\r
44\r
45\r
46 @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r
47 @param[out] OutputBufferSize A pointer to the size, in bytes, of an output buffer required\r
48 if the buffer specified by InputSection were decoded.\r
49 @param[out] ScratchBufferSize A pointer to the size, in bytes, required as scratch space\r
50 if the buffer specified by InputSection were decoded.\r
51 @param[out] SectionAttribute A pointer to the attributes of the GUIDed section. See the Attributes\r
52 field of EFI_GUID_DEFINED_SECTION in the PI Specification.\r
53\r
54 @retval RETURN_SUCCESS The information about InputSection was returned.\r
55 @retval RETURN_UNSUPPORTED The section specified by InputSection does not match the GUID this handler supports.\r
56 @retval RETURN_INVALID_PARAMETER The information can not be retrieved from the section specified by InputSection.\r
18fd8d65
LG
57\r
58**/\r
59typedef\r
60RETURN_STATUS\r
61(EFIAPI *EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER)(\r
62 IN CONST VOID *InputSection,\r
63 OUT UINT32 *OutputBufferSize,\r
64 OUT UINT32 *ScratchBufferSize,\r
65 OUT UINT16 *SectionAttribute\r
66 );\r
67\r
98c39c6b 68/**\r
f1db45f8 69 Decodes a GUIDed section into a caller allocated output buffer.\r
70 \r
71 Decodes the GUIDed section specified by InputSection. \r
72 If GUID for InputSection does not match the GUID that this handler supports, then RETURN_UNSUPPORTED is returned. \r
73 If the data in InputSection can not be decoded, then RETURN_INVALID_PARAMETER is returned.\r
74 If the GUID of InputSection does match the GUID that this handler supports, then InputSection\r
75 is decoded into the buffer specified by OutputBuffer and the authentication status of this\r
76 decode operation is returned in AuthenticationStatus. If the decoded buffer is identical to the\r
77 data in InputSection, then OutputBuffer is set to point at the data in InputSection. Otherwise,\r
78 the decoded data will be placed in caller allocated buffer specified by OutputBuffer.\r
3e5c3238 79 \r
f1db45f8 80 If InputSection is NULL, then ASSERT().\r
81 If OutputBuffer is NULL, then ASSERT().\r
82 If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
83 If AuthenticationStatus is NULL, then ASSERT().\r
84\r
85\r
86 @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r
87 @param[out] OutputBuffer A pointer to a buffer that contains the result of a decode operation. \r
88 @param[out] ScratchBuffer A caller allocated buffer that may be required by this function\r
89 as a scratch buffer to perform the decode operation. \r
18fd8d65 90 @param[out] AuthenticationStatus \r
f1db45f8 91 A pointer to the authentication status of the decoded output buffer.\r
92 See the definition of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI\r
93 section of the PI Specification. EFI_AUTH_STATUS_PLATFORM_OVERRIDE must\r
94 never be set by this handler.\r
98c39c6b 95\r
f1db45f8 96 @retval RETURN_SUCCESS The buffer specified by InputSection was decoded.\r
db5d3dbd 97 @retval RETURN_UNSUPPORTED The section specified by InputSection does not match the GUID this handler supports.\r
f1db45f8 98 @retval RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.\r
18fd8d65
LG
99\r
100**/\r
101typedef\r
102RETURN_STATUS\r
103(EFIAPI *EXTRACT_GUIDED_SECTION_DECODE_HANDLER)(\r
104 IN CONST VOID *InputSection,\r
105 OUT VOID **OutputBuffer,\r
106 IN VOID *ScratchBuffer, OPTIONAL\r
107 OUT UINT32 *AuthenticationStatus\r
108 );\r
109\r
98c39c6b 110/**\r
f1db45f8 111 Registers handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and EXTRACT_GUIDED_SECTION_DECODE_HANDLER\r
112 for a specific GUID section type.\r
113\r
3e5c3238 114 Registers the handlers specified by GetInfoHandler and DecodeHandler with the GUID specified by SectionGuid.\r
f1db45f8 115 If the GUID value specified by SectionGuid has already been registered, then return RETURN_ALREADY_STARTED.\r
116 If there are not enough resources available to register the handlers then RETURN_OUT_OF_RESOURCES is returned.\r
3e5c3238 117 \r
f1db45f8 118 If SectionGuid is NULL, then ASSERT().\r
119 If GetInfoHandler is NULL, then ASSERT().\r
120 If DecodeHandler is NULL, then ASSERT().\r
121\r
122 @param[in] SectionGuid A pointer to the GUID associated with the the handlers\r
123 of the GUIDed section type being registered.\r
124 @param[in] GetInfoHandler Pointer to a function that examines a GUIDed section and returns the\r
125 size of the decoded buffer and the size of an optional scratch buffer\r
126 required to actually decode the data in a GUIDed section.\r
127 @param[in] DecodeHandler Pointer to a function that decodes a GUIDed section into a caller\r
128 allocated output buffer. \r
129\r
130 @retval RETURN_SUCCESS The handlers were registered.\r
f1db45f8 131 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to register the handlers.\r
18fd8d65
LG
132\r
133**/\r
134RETURN_STATUS\r
135EFIAPI\r
136ExtractGuidedSectionRegisterHandlers (\r
137 IN CONST GUID *SectionGuid,\r
138 IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler,\r
139 IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler\r
140 );\r
141\r
98c39c6b 142/**\r
f1db45f8 143 Retrieve the list GUIDs that have been registered through ExtractGuidedSectionRegisterHandlers().\r
144\r
145 Sets ExtractHandlerGuidTable so it points at a callee allocated array of registered GUIDs.\r
146 The total number of GUIDs in the array are returned. Since the array of GUIDs is callee allocated\r
147 and caller must treat this array of GUIDs as read-only data. \r
148 If ExtractHandlerGuidTable is NULL, then ASSERT().\r
18fd8d65 149\r
3e5c3238 150 @param[out] ExtractHandlerGuidTable A pointer to the array of GUIDs that have been registered through\r
f1db45f8 151 ExtractGuidedSectionRegisterHandlers().\r
18fd8d65 152\r
98c39c6b 153 @return the number of the supported extract guided Handler.\r
f1db45f8 154\r
18fd8d65
LG
155**/\r
156UINTN\r
157EFIAPI\r
158ExtractGuidedSectionGetGuidList (\r
eceb3a4c 159 OUT GUID **ExtractHandlerGuidTable\r
18fd8d65
LG
160 );\r
161\r
98c39c6b 162/**\r
3e5c3238 163 Retrieves a GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
f1db45f8 164 EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r
165 The selected handler is used to retrieve and return the size of the decoded buffer and the size of an\r
166 optional scratch buffer required to actually decode the data in a GUIDed section.\r
167\r
168 Examines a GUIDed section specified by InputSection. \r
169 If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
170 then RETURN_UNSUPPORTED is returned. \r
171 If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler \r
172 of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r
173 is used to retrieve the OututBufferSize, ScratchSize, and Attributes values. The return status from the handler of\r
174 type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER is returned.\r
3e5c3238 175 \r
f1db45f8 176 If InputSection is NULL, then ASSERT().\r
177 If OutputBufferSize is NULL, then ASSERT().\r
178 If ScratchBufferSize is NULL, then ASSERT().\r
179 If SectionAttribute is NULL, then ASSERT().\r
180\r
181 @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r
182 @param[out] OutputBufferSize A pointer to the size, in bytes, of an output buffer required if the buffer\r
183 specified by InputSection were decoded.\r
184 @param[out] ScratchBufferSize A pointer to the size, in bytes, required as scratch space if the buffer specified by\r
185 InputSection were decoded.\r
186 @param[out] SectionAttribute A pointer to the attributes of the GUIDed section. See the Attributes field of\r
187 EFI_GUID_DEFINED_SECTION in the PI Specification.\r
188\r
189 @retval RETURN_SUCCESS Get the required information successfully.\r
190 @retval RETURN_UNSUPPORTED The GUID from the section specified by InputSection does not match any of\r
191 the GUIDs registered with ExtractGuidedSectionRegisterHandlers().\r
192 @retval Others The return status from the handler associated with the GUID retrieved from\r
193 the section specified by InputSection.\r
18fd8d65
LG
194\r
195**/\r
196RETURN_STATUS\r
197EFIAPI\r
198ExtractGuidedSectionGetInfo (\r
199 IN CONST VOID *InputSection,\r
200 OUT UINT32 *OutputBufferSize,\r
201 OUT UINT32 *ScratchBufferSize,\r
202 OUT UINT16 *SectionAttribute \r
203 );\r
204\r
98c39c6b 205/**\r
3e5c3238 206 Retrieves the GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
f1db45f8 207 EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r
208 The selected handler is used to decode the data in a GUIDed section and return the result in a caller\r
209 allocated output buffer.\r
210\r
211 Decodes the GUIDed section specified by InputSection. \r
212 If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
213 then RETURN_UNSUPPORTED is returned. \r
214 If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler\r
215 of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r
216 is used to decode InputSection into the buffer specified by OutputBuffer and the authentication status of this\r
217 decode operation is returned in AuthenticationStatus. If the decoded buffer is identical to the data in InputSection,\r
218 then OutputBuffer is set to point at the data in InputSection. Otherwise, the decoded data will be placed in caller\r
219 allocated buffer specified by OutputBuffer. This function is responsible for computing the EFI_AUTH_STATUS_PLATFORM_OVERRIDE\r
3e5c3238 220 bit of in AuthenticationStatus. The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned. \r
221 \r
f1db45f8 222 If InputSection is NULL, then ASSERT().\r
223 If OutputBuffer is NULL, then ASSERT().\r
224 If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
225 If AuthenticationStatus is NULL, then ASSERT(). \r
226\r
227 @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r
228 @param[out] OutputBuffer A pointer to a buffer that contains the result of a decode operation. \r
229 @param[in] ScratchBuffer A caller allocated buffer that may be required by this function as a scratch buffer to perform the decode operation. \r
18fd8d65 230 @param[out] AuthenticationStatus \r
f1db45f8 231 A pointer to the authentication status of the decoded output buffer. See the definition\r
232 of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI section of the PI\r
233 Specification.\r
234\r
235 @retval RETURN_SUCCESS The buffer specified by InputSection was decoded.\r
236 @retval RETURN_UNSUPPORTED The section specified by InputSection does not match the GUID this handler supports.\r
237 @retval RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.\r
98c39c6b 238\r
18fd8d65
LG
239**/\r
240RETURN_STATUS\r
241EFIAPI\r
242ExtractGuidedSectionDecode (\r
243 IN CONST VOID *InputSection,\r
244 OUT VOID **OutputBuffer,\r
f1db45f8 245 IN VOID *ScratchBuffer, OPTIONAL\r
18fd8d65
LG
246 OUT UINT32 *AuthenticationStatus \r
247 );\r
248\r
9be899c5
ED
249/**\r
250 Retrieves handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and \r
251 EXTRACT_GUIDED_SECTION_DECODE_HANDLER for a specific GUID section type.\r
252 \r
253 Retrieves the handlers associated with SectionGuid and returns them in \r
254 GetInfoHandler and DecodeHandler.\r
255\r
256 If the GUID value specified by SectionGuid has not been registered, then \r
257 return RETURN_NOT_FOUND.\r
258 \r
259 If SectionGuid is NULL, then ASSERT().\r
260\r
261 @param[in] SectionGuid A pointer to the GUID associated with the handlersof the GUIDed \r
262 section type being retrieved.\r
263 @param[out] GetInfoHandler Pointer to a function that examines a GUIDed section and returns \r
264 the size of the decoded buffer and the size of an optional scratch \r
265 buffer required to actually decode the data in a GUIDed section. \r
266 This is an optional parameter that may be NULL. If it is NULL, then \r
267 the previously registered handler is not returned.\r
268 @param[out] DecodeHandler Pointer to a function that decodes a GUIDed section into a caller\r
269 allocated output buffer. This is an optional parameter that may be NULL.\r
270 If it is NULL, then the previously registered handler is not returned.\r
271\r
272 @retval RETURN_SUCCESS The handlers were retrieved.\r
273 @retval RETURN_NOT_FOUND No handlers have been registered with the specified GUID.\r
274\r
275**/\r
276RETURN_STATUS\r
277EFIAPI\r
278ExtractGuidedSectionGetHandlers (\r
279 IN CONST GUID *SectionGuid,\r
280 OUT EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *GetInfoHandler, OPTIONAL\r
281 OUT EXTRACT_GUIDED_SECTION_DECODE_HANDLER *DecodeHandler OPTIONAL\r
282 );\r
283\r
18fd8d65 284#endif\r