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