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