]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Code Scrub: Code has been checked with MDE spec
authorjji4 <jji4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 18 Nov 2008 11:33:48 +0000 (11:33 +0000)
committerjji4 <jji4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 18 Nov 2008 11:33:48 +0000 (11:33 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6606 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/ExtractGuidedSectionLib.h
MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c

index 5a2e5f018e271dd8276369cb820a657b9baef50b..be963cb5a7dca4ce10369887f29b88e42fb371a2 100644 (file)
@@ -15,18 +15,35 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define __EXTRACT_GUIDED_SECTION_H__\r
 \r
 /**\r
-  Get information for the input guided section data.\r
-  It will ASSERT () if the pointer to OutputBufferSize is NULL.\r
-  It will ASSERT () if the pointer to ScratchBufferSize is NULL.\r
-  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
-\r
-  @retval  RETURN_SUCCESS           Get the required information successfully.\r
-  @retval  RETURN_INVALID_PARAMETER The input data is not the valid guided section.\r
+  Examines a GUIDed section and returns the size of the decoded buffer and the\r
+  size of an optional scratch buffer required to actually decode the data in a GUIDed section.\r
+\r
+  Examines a GUIDed section specified by InputSection.  \r
+  If GUID for InputSection does not match the GUID that this handler supports,\r
+  then RETURN_UNSUPPORTED is returned.  \r
+  If the required information can not be retrieved from InputSection,\r
+  then RETURN_INVALID_PARAMETER is returned.\r
+  If the GUID of InputSection does match the GUID that this handler supports,\r
+  then the size required to hold the decoded buffer is returned in OututBufferSize,\r
+  the size of an optional scratch buffer is returned in ScratchSize, and the Attributes field\r
+  from EFI_GUID_DEFINED_SECTION header of InputSection is returned in SectionAttribute.\r
+  If InputSection is NULL, then ASSERT().\r
+  If OutputBufferSize is NULL, then ASSERT().\r
+  If ScratchBufferSize is NULL, then ASSERT().\r
+  If SectionAttribute is NULL, then ASSERT().\r
+\r
+\r
+  @param[in]  InputSection       A pointer to a GUIDed section of an FFS formatted file.\r
+  @param[out] OutputBufferSize   A pointer to the size, in bytes, of an output buffer required\r
+                                 if the buffer specified by InputSection were decoded.\r
+  @param[out] ScratchBufferSize  A pointer to the size, in bytes, required as scratch space\r
+                                 if the buffer specified by InputSection were decoded.\r
+  @param[out] SectionAttribute   A pointer to the attributes of the GUIDed section. See the Attributes\r
+                                 field of EFI_GUID_DEFINED_SECTION in the PI Specification.\r
+\r
+  @retval  RETURN_SUCCESS            The information about InputSection was returned.\r
+  @retval  RETURN_UNSUPPORTED        The section specified by InputSection does not match the GUID this handler supports.\r
+  @retval  RETURN_INVALID_PARAMETER  The information can not be retrieved from the section specified by InputSection.\r
 \r
 **/\r
 typedef\r
@@ -39,21 +56,35 @@ RETURN_STATUS
   );\r
 \r
 /**\r
-  Extract data and Auth from the specific guided section.\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 directly points to the start of the section's contents,\r
-                            if guided data is not prcessed. Otherwise,\r
-                            OutputBuffer contains the output data, which is allocated by the caller.\r
-  @param[out] ScratchBuffer A pointer to a caller-allocated buffer for function internal use. \r
+  Decodes a GUIDed section into a caller allocated output buffer.\r
+  \r
+  Decodes the GUIDed section specified by InputSection.  \r
+  If GUID for InputSection does not match the GUID that this handler supports, then RETURN_UNSUPPORTED is returned.  \r
+  If the data in InputSection can not be decoded, then RETURN_INVALID_PARAMETER is returned.\r
+  If the GUID of InputSection does match the GUID that this handler supports, then InputSection\r
+  is decoded into the buffer specified by OutputBuffer and the authentication status of this\r
+  decode operation is returned in AuthenticationStatus.  If the decoded buffer is identical to the\r
+  data in InputSection, then OutputBuffer is set to point at the data in InputSection.  Otherwise,\r
+  the decoded data will be placed in caller allocated buffer specified by OutputBuffer.\r
+  If InputSection is NULL, then ASSERT().\r
+  If OutputBuffer is NULL, then ASSERT().\r
+  If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
+  If AuthenticationStatus is NULL, then ASSERT().\r
+\r
+\r
+  @param[in]  InputSection  A pointer to a GUIDed section of an FFS formatted file.\r
+  @param[out] OutputBuffer  A pointer to a buffer that contains the result of a decode operation. \r
+  @param[out] ScratchBuffer A caller allocated buffer that may be required by this function\r
+                            as a scratch buffer to perform the decode operation. \r
   @param[out] AuthenticationStatus \r
-                            A pointer to a caller-allocated UINT32 that indicates the\r
-                            authentication status of the output buffer. \r
+                            A pointer to the authentication status of the decoded output buffer.\r
+                            See the definition of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI\r
+                            section of the PI Specification. EFI_AUTH_STATUS_PLATFORM_OVERRIDE must\r
+                            never be set by this handler.\r
 \r
-  @retval  RETURN_SUCCESS               Get the output data and AuthenticationStatus successfully.\r
-  @retval  RETURN_INVALID_PARAMETER     The input data is not the valid guided section.\r
+  @retval  RETURN_SUCCESS            The buffer specified by InputSection was decoded.\r
+  @retval  RETURN_UNSPPORTED         The section specified by InputSection does not match the GUID this handler supports.\r
+  @retval  RETURN_INVALID_PARAMETER  The section specified by InputSection can not be decoded.\r
 \r
 **/\r
 typedef\r
