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