Revision: 14300
          http://edk2.svn.sourceforge.net/edk2/?rev=14300&view=rev
Author:   vanjeff
Date:     2013-04-19 07:46:35 +0000 (Fri, 19 Apr 2013)
Log Message:
-----------
Sync patch r13930 from main trunk.
Build the registered guid HOB and SystemTable to record the GUID itself in 
PeiExtractGuidedSectionLib and DxeExtractGuidedSectionLib, and also state the 
restriction in BaseExtractGuidedSectionLib.

Revision Links:
--------------
    http://edk2.svn.sourceforge.net/edk2/?rev=13930&view=rev

Modified Paths:
--------------
    
branches/UDK2010.SR1/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c
    
branches/UDK2010.SR1/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.inf
    
branches/UDK2010.SR1/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
    branches/UDK2010.SR1/MdeModulePkg/Core/Pei/FwVol/FwVol.c
    
branches/UDK2010.SR1/MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
    
branches/UDK2010.SR1/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
    
branches/UDK2010.SR1/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
    
branches/UDK2010.SR1/MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c

Modified: 
branches/UDK2010.SR1/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c
===================================================================
--- 
branches/UDK2010.SR1/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c
     2013-04-19 07:34:41 UTC (rev 14299)
+++ 
branches/UDK2010.SR1/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c
     2013-04-19 07:46:35 UTC (rev 14300)
@@ -45,6 +45,7 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/BaseMemoryLib.h>
+#include <Library/UefiLib.h>
 #include <Protocol/Decompress.h>
 #include <Protocol/GuidedSectionExtraction.h>
 #include <Protocol/SectionExtraction.h>