@@ -66,15 +97,27 @@ RETURN_STATUS
   );\r
 \r
 /**\r
-  Register Guided Section Extract and GetInfo Handler.\r
-\r
-  @param[in]     SectionGuid    The guid matches this Extraction Handler.\r
-  @param[in]     GetInfoHandler Handler to get information from guided section.\r
-  @param[in]     DecodeHandler  Handler to extract guided section.\r
-\r
-  @retval  RETURN_SUCCESS           Register Guided Section Extract Handler successfully.\r
-  @retval  RETURN_OUT_OF_RESOURCES  Resource is not enough to register new Handler. \r
-  @retval  RETURN_INVALID_PARAMETER Pointer to Guid value is not valid.\r
+  Registers handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and EXTRACT_GUIDED_SECTION_DECODE_HANDLER\r
+  for a specific GUID section type.\r
+\r
+  Registers the handlers specified by GetInfoHandler and DecodeHandler witg the GUID specified by SectionGuid.\r
+  If the GUID value specified by SectionGuid has already been registered, then return RETURN_ALREADY_STARTED.\r
+  If there are not enough resources available to register the handlers  then RETURN_OUT_OF_RESOURCES is returned.\r
+  If SectionGuid is NULL, then ASSERT().\r
+  If GetInfoHandler is NULL, then ASSERT().\r
+  If DecodeHandler is NULL, then ASSERT().\r
+\r
+  @param[in]  SectionGuid    A pointer to the GUID associated with the the handlers\r
+                             of the GUIDed section type being registered.\r
+  @param[in]  GetInfoHandler Pointer to a function that examines a GUIDed section and returns the\r
+                             size of the decoded buffer and the size of an optional scratch buffer\r
+                             required to actually decode the data in a GUIDed section.\r
+  @param[in]  DecodeHandler  Pointer to a function that decodes a GUIDed section into a caller\r
+                             allocated output buffer. \r
+\r
+  @retval  RETURN_SUCCESS           The handlers were registered.\r
+  @retval  RETURN_ALREADY_STARTED   Handlers have already been registered for the GUID specified by SectionGuid. \r
+  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources available to register the handlers.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -86,14 +129,18 @@ ExtractGuidedSectionRegisterHandlers (
   );\r
 \r
 /**\r
-  Get the supported exract guided section Handler guid table, which is maintained\r
-  by library. The caller can directly get the guid table \r
-  without responsibility to allocate or free this table buffer.  \r
-  It will ASSERT () if ExtractHandlerGuidTable = NULL.\r
+  Retrieve the list GUIDs that have been registered through ExtractGuidedSectionRegisterHandlers().\r
+\r
+  Sets ExtractHandlerGuidTable so it points at a callee allocated array of registered GUIDs.\r
+  The total number of GUIDs in the array are returned. Since the array of GUIDs is callee allocated\r
+  and caller must treat this array of GUIDs as read-only data. \r
+  If ExtractHandlerGuidTable is NULL, then ASSERT().\r
 \r
-  @param[out]  ExtractHandlerGuidTable   The extract Handler guid pointer list.\r
+  @param[out]  ExtractHandlerGuidTable  A pointer to the array of GUIDs tht have been registerd through\r
+                                        ExtractGuidedSectionRegisterHandlers().\r
 \r
   @return the number of the supported extract guided Handler.\r
+\r
 **/\r
 UINTN\r
 EFIAPI\r
