]>
Commit | Line | Data |
---|---|---|
8069d49e | 1 | /** @file\r |
eceb3a4c | 2 | Provide generic extract guided section functions for Dxe phase.\r |
0fa00159 | 3 | \r |
8472f1f5 | 4 | Copyright (c) 2007 - 2012, 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 <PiDxe.h>\r | |
16 | \r | |
17 | #include <Library/DebugLib.h>\r | |
0fa00159 LG |
18 | #include <Library/BaseMemoryLib.h>\r |
19 | #include <Library/MemoryAllocationLib.h>\r | |
20 | #include <Library/ExtractGuidedSectionLib.h>\r | |
8472f1f5 | 21 | #include <Library/UefiBootServicesTableLib.h>\r |
0fa00159 | 22 | \r |
de2314f8 LG |
23 | #define EXTRACT_HANDLER_TABLE_SIZE 0x10\r |
24 | \r | |
fe467413 | 25 | UINT32 mNumberOfExtractHandler = 0;\r |
de2314f8 | 26 | UINT32 mMaxNumberOfExtractHandler = 0;\r |
0fa00159 | 27 | \r |
de2314f8 LG |
28 | GUID *mExtractHandlerGuidTable = NULL;\r |
29 | EXTRACT_GUIDED_SECTION_DECODE_HANDLER *mExtractDecodeHandlerTable = NULL;\r | |
30 | EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *mExtractGetInfoHandlerTable = NULL;\r | |
0fa00159 | 31 | \r |
4754c98b | 32 | /**\r |
de2314f8 | 33 | Reallocates more global memory to store the registered guid and Handler list.\r |
0fa00159 | 34 | \r |
58380e9c | 35 | @retval RETURN_SUCCESS Reallocated more global memory space to store guid and function tables.\r |
36 | @retval RETURN_OUT_OF_RESOURCES Not enough memory to allocate.\r | |
0fa00159 LG |
37 | **/\r |
38 | RETURN_STATUS\r | |
39 | EFIAPI\r | |
de2314f8 | 40 | ReallocateExtractHandlerTable (\r |
50de6bfb | 41 | VOID\r |
0fa00159 | 42 | )\r |
de2314f8 | 43 | { \r |
0fa00159 | 44 | //\r |
de2314f8 | 45 | // Reallocate memory for GuidTable\r |
0fa00159 | 46 | //\r |
de2314f8 LG |
47 | mExtractHandlerGuidTable = ReallocatePool (\r |
48 | mMaxNumberOfExtractHandler * sizeof (GUID), \r | |
49 | (mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE) * sizeof (GUID), \r | |
50 | mExtractHandlerGuidTable\r | |
51 | );\r | |
52 | \r | |
0fa00159 | 53 | if (mExtractHandlerGuidTable == NULL) {\r |
de2314f8 | 54 | goto Done;\r |
0fa00159 | 55 | }\r |
de2314f8 LG |
56 | \r |
57 | //\r | |
58 | // Reallocate memory for Decode handler Table\r | |
59 | //\r | |
60 | mExtractDecodeHandlerTable = ReallocatePool (\r | |
61 | mMaxNumberOfExtractHandler * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER), \r | |
62 | (mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE) * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER), \r | |
63 | mExtractDecodeHandlerTable\r | |
64 | );\r | |
65 | \r | |
0fa00159 | 66 | if (mExtractDecodeHandlerTable == NULL) {\r |
de2314f8 | 67 | goto Done;\r |
0fa00159 LG |
68 | }\r |
69 | \r | |
de2314f8 LG |
70 | //\r |
71 | // Reallocate memory for GetInfo handler Table\r | |
72 | //\r | |
73 | mExtractGetInfoHandlerTable = ReallocatePool (\r | |
74 | mMaxNumberOfExtractHandler * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER), \r | |
75 | (mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE) * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER), \r | |
76 | mExtractGetInfoHandlerTable\r | |
77 | );\r | |
78 | \r | |
0fa00159 | 79 | if (mExtractGetInfoHandlerTable == NULL) {\r |
de2314f8 LG |
80 | goto Done;\r |
81 | }\r | |
82 | \r | |
83 | //\r | |
84 | // Increase max handler number\r | |
85 | //\r | |
86 | mMaxNumberOfExtractHandler = mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE;\r | |
87 | return RETURN_SUCCESS;\r | |
88 | \r | |
89 | Done:\r | |
90 | if (mExtractHandlerGuidTable != NULL) {\r | |
b911d09f | 91 | FreePool (mExtractHandlerGuidTable);\r |
de2314f8 LG |
92 | }\r |
93 | if (mExtractDecodeHandlerTable != NULL) {\r | |
b911d09f | 94 | FreePool (mExtractDecodeHandlerTable);\r |
de2314f8 LG |
95 | }\r |
96 | if (mExtractGetInfoHandlerTable != NULL) {\r | |
97 | FreePool (mExtractGetInfoHandlerTable);\r | |
0fa00159 LG |
98 | }\r |
99 | \r | |
de2314f8 LG |
100 | return RETURN_OUT_OF_RESOURCES;\r |
101 | }\r | |
102 | /**\r | |
103 | Constructor allocates the global memory to store the registered guid and Handler list.\r | |
104 | \r | |
105 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
106 | @param SystemTable A pointer to the EFI System Table.\r | |
107 | \r | |
58380e9c | 108 | @retval RETURN_SUCCESS Allocated the global memory space to store guid and function tables.\r |
109 | @retval RETURN_OUT_OF_RESOURCES Not enough memory to allocate.\r | |
de2314f8 LG |
110 | **/\r |
111 | RETURN_STATUS\r | |
112 | EFIAPI\r | |
113 | DxeExtractGuidedSectionLibConstructor (\r | |
114 | IN EFI_HANDLE ImageHandle,\r | |
115 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
116 | )\r | |
117 | {\r | |
118 | return ReallocateExtractHandlerTable ();\r | |
0fa00159 LG |
119 | }\r |
120 | \r | |
4754c98b | 121 | /**\r |
f1db45f8 | 122 | Retrieve the list GUIDs that have been registered through ExtractGuidedSectionRegisterHandlers().\r |
0fa00159 | 123 | \r |
f1db45f8 | 124 | Sets ExtractHandlerGuidTable so it points at a callee allocated array of registered GUIDs.\r |
125 | The total number of GUIDs in the array are returned. Since the array of GUIDs is callee allocated\r | |
126 | and caller must treat this array of GUIDs as read-only data. \r | |
127 | If ExtractHandlerGuidTable is NULL, then ASSERT().\r | |
128 | \r | |
0057fda6 | 129 | @param[out] ExtractHandlerGuidTable A pointer to the array of GUIDs that have been registered through\r |
f1db45f8 | 130 | ExtractGuidedSectionRegisterHandlers().\r |
0fa00159 | 131 | \r |
58380e9c | 132 | @return The number of the supported extract guided Handler.\r |
f1db45f8 | 133 | \r |
0fa00159 LG |
134 | **/\r |
135 | UINTN\r | |
136 | EFIAPI\r | |
137 | ExtractGuidedSectionGetGuidList (\r | |
eceb3a4c | 138 | OUT GUID **ExtractHandlerGuidTable\r |
0fa00159 LG |
139 | )\r |
140 | {\r | |
141 | ASSERT (ExtractHandlerGuidTable != NULL);\r | |
142 | \r | |
143 | *ExtractHandlerGuidTable = mExtractHandlerGuidTable;\r | |
144 | return mNumberOfExtractHandler;\r | |
145 | }\r | |
146 | \r | |
4754c98b | 147 | /**\r |
f1db45f8 | 148 | Registers handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and EXTRACT_GUIDED_SECTION_DECODE_HANDLER\r |
149 | for a specific GUID section type.\r | |
150 | \r | |
0057fda6 | 151 | Registers the handlers specified by GetInfoHandler and DecodeHandler with the GUID specified by SectionGuid.\r |
f1db45f8 | 152 | If the GUID value specified by SectionGuid has already been registered, then return RETURN_ALREADY_STARTED.\r |
153 | If there are not enough resources available to register the handlers then RETURN_OUT_OF_RESOURCES is returned.\r | |
57209470 | 154 | \r |
f1db45f8 | 155 | If SectionGuid is NULL, then ASSERT().\r |
156 | If GetInfoHandler is NULL, then ASSERT().\r | |
157 | If DecodeHandler is NULL, then ASSERT().\r | |
158 | \r | |
159 | @param[in] SectionGuid A pointer to the GUID associated with the the handlers\r | |
160 | of the GUIDed section type being registered.\r | |
2fc59a00 | 161 | @param[in] GetInfoHandler The pointer to a function that examines a GUIDed section and returns the\r |
f1db45f8 | 162 | size of the decoded buffer and the size of an optional scratch buffer\r |
163 | required to actually decode the data in a GUIDed section.\r | |
2fc59a00 | 164 | @param[in] DecodeHandler The pointer to a function that decodes a GUIDed section into a caller\r |
f1db45f8 | 165 | allocated output buffer. \r |
166 | \r | |
167 | @retval RETURN_SUCCESS The handlers were registered.\r | |
f1db45f8 | 168 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to register the handlers.\r |
0fa00159 | 169 | \r |
0fa00159 LG |
170 | **/\r |
171 | RETURN_STATUS\r | |
172 | EFIAPI\r | |
173 | ExtractGuidedSectionRegisterHandlers (\r | |
174 | IN CONST GUID *SectionGuid,\r | |
175 | IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler,\r | |
176 | IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler\r | |
177 | )\r | |
178 | {\r | |
e2701217 | 179 | UINT32 Index;\r |
8472f1f5 SZ |
180 | VOID *GuidData;\r |
181 | \r | |
0fa00159 | 182 | //\r |
a750b4ae | 183 | // Check input parameter.\r |
0fa00159 | 184 | //\r |
f1db45f8 | 185 | ASSERT (SectionGuid != NULL);\r |
186 | ASSERT (GetInfoHandler != NULL);\r | |
187 | ASSERT (DecodeHandler != NULL);\r | |
e2701217 LG |
188 | \r |
189 | //\r | |
190 | // Search the match registered GetInfo handler for the input guided section.\r | |
191 | //\r | |
192 | for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {\r | |
193 | if (CompareGuid (&mExtractHandlerGuidTable[Index], SectionGuid)) {\r | |
b911d09f LG |
194 | //\r |
195 | // If the guided handler has been registered before, only update its handler.\r | |
196 | //\r | |
197 | mExtractDecodeHandlerTable [Index] = DecodeHandler;\r | |
198 | mExtractGetInfoHandlerTable [Index] = GetInfoHandler;\r | |
199 | return RETURN_SUCCESS;\r | |
e2701217 LG |
200 | }\r |
201 | }\r | |
e2701217 | 202 | \r |
0fa00159 LG |
203 | //\r |
204 | // Check the global table is enough to contain new Handler.\r | |
205 | //\r | |
de2314f8 LG |
206 | if (mNumberOfExtractHandler >= mMaxNumberOfExtractHandler) {\r |
207 | if (ReallocateExtractHandlerTable () != RETURN_SUCCESS) {\r | |
208 | return RETURN_OUT_OF_RESOURCES;\r | |
209 | }\r | |
0fa00159 LG |
210 | }\r |
211 | \r | |
212 | //\r | |
213 | // Register new Handler and guid value.\r | |
214 | //\r | |
215 | CopyGuid (&mExtractHandlerGuidTable [mNumberOfExtractHandler], SectionGuid);\r | |
216 | mExtractDecodeHandlerTable [mNumberOfExtractHandler] = DecodeHandler;\r | |
217 | mExtractGetInfoHandlerTable [mNumberOfExtractHandler++] = GetInfoHandler;\r | |
8472f1f5 SZ |
218 | \r |
219 | //\r | |
220 | // Install the Guided Section GUID configuration table to record the GUID itself.\r | |
221 | // Then the content of the configuration table buffer will be the same as the GUID value itself.\r | |
222 | //\r | |
223 | GuidData = AllocateCopyPool (sizeof (GUID), (VOID *) SectionGuid);\r | |
224 | if (GuidData != NULL) {\r | |
225 | gBS->InstallConfigurationTable ((EFI_GUID *) SectionGuid, GuidData);\r | |
226 | }\r | |
227 | \r | |
0fa00159 LG |
228 | return RETURN_SUCCESS;\r |
229 | }\r | |
230 | \r | |
4754c98b | 231 | /**\r |
0057fda6 | 232 | Retrieves a GUID from a GUIDed section and uses that GUID to select an associated handler of type\r |
f1db45f8 | 233 | EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r |
234 | The selected handler is used to retrieve and return the size of the decoded buffer and the size of an\r | |
235 | optional scratch buffer required to actually decode the data in a GUIDed section.\r | |
236 | \r | |
237 | Examines a GUIDed section specified by InputSection. \r | |
238 | If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r | |
239 | then RETURN_UNSUPPORTED is returned. \r | |
240 | If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler \r | |
241 | of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r | |
242 | is used to retrieve the OututBufferSize, ScratchSize, and Attributes values. The return status from the handler of\r | |
243 | type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER is returned.\r | |
518db1d9 | 244 | \r |
f1db45f8 | 245 | If InputSection is NULL, then ASSERT().\r |
246 | If OutputBufferSize is NULL, then ASSERT().\r | |
247 | If ScratchBufferSize is NULL, then ASSERT().\r | |
248 | If SectionAttribute is NULL, then ASSERT().\r | |
249 | \r | |
250 | @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r | |
251 | @param[out] OutputBufferSize A pointer to the size, in bytes, of an output buffer required if the buffer\r | |
252 | specified by InputSection were decoded.\r | |
253 | @param[out] ScratchBufferSize A pointer to the size, in bytes, required as scratch space if the buffer specified by\r | |
254 | InputSection were decoded.\r | |
255 | @param[out] SectionAttribute A pointer to the attributes of the GUIDed section. See the Attributes field of\r | |
256 | EFI_GUID_DEFINED_SECTION in the PI Specification.\r | |
257 | \r | |
58380e9c | 258 | @retval RETURN_SUCCESS Successfully obtained the required information.\r |
f1db45f8 | 259 | @retval RETURN_UNSUPPORTED The GUID from the section specified by InputSection does not match any of\r |
260 | the GUIDs registered with ExtractGuidedSectionRegisterHandlers().\r | |
261 | @retval Others The return status from the handler associated with the GUID retrieved from\r | |
262 | the section specified by InputSection.\r | |
0fa00159 LG |
263 | \r |
264 | **/\r | |
265 | RETURN_STATUS\r | |
266 | EFIAPI\r | |
267 | ExtractGuidedSectionGetInfo (\r | |
268 | IN CONST VOID *InputSection,\r | |
269 | OUT UINT32 *OutputBufferSize,\r | |
270 | OUT UINT32 *ScratchBufferSize,\r | |
271 | OUT UINT16 *SectionAttribute \r | |
272 | )\r | |
273 | {\r | |
274 | UINT32 Index;\r | |
30f001ca | 275 | EFI_GUID *SectionDefinitionGuid;\r |
f1db45f8 | 276 | \r |
277 | ASSERT (InputSection != NULL); \r | |
0fa00159 LG |
278 | ASSERT (OutputBufferSize != NULL);\r |
279 | ASSERT (ScratchBufferSize != NULL);\r | |
280 | ASSERT (SectionAttribute != NULL);\r | |
30f001ca SZ |
281 | \r |
282 | if (IS_SECTION2 (InputSection)) {\r | |
283 | SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);\r | |
284 | } else {\r | |
285 | SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);\r | |
286 | }\r | |
0fa00159 LG |
287 | \r |
288 | //\r | |
289 | // Search the match registered GetInfo handler for the input guided section.\r | |
290 | //\r | |
291 | for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {\r | |
30f001ca | 292 | if (CompareGuid (&mExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {\r |
b911d09f LG |
293 | //\r |
294 | // Call the match handler to getinfo for the input section data.\r | |
295 | //\r | |
296 | return mExtractGetInfoHandlerTable [Index] (\r | |
297 | InputSection,\r | |
298 | OutputBufferSize,\r | |
299 | ScratchBufferSize,\r | |
300 | SectionAttribute\r | |
301 | );\r | |
0fa00159 LG |
302 | }\r |
303 | }\r | |
304 | \r | |
305 | //\r | |
306 | // Not found, the input guided section is not supported. \r | |
307 | //\r | |
b911d09f | 308 | return RETURN_UNSUPPORTED;\r |
0fa00159 LG |
309 | }\r |
310 | \r | |
4754c98b | 311 | /**\r |
0057fda6 | 312 | Retrieves the GUID from a GUIDed section and uses that GUID to select an associated handler of type\r |
f1db45f8 | 313 | EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r |
314 | The selected handler is used to decode the data in a GUIDed section and return the result in a caller\r | |
315 | allocated output buffer.\r | |
316 | \r | |
317 | Decodes the GUIDed section specified by InputSection. \r | |
318 | If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r | |
319 | then RETURN_UNSUPPORTED is returned. \r | |
320 | If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler\r | |
321 | of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r | |
322 | is used to decode InputSection into the buffer specified by OutputBuffer and the authentication status of this\r | |
323 | decode operation is returned in AuthenticationStatus. If the decoded buffer is identical to the data in InputSection,\r | |
324 | then OutputBuffer is set to point at the data in InputSection. Otherwise, the decoded data will be placed in caller\r | |
325 | allocated buffer specified by OutputBuffer. This function is responsible for computing the EFI_AUTH_STATUS_PLATFORM_OVERRIDE\r | |
518db1d9 | 326 | bit of in AuthenticationStatus. The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned. \r |
327 | \r | |
f1db45f8 | 328 | If InputSection is NULL, then ASSERT().\r |
329 | If OutputBuffer is NULL, then ASSERT().\r | |
330 | If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r | |
331 | If AuthenticationStatus is NULL, then ASSERT(). \r | |
332 | \r | |
333 | @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r | |
334 | @param[out] OutputBuffer A pointer to a buffer that contains the result of a decode operation. \r | |
335 | @param[in] ScratchBuffer A caller allocated buffer that may be required by this function as a scratch buffer to perform the decode operation. \r | |
0fa00159 | 336 | @param[out] AuthenticationStatus \r |
f1db45f8 | 337 | A pointer to the authentication status of the decoded output buffer. See the definition\r |
338 | of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI section of the PI\r | |
339 | Specification.\r | |
4754c98b | 340 | \r |
f1db45f8 | 341 | @retval RETURN_SUCCESS The buffer specified by InputSection was decoded.\r |
342 | @retval RETURN_UNSUPPORTED The section specified by InputSection does not match the GUID this handler supports.\r | |
343 | @retval RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.\r | |
4754c98b | 344 | \r |
0fa00159 LG |
345 | **/\r |
346 | RETURN_STATUS\r | |
347 | EFIAPI\r | |
348 | ExtractGuidedSectionDecode (\r | |
349 | IN CONST VOID *InputSection,\r | |
350 | OUT VOID **OutputBuffer,\r | |
f1db45f8 | 351 | IN VOID *ScratchBuffer, OPTIONAL\r |
0fa00159 LG |
352 | OUT UINT32 *AuthenticationStatus \r |
353 | )\r | |
354 | {\r | |
355 | UINT32 Index;\r | |
30f001ca | 356 | EFI_GUID *SectionDefinitionGuid;\r |
0fa00159 | 357 | \r |
eceb3a4c LG |
358 | //\r |
359 | // Check the input parameters\r | |
360 | //\r | |
f1db45f8 | 361 | ASSERT (InputSection != NULL);\r |
0fa00159 LG |
362 | ASSERT (OutputBuffer != NULL);\r |
363 | ASSERT (AuthenticationStatus != NULL);\r | |
364 | \r | |
30f001ca SZ |
365 | if (IS_SECTION2 (InputSection)) {\r |
366 | SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);\r | |
367 | } else {\r | |
368 | SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);\r | |
369 | }\r | |
370 | \r | |
0fa00159 | 371 | //\r |
eceb3a4c | 372 | // Search the match registered extract handler for the input guided section.\r |
0fa00159 LG |
373 | //\r |
374 | for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {\r | |
30f001ca | 375 | if (CompareGuid (&mExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {\r |
b911d09f LG |
376 | //\r |
377 | // Call the match handler to extract raw data for the input section data.\r | |
378 | //\r | |
379 | return mExtractDecodeHandlerTable [Index] (\r | |
380 | InputSection,\r | |
381 | OutputBuffer,\r | |
382 | ScratchBuffer,\r | |
383 | AuthenticationStatus\r | |
384 | );\r | |
0fa00159 LG |
385 | }\r |
386 | }\r | |
387 | \r | |
388 | //\r | |
389 | // Not found, the input guided section is not supported. \r | |
390 | //\r | |
b911d09f | 391 | return RETURN_UNSUPPORTED;\r |
0fa00159 | 392 | }\r |
9be899c5 ED |
393 | \r |
394 | /**\r | |
395 | Retrieves handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and \r | |
396 | EXTRACT_GUIDED_SECTION_DECODE_HANDLER for a specific GUID section type.\r | |
397 | \r | |
398 | Retrieves the handlers associated with SectionGuid and returns them in \r | |
399 | GetInfoHandler and DecodeHandler.\r | |
400 | \r | |
401 | If the GUID value specified by SectionGuid has not been registered, then \r | |
402 | return RETURN_NOT_FOUND.\r | |
403 | \r | |
404 | If SectionGuid is NULL, then ASSERT().\r | |
405 | \r | |
406 | @param[in] SectionGuid A pointer to the GUID associated with the handlersof the GUIDed \r | |
407 | section type being retrieved.\r | |
408 | @param[out] GetInfoHandler Pointer to a function that examines a GUIDed section and returns \r | |
409 | the size of the decoded buffer and the size of an optional scratch \r | |
410 | buffer required to actually decode the data in a GUIDed section. \r | |
411 | This is an optional parameter that may be NULL. If it is NULL, then \r | |
412 | the previously registered handler is not returned.\r | |
413 | @param[out] DecodeHandler Pointer to a function that decodes a GUIDed section into a caller\r | |
414 | allocated output buffer. This is an optional parameter that may be NULL.\r | |
415 | If it is NULL, then the previously registered handler is not returned.\r | |
416 | \r | |
417 | @retval RETURN_SUCCESS The handlers were retrieved.\r | |
418 | @retval RETURN_NOT_FOUND No handlers have been registered with the specified GUID.\r | |
419 | \r | |
420 | **/\r | |
421 | RETURN_STATUS\r | |
422 | EFIAPI\r | |
423 | ExtractGuidedSectionGetHandlers (\r | |
424 | IN CONST GUID *SectionGuid,\r | |
425 | OUT EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *GetInfoHandler, OPTIONAL\r | |
426 | OUT EXTRACT_GUIDED_SECTION_DECODE_HANDLER *DecodeHandler OPTIONAL\r | |
427 | )\r | |
428 | {\r | |
429 | UINT32 Index; \r | |
430 | \r | |
431 | //\r | |
432 | // Check input parameter.\r | |
433 | //\r | |
434 | ASSERT (SectionGuid != NULL);\r | |
435 | \r | |
436 | //\r | |
437 | // Search the match registered GetInfo handler for the input guided section.\r | |
438 | //\r | |
439 | for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {\r | |
440 | if (CompareGuid (&mExtractHandlerGuidTable[Index], SectionGuid)) {\r | |
441 | \r | |
442 | //\r | |
443 | // If the guided handler has been registered before, then return the registered handlers.\r | |
444 | //\r | |
445 | if (GetInfoHandler != NULL) {\r | |
446 | *GetInfoHandler = mExtractGetInfoHandlerTable[Index];\r | |
447 | }\r | |
448 | if (DecodeHandler != NULL) {\r | |
449 | *DecodeHandler = mExtractDecodeHandlerTable[Index];\r | |
450 | }\r | |
451 | return RETURN_SUCCESS;\r | |
452 | }\r | |
453 | }\r | |
454 | return RETURN_NOT_FOUND;\r | |
455 | }\r |