]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/ExtractGuidedSectionLib.h
Synchronize function comment in
[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 - 2008, Intel Corporation<BR>
14 All rights reserved. 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_UNSPPORTED 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_ALREADY_STARTED Handlers have already been registered for the GUID specified by SectionGuid.
132 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to register the handlers.
133
134 **/
135 RETURN_STATUS
136 EFIAPI
137 ExtractGuidedSectionRegisterHandlers (
138 IN CONST GUID *SectionGuid,
139 IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler,
140 IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler
141 );
142
143 /**
144 Retrieve the list GUIDs that have been registered through ExtractGuidedSectionRegisterHandlers().
145
146 Sets ExtractHandlerGuidTable so it points at a callee allocated array of registered GUIDs.
147 The total number of GUIDs in the array are returned. Since the array of GUIDs is callee allocated
148 and caller must treat this array of GUIDs as read-only data.
149 If ExtractHandlerGuidTable is NULL, then ASSERT().
150
151 @param[out] ExtractHandlerGuidTable A pointer to the array of GUIDs that have been registered through
152 ExtractGuidedSectionRegisterHandlers().
153
154 @return the number of the supported extract guided Handler.
155
156 **/
157 UINTN
158 EFIAPI
159 ExtractGuidedSectionGetGuidList (
160 OUT GUID **ExtractHandlerGuidTable
161 );
162
163 /**
164 Retrieves a GUID from a GUIDed section and uses that GUID to select an associated handler of type
165 EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().
166 The selected handler is used to retrieve and return the size of the decoded buffer and the size of an
167 optional scratch buffer required to actually decode the data in a GUIDed section.
168
169 Examines a GUIDed section specified by InputSection.
170 If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),
171 then RETURN_UNSUPPORTED is returned.
172 If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler
173 of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()
174 is used to retrieve the OututBufferSize, ScratchSize, and Attributes values. The return status from the handler of
175 type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER is returned.
176
177 If InputSection is NULL, then ASSERT().
178 If OutputBufferSize is NULL, then ASSERT().
179 If ScratchBufferSize is NULL, then ASSERT().
180 If SectionAttribute is NULL, then ASSERT().
181
182 @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.
183 @param[out] OutputBufferSize A pointer to the size, in bytes, of an output buffer required if the buffer
184 specified by InputSection were decoded.
185 @param[out] ScratchBufferSize A pointer to the size, in bytes, required as scratch space if the buffer specified by
186 InputSection were decoded.
187 @param[out] SectionAttribute A pointer to the attributes of the GUIDed section. See the Attributes field of
188 EFI_GUID_DEFINED_SECTION in the PI Specification.
189
190 @retval RETURN_SUCCESS Get the required information successfully.
191 @retval RETURN_UNSUPPORTED The GUID from the section specified by InputSection does not match any of
192 the GUIDs registered with ExtractGuidedSectionRegisterHandlers().
193 @retval Others The return status from the handler associated with the GUID retrieved from
194 the section specified by InputSection.
195
196 **/
197 RETURN_STATUS
198 EFIAPI
199 ExtractGuidedSectionGetInfo (
200 IN CONST VOID *InputSection,
201 OUT UINT32 *OutputBufferSize,
202 OUT UINT32 *ScratchBufferSize,
203 OUT UINT16 *SectionAttribute
204 );
205
206 /**
207 Retrieves the GUID from a GUIDed section and uses that GUID to select an associated handler of type
208 EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().
209 The selected handler is used to decode the data in a GUIDed section and return the result in a caller
210 allocated output buffer.
211
212 Decodes the GUIDed section specified by InputSection.
213 If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),
214 then RETURN_UNSUPPORTED is returned.
215 If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler
216 of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()
217 is used to decode InputSection into the buffer specified by OutputBuffer and the authentication status of this
218 decode operation is returned in AuthenticationStatus. If the decoded buffer is identical to the data in InputSection,
219 then OutputBuffer is set to point at the data in InputSection. Otherwise, the decoded data will be placed in caller
220 allocated buffer specified by OutputBuffer. This function is responsible for computing the EFI_AUTH_STATUS_PLATFORM_OVERRIDE
221 bit of in AuthenticationStatus. The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned.
222
223 If InputSection is NULL, then ASSERT().
224 If OutputBuffer is NULL, then ASSERT().
225 If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().
226 If AuthenticationStatus is NULL, then ASSERT().
227
228 @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.
229 @param[out] OutputBuffer A pointer to a buffer that contains the result of a decode operation.
230 @param[in] ScratchBuffer A caller allocated buffer that may be required by this function as a scratch buffer to perform the decode operation.
231 @param[out] AuthenticationStatus
232 A pointer to the authentication status of the decoded output buffer. See the definition
233 of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI section of the PI
234 Specification.
235
236 @retval RETURN_SUCCESS The buffer specified by InputSection was decoded.
237 @retval RETURN_UNSUPPORTED The section specified by InputSection does not match the GUID this handler supports.
238 @retval RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.
239
240 **/
241 RETURN_STATUS
242 EFIAPI
243 ExtractGuidedSectionDecode (
244 IN CONST VOID *InputSection,
245 OUT VOID **OutputBuffer,
246 IN VOID *ScratchBuffer, OPTIONAL
247 OUT UINT32 *AuthenticationStatus
248 );
249
250 #endif