@@ -102,24 +149,36 @@ ExtractGuidedSectionGetGuidList (
   );\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.\r
-  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
-\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 is not the valid guided section.\r
+  Retrives a GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
+  EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r
+  The selected handler is used to retrieve and return the size of the decoded buffer and the size of an\r
+  optional scratch buffer required to actually decode the data in a GUIDed section.\r
+\r
+  Examines a GUIDed section specified by InputSection.  \r
+  If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
+  then RETURN_UNSUPPORTED is returned.  \r
+  If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler \r
+  of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r
+  is used to retrieve the OututBufferSize, ScratchSize, and Attributes values. The return status from the handler of\r
+  type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER is returned.\r
+  If InputSection is NULL, then ASSERT().\r
+  If OutputBufferSize is NULL, then ASSERT().\r
+  If ScratchBufferSize is NULL, then ASSERT().\r
+  If SectionAttribute is NULL, then ASSERT().\r
+\r
+  @param[in]  InputSection       A pointer to a GUIDed section of an FFS formatted file.\r
+  @param[out] OutputBufferSize   A pointer to the size, in bytes, of an output buffer required if the buffer\r
+                                 specified by InputSection were decoded.\r
+  @param[out] ScratchBufferSize  A pointer to the size, in bytes, required as scratch space if the buffer specified by\r
+                                 InputSection were decoded.\r
+  @param[out] SectionAttribute   A pointer to the attributes of the GUIDed section.  See the Attributes field of\r
+                                 EFI_GUID_DEFINED_SECTION in the PI Specification.\r
+\r
+  @retval  RETURN_SUCCESS      Get the required information successfully.\r
+  @retval  RETURN_UNSUPPORTED  The GUID from the section specified by InputSection does not match any of\r
+                               the GUIDs registered with ExtractGuidedSectionRegisterHandlers().\r
+  @retval  Others              The return status from the handler associated with the GUID retrieved from\r
+                               the section specified by InputSection.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -132,35 +191,45 @@ ExtractGuidedSectionGetInfo (
   );\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
-\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
+  Retrives the GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
+  EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r
+  The selected handler is used to decode the data in a GUIDed section and return the result in a caller\r
+  allocated output buffer.\r
+\r
+  Decodes the GUIDed section specified by InputSection.  \r
+  If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
+  then RETURN_UNSUPPORTED is returned.  \r
+  If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler\r
+  of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r
+  is used to decode InputSection into the buffer specified by OutputBuffer and the authentication status of this\r
+  decode operation is returned in AuthenticationStatus.  If the decoded buffer is identical to the data in InputSection,\r
+  then OutputBuffer is set to point at the data in InputSection.  Otherwise, the decoded data will be placed in caller\r
+  allocated buffer specified by OutputBuffer.    This function is responsible for computing the  EFI_AUTH_STATUS_PLATFORM_OVERRIDE\r
+  bit of in AuthenticationStatus.  The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned.  \r
+  If InputSection is NULL, then ASSERT().\r
+  If OutputBuffer is NULL, then ASSERT().\r
+  If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
+  If AuthenticationStatus is NULL, then ASSERT().  \r
+\r
+  @param[in]  InputSection   A pointer to a GUIDed section of an FFS formatted file.\r
+  @param[out] OutputBuffer   A pointer to a buffer that contains the result of a decode operation. \r
+  @param[in]  ScratchBuffer  A caller allocated buffer that may be required by this function as a scratch buffer to perform the decode operation. \r
   @param[out] AuthenticationStatus \r
