-/*++\r
+/** @file\r
+ Provide generic extract guided section functions for PEI phase.\r
\r
-Copyright (c) 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
+ Copyright (c) 2007 - 2008, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- PeiExtractGuidedSectionLib.c\r
-\r
-Abstract:\r
-\r
- Provide generic extract guided section functions. \r
-\r
---*/\r
+**/\r
\r
#include <PiPei.h>\r
\r
//\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+ //\r
+ // Init HandlerInfo structure\r
+ //\r
HandlerInfo->Signature = PEI_EXTRACT_HANDLER_INFO_SIGNATURE;\r
HandlerInfo->NumberOfExtractHandler = 0;\r
HandlerInfo->ExtractHandlerGuidTable = (GUID *) (HandlerInfo + 1);\r
PcdGet32 (PcdMaximumGuidedExtractHandler) * \r
sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER)\r
);\r
- \r
+ //\r
+ // return the created HandlerInfo.\r
+ //\r
*InfoPointer = HandlerInfo;\r
return EFI_SUCCESS;\r
}\r
Get the supported exract guided section Handler guid list.\r
If ExtractHandlerGuidTable = NULL, then ASSERT.\r
\r
- @param[in, out] ExtractHandlerGuidTable The extract Handler guid pointer list.
+ @param[out] ExtractHandlerGuidTable The extract Handler guid pointer list.
\r
- @retval return the number of the supported extract guided Handler.
+ @return the number of the supported extract guided Handler.
**/\r
UINTN\r
EFIAPI\r
ExtractGuidedSectionGetGuidList (\r
- IN OUT GUID **ExtractHandlerGuidTable\r
+ OUT GUID **ExtractHandlerGuidTable\r
)\r
{\r
EFI_STATUS Status;\r
\r
ASSERT (ExtractHandlerGuidTable != NULL);\r
\r
+ //\r
+ // Get all registered handler information\r
+ //\r
Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
+ //\r
+ // Get GuidTable and Table Number\r
+ //\r
*ExtractHandlerGuidTable = HandlerInfo->ExtractHandlerGuidTable;\r
return HandlerInfo->NumberOfExtractHandler;\r
}\r
//\r
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionGuid)) {\r
- break;\r
+ //\r
+ // If the guided handler has been registered before, only update its handler.\r
+ //\r
+ HandlerInfo->ExtractDecodeHandlerTable [Index] = DecodeHandler;\r
+ HandlerInfo->ExtractGetInfoHandlerTable [Index] = GetInfoHandler;\r
+ return RETURN_SUCCESS;\r
}\r
}\r
\r
- //\r
- // If the guided handler has been registered before, only update its handler.\r
- //\r
- if (Index < HandlerInfo->NumberOfExtractHandler) {\r
- HandlerInfo->ExtractDecodeHandlerTable [Index] = DecodeHandler;\r
- HandlerInfo->ExtractGetInfoHandlerTable [Index] = GetInfoHandler;\r
- return RETURN_SUCCESS;\r
- }\r
-\r
//\r
// Check the global table is enough to contain new Handler.\r
//\r
@param[out] SectionAttribute The attribute of the input guided section.\r
@retval RETURN_SUCCESS Get the required information successfully.\r
- @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly. \r
- The GUID in InputSection does not match any registered guid list.\r
+ @retval RETURN_UNSUPPORTED Guided section data is not supported.\r
+ @retval RETURN_INVALID_PARAMETER The input data is not the valid guided section.\r
\r
**/\r
RETURN_STATUS\r
ASSERT (SectionAttribute != NULL);\r
\r
//\r
- // Get the registered handler information.\r
+ // Get all registered handler information.\r
//\r
Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r
if (EFI_ERROR (Status)) {\r
//\r
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
- break;\r
+ //\r
+ // Call the match handler to getinfo for the input section data.\r
+ //\r
+ return HandlerInfo->ExtractGetInfoHandlerTable [Index] (\r
+ InputSection,\r
+ OutputBufferSize,\r
+ ScratchBufferSize,\r
+ SectionAttribute\r
+ );\r
}\r
}\r
\r
//\r
// Not found, the input guided section is not supported. \r
//\r
- if (Index == HandlerInfo->NumberOfExtractHandler) {\r
- return RETURN_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Call the match handler to getinfo for the input section data.\r
- //\r
- return HandlerInfo->ExtractGetInfoHandlerTable [Index] (\r
- InputSection,\r
- OutputBufferSize,\r
- ScratchBufferSize,\r
- SectionAttribute\r
- );\r
+ return RETURN_UNSUPPORTED;\r
}\r
\r
/**
authentication status of the output buffer.
@retval RETURN_SUCCESS Get the output data, size and AuthenticationStatus successfully.\r
- @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly. \r
- The GUID in InputSection does not match any registered guid list.\r
+ @retval RETURN_UNSUPPORTED Guided section data is not supported to be decoded.\r
+ @retval RETURN_INVALID_PARAMETER The input data is not the valid guided section.
**/\r
RETURN_STATUS\r
EFI_STATUS Status;\r
PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
\r
+ //\r
+ // Check input parameter\r
+ //\r
if (InputSection == NULL) {\r
return RETURN_INVALID_PARAMETER;\r
- }\r
- \r
+ } \r
ASSERT (OutputBuffer != NULL);\r
ASSERT (AuthenticationStatus != NULL);\r
- \r
+\r
+ //\r
+ // Get all registered handler information.\r
+ // \r
Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
//\r
- // Search the match registered GetInfo handler for the input guided section.\r
+ // Search the match registered Extract handler for the input guided section.\r
//\r
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
- break;\r
+ //\r
+ // Call the match handler to extract raw data for the input guided section.\r
+ //\r
+ return HandlerInfo->ExtractDecodeHandlerTable [Index] (\r
+ InputSection,\r
+ OutputBuffer,\r
+ ScratchBuffer,\r
+ AuthenticationStatus\r
+ );\r
}\r
}\r
\r
//\r
// Not found, the input guided section is not supported. \r
//\r
- if (Index == HandlerInfo->NumberOfExtractHandler) {\r
- return RETURN_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Call the match handler to getinfo for the input section data.\r
- //\r
- return HandlerInfo->ExtractDecodeHandlerTable [Index] (\r
- InputSection,\r
- OutputBuffer,\r
- ScratchBuffer,\r
- AuthenticationStatus\r
- );\r
+ return RETURN_UNSUPPORTED;\r
}\r