);\r
\r
/**
- Get the supported exract guided section Handler guid list.\r
+ Get the supported exract guided section Handler guid table, which is maintained\r
+ by library. The caller can directly get this guid table pointer \r
+ without responsibility to allocate or free this table buffer. \r
It will ASSERT () if ExtractHandlerGuidTable = NULL.\r
\r
@param[in, out] ExtractHandlerGuidTable The extract Handler guid pointer list.
--- /dev/null
+/*++\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
+\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
+ DxeExtractGuidedSectionLib.c\r
+\r
+Abstract:\r
+\r
+ Provide generic extract guided section functions. \r
+\r
+--*/\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/ExtractGuidedSectionLib.h>\r
+\r
+STATIC GUID *mExtractHandlerGuidTable;\r
+STATIC UINT32 mNumberOfExtractHandler;\r
+\r
+STATIC EXTRACT_GUIDED_SECTION_DECODE_HANDLER *mExtractDecodeHandlerTable;\r
+STATIC EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *mExtractGetInfoHandlerTable;\r
+\r
+/**
+ Construtor allocates the global memory to store the registered guid and Handler list.\r
+\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.
+\r
+ @retval RETURN_SUCCESS Allocate the global memory space to store guid and funciton tables.\r
+ @retval RETURN_OUT_OF_RESOURCES No enough memory to allocated.
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+DxeExtractGuidedSectionLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ //\r
+ // Allocate global pool space to store the registered handler and its guid value.\r
+ //\r
+ mExtractHandlerGuidTable = (GUID *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID));\r
+ if (mExtractHandlerGuidTable == NULL) {\r
+ return RETURN_OUT_OF_RESOURCES;\r
+ }\r
+ \r
+ mExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER));\r
+ if (mExtractDecodeHandlerTable == NULL) {\r
+ return RETURN_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ mExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER));\r
+ if (mExtractGetInfoHandlerTable == NULL) {\r
+ return RETURN_OUT_OF_RESOURCES;\r
+ }\r
+ \r
+ //\r
+ // the initialized number is Zero.\r
+ //\r
+ mNumberOfExtractHandler = 0;\r
+ \r
+ return RETURN_SUCCESS;\r
+}\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.
+\r
+ @retval return the number of the supported extract guided Handler.
+**/\r
+UINTN\r
+EFIAPI\r
+ExtractGuidedSectionGetGuidList (\r
+ IN OUT GUID **ExtractHandlerGuidTable\r
+ )\r
+{\r
+ ASSERT (ExtractHandlerGuidTable != NULL);\r
+\r
+ *ExtractHandlerGuidTable = mExtractHandlerGuidTable;\r
+ return mNumberOfExtractHandler;\r
+}\r
+\r
+/**
+ Register Guided Section Extract and GetInfo handler.\r
+\r
+ @param[in] SectionGuid The guid matches this Extraction function.
+ @param[in] GetInfoHandler Function to get info from guided section.\r
+ @param[in] DecodeHandler Function to extract guided section.
+
+ @retval RETURN_SUCCESS Register Guided Section Extract function successfully.
+ @retval RETURN_OUT_OF_RESOURCES Resource is not enough to register new function. \r
+ @retval RETURN_INVALID_PARAMETER Input pointer to Guid value is not valid.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionRegisterHandlers (\r
+ IN CONST GUID *SectionGuid,\r
+ IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler,\r
+ IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler\r
+ )\r
+{\r
+ //\r
+ // Check input paramter.\r
+ //\r
+ if (SectionGuid == NULL) {\r
+ return RETURN_INVALID_PARAMETER;\r
+ }\r
+ //\r
+ // Check the global table is enough to contain new Handler.\r
+ //\r
+ if (mNumberOfExtractHandler >= PcdGet32 (PcdMaximumGuidedExtractHandler)) {\r
+ return RETURN_OUT_OF_RESOURCES;\r
+ }\r
+ \r
+ //\r
+ // Register new Handler and guid value.\r
+ //\r
+ CopyGuid (&mExtractHandlerGuidTable [mNumberOfExtractHandler], SectionGuid);\r
+ mExtractDecodeHandlerTable [mNumberOfExtractHandler] = DecodeHandler;\r
+ mExtractGetInfoHandlerTable [mNumberOfExtractHandler++] = GetInfoHandler;\r
+ \r
+ return RETURN_SUCCESS;\r
+}\r
+\r
+/**
+ Get information from the guided section. This function first gets the guid value\r
+ from guided section header, then match this guid in the registered extract Handler list\r
+ to its corresponding getinfo Handler. \r
+ If not found, RETURN_UNSUPPORTED will be return. \r
+ If found, it will call the getinfo Handler to get the required size and attribute.\r
+\r
+ It will ASSERT () if the pointer to OutputBufferSize is NULL.\r
+ It will ASSERT () if the pointer to ScratchBufferSize is NULL.
+ It will ASSERT () if the pointer to SectionAttribute is NULL.\r
+\r
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed. \r
+ @param[out] OutputBufferSize The size of OutputBuffer.\r
+ @param[out] ScratchBufferSize The size of ScratchBuffer. \r
+ @param[out] SectionAttribute The attribute of the input guided section.\r
+
+ @retval RETURN_SUCCESS Get the required information successfully.\r
+ @retval RETURN_UNSUPPORTED Guided section data is not supported.\r
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionGetInfo (\r
+ IN CONST VOID *InputSection,\r
+ OUT UINT32 *OutputBufferSize,\r
+ OUT UINT32 *ScratchBufferSize,\r
+ OUT UINT16 *SectionAttribute \r
+ )\r
+{\r
+ UINT32 Index;\r
+ \r
+ if (InputSection == NULL) {\r
+ return RETURN_INVALID_PARAMETER;\r
+ }\r
+ \r
+ ASSERT (OutputBufferSize != NULL);\r
+ ASSERT (ScratchBufferSize != NULL);\r
+ ASSERT (SectionAttribute != NULL);\r
+ \r
+ //\r
+ // Search the match registered GetInfo handler for the input guided section.\r
+ //\r
+ for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {\r
+ if (CompareGuid (&mExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+ break;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Not found, the input guided section is not supported. \r
+ //\r
+ if (Index == mNumberOfExtractHandler) {\r
+ return RETURN_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Call the match handler to getinfo for the input section data.\r
+ //\r
+ return mExtractGetInfoHandlerTable [Index] (\r
+ InputSection,\r
+ OutputBufferSize,\r
+ ScratchBufferSize,\r
+ SectionAttribute\r
+ );\r
+}\r
+\r
+/**
+ Extract data from the guided section. This function first gets the guid value\r
+ from guided section header, then match this guid in the registered extract Handler list\r
+ to its corresponding extract Handler. \r
+ If not found, RETURN_UNSUPPORTED will be return. \r
+ If found, it will call this extract Handler to get output data and AuthenticationStatus.
+\r
+ It will ASSERT () if the pointer to OutputBuffer is NULL.\r
+ It will ASSERT () if the pointer to AuthenticationStatus is NULL.\r
+\r
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed. \r
+ @param[out] OutputBuffer OutputBuffer to point the start of the section's contents \r
+ if guided data is not required prcessing. Otherwise,\r
+ OutputBuffer to contain the output data, which is \r
+ allocated by the caller.\r
+ @param[out] ScratchBuffer A pointer to a caller-allocated buffer for function internal use. \r
+ @param[out] AuthenticationStatus \r
+ A pointer to a caller-allocated UINT32 that indicates the\r
+ authentication status of the output buffer.
+
+ @retval RETURN_SUCCESS Get the output data, size and AuthenticationStatus successfully.\r
+ @retval RETURN_UNSUPPORTED Guided section data is not supported to be decoded.\r
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.\r
+
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionDecode (\r
+ IN CONST VOID *InputSection,\r
+ OUT VOID **OutputBuffer,\r
+ OUT VOID *ScratchBuffer, OPTIONAL\r
+ OUT UINT32 *AuthenticationStatus \r
+ )\r
+{\r
+ UINT32 Index;\r
+ \r
+ if (InputSection == NULL) {\r
+ return RETURN_INVALID_PARAMETER;\r
+ }\r
+ \r
+ ASSERT (OutputBuffer != NULL);\r
+ ASSERT (AuthenticationStatus != NULL);\r
+\r
+ //\r
+ // Search the match registered GetInfo handler for the input guided section.\r
+ //\r
+ for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {\r
+ if (CompareGuid (&mExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+ break;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Not found, the input guided section is not supported. \r
+ //\r
+ if (Index == mNumberOfExtractHandler) {\r
+ return RETURN_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Call the match handler to getinfo for the input section data.\r
+ //\r
+ return mExtractDecodeHandlerTable [Index] (\r
+ InputSection,\r
+ OutputBuffer,\r
+ ScratchBuffer,\r
+ AuthenticationStatus\r
+ );\r
+}\r
--- /dev/null
+#/** @file\r
+# Component description file for DxeCore Performance Library\r
+#\r
+# This library provides intrastructure for DxeCore to log performance.\r
+# Copyright (c) 2007, Intel Corporation.\r
+#\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
+# 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
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = DxeExtractGuidedSectionLib\r
+ FILE_GUID = f773469b-e265-4b0c-b0a6-2f971fbfe72b\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = ExtractGuidedSectionLib\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ CONSTRUCTOR = DxeExtractGuidedSectionLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+ DxeExtractGuidedSectionLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+ MemoryAllocationLib\r
+ BaseMemoryLib\r
+ DebugLib\r
+\r
+[FixedPcd.common]\r
+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler \r
+\r
+\r
--- /dev/null
+/*++\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
+\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
+#include <PiPei.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/ExtractGuidedSectionLib.h>\r
+\r
+#define PEI_EXTRACT_HANDLER_INFO_SIGNATURE EFI_SIGNATURE_32 ('P', 'E', 'H', 'I')\r
+\r
+typedef struct {\r
+ UINT32 Signature;\r
+ UINT32 NumberOfExtractHandler;\r
+ GUID *ExtractHandlerGuidTable;\r
+ EXTRACT_GUIDED_SECTION_DECODE_HANDLER *ExtractDecodeHandlerTable;\r
+ EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *ExtractGetInfoHandlerTable;\r
+} PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO;\r
+\r
+/**
+ Build guid hob for the global memory to store the registered guid and Handler list.\r
+ If GuidHob exists, HandlerInfo will be directly got from Guid hob data.\r
+\r
+ @param[in, out] InfoPointer Pointer to pei handler info structure.
+\r
+ @retval RETURN_SUCCESS Build Guid hob for the global memory space to store guid and funciton tables.\r
+ @retval RETURN_OUT_OF_RESOURCES No enough memory to allocated.
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeiGetExtractGuidedSectionHandlerInfo (\r
+ IN OUT PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO **InfoPointer\r
+ )\r
+{\r
+ PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ \r
+ //\r
+ // First try to get handler info from guid hob specified by CallerId.\r
+ //\r
+ Hob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GetHobList ());\r
+ while (Hob.Raw != NULL) {\r
+ if (CompareGuid (&(Hob.Guid->Name), &gEfiCallerIdGuid)) {\r
+ HandlerInfo = (PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *) GET_GUID_HOB_DATA (Hob.Guid);\r
+ if (HandlerInfo->Signature == PEI_EXTRACT_HANDLER_INFO_SIGNATURE) {\r
+ *InfoPointer = HandlerInfo;\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+ Hob.Raw = GET_NEXT_HOB (Hob);\r
+ Hob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, Hob.Raw);\r
+ }\r
+ \r
+ //\r
+ // If Guid Hob is not found, Build CallerId Guid hob to store Handler Info\r
+ //\r
+ HandlerInfo = BuildGuidHob (\r
+ &gEfiCallerIdGuid, \r
+ sizeof (PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO) +\r
+ PcdGet32 (PcdMaximumGuidedExtractHandler) * \r
+ (sizeof (GUID) + sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER) + sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER))\r
+ );\r
+ if (HandlerInfo == NULL) {\r
+ //\r
+ // No enough resource to build guid hob.\r
+ //\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ HandlerInfo->Signature = PEI_EXTRACT_HANDLER_INFO_SIGNATURE;\r
+ HandlerInfo->NumberOfExtractHandler = 0;\r
+ HandlerInfo->ExtractHandlerGuidTable = (GUID *) (HandlerInfo + 1);\r
+ HandlerInfo->ExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *) (\r
+ (UINT8 *)HandlerInfo->ExtractHandlerGuidTable + \r
+ PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID)\r
+ );\r
+ HandlerInfo->ExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *) (\r
+ (UINT8 *)HandlerInfo->ExtractDecodeHandlerTable + \r
+ PcdGet32 (PcdMaximumGuidedExtractHandler) * \r
+ sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER)\r
+ );\r
+ \r
+ *InfoPointer = HandlerInfo;\r
+ return EFI_SUCCESS;\r
+}\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.
+\r
+ @retval return the number of the supported extract guided Handler.
+**/\r
+UINTN\r
+EFIAPI\r
+ExtractGuidedSectionGetGuidList (\r
+ IN OUT GUID **ExtractHandlerGuidTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
+\r
+ ASSERT (ExtractHandlerGuidTable != NULL);\r
+\r
+ Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ *ExtractHandlerGuidTable = HandlerInfo->ExtractHandlerGuidTable;\r
+ return HandlerInfo->NumberOfExtractHandler;\r
+}\r
+\r
+/**
+ Register Guided Section Extract and GetInfo handler.\r
+\r
+ @param[in] SectionGuid The guid matches this Extraction function.
+ @param[in] GetInfoHandler Function to get info from guided section.\r
+ @param[in] DecodeHandler Function to extract guided section.
+
+ @retval RETURN_SUCCESS Register Guided Section Extract function successfully.
+ @retval RETURN_OUT_OF_RESOURCES Resource is not enough to register new function. \r
+ @retval RETURN_INVALID_PARAMETER Input pointer to Guid value is not valid.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionRegisterHandlers (\r
+ IN CONST GUID *SectionGuid,\r
+ IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler,\r
+ IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
+\r
+ //\r
+ // Check input paramter.\r
+ //\r
+ if (SectionGuid == NULL) {\r
+ return RETURN_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Get the registered handler information\r
+ //\r
+ Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Check the global table is enough to contain new Handler.\r
+ //\r
+ if (HandlerInfo->NumberOfExtractHandler >= PcdGet32 (PcdMaximumGuidedExtractHandler)) {\r
+ return RETURN_OUT_OF_RESOURCES;\r
+ }\r
+ \r
+ //\r
+ // Register new Handler and guid value.\r
+ //\r
+ CopyGuid (&(HandlerInfo->ExtractHandlerGuidTable [HandlerInfo->NumberOfExtractHandler]), SectionGuid);\r
+ HandlerInfo->ExtractDecodeHandlerTable [HandlerInfo->NumberOfExtractHandler] = DecodeHandler;\r
+ HandlerInfo->ExtractGetInfoHandlerTable [HandlerInfo->NumberOfExtractHandler++] = GetInfoHandler;\r
+ \r
+ return RETURN_SUCCESS;\r
+}\r
+\r
+/**
+ Get information from the guided section. This function first gets the guid value\r
+ from guided section header, then match this guid in the registered extract Handler list\r
+ to its corresponding getinfo Handler. \r
+ If not found, RETURN_UNSUPPORTED will be return. \r
+ If found, it will call the getinfo Handler to get the required size and attribute.\r
+\r
+ It will ASSERT () if the pointer to OutputBufferSize is NULL.\r
+ It will ASSERT () if the pointer to ScratchBufferSize is NULL.
+ It will ASSERT () if the pointer to SectionAttribute is NULL.\r
+\r
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed. \r
+ @param[out] OutputBufferSize The size of OutputBuffer.\r
+ @param[out] ScratchBufferSize The size of ScratchBuffer. \r
+ @param[out] SectionAttribute The attribute of the input guided section.\r
+
+ @retval RETURN_SUCCESS Get the required information successfully.\r
+ @retval RETURN_UNSUPPORTED Guided section data is not supported.\r
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionGetInfo (\r
+ IN CONST VOID *InputSection,\r
+ OUT UINT32 *OutputBufferSize,\r
+ OUT UINT32 *ScratchBufferSize,\r
+ OUT UINT16 *SectionAttribute \r
+ )\r
+{\r
+ UINT32 Index;\r
+ EFI_STATUS Status;\r
+ PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
+ \r
+ //\r
+ // Check input paramter\r
+ //\r
+ if (InputSection == NULL) {\r
+ return RETURN_INVALID_PARAMETER;\r
+ }\r
+ \r
+ ASSERT (OutputBufferSize != NULL);\r
+ ASSERT (ScratchBufferSize != NULL);\r
+ ASSERT (SectionAttribute != NULL);\r
+\r
+ //\r
+ // Get the 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
+ //\r
+ for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
+ if (CompareGuid (&(HandlerInfo->ExtractHandlerGuidTable[Index]), &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+ break;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Not found, the input guided section is not supported. \r
+ //\r
+ if (Index == HandlerInfo->NumberOfExtractHandler) {\r
+ return RETURN_UNSUPPORTED;\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
+}\r
+\r
+/**
+ Extract data from the guided section. This function first gets the guid value\r
+ from guided section header, then match this guid in the registered extract Handler list\r
+ to its corresponding extract Handler. \r
+ If not found, RETURN_UNSUPPORTED will be return. \r
+ If found, it will call this extract Handler to get output data and AuthenticationStatus.
+\r
+ It will ASSERT () if the pointer to OutputBuffer is NULL.\r
+ It will ASSERT () if the pointer to AuthenticationStatus is NULL.\r
+\r
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed. \r
+ @param[out] OutputBuffer OutputBuffer to point the start of the section's contents \r
+ if guided data is not required prcessing. Otherwise,\r
+ OutputBuffer to contain the output data, which is \r
+ allocated by the caller.\r
+ @param[out] ScratchBuffer A pointer to a caller-allocated buffer for function internal use. \r
+ @param[out] AuthenticationStatus \r
+ A pointer to a caller-allocated UINT32 that indicates the\r
+ authentication status of the output buffer.
+
+ @retval RETURN_SUCCESS Get the output data, size and AuthenticationStatus successfully.\r
+ @retval RETURN_UNSUPPORTED Guided section data is not supported to be decoded.\r
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.\r
+
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionDecode (\r
+ IN CONST VOID *InputSection,\r
+ OUT VOID **OutputBuffer,\r
+ OUT VOID *ScratchBuffer, OPTIONAL\r
+ OUT UINT32 *AuthenticationStatus \r
+ )\r
+{\r
+ UINT32 Index;\r
+ EFI_STATUS Status;\r
+ PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
+ \r
+ if (InputSection == NULL) {\r
+ return RETURN_INVALID_PARAMETER;\r
+ }\r
+ \r
+ ASSERT (OutputBuffer != NULL);\r
+ ASSERT (AuthenticationStatus != NULL);\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
+ //\r
+ for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
+ if (CompareGuid (&(HandlerInfo->ExtractHandlerGuidTable[Index]), &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+ break;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Not found, the input guided section is not supported. \r
+ //\r
+ if (Index == HandlerInfo->NumberOfExtractHandler) {\r
+ return RETURN_UNSUPPORTED;\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
+}\r
--- /dev/null
+#/** @file\r
+# Component description file for DxeCore Performance Library\r
+#\r
+# This library provides intrastructure for DxeCore to log performance.\r
+# Copyright (c) 2007, Intel Corporation.\r
+#\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
+# 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
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PeiExtractGuidedSectionLib\r
+ FILE_GUID = 41ddf016-2a11-415f-8880-00d938e9541a\r
+ MODULE_TYPE = PEIM\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = ExtractGuidedSectionLib\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+ PeiExtractGuidedSectionLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+ BaseMemoryLib\r
+ DebugLib\r
+ HobLib\r
+\r
+[FixedPcd.common]\r
+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler \r
+\r
+\r