]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.c
PerformancePkg.dsc:
[mirror_edk2.git] / MdePkg / Library / BaseExtractGuidedSectionLib / BaseExtractGuidedSectionLib.c
index 35cf9a87931763fc69bab2bd90e4bb60cbaa8b63..6a2cde5200c93437fef57101045866014e2634fd 100644 (file)
@@ -34,7 +34,7 @@ typedef struct {
   the registered guid and Handler list. When it is initialized, it will be directly returned. \r
   Or, HandlerInfo table will be initialized in this function.\r
 \r
-  @param[in, out]  InfoPointer   Pointer to the handler info structure.\r
+  @param[in, out]  InfoPointer   The pointer to the handler information structure.\r
 \r
   @retval  RETURN_SUCCESS            HandlerInfo table can be used to store guid and function tables.\r
   @retval  RETURN_OUT_OF_RESOURCES   HandlerInfo table address is not writable.\r
@@ -52,23 +52,23 @@ GetExtractGuidedSectionHandlerInfo (
   HandlerInfo = (EXTRACT_GUIDED_SECTION_HANDLER_INFO*)(VOID*)(UINTN) PcdGet64 (PcdGuidedExtractHandlerTableAddress);\r
 \r
   //\r
-  // First check whether the handler info structure is initialized.\r
+  // First check whether the handler information structure is initialized.\r
   //\r
   if (HandlerInfo->Signature == EXTRACT_HANDLER_INFO_SIGNATURE) {\r
     //\r
-    // The handler info has been initialized and is returned.\r
+    // The handler information has been initialized and is returned.\r
     //\r
     *InfoPointer = HandlerInfo;\r
     return RETURN_SUCCESS;\r
   }\r
 \r
   //\r
-  // Try to initialize the handler info structure\r
+  // Try to initialize the handler information structure\r
   //\r
   HandlerInfo->Signature = EXTRACT_HANDLER_INFO_SIGNATURE;\r
   if (HandlerInfo->Signature != EXTRACT_HANDLER_INFO_SIGNATURE) {\r
     //\r
-    // The handler info structure was not writeable because the memory is not ready.\r
+    // The handler information structure was not writeable because the memory is not ready.\r
     //\r
     *InfoPointer = NULL;\r
     return RETURN_OUT_OF_RESOURCES;\r
@@ -147,10 +147,10 @@ ExtractGuidedSectionGetGuidList (
 \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
+  @param[in]  GetInfoHandler The 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
+  @param[in]  DecodeHandler  The 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
@@ -284,7 +284,7 @@ ExtractGuidedSectionGetInfo (
   for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
     if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
       //\r
-      // Call the match handler to get info for the input section data.\r
+      // Call the match handler to get information for the input section data.\r
       //\r
       return HandlerInfo->ExtractGetInfoHandlerTable [Index] (\r
                 InputSection,\r
@@ -386,3 +386,77 @@ ExtractGuidedSectionDecode (
   //\r
   return RETURN_UNSUPPORTED;\r
 }\r
+\r
+/**\r
+  Retrieves handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and \r
+  EXTRACT_GUIDED_SECTION_DECODE_HANDLER for a specific GUID section type.\r
+  \r
+  Retrieves the handlers associated with SectionGuid and returns them in \r
+  GetInfoHandler and DecodeHandler.\r
+\r
+  If the GUID value specified by SectionGuid has not been registered, then \r
+  return RETURN_NOT_FOUND.\r
+  \r
+  If SectionGuid is NULL, then ASSERT().\r
+\r
+  @param[in]  SectionGuid    A pointer to the GUID associated with the handlersof the GUIDed \r
+                             section type being retrieved.\r
+  @param[out] GetInfoHandler Pointer to a function that examines a GUIDed section and returns \r
+                             the size of the decoded buffer and the size of an optional scratch \r
+                             buffer required to actually decode the data in a GUIDed section.  \r
+                             This is an optional parameter that may be NULL. If it is NULL, then \r
+                             the previously registered handler is not returned.\r
+  @param[out] DecodeHandler  Pointer to a function that decodes a GUIDed section into a caller\r
+                             allocated output buffer. This is an optional parameter that may be NULL.\r
+                             If it is NULL, then the previously registered handler is not returned.\r
+\r
+  @retval  RETURN_SUCCESS     The handlers were retrieved.\r
+  @retval  RETURN_NOT_FOUND   No handlers have been registered with the specified GUID.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionGetHandlers (\r
+  IN CONST   GUID                                     *SectionGuid,\r
+  OUT        EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER  *GetInfoHandler,  OPTIONAL\r
+  OUT        EXTRACT_GUIDED_SECTION_DECODE_HANDLER    *DecodeHandler    OPTIONAL\r
+  )\r
+{\r
+  UINT32                              Index;\r
+  RETURN_STATUS                       Status;\r
+  EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
+\r
+  //\r
+  // Check input paramter\r
+  //\r
+  ASSERT (SectionGuid != NULL);\r
+\r
+  //\r
+  // Get the registered handler information\r
+  //\r
+  Status = GetExtractGuidedSectionHandlerInfo (&HandlerInfo);\r
+  if (RETURN_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Search the match registered GetInfo handler for the input guided section.\r
+  //\r
+  ASSERT (HandlerInfo != NULL);\r
+  for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
+    if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionGuid)) {\r
+\r
+      //\r
+      // If the guided handler has been registered before, then return the registered handlers.\r
+      //\r
+      if (GetInfoHandler != NULL) {\r
+        *GetInfoHandler = HandlerInfo->ExtractGetInfoHandlerTable[Index];\r
+      }\r
+      if (DecodeHandler != NULL) {\r
+        *DecodeHandler = HandlerInfo->ExtractDecodeHandlerTable[Index];\r
+      }\r
+      return RETURN_SUCCESS;\r
+    }\r
+  }\r
+  return RETURN_NOT_FOUND;\r
+}\r