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