]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Library/ExtractGuidedSectionLib.h
MdePkg Base.h: Use correct style to check the defined macro
[mirror_edk2.git] / MdePkg / Include / Library / ExtractGuidedSectionLib.h
... / ...
CommitLineData
1/** @file\r
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
11 providing a simple method to extend the number of GUIDed sections types a platform supports.\r
12\r
13Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
14SPDX-License-Identifier: BSD-2-Clause-Patent\r
15\r
16**/\r
17#ifndef __EXTRACT_GUIDED_SECTION_H__\r
18#define __EXTRACT_GUIDED_SECTION_H__\r
19\r
20/**\r
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
24 Examines a GUIDed section specified by InputSection.\r
25 If GUID for InputSection does not match the GUID that this handler supports,\r
26 then RETURN_UNSUPPORTED is returned.\r
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
33\r
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
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
62/**\r
63 Decodes a GUIDed section into a caller allocated output buffer.\r
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
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
73\r
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
81 @param[out] OutputBuffer A pointer to a buffer that contains the result of a decode operation.\r
82 @param[out] ScratchBuffer A caller allocated buffer that may be required by this function\r
83 as a scratch buffer to perform the decode operation.\r
84 @param[out] AuthenticationStatus\r
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
89\r
90 @retval RETURN_SUCCESS The buffer specified by InputSection was decoded.\r
91 @retval RETURN_UNSUPPORTED The section specified by InputSection does not match the GUID this handler supports.\r
92 @retval RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.\r
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
100 IN VOID *ScratchBuffer, OPTIONAL\r
101 OUT UINT32 *AuthenticationStatus\r
102 );\r
103\r
104/**\r
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
108 Registers the handlers specified by GetInfoHandler and DecodeHandler with the GUID specified by SectionGuid.\r
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
111\r
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
122 allocated output buffer.\r
123\r
124 @retval RETURN_SUCCESS The handlers were registered.\r
125 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to register the handlers.\r
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
136/**\r
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
141 and caller must treat this array of GUIDs as read-only data.\r
142 If ExtractHandlerGuidTable is NULL, then ASSERT().\r
143\r
144 @param[out] ExtractHandlerGuidTable A pointer to the array of GUIDs that have been registered through\r
145 ExtractGuidedSectionRegisterHandlers().\r
146\r
147 @return the number of the supported extract guided Handler.\r
148\r
149**/\r
150UINTN\r
151EFIAPI\r
152ExtractGuidedSectionGetGuidList (\r
153 OUT GUID **ExtractHandlerGuidTable\r
154 );\r
155\r
156/**\r
157 Retrieves a GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
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
162 Examines a GUIDed section specified by InputSection.\r
163 If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
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
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
169\r
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
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
196 OUT UINT16 *SectionAttribute\r
197 );\r
198\r
199/**\r
200 Retrieves the GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
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
205 Decodes the GUIDed section specified by InputSection.\r
206 If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
207 then RETURN_UNSUPPORTED is returned.\r
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
214 bit of in AuthenticationStatus. The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned.\r
215\r
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
219 If AuthenticationStatus is NULL, then ASSERT().\r
220\r
221 @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r
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
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
232\r
233**/\r
234RETURN_STATUS\r
235EFIAPI\r
236ExtractGuidedSectionDecode (\r
237 IN CONST VOID *InputSection,\r
238 OUT VOID **OutputBuffer,\r
239 IN VOID *ScratchBuffer, OPTIONAL\r
240 OUT UINT32 *AuthenticationStatus\r
241 );\r
242\r
243/**\r
244 Retrieves handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and\r
245 EXTRACT_GUIDED_SECTION_DECODE_HANDLER for a specific GUID section type.\r
246\r
247 Retrieves the handlers associated with SectionGuid and returns them in\r
248 GetInfoHandler and DecodeHandler.\r
249\r
250 If the GUID value specified by SectionGuid has not been registered, then\r
251 return RETURN_NOT_FOUND.\r
252\r
253 If SectionGuid is NULL, then ASSERT().\r
254\r
255 @param[in] SectionGuid A pointer to the GUID associated with the handlersof the GUIDed\r
256 section type being retrieved.\r
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
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
274 OUT EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *GetInfoHandler, OPTIONAL\r
275 OUT EXTRACT_GUIDED_SECTION_DECODE_HANDLER *DecodeHandler OPTIONAL\r
276 );\r
277\r
278#endif\r