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