-                            A pointer to a caller-allocated UINT32 that indicates the\r
-                            authentication status of the output buffer. \r
+                             A pointer to the authentication status of the decoded output buffer. See the definition\r
+                             of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI section of the PI\r
+                             Specification.\r
+\r
+  @retval  RETURN_SUCCESS           The buffer specified by InputSection was decoded.\r
+  @retval  RETURN_UNSUPPORTED       The section specified by InputSection does not match the GUID this handler supports.\r
+  @retval  RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.\r
 \r
-  @retval  RETURN_SUCCESS           Get the output data and AuthenticationStatus successfully.\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
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
 ExtractGuidedSectionDecode (\r
   IN  CONST VOID    *InputSection,\r
   OUT       VOID    **OutputBuffer,\r
-  OUT       VOID    *ScratchBuffer,        OPTIONAL\r
+  IN        VOID    *ScratchBuffer,        OPTIONAL\r
   OUT       UINT32  *AuthenticationStatus  \r
   );\r
 \r
index 100c5f90f1f7921535d5636825760985b7fe83e7..3a8ed28486d8da36a325d0a45e4fa35102db92bc 100644 (file)
@@ -67,14 +67,18 @@ DxeExtractGuidedSectionLibConstructor (
 }\r
 \r
 /**\r
-  Get the supported exract guided section Handler guid table, which is maintained\r
-  by library. The caller can directly get the guid table \r
-  without responsibility to allocate or free this table buffer.  \r
-  It will ASSERT () if ExtractHandlerGuidTable = NULL.\r
+  Retrieve the list GUIDs that have been registered through ExtractGuidedSectionRegisterHandlers().\r
 \r
-  @param[out]  ExtractHandlerGuidTable   The extract Handler guid pointer list.\r
+  Sets ExtractHandlerGuidTable so it points at a callee allocated array of registered GUIDs.\r
+  The total number of GUIDs in the array are returned. Since the array of GUIDs is callee allocated\r
+  and caller must treat this array of GUIDs as read-only data. \r
+  If ExtractHandlerGuidTable is NULL, then ASSERT().\r
+\r
+  @param[out]  ExtractHandlerGuidTable  A pointer to the array of GUIDs tht have been registerd through\r
+                                        ExtractGuidedSectionRegisterHandlers().\r
 \r
   @return the number of the supported extract guided Handler.\r
+\r
 **/\r
 UINTN\r
 EFIAPI\r
