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