]>
Commit | Line | Data |
---|---|---|
8069d49e | 1 | /** @file\r |
eceb3a4c | 2 | Provide generic extract guided section functions for PEI phase.\r |
0fa00159 | 3 | \r |
9095d37b | 4 | Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r |
19388d29 | 5 | This program and the accompanying materials\r |
8069d49e LG |
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 | |
2fc59a00 | 8 | http://opensource.org/licenses/bsd-license.php.\r |
0fa00159 | 9 | \r |
8069d49e LG |
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 | |
0fa00159 | 12 | \r |
8069d49e | 13 | **/\r |
0fa00159 LG |
14 | \r |
15 | #include <PiPei.h>\r | |
16 | \r | |
17 | #include <Library/DebugLib.h>\r | |
18 | #include <Library/PcdLib.h>\r | |
19 | #include <Library/BaseMemoryLib.h>\r | |
20 | #include <Library/HobLib.h>\r | |
21 | #include <Library/ExtractGuidedSectionLib.h>\r | |
22 | \r | |
07636730 | 23 | #define PEI_EXTRACT_HANDLER_INFO_SIGNATURE SIGNATURE_32 ('P', 'E', 'H', 'I')\r |
0fa00159 LG |
24 | \r |
25 | typedef struct {\r | |
26 | UINT32 Signature;\r | |
27 | UINT32 NumberOfExtractHandler;\r | |
28 | GUID *ExtractHandlerGuidTable;\r | |
29 | EXTRACT_GUIDED_SECTION_DECODE_HANDLER *ExtractDecodeHandlerTable;\r | |
30 | EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *ExtractGetInfoHandlerTable;\r | |
31 | } PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO;\r | |
32 | \r | |
4754c98b | 33 | /**\r |
0fa00159 LG |
34 | Build guid hob for the global memory to store the registered guid and Handler list.\r |
35 | If GuidHob exists, HandlerInfo will be directly got from Guid hob data.\r | |
36 | \r | |
58380e9c | 37 | @param[in, out] InfoPointer The pointer to pei handler information structure.\r |
0fa00159 | 38 | \r |
3e5c3238 | 39 | @retval RETURN_SUCCESS Build Guid hob for the global memory space to store guid and function tables.\r |
4754c98b | 40 | @retval RETURN_OUT_OF_RESOURCES No enough memory to allocated.\r |
0fa00159 LG |
41 | **/\r |
42 | RETURN_STATUS\r | |
0fa00159 LG |
43 | PeiGetExtractGuidedSectionHandlerInfo (\r |
44 | IN OUT PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO **InfoPointer\r | |
45 | )\r | |
46 | {\r | |
47 | PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r | |
48 | EFI_PEI_HOB_POINTERS Hob;\r | |
9095d37b | 49 | \r |
0fa00159 | 50 | //\r |
58380e9c | 51 | // First try to get handler information from guid hob specified by CallerId.\r |
0fa00159 LG |
52 | //\r |
53 | Hob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GetHobList ());\r | |
54 | while (Hob.Raw != NULL) {\r | |
55 | if (CompareGuid (&(Hob.Guid->Name), &gEfiCallerIdGuid)) {\r | |
56 | HandlerInfo = (PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *) GET_GUID_HOB_DATA (Hob.Guid);\r | |
57 | if (HandlerInfo->Signature == PEI_EXTRACT_HANDLER_INFO_SIGNATURE) {\r | |
e111752c LG |
58 | //\r |
59 | // Update Table Pointer when hob start address is changed.\r | |
60 | //\r | |
61 | if (HandlerInfo->ExtractHandlerGuidTable != (GUID *) (HandlerInfo + 1)) {\r | |
62 | HandlerInfo->ExtractHandlerGuidTable = (GUID *) (HandlerInfo + 1);\r | |
63 | HandlerInfo->ExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *) (\r | |
9095d37b | 64 | (UINT8 *)HandlerInfo->ExtractHandlerGuidTable +\r |
e111752c LG |
65 | PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID)\r |
66 | );\r | |
67 | HandlerInfo->ExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *) (\r | |
9095d37b LG |
68 | (UINT8 *)HandlerInfo->ExtractDecodeHandlerTable +\r |
69 | PcdGet32 (PcdMaximumGuidedExtractHandler) *\r | |
b9d5a7f1 | 70 | sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER)\r |
e111752c LG |
71 | );\r |
72 | }\r | |
73 | //\r | |
74 | // Return HandlerInfo pointer.\r | |
75 | //\r | |
0fa00159 LG |
76 | *InfoPointer = HandlerInfo;\r |
77 | return EFI_SUCCESS;\r | |
78 | }\r | |
79 | }\r | |
80 | Hob.Raw = GET_NEXT_HOB (Hob);\r | |
81 | Hob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, Hob.Raw);\r | |
82 | }\r | |
9095d37b | 83 | \r |
0fa00159 LG |
84 | //\r |
85 | // If Guid Hob is not found, Build CallerId Guid hob to store Handler Info\r | |
86 | //\r | |
87 | HandlerInfo = BuildGuidHob (\r | |
9095d37b | 88 | &gEfiCallerIdGuid,\r |
0fa00159 | 89 | sizeof (PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO) +\r |
9095d37b | 90 | PcdGet32 (PcdMaximumGuidedExtractHandler) *\r |
0fa00159 LG |
91 | (sizeof (GUID) + sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER) + sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER))\r |
92 | );\r | |
93 | if (HandlerInfo == NULL) {\r | |
94 | //\r | |
95 | // No enough resource to build guid hob.\r | |
96 | //\r | |
b9d5a7f1 | 97 | *InfoPointer = NULL;\r |
0fa00159 LG |
98 | return EFI_OUT_OF_RESOURCES;\r |
99 | }\r | |
eceb3a4c LG |
100 | //\r |
101 | // Init HandlerInfo structure\r | |
102 | //\r | |
0fa00159 LG |
103 | HandlerInfo->Signature = PEI_EXTRACT_HANDLER_INFO_SIGNATURE;\r |
104 | HandlerInfo->NumberOfExtractHandler = 0;\r | |
105 | HandlerInfo->ExtractHandlerGuidTable = (GUID *) (HandlerInfo + 1);\r | |
106 | HandlerInfo->ExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *) (\r | |
9095d37b | 107 | (UINT8 *)HandlerInfo->ExtractHandlerGuidTable +\r |
0fa00159 LG |
108 | PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID)\r |
109 | );\r | |
110 | HandlerInfo->ExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *) (\r | |
9095d37b LG |
111 | (UINT8 *)HandlerInfo->ExtractDecodeHandlerTable +\r |
112 | PcdGet32 (PcdMaximumGuidedExtractHandler) *\r | |
b9d5a7f1 | 113 | sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER)\r |
0fa00159 | 114 | );\r |
eceb3a4c LG |
115 | //\r |
116 | // return the created HandlerInfo.\r | |
117 | //\r | |
0fa00159 LG |
118 | *InfoPointer = HandlerInfo;\r |
119 | return EFI_SUCCESS;\r | |
120 | }\r | |
121 | \r | |
4754c98b | 122 | /**\r |
f1db45f8 | 123 | Retrieve the list GUIDs that have been registered through ExtractGuidedSectionRegisterHandlers().\r |
0fa00159 | 124 | \r |
f1db45f8 | 125 | Sets ExtractHandlerGuidTable so it points at a callee allocated array of registered GUIDs.\r |
126 | The total number of GUIDs in the array are returned. Since the array of GUIDs is callee allocated\r | |
9095d37b | 127 | and caller must treat this array of GUIDs as read-only data.\r |
f1db45f8 | 128 | If ExtractHandlerGuidTable is NULL, then ASSERT().\r |
129 | \r | |
3e5c3238 | 130 | @param[out] ExtractHandlerGuidTable A pointer to the array of GUIDs that have been registered through\r |
f1db45f8 | 131 | ExtractGuidedSectionRegisterHandlers().\r |
0fa00159 | 132 | \r |
4754c98b | 133 | @return the number of the supported extract guided Handler.\r |
f1db45f8 | 134 | \r |
0fa00159 LG |
135 | **/\r |
136 | UINTN\r | |
137 | EFIAPI\r | |
138 | ExtractGuidedSectionGetGuidList (\r | |
eceb3a4c | 139 | OUT GUID **ExtractHandlerGuidTable\r |
0fa00159 LG |
140 | )\r |
141 | {\r | |
142 | EFI_STATUS Status;\r | |
143 | PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r | |
144 | \r | |
145 | ASSERT (ExtractHandlerGuidTable != NULL);\r | |
146 | \r | |
eceb3a4c LG |
147 | //\r |
148 | // Get all registered handler information\r | |
149 | //\r | |
0fa00159 LG |
150 | Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r |
151 | if (EFI_ERROR (Status)) {\r | |
b9d5a7f1 LG |
152 | *ExtractHandlerGuidTable = NULL;\r |
153 | return 0;\r | |
0fa00159 LG |
154 | }\r |
155 | \r | |
eceb3a4c LG |
156 | //\r |
157 | // Get GuidTable and Table Number\r | |
158 | //\r | |
3dbef428 | 159 | ASSERT (HandlerInfo != NULL);\r |
0fa00159 LG |
160 | *ExtractHandlerGuidTable = HandlerInfo->ExtractHandlerGuidTable;\r |
161 | return HandlerInfo->NumberOfExtractHandler;\r | |
162 | }\r | |
163 | \r | |
4754c98b | 164 | /**\r |
f1db45f8 | 165 | Registers handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and EXTRACT_GUIDED_SECTION_DECODE_HANDLER\r |
166 | for a specific GUID section type.\r | |
167 | \r | |
3e5c3238 | 168 | Registers the handlers specified by GetInfoHandler and DecodeHandler with the GUID specified by SectionGuid.\r |
f1db45f8 | 169 | If the GUID value specified by SectionGuid has already been registered, then return RETURN_ALREADY_STARTED.\r |
170 | If there are not enough resources available to register the handlers then RETURN_OUT_OF_RESOURCES is returned.\r | |
9095d37b | 171 | \r |
f1db45f8 | 172 | If SectionGuid is NULL, then ASSERT().\r |
173 | If GetInfoHandler is NULL, then ASSERT().\r | |
174 | If DecodeHandler is NULL, then ASSERT().\r | |
175 | \r | |
176 | @param[in] SectionGuid A pointer to the GUID associated with the the handlers\r | |
177 | of the GUIDed section type being registered.\r | |
2fc59a00 | 178 | @param[in] GetInfoHandler The pointer to a function that examines a GUIDed section and returns the\r |
f1db45f8 | 179 | size of the decoded buffer and the size of an optional scratch buffer\r |
180 | required to actually decode the data in a GUIDed section.\r | |
2fc59a00 | 181 | @param[in] DecodeHandler The pointer to a function that decodes a GUIDed section into a caller\r |
9095d37b | 182 | allocated output buffer.\r |
f1db45f8 | 183 | \r |
184 | @retval RETURN_SUCCESS The handlers were registered.\r | |
f1db45f8 | 185 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to register the handlers.\r |
4754c98b | 186 | \r |
0fa00159 LG |
187 | **/\r |
188 | RETURN_STATUS\r | |
189 | EFIAPI\r | |
190 | ExtractGuidedSectionRegisterHandlers (\r | |
191 | IN CONST GUID *SectionGuid,\r | |
192 | IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler,\r | |
193 | IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler\r | |
194 | )\r | |
195 | {\r | |
196 | EFI_STATUS Status;\r | |
e2701217 | 197 | UINT32 Index;\r |
0fa00159 LG |
198 | PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r |
199 | \r | |
200 | //\r | |
a750b4ae | 201 | // Check input parameter\r |
0fa00159 | 202 | //\r |
f1db45f8 | 203 | ASSERT (SectionGuid != NULL);\r |
204 | ASSERT (GetInfoHandler != NULL);\r | |
205 | ASSERT (DecodeHandler != NULL);\r | |
206 | \r | |
207 | \r | |
0fa00159 LG |
208 | \r |
209 | //\r | |
210 | // Get the registered handler information\r | |
211 | //\r | |
212 | Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r | |
213 | if (EFI_ERROR (Status)) {\r | |
214 | return Status;\r | |
215 | }\r | |
e2701217 LG |
216 | \r |
217 | //\r | |
218 | // Search the match registered GetInfo handler for the input guided section.\r | |
219 | //\r | |
3dbef428 | 220 | ASSERT (HandlerInfo != NULL);\r |
e2701217 | 221 | for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r |
e111752c | 222 | if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionGuid)) {\r |
b911d09f LG |
223 | //\r |
224 | // If the guided handler has been registered before, only update its handler.\r | |
225 | //\r | |
226 | HandlerInfo->ExtractDecodeHandlerTable [Index] = DecodeHandler;\r | |
227 | HandlerInfo->ExtractGetInfoHandlerTable [Index] = GetInfoHandler;\r | |
228 | return RETURN_SUCCESS;\r | |
e2701217 LG |
229 | }\r |
230 | }\r | |
231 | \r | |
0fa00159 LG |
232 | //\r |
233 | // Check the global table is enough to contain new Handler.\r | |
234 | //\r | |
235 | if (HandlerInfo->NumberOfExtractHandler >= PcdGet32 (PcdMaximumGuidedExtractHandler)) {\r | |
236 | return RETURN_OUT_OF_RESOURCES;\r | |
237 | }\r | |
9095d37b | 238 | \r |
0fa00159 LG |
239 | //\r |
240 | // Register new Handler and guid value.\r | |
241 | //\r | |
e111752c | 242 | CopyGuid (HandlerInfo->ExtractHandlerGuidTable + HandlerInfo->NumberOfExtractHandler, SectionGuid);\r |
0fa00159 LG |
243 | HandlerInfo->ExtractDecodeHandlerTable [HandlerInfo->NumberOfExtractHandler] = DecodeHandler;\r |
244 | HandlerInfo->ExtractGetInfoHandlerTable [HandlerInfo->NumberOfExtractHandler++] = GetInfoHandler;\r | |
b9d5a7f1 | 245 | \r |
8472f1f5 SZ |
246 | //\r |
247 | // Build the Guided Section GUID HOB to record the GUID itself.\r | |
248 | // Then the content of the GUIDed HOB will be the same as the GUID value itself.\r | |
249 | //\r | |
250 | BuildGuidDataHob (\r | |
251 | (EFI_GUID *) SectionGuid,\r | |
252 | (VOID *) SectionGuid,\r | |
253 | sizeof (GUID)\r | |
254 | );\r | |
255 | \r | |
0fa00159 LG |
256 | return RETURN_SUCCESS;\r |
257 | }\r | |
258 | \r | |
4754c98b | 259 | /**\r |
3e5c3238 | 260 | Retrieves a GUID from a GUIDed section and uses that GUID to select an associated handler of type\r |
f1db45f8 | 261 | EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r |
262 | The selected handler is used to retrieve and return the size of the decoded buffer and the size of an\r | |
263 | optional scratch buffer required to actually decode the data in a GUIDed section.\r | |
264 | \r | |
9095d37b | 265 | Examines a GUIDed section specified by InputSection.\r |
f1db45f8 | 266 | If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r |
9095d37b LG |
267 | then RETURN_UNSUPPORTED is returned.\r |
268 | If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler\r | |
f1db45f8 | 269 | of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r |
270 | is used to retrieve the OututBufferSize, ScratchSize, and Attributes values. The return status from the handler of\r | |
271 | type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER is returned.\r | |
9095d37b | 272 | \r |
f1db45f8 | 273 | If InputSection is NULL, then ASSERT().\r |
274 | If OutputBufferSize is NULL, then ASSERT().\r | |
275 | If ScratchBufferSize is NULL, then ASSERT().\r | |
276 | If SectionAttribute is NULL, then ASSERT().\r | |
277 | \r | |
278 | @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r | |
279 | @param[out] OutputBufferSize A pointer to the size, in bytes, of an output buffer required if the buffer\r | |
280 | specified by InputSection were decoded.\r | |
281 | @param[out] ScratchBufferSize A pointer to the size, in bytes, required as scratch space if the buffer specified by\r | |
282 | InputSection were decoded.\r | |
283 | @param[out] SectionAttribute A pointer to the attributes of the GUIDed section. See the Attributes field of\r | |
284 | EFI_GUID_DEFINED_SECTION in the PI Specification.\r | |
285 | \r | |
286 | @retval RETURN_SUCCESS Get the required information successfully.\r | |
287 | @retval RETURN_UNSUPPORTED The GUID from the section specified by InputSection does not match any of\r | |
288 | the GUIDs registered with ExtractGuidedSectionRegisterHandlers().\r | |
289 | @retval Others The return status from the handler associated with the GUID retrieved from\r | |
290 | the section specified by InputSection.\r | |
0fa00159 LG |
291 | \r |
292 | **/\r | |
293 | RETURN_STATUS\r | |
294 | EFIAPI\r | |
295 | ExtractGuidedSectionGetInfo (\r | |
296 | IN CONST VOID *InputSection,\r | |
297 | OUT UINT32 *OutputBufferSize,\r | |
298 | OUT UINT32 *ScratchBufferSize,\r | |
9095d37b | 299 | OUT UINT16 *SectionAttribute\r |
0fa00159 LG |
300 | )\r |
301 | {\r | |
302 | UINT32 Index;\r | |
303 | EFI_STATUS Status;\r | |
304 | PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r | |
30f001ca | 305 | EFI_GUID *SectionDefinitionGuid;\r |
9095d37b | 306 | \r |
0fa00159 | 307 | //\r |
a750b4ae | 308 | // Check input parameter\r |
0fa00159 | 309 | //\r |
f1db45f8 | 310 | ASSERT (InputSection != NULL);\r |
0fa00159 LG |
311 | ASSERT (OutputBufferSize != NULL);\r |
312 | ASSERT (ScratchBufferSize != NULL);\r | |
313 | ASSERT (SectionAttribute != NULL);\r | |
314 | \r | |
315 | //\r | |
eceb3a4c | 316 | // Get all registered handler information.\r |
0fa00159 LG |
317 | //\r |
318 | Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r | |
319 | if (EFI_ERROR (Status)) {\r | |
320 | return Status;\r | |
321 | }\r | |
30f001ca SZ |
322 | \r |
323 | if (IS_SECTION2 (InputSection)) {\r | |
324 | SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);\r | |
325 | } else {\r | |
326 | SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);\r | |
327 | }\r | |
328 | \r | |
0fa00159 LG |
329 | //\r |
330 | // Search the match registered GetInfo handler for the input guided section.\r | |
331 | //\r | |
3dbef428 | 332 | ASSERT (HandlerInfo != NULL);\r |
0fa00159 | 333 | for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r |
30f001ca | 334 | if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) {\r |
b911d09f | 335 | //\r |
58380e9c | 336 | // Call the match handler to get information for the input section data.\r |
b911d09f LG |
337 | //\r |
338 | return HandlerInfo->ExtractGetInfoHandlerTable [Index] (\r | |
339 | InputSection,\r | |
340 | OutputBufferSize,\r | |
341 | ScratchBufferSize,\r | |
342 | SectionAttribute\r | |
343 | );\r | |
0fa00159 LG |
344 | }\r |
345 | }\r | |
346 | \r | |
347 | //\r | |
9095d37b | 348 | // Not found, the input guided section is not supported.\r |
0fa00159 | 349 | //\r |
b911d09f | 350 | return RETURN_UNSUPPORTED;\r |
0fa00159 LG |
351 | }\r |
352 | \r | |
4754c98b | 353 | /**\r |
3e5c3238 | 354 | Retrieves the GUID from a GUIDed section and uses that GUID to select an associated handler of type\r |
f1db45f8 | 355 | EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r |
356 | The selected handler is used to decode the data in a GUIDed section and return the result in a caller\r | |
357 | allocated output buffer.\r | |
358 | \r | |
9095d37b | 359 | Decodes the GUIDed section specified by InputSection.\r |
f1db45f8 | 360 | If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r |
9095d37b | 361 | then RETURN_UNSUPPORTED is returned.\r |
f1db45f8 | 362 | If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler\r |
363 | of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r | |
364 | is used to decode InputSection into the buffer specified by OutputBuffer and the authentication status of this\r | |
365 | decode operation is returned in AuthenticationStatus. If the decoded buffer is identical to the data in InputSection,\r | |
366 | then OutputBuffer is set to point at the data in InputSection. Otherwise, the decoded data will be placed in caller\r | |
367 | allocated buffer specified by OutputBuffer. This function is responsible for computing the EFI_AUTH_STATUS_PLATFORM_OVERRIDE\r | |
9095d37b LG |
368 | bit of in AuthenticationStatus. The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned.\r |
369 | \r | |
f1db45f8 | 370 | If InputSection is NULL, then ASSERT().\r |
371 | If OutputBuffer is NULL, then ASSERT().\r | |
372 | If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r | |
9095d37b | 373 | If AuthenticationStatus is NULL, then ASSERT().\r |
f1db45f8 | 374 | \r |
375 | @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r | |
9095d37b LG |
376 | @param[out] OutputBuffer A pointer to a buffer that contains the result of a decode operation.\r |
377 | @param[in] ScratchBuffer A caller allocated buffer that may be required by this function as a scratch buffer to perform the decode operation.\r | |
378 | @param[out] AuthenticationStatus\r | |
f1db45f8 | 379 | A pointer to the authentication status of the decoded output buffer. See the definition\r |
380 | of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI section of the PI\r | |
381 | Specification.\r | |
4754c98b | 382 | \r |
f1db45f8 | 383 | @retval RETURN_SUCCESS The buffer specified by InputSection was decoded.\r |
384 | @retval RETURN_UNSUPPORTED The section specified by InputSection does not match the GUID this handler supports.\r | |
385 | @retval RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.\r | |
4754c98b | 386 | \r |
0fa00159 LG |
387 | **/\r |
388 | RETURN_STATUS\r | |
389 | EFIAPI\r | |
390 | ExtractGuidedSectionDecode (\r | |
391 | IN CONST VOID *InputSection,\r | |
392 | OUT VOID **OutputBuffer,\r | |
f1db45f8 | 393 | IN VOID *ScratchBuffer, OPTIONAL\r |
9095d37b | 394 | OUT UINT32 *AuthenticationStatus\r |
0fa00159 LG |
395 | )\r |
396 | {\r | |
397 | UINT32 Index;\r | |
398 | EFI_STATUS Status;\r | |
399 | PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r | |
30f001ca | 400 | EFI_GUID *SectionDefinitionGuid;\r |
9095d37b | 401 | \r |
eceb3a4c LG |
402 | //\r |
403 | // Check input parameter\r | |
404 | //\r | |
f1db45f8 | 405 | ASSERT (InputSection != NULL);\r |
0fa00159 LG |
406 | ASSERT (OutputBuffer != NULL);\r |
407 | ASSERT (AuthenticationStatus != NULL);\r | |
eceb3a4c LG |
408 | \r |
409 | //\r | |
410 | // Get all registered handler information.\r | |
9095d37b | 411 | //\r |
0fa00159 LG |
412 | Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r |
413 | if (EFI_ERROR (Status)) {\r | |
414 | return Status;\r | |
415 | }\r | |
416 | \r | |
30f001ca SZ |
417 | if (IS_SECTION2 (InputSection)) {\r |
418 | SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);\r | |
419 | } else {\r | |
420 | SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);\r | |
421 | }\r | |
422 | \r | |
0fa00159 | 423 | //\r |
eceb3a4c | 424 | // Search the match registered Extract handler for the input guided section.\r |
0fa00159 | 425 | //\r |
3dbef428 | 426 | ASSERT (HandlerInfo != NULL);\r |
0fa00159 | 427 | for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r |
30f001ca | 428 | if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) {\r |
b911d09f LG |
429 | //\r |
430 | // Call the match handler to extract raw data for the input guided section.\r | |
431 | //\r | |
432 | return HandlerInfo->ExtractDecodeHandlerTable [Index] (\r | |
433 | InputSection,\r | |
434 | OutputBuffer,\r | |
435 | ScratchBuffer,\r | |
436 | AuthenticationStatus\r | |
437 | );\r | |
0fa00159 LG |
438 | }\r |
439 | }\r | |
440 | \r | |
441 | //\r | |
9095d37b | 442 | // Not found, the input guided section is not supported.\r |
0fa00159 | 443 | //\r |
b911d09f | 444 | return RETURN_UNSUPPORTED;\r |
0fa00159 | 445 | }\r |
9be899c5 ED |
446 | \r |
447 | /**\r | |
9095d37b | 448 | Retrieves handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and\r |
9be899c5 | 449 | EXTRACT_GUIDED_SECTION_DECODE_HANDLER for a specific GUID section type.\r |
9095d37b LG |
450 | \r |
451 | Retrieves the handlers associated with SectionGuid and returns them in\r | |
9be899c5 ED |
452 | GetInfoHandler and DecodeHandler.\r |
453 | \r | |
9095d37b | 454 | If the GUID value specified by SectionGuid has not been registered, then\r |
9be899c5 | 455 | return RETURN_NOT_FOUND.\r |
9095d37b | 456 | \r |
9be899c5 ED |
457 | If SectionGuid is NULL, then ASSERT().\r |
458 | \r | |
9095d37b | 459 | @param[in] SectionGuid A pointer to the GUID associated with the handlersof the GUIDed\r |
9be899c5 | 460 | section type being retrieved.\r |
9095d37b LG |
461 | @param[out] GetInfoHandler Pointer to a function that examines a GUIDed section and returns\r |
462 | the size of the decoded buffer and the size of an optional scratch\r | |
463 | buffer required to actually decode the data in a GUIDed section.\r | |
464 | This is an optional parameter that may be NULL. If it is NULL, then\r | |
9be899c5 ED |
465 | the previously registered handler is not returned.\r |
466 | @param[out] DecodeHandler Pointer to a function that decodes a GUIDed section into a caller\r | |
467 | allocated output buffer. This is an optional parameter that may be NULL.\r | |
468 | If it is NULL, then the previously registered handler is not returned.\r | |
469 | \r | |
470 | @retval RETURN_SUCCESS The handlers were retrieved.\r | |
471 | @retval RETURN_NOT_FOUND No handlers have been registered with the specified GUID.\r | |
472 | \r | |
473 | **/\r | |
474 | RETURN_STATUS\r | |
475 | EFIAPI\r | |
476 | ExtractGuidedSectionGetHandlers (\r | |
477 | IN CONST GUID *SectionGuid,\r | |
478 | OUT EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *GetInfoHandler, OPTIONAL\r | |
479 | OUT EXTRACT_GUIDED_SECTION_DECODE_HANDLER *DecodeHandler OPTIONAL\r | |
480 | )\r | |
481 | {\r | |
482 | EFI_STATUS Status;\r | |
483 | UINT32 Index;\r | |
484 | PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r | |
485 | \r | |
486 | //\r | |
487 | // Check input parameter\r | |
488 | //\r | |
489 | ASSERT (SectionGuid != NULL);\r | |
490 | \r | |
491 | //\r | |
492 | // Get the registered handler information\r | |
493 | //\r | |
494 | Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r | |
495 | if (EFI_ERROR (Status)) {\r | |
496 | return Status;\r | |
497 | }\r | |
498 | \r | |
499 | //\r | |
500 | // Search the match registered GetInfo handler for the input guided section.\r | |
501 | //\r | |
502 | ASSERT (HandlerInfo != NULL);\r | |
503 | for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r | |
504 | if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionGuid)) {\r | |
505 | \r | |
506 | //\r | |
507 | // If the guided handler has been registered before, then return the registered handlers.\r | |
508 | //\r | |
509 | if (GetInfoHandler != NULL) {\r | |
510 | *GetInfoHandler = HandlerInfo->ExtractGetInfoHandlerTable[Index];\r | |
511 | }\r | |
512 | if (DecodeHandler != NULL) {\r | |
513 | *DecodeHandler = HandlerInfo->ExtractDecodeHandlerTable[Index];\r | |
514 | }\r | |
515 | return RETURN_SUCCESS;\r | |
516 | }\r | |
517 | }\r | |
518 | return RETURN_NOT_FOUND;\r | |
519 | }\r |