@@ -536,6 +537,53 @@
 }
 
 /**
+  Verify the Guided Section GUID by checking if there is the Guided Section 
GUID configuration table recorded the GUID itself.
+
+  @param GuidedSectionGuid          The Guided Section GUID.
+  @param GuidedSectionExtraction    A pointer to the pointer to the supported 
Guided Section Extraction Protocol
+                                    for the Guided Section.
+
+  @return TRUE      The GuidedSectionGuid could be identified, and the pointer 
to
+                    the Guided Section Extraction Protocol will be returned to 
*GuidedSectionExtraction.
+  @return FALSE     The GuidedSectionGuid could not be identified, or 
+                    the Guided Section Extraction Protocol has not been 
installed yet.
+
+**/
+BOOLEAN
+VerifyGuidedSectionGuid (
+  IN  EFI_GUID                                  *GuidedSectionGuid,
+  OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL    **GuidedSectionExtraction
+  )
+{
+  EFI_GUID              *GuidRecorded;
+  VOID                  *Interface;
+  EFI_STATUS            Status;
+
+  //
+  // Check if there is the Guided Section GUID configuration table recorded 
the GUID itself.
+  //
+  Status = EfiGetSystemConfigurationTable (GuidedSectionGuid, (VOID **) 
&GuidRecorded);
+  if (Status == EFI_SUCCESS) {
+    if (CompareGuid (GuidRecorded, GuidedSectionGuid)) {
+      //
+      // Found the recorded GuidedSectionGuid.
+      //
+      Status = gBS->LocateProtocol (GuidedSectionGuid, NULL, (VOID **) 
&Interface);
+      if (!EFI_ERROR (Status) && Interface != NULL) {
+        //
+        // Found the supported Guided Section Extraction Porotocol for the 
Guided Section.
+        //
+        *GuidedSectionExtraction = (EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *) 
Interface;
+        return TRUE;
+      }
+      return FALSE;
+    }
+  }
+
+  return FALSE;
+}
+
+/**
   RPN callback function.  
   1. Initialize the section stream when the GUIDED_SECTION_EXTRACTION_PROTOCOL 
is installed.
   2. Removes a stale section stream and re-initializes it with an updated 
AuthenticationStatus.
@@ -575,10 +623,10 @@
       (Context->ParentStream->StreamBuffer + 
Context->ChildNode->OffsetInStream);
     ASSERT (GuidedHeader->CommonHeader.Type == EFI_SECTION_GUID_DEFINED);
     
-    Status = gBS->LocateProtocol (Context->ChildNode->EncapsulationGuid, NULL, 
(VOID **)&GuidedExtraction);
-    ASSERT_EFI_ERROR (Status);
+    if (!VerifyGuidedSectionGuid (Context->ChildNode->EncapsulationGuid, 
&GuidedExtraction)) {
+      return;
+    }
 
-    
     Status = GuidedExtraction->ExtractSection (
                                  GuidedExtraction,
                                  GuidedHeader,
@@ -837,8 +885,7 @@
         Node->EncapsulationGuid = &GuidedHeader->SectionDefinitionGuid;
         GuidedSectionAttributes = GuidedHeader->Attributes;
       }
-      Status = gBS->LocateProtocol (Node->EncapsulationGuid, NULL, (VOID 
**)&GuidedExtraction);
-      if (!EFI_ERROR (Status)) {
+      if (VerifyGuidedSectionGuid (Node->EncapsulationGuid, 
&GuidedExtraction)) {
         //
         // NewStreamBuffer is always allocated by ExtractSection... No caller
         // allocation here.

Modified: 
branches/UDK2010.SR1/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.inf
===================================================================
--- 
branches/UDK2010.SR1/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.inf
        2013-04-19 07:34:41 UTC (rev 14299)
+++ 
branches/UDK2010.SR1/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.inf
        2013-04-19 07:46:35 UTC (rev 14300)
@@ -6,7 +6,7 @@
 #  where each stream contains a linked list of children, which may be leaves or
 #  encapsulations. Encapsulation section will further generate new section 
stream entries.
 #  
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution.  The full text of the license may be 
found at
@@ -40,6 +40,7 @@
   BaseLib
   BaseMemoryLib
   UefiDriverEntryPoint
+  UefiLib
 
 [Packages]
   MdePkg/MdePkg.dec

Modified: 
branches/UDK2010.SR1/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
===================================================================
--- 
branches/UDK2010.SR1/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
        2013-04-19 07:34:41 UTC (rev 14299)
+++ 
branches/UDK2010.SR1/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
        2013-04-19 07:46:35 UTC (rev 14300)
@@ -487,6 +487,53 @@
 }
 
 /**
+  Verify the Guided Section GUID by checking if there is the Guided Section 
GUID configuration table recorded the GUID itself.
+
+  @param GuidedSectionGuid          The Guided Section GUID.
+  @param GuidedSectionExtraction    A pointer to the pointer to the supported 
Guided Section Extraction Protocol
+                                    for the Guided Section.
+
+  @return TRUE      The GuidedSectionGuid could be identified, and the pointer 
to
+                    the Guided Section Extraction Protocol will be returned to 
*GuidedSectionExtraction.
+  @return FALSE     The GuidedSectionGuid could not be identified, or 
+                    the Guided Section Extraction Protocol has not been 
installed yet.
+
+**/
+BOOLEAN
+VerifyGuidedSectionGuid (
+  IN  EFI_GUID                                  *GuidedSectionGuid,
+  OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL    **GuidedSectionExtraction
+  )
+{
+  EFI_GUID              *GuidRecorded;
+  VOID                  *Interface;
+  EFI_STATUS            Status;
+
+  //
+  // Check if there is the Guided Section GUID configuration table recorded 
the GUID itself.
+  //
+  Status = EfiGetSystemConfigurationTable (GuidedSectionGuid, (VOID **) 
&GuidRecorded);
+  if (Status == EFI_SUCCESS) {
+    if (CompareGuid (GuidRecorded, GuidedSectionGuid)) {
+      //
+      // Found the recorded GuidedSectionGuid.
+      //
+      Status = CoreLocateProtocol (GuidedSectionGuid, NULL, (VOID **) 
&Interface);
+      if (!EFI_ERROR (Status) && Interface != NULL) {
+        //
+        // Found the supported Guided Section Extraction Porotocol for the 
Guided Section.
+        //
+        *GuidedSectionExtraction = (EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *) 
Interface;
+        return TRUE;
+      }
+      return FALSE;
+    }
+  }
+
+  return FALSE;
+}
+
+/**
   RPN callback function. Initializes the section stream
   when GUIDED_SECTION_EXTRACTION_PROTOCOL is installed.
 
@@ -513,12 +560,11 @@
   
   GuidedHeader = (EFI_GUID_DEFINED_SECTION *) 
(Context->ParentStream->StreamBuffer + Context->ChildNode->OffsetInStream);
   ASSERT (GuidedHeader->CommonHeader.Type == EFI_SECTION_GUID_DEFINED);
-  
-  Status = gBS->LocateProtocol (Context->ChildNode->EncapsulationGuid, NULL, 
(VOID **)&GuidedExtraction);
-  if (EFI_ERROR (Status)) {
+
+  if (!VerifyGuidedSectionGuid (Context->ChildNode->EncapsulationGuid, 
&GuidedExtraction)) {
     return;
   }
-  
+
   Status = GuidedExtraction->ExtractSection (
                                GuidedExtraction,
                                GuidedHeader,
@@ -788,8 +834,7 @@
         Node->EncapsulationGuid = &GuidedHeader->SectionDefinitionGuid;
         GuidedSectionAttributes = GuidedHeader->Attributes;
       }
-      Status = CoreLocateProtocol (Node->EncapsulationGuid, NULL, (VOID 
**)&GuidedExtraction);
-      if (!EFI_ERROR (Status) && GuidedExtraction != NULL) {
+      if (VerifyGuidedSectionGuid (Node->EncapsulationGuid, 
&GuidedExtraction)) {
         //
         // NewStreamBuffer is always allocated by ExtractSection... No caller
         // allocation here.

Modified: branches/UDK2010.SR1/MdeModulePkg/Core/Pei/FwVol/FwVol.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Core/Pei/FwVol/FwVol.c    2013-04-19 
07:34:41 UTC (rev 14299)
+++ branches/UDK2010.SR1/MdeModulePkg/Core/Pei/FwVol/FwVol.c    2013-04-19 
07:46:35 UTC (rev 14300)
@@ -607,6 +607,55 @@
 }
 
 /**
+  Verify the Guided Section GUID by checking if there is the Guided Section 
GUID HOB recorded the GUID itself.
+
+  @param GuidedSectionGuid          The Guided Section GUID.
+  @param GuidedSectionExtraction    A pointer to the pointer to the supported 
Guided Section Extraction Ppi
+                                    for the Guided Section.
+
+  @return TRUE      The GuidedSectionGuid could be identified, and the pointer 
to
+                    the Guided Section Extraction Ppi will be returned to 
*GuidedSectionExtraction.
+  @return FALSE     The GuidedSectionGuid could not be identified, or 
+                    the Guided Section Extraction Ppi has not been installed 
yet.
+
+**/
+BOOLEAN
+VerifyGuidedSectionGuid (
+  IN  EFI_GUID                                  *GuidedSectionGuid,
+  OUT EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI     **GuidedSectionExtraction
+  )
+{
+  EFI_PEI_HOB_POINTERS  Hob;
+  EFI_GUID              *GuidRecorded;
+  VOID                  *Interface;
+  EFI_STATUS            Status;
+
+  //
+  // Check if there is the Guided Section GUID HOB recorded the GUID itself.
+  //
+  Hob.Raw = GetFirstGuidHob (GuidedSectionGuid);
+  if (Hob.Raw != NULL) {
+    GuidRecorded = (EFI_GUID *) GET_GUID_HOB_DATA (Hob);
+    if (CompareGuid (GuidRecorded, GuidedSectionGuid)) {
+      //
+      // Found the recorded GuidedSectionGuid.
+      //
+      Status = PeiServicesLocatePpi (GuidedSectionGuid, 0, NULL, (VOID **) 
&Interface);
+      if (!EFI_ERROR (Status) && Interface != NULL) {
+        //
+        // Found the supported Guided Section Extraction Ppi for the Guided 
Section.
+        //
+        *GuidedSectionExtraction = (EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *) 
Interface;
+        return TRUE;
+      }
+      return FALSE;
+    }
+  }
+
+  return FALSE;
+}
+
+/**
   Go through the file to search SectionType section. 
   Search within encapsulation sections (compression and GUIDed) recursively, 
   until the match section is found.
@@ -643,6 +692,7 @@
   UINTN                                   Index;
   UINT32                                  Authentication;
   PEI_CORE_INSTANCE                       *PrivateData;
+  EFI_GUID                                *SectionDefinitionGuid;
 
   PrivateData   = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
   *OutputBuffer = NULL;
@@ -702,21 +752,11 @@
       Status = EFI_NOT_FOUND;
       if (Section->Type == EFI_SECTION_GUID_DEFINED) {
         if (IS_SECTION2 (Section)) {
-          Status = PeiServicesLocatePpi (
-                     &((EFI_GUID_DEFINED_SECTION2 
*)Section)->SectionDefinitionGuid, 
-                     0, 
-                     NULL, 
-                     (VOID **) &GuidSectionPpi
-                     );
+          SectionDefinitionGuid = &((EFI_GUID_DEFINED_SECTION2 
*)Section)->SectionDefinitionGuid;
         } else {
-          Status = PeiServicesLocatePpi (
-                     &((EFI_GUID_DEFINED_SECTION 
*)Section)->SectionDefinitionGuid, 
-                     0, 
-                     NULL, 
-                     (VOID **) &GuidSectionPpi
-                     );
+          SectionDefinitionGuid = &((EFI_GUID_DEFINED_SECTION 
*)Section)->SectionDefinitionGuid;
         }
-        if (!EFI_ERROR (Status)) {
+        if (VerifyGuidedSectionGuid (SectionDefinitionGuid, &GuidSectionPpi)) {
           Status = GuidSectionPpi->ExtractSection (
                                      GuidSectionPpi,
                                      Section,

Modified: 
branches/UDK2010.SR1/MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
===================================================================
--- 
branches/UDK2010.SR1/MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
     2013-04-19 07:34:41 UTC (rev 14299)
+++ 
branches/UDK2010.SR1/MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
     2013-04-19 07:46:35 UTC (rev 14300)
@@ -7,9 +7,12 @@
 #  in their initialization without any issues. They only have to be careful in 
 #  the implementation of runtime services, because this BASE library instance 
doesn't 
 #  convert the address pointed by PcdGuidedExtractHandlerTableAddress to the 
virtual address.
-#  
-#  Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+#  And a driver should use this ExtractGuidedSectionLib to do implementation 
internally, also
+#  this ExtractGuidedSectionLib couldn't be used for guided section extraction 
that is required
+#  by PEI and DXE core for recovery or capsule image processing, etc.
 #
+#  Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
+#
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution. The full text of the license may be 
found at

Modified: 
branches/UDK2010.SR1/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
===================================================================
--- 
branches/UDK2010.SR1/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
 2013-04-19 07:34:41 UTC (rev 14299)
+++ 
branches/UDK2010.SR1/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
 2013-04-19 07:46:35 UTC (rev 14300)
@@ -1,7 +1,7 @@
 /** @file
   Provide generic extract guided section functions for Dxe phase.
 
-  Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -18,6 +18,7 @@
 #include <Library/BaseMemoryLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/ExtractGuidedSectionLib.h>
+#include <Library/UefiBootServicesTableLib.h>
 
 #define EXTRACT_HANDLER_TABLE_SIZE   0x10
 
@@ -175,6 +176,8 @@
   )
 {
   UINT32 Index;
+  VOID   *GuidData;
+
   //
   // Check input paramter.
   //
@@ -211,7 +214,16 @@
   CopyGuid (&mExtractHandlerGuidTable [mNumberOfExtractHandler], SectionGuid);
   mExtractDecodeHandlerTable [mNumberOfExtractHandler] = DecodeHandler;
   mExtractGetInfoHandlerTable [mNumberOfExtractHandler++] = GetInfoHandler;
-  
+
+  //
+  // Install the Guided Section GUID configuration table to record the GUID 
itself.
+  // Then the content of the configuration table buffer will be the same as 
the GUID value itself.
+  //
+  GuidData = AllocateCopyPool (sizeof (GUID), (VOID *) SectionGuid);
+  if (GuidData != NULL) {
+    gBS->InstallConfigurationTable ((EFI_GUID *) SectionGuid, GuidData);
+  }
+
   return RETURN_SUCCESS;
 }
 

Modified: 
branches/UDK2010.SR1/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
===================================================================
--- 
branches/UDK2010.SR1/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
       2013-04-19 07:34:41 UTC (rev 14299)
+++ 
branches/UDK2010.SR1/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
       2013-04-19 07:46:35 UTC (rev 14300)
@@ -3,7 +3,7 @@
 #
 # This library provides generic extract guided section functions for DXE 
module.
 #
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -42,4 +42,5 @@
   MemoryAllocationLib
   BaseMemoryLib
   DebugLib
+  UefiBootServicesTableLib
 

Modified: 
branches/UDK2010.SR1/MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c
===================================================================
--- 
branches/UDK2010.SR1/MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c
 2013-04-19 07:34:41 UTC (rev 14299)
+++ 
branches/UDK2010.SR1/MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c
 2013-04-19 07:46:35 UTC (rev 14300)
@@ -1,7 +1,7 @@
 /** @file
   Provide generic extract guided section functions for PEI phase.
 
-  Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -243,6 +243,16 @@
   HandlerInfo->ExtractDecodeHandlerTable [HandlerInfo->NumberOfExtractHandler] 
= DecodeHandler;
   HandlerInfo->ExtractGetInfoHandlerTable 
[HandlerInfo->NumberOfExtractHandler++] = GetInfoHandler;
 
+  //
+  // Build the Guided Section GUID HOB to record the GUID itself.
+  // Then the content of the GUIDed HOB will be the same as the GUID value 
itself.
+  //
+  BuildGuidDataHob (
+    (EFI_GUID *) SectionGuid,
+    (VOID *) SectionGuid,
+    sizeof (GUID)
+    );
+
   return RETURN_SUCCESS;
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to