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