@@ -89,15 +93,28 @@ ExtractGuidedSectionGetGuidList (
 }\r
 \r
 /**\r
-  Register Guided Section Extract and GetInfo handler.\r
+  Registers handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and EXTRACT_GUIDED_SECTION_DECODE_HANDLER\r
+  for a specific GUID section type.\r
+\r
+  Registers the handlers specified by GetInfoHandler and DecodeHandler witg the GUID specified by SectionGuid.\r
+  If the GUID value specified by SectionGuid has already been registered, then return RETURN_ALREADY_STARTED.\r
+  If there are not enough resources available to register the handlers  then RETURN_OUT_OF_RESOURCES is returned.\r
+  If SectionGuid is NULL, then ASSERT().\r
+  If GetInfoHandler is NULL, then ASSERT().\r
+  If DecodeHandler is NULL, then ASSERT().\r
+\r
+  @param[in]  SectionGuid    A pointer to the GUID associated with the the handlers\r
+                             of the GUIDed section type being registered.\r
+  @param[in]  GetInfoHandler Pointer to a function that examines a GUIDed section and returns the\r
+                             size of the decoded buffer and the size of an optional scratch buffer\r
+                             required to actually decode the data in a GUIDed section.\r
+  @param[in]  DecodeHandler  Pointer to a function that decodes a GUIDed section into a caller\r
+                             allocated output buffer. \r
+\r
+  @retval  RETURN_SUCCESS           The handlers were registered.\r
+  @retval  RETURN_ALREADY_STARTED   Handlers have already been registered for the GUID specified by SectionGuid. \r
+  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources available to register the handlers.\r
 \r
-  @param[in]     SectionGuid    The guid matches this Extraction function.\r
-  @param[in]     GetInfoHandler Function to get info from guided section.\r
-  @param[in]     DecodeHandler  Function to extract guided section.\r
-\r
-  @retval  RETURN_SUCCESS           Register Guided Section Extract function successfully.\r
-  @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
@@ -111,9 +128,9 @@ ExtractGuidedSectionRegisterHandlers (
   //\r
   // Check input paramter.\r
   //\r
-  if (SectionGuid == NULL) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
+  ASSERT (SectionGuid != NULL);\r
+  ASSERT (GetInfoHandler != NULL);\r
+  ASSERT (DecodeHandler != NULL);\r
 \r
   //\r
   // Search the match registered GetInfo handler for the input guided section.\r
@@ -147,24 +164,36 @@ ExtractGuidedSectionRegisterHandlers (
 }\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_INVALID_PARAMETER 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.\r
-  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
-\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 is not the valid guided section.\r
+  Retrives a GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
+  EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r
+  The selected handler is used to retrieve and return the size of the decoded buffer and the size of an\r
+  optional scratch buffer required to actually decode the data in a GUIDed section.\r
+\r
+  Examines a GUIDed section specified by InputSection.  \r
+  If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
+  then RETURN_UNSUPPORTED is returned.  \r
+  If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler \r
+  of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r
+  is used to retrieve the OututBufferSize, ScratchSize, and Attributes values. The return status from the handler of\r
+  type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER is returned.\r
+  If InputSection is NULL, then ASSERT().\r
+  If OutputBufferSize is NULL, then ASSERT().\r
+  If ScratchBufferSize is NULL, then ASSERT().\r
+  If SectionAttribute is NULL, then ASSERT().\r
+\r
+  @param[in]  InputSection       A pointer to a GUIDed section of an FFS formatted file.\r
+  @param[out] OutputBufferSize   A pointer to the size, in bytes, of an output buffer required if the buffer\r
+                                 specified by InputSection were decoded.\r
+  @param[out] ScratchBufferSize  A pointer to the size, in bytes, required as scratch space if the buffer specified by\r
+                                 InputSection were decoded.\r
+  @param[out] SectionAttribute   A pointer to the attributes of the GUIDed section.  See the Attributes field of\r
+                                 EFI_GUID_DEFINED_SECTION in the PI Specification.\r
+\r
+  @retval  RETURN_SUCCESS      Get the required information successfully.\r
+  @retval  RETURN_UNSUPPORTED  The GUID from the section specified by InputSection does not match any of\r
+                               the GUIDs registered with ExtractGuidedSectionRegisterHandlers().\r
+  @retval  Others              The return status from the handler associated with the GUID retrieved from\r
+                               the section specified by InputSection.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -177,11 +206,8 @@ ExtractGuidedSectionGetInfo (
   )\r
 {\r
   UINT32 Index;\r
-  \r
-  if (InputSection == NULL) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
-  \r
+\r
+  ASSERT (InputSection != NULL);  \r
   ASSERT (OutputBufferSize != NULL);\r
   ASSERT (ScratchBufferSize != NULL);\r
   ASSERT (SectionAttribute != NULL);\r
@@ -210,28 +236,37 @@ ExtractGuidedSectionGetInfo (
 }\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_INVALID_PARAMETER will be return. \r
-  If found, it will call this extract Handler to get output data and AuthenticationStatus.\r
-\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
+  Retrives the GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
+  EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r
+  The selected handler is used to decode the data in a GUIDed section and return the result in a caller\r
+  allocated output buffer.\r
+\r
+  Decodes the GUIDed section specified by InputSection.  \r
+  If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
+  then RETURN_UNSUPPORTED is returned.  \r
+  If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler\r
+  of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r
+  is used to decode InputSection into the buffer specified by OutputBuffer and the authentication status of this\r
+  decode operation is returned in AuthenticationStatus.  If the decoded buffer is identical to the data in InputSection,\r
+  then OutputBuffer is set to point at the data in InputSection.  Otherwise, the decoded data will be placed in caller\r
+  allocated buffer specified by OutputBuffer.    This function is responsible for computing the  EFI_AUTH_STATUS_PLATFORM_OVERRIDE\r
+  bit of in AuthenticationStatus.  The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned.  \r
+  If InputSection is NULL, then ASSERT().\r
+  If OutputBuffer is NULL, then ASSERT().\r
+  If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
+  If AuthenticationStatus is NULL, then ASSERT().  \r
+\r
+  @param[in]  InputSection   A pointer to a GUIDed section of an FFS formatted file.\r
+  @param[out] OutputBuffer   A pointer to a buffer that contains the result of a decode operation. \r
+  @param[in]  ScratchBuffer  A caller allocated buffer that may be required by this function as a scratch buffer to perform the decode operation. \r
   @param[out] AuthenticationStatus \r
-                            A pointer to a caller-allocated UINT32 that indicates the\r
-                            authentication status of the output buffer. \r
+                             A pointer to the authentication status of the decoded output buffer. See the definition\r
+                             of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI section of the PI\r
+                             Specification.\r
 \r
-  @retval  RETURN_SUCCESS           Get the output data and AuthenticationStatus successfully.\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
+  @retval  RETURN_SUCCESS           The buffer specified by InputSection was decoded.\r
+  @retval  RETURN_UNSUPPORTED       The section specified by InputSection does not match the GUID this handler supports.\r
+  @retval  RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -239,7 +274,7 @@ EFIAPI
 ExtractGuidedSectionDecode (\r
   IN  CONST VOID    *InputSection,\r
   OUT       VOID    **OutputBuffer,\r
-  OUT       VOID    *ScratchBuffer,        OPTIONAL\r
+  IN        VOID    *ScratchBuffer,        OPTIONAL\r
   OUT       UINT32  *AuthenticationStatus  \r
   )\r
 {\r
@@ -248,10 +283,7 @@ ExtractGuidedSectionDecode (
   //\r
   // Check the input parameters\r
   //\r
-  if (InputSection == NULL) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
-  \r
+  ASSERT (InputSection != NULL);\r
   ASSERT (OutputBuffer != NULL);\r
   ASSERT (AuthenticationStatus != NULL);\r
 \r
index 43a1a3c22ea48623a3baf3e9ddcf4dc8a9e076b8..1633f1b8f40e11f83d93389f662ab2943973313c 100644 (file)
@@ -120,12 +120,18 @@ PeiGetExtractGuidedSectionHandlerInfo (
 }\r
 \r
 /**\r
-  Get the supported exract guided section Handler guid list.\r
-  If ExtractHandlerGuidTable = NULL, then ASSERT.\r
+  Retrieve the list GUIDs that have been registered through ExtractGuidedSectionRegisterHandlers().\r
 \r
-  @param[out]  ExtractHandlerGuidTable   The extract Handler guid pointer list.\r
+  Sets ExtractHandlerGuidTable so it points at a callee allocated array of registered GUIDs.\r
+  The total number of GUIDs in the array are returned. Since the array of GUIDs is callee allocated\r
+  and caller must treat this array of GUIDs as read-only data. \r
+  If ExtractHandlerGuidTable is NULL, then ASSERT().\r
+\r
+  @param[out]  ExtractHandlerGuidTable  A pointer to the array of GUIDs tht have been registerd through\r
+                                        ExtractGuidedSectionRegisterHandlers().\r
 \r
   @return the number of the supported extract guided Handler.\r
+\r
 **/\r
 UINTN\r
 EFIAPI\r
@@ -154,15 +160,28 @@ ExtractGuidedSectionGetGuidList (
 }\r
 \r
 /**\r
-  Register Guided Section Extract and GetInfo handler.\r
-\r
-  @param[in]     SectionGuid    The guid matches this Extraction function.\r
-  @param[in]     GetInfoHandler Function to get info from guided section.\r
-  @param[in]     DecodeHandler  Function to extract guided section.\r
+  Registers handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and EXTRACT_GUIDED_SECTION_DECODE_HANDLER\r
+  for a specific GUID section type.\r
+\r
+  Registers the handlers specified by GetInfoHandler and DecodeHandler witg the GUID specified by SectionGuid.\r
+  If the GUID value specified by SectionGuid has already been registered, then return RETURN_ALREADY_STARTED.\r
+  If there are not enough resources available to register the handlers  then RETURN_OUT_OF_RESOURCES is returned.\r
+  If SectionGuid is NULL, then ASSERT().\r
+  If GetInfoHandler is NULL, then ASSERT().\r
+  If DecodeHandler is NULL, then ASSERT().\r
+\r
+  @param[in]  SectionGuid    A pointer to the GUID associated with the the handlers\r
+                             of the GUIDed section type being registered.\r
+  @param[in]  GetInfoHandler Pointer to a function that examines a GUIDed section and returns the\r
+                             size of the decoded buffer and the size of an optional scratch buffer\r
+                             required to actually decode the data in a GUIDed section.\r
+  @param[in]  DecodeHandler  Pointer to a function that decodes a GUIDed section into a caller\r
+                             allocated output buffer. \r
+\r
+  @retval  RETURN_SUCCESS           The handlers were registered.\r
+  @retval  RETURN_ALREADY_STARTED   Handlers have already been registered for the GUID specified by SectionGuid. \r
+  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources available to register the handlers.\r
 \r
-  @retval  RETURN_SUCCESS           Register Guided Section Extract function successfully.\r
-  @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
@@ -177,11 +196,13 @@ ExtractGuidedSectionRegisterHandlers (
   PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
 \r
   //\r
-  // Check input paramter.\r
+  // Check input paramter\r
   //\r
-  if (SectionGuid == NULL) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
+  ASSERT (SectionGuid != NULL);\r
+  ASSERT (GetInfoHandler != NULL);\r
+  ASSERT (DecodeHandler != NULL);\r
+\r
+\r
 \r
   //\r
   // Get the registered handler information\r
@@ -223,24 +244,36 @@ ExtractGuidedSectionRegisterHandlers (
 }\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_INVALID_PARAMETER 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.\r
-  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
-\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 is not the valid guided section.\r
+  Retrives a GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
+  EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r
+  The selected handler is used to retrieve and return the size of the decoded buffer and the size of an\r
+  optional scratch buffer required to actually decode the data in a GUIDed section.\r
+\r
+  Examines a GUIDed section specified by InputSection.  \r
+  If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
+  then RETURN_UNSUPPORTED is returned.  \r
+  If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler \r
+  of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r
+  is used to retrieve the OututBufferSize, ScratchSize, and Attributes values. The return status from the handler of\r
+  type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER is returned.\r
+  If InputSection is NULL, then ASSERT().\r
+  If OutputBufferSize is NULL, then ASSERT().\r
+  If ScratchBufferSize is NULL, then ASSERT().\r
+  If SectionAttribute is NULL, then ASSERT().\r
+\r
+  @param[in]  InputSection       A pointer to a GUIDed section of an FFS formatted file.\r
+  @param[out] OutputBufferSize   A pointer to the size, in bytes, of an output buffer required if the buffer\r
+                                 specified by InputSection were decoded.\r
+  @param[out] ScratchBufferSize  A pointer to the size, in bytes, required as scratch space if the buffer specified by\r
+                                 InputSection were decoded.\r
+  @param[out] SectionAttribute   A pointer to the attributes of the GUIDed section.  See the Attributes field of\r
+                                 EFI_GUID_DEFINED_SECTION in the PI Specification.\r
+\r
+  @retval  RETURN_SUCCESS      Get the required information successfully.\r
+  @retval  RETURN_UNSUPPORTED  The GUID from the section specified by InputSection does not match any of\r
+                               the GUIDs registered with ExtractGuidedSectionRegisterHandlers().\r
+  @retval  Others              The return status from the handler associated with the GUID retrieved from\r
+                               the section specified by InputSection.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -259,10 +292,7 @@ ExtractGuidedSectionGetInfo (
   //\r
   // Check input paramter\r
   //\r
-  if (InputSection == NULL) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
-  \r
+  ASSERT (InputSection != NULL);\r
   ASSERT (OutputBufferSize != NULL);\r
   ASSERT (ScratchBufferSize != NULL);\r
   ASSERT (SectionAttribute != NULL);\r
@@ -299,28 +329,37 @@ ExtractGuidedSectionGetInfo (
 }\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_INVALID_PARAMETER will be return. \r
-  If found, it will call this extract Handler to get output data and AuthenticationStatus.\r
-\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
+  Retrives the GUID from a GUIDed section and uses that GUID to select an associated handler of type\r
+  EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers().\r
+  The selected handler is used to decode the data in a GUIDed section and return the result in a caller\r
+  allocated output buffer.\r
+\r
+  Decodes the GUIDed section specified by InputSection.  \r
+  If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),\r
+  then RETURN_UNSUPPORTED is returned.  \r
+  If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler\r
+  of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r
+  is used to decode InputSection into the buffer specified by OutputBuffer and the authentication status of this\r
+  decode operation is returned in AuthenticationStatus.  If the decoded buffer is identical to the data in InputSection,\r
+  then OutputBuffer is set to point at the data in InputSection.  Otherwise, the decoded data will be placed in caller\r
+  allocated buffer specified by OutputBuffer.    This function is responsible for computing the  EFI_AUTH_STATUS_PLATFORM_OVERRIDE\r
+  bit of in AuthenticationStatus.  The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned.  \r
+  If InputSection is NULL, then ASSERT().\r
+  If OutputBuffer is NULL, then ASSERT().\r
+  If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
+  If AuthenticationStatus is NULL, then ASSERT().  \r
+\r
+  @param[in]  InputSection   A pointer to a GUIDed section of an FFS formatted file.\r
+  @param[out] OutputBuffer   A pointer to a buffer that contains the result of a decode operation. \r
+  @param[in]  ScratchBuffer  A caller allocated buffer that may be required by this function as a scratch buffer to perform the decode operation. \r
   @param[out] AuthenticationStatus \r
-                            A pointer to a caller-allocated UINT32 that indicates the\r
-                            authentication status of the output buffer. \r
+                             A pointer to the authentication status of the decoded output buffer. See the definition\r
+                             of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI section of the PI\r
+                             Specification.\r
 \r
-  @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 is not the valid guided section.\r
+  @retval  RETURN_SUCCESS           The buffer specified by InputSection was decoded.\r
+  @retval  RETURN_UNSUPPORTED       The section specified by InputSection does not match the GUID this handler supports.\r
+  @retval  RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -328,7 +367,7 @@ EFIAPI
 ExtractGuidedSectionDecode (\r
   IN  CONST VOID    *InputSection,\r
   OUT       VOID    **OutputBuffer,\r
-  OUT       VOID    *ScratchBuffer,        OPTIONAL\r
+  IN        VOID    *ScratchBuffer,        OPTIONAL\r
   OUT       UINT32  *AuthenticationStatus  \r
   )\r
 {\r
@@ -339,9 +378,7 @@ ExtractGuidedSectionDecode (
   //\r
   // Check input parameter\r
   //\r
-  if (InputSection == NULL) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }  \r
+  ASSERT (InputSection != NULL);\r
   ASSERT (OutputBuffer != NULL);\r
   ASSERT (AuthenticationStatus != NULL);\r
 \r