]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVol.c
IntelFrameworkModulePkg FwVolDxe: Get FV auth status propagated from PEI
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / FirmwareVolume / FwVolDxe / FwVol.c
index 2ba09c49b58ae2f125a232583ecda887a02588f1..91fcd472124444d121561a5bea742ad88c80b7fc 100644 (file)
@@ -4,7 +4,7 @@
   Layers on top of Firmware Block protocol to produce a file abstraction\r
   of FV based files.\r
 \r
   Layers on top of Firmware Block protocol to produce a file abstraction\r
   of FV based files.\r
 \r
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -195,7 +195,7 @@ FreeFvDeviceResource (
 /**\r
 \r
   Firmware volume inherits authentication status from the FV image file and section(in another firmware volume)\r
 /**\r
 \r
   Firmware volume inherits authentication status from the FV image file and section(in another firmware volume)\r
-  where it came from.\r
+  where it came from or propagated from PEI-phase.\r
 \r
   @param  FvDevice              A pointer to the FvDevice.\r
 \r
 \r
   @param  FvDevice              A pointer to the FvDevice.\r
 \r
@@ -205,26 +205,30 @@ FwVolInheritAuthenticationStatus (
   IN FV_DEVICE  *FvDevice\r
   )\r
 {\r
   IN FV_DEVICE  *FvDevice\r
   )\r
 {\r
-  EFI_STATUS                        Status;\r
-  EFI_FIRMWARE_VOLUME_HEADER        *CachedFvHeader;\r
-  EFI_FIRMWARE_VOLUME_EXT_HEADER    *CachedFvExtHeader;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL     *ParentFvProtocol;\r
-  UINTN                             Key;\r
-  EFI_GUID                          FileNameGuid;\r
-  EFI_FV_FILETYPE                   FileType;\r
-  EFI_FV_FILE_ATTRIBUTES            FileAttributes;\r
-  UINTN                             FileSize;\r
-  EFI_SECTION_TYPE                  SectionType;\r
-  UINT32                            AuthenticationStatus;\r
-  EFI_FIRMWARE_VOLUME_HEADER        *FvHeader;\r
-  EFI_FIRMWARE_VOLUME_EXT_HEADER    *FvExtHeader;\r
-  UINTN                             BufferSize;\r
-\r
-  CachedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvDevice->CachedFv;\r
+  EFI_STATUS                            Status;\r
+  EFI_FIRMWARE_VOLUME_HEADER            *CachedFvHeader;\r
+  EFI_FIRMWARE_VOLUME_EXT_HEADER        *CachedFvExtHeader;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL         *ParentFvProtocol;\r
+  UINTN                                 Key;\r
+  EFI_GUID                              FileNameGuid;\r
+  EFI_FV_FILETYPE                       FileType;\r
+  EFI_FV_FILE_ATTRIBUTES                FileAttributes;\r
+  UINTN                                 FileSize;\r
+  EFI_SECTION_TYPE                      SectionType;\r
+  UINT32                                AuthenticationStatus;\r
+  EFI_FIRMWARE_VOLUME_HEADER            *FvHeader;\r
+  EFI_FIRMWARE_VOLUME_EXT_HEADER        *FvExtHeader;\r
+  UINTN                                 BufferSize;\r
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *Fvb;\r
+  EFI_FVB_ATTRIBUTES_2                  FvbAttributes;\r
+  EFI_PHYSICAL_ADDRESS                  BaseAddress;\r
+  EFI_PEI_HOB_POINTERS                  Fv3Hob;\r
 \r
   if (FvDevice->Fv.ParentHandle != NULL) {\r
 \r
   if (FvDevice->Fv.ParentHandle != NULL) {\r
+    CachedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvDevice->CachedFv;\r
+\r
     //\r
     //\r
-    // By Parent Handle, find out the FV image file and section(in another firmware volume) where the firmware volume came from \r
+    // By Parent Handle, find out the FV image file and section(in another firmware volume) where the firmware volume came from\r
     //\r
     Status = gBS->HandleProtocol (FvDevice->Fv.ParentHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **) &ParentFvProtocol);\r
     if (!EFI_ERROR (Status) && (ParentFvProtocol != NULL)) {\r
     //\r
     Status = gBS->HandleProtocol (FvDevice->Fv.ParentHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **) &ParentFvProtocol);\r
     if (!EFI_ERROR (Status) && (ParentFvProtocol != NULL)) {\r
@@ -258,7 +262,7 @@ FwVolInheritAuthenticationStatus (
         if (!EFI_ERROR (Status)) {\r
           if ((FvHeader->FvLength == CachedFvHeader->FvLength) &&\r
               (FvHeader->ExtHeaderOffset == CachedFvHeader->ExtHeaderOffset)) {\r
         if (!EFI_ERROR (Status)) {\r
           if ((FvHeader->FvLength == CachedFvHeader->FvLength) &&\r
               (FvHeader->ExtHeaderOffset == CachedFvHeader->ExtHeaderOffset)) {\r
-            if (FvHeader->ExtHeaderOffset !=0) {\r
+            if (FvHeader->ExtHeaderOffset != 0) {\r
               //\r
               // Both FVs contain extension header, then compare their FV Name GUID\r
               //\r
               //\r
               // Both FVs contain extension header, then compare their FV Name GUID\r
               //\r
@@ -292,6 +296,35 @@ FwVolInheritAuthenticationStatus (
         }\r
       } while (TRUE);\r
     }\r
         }\r
       } while (TRUE);\r
     }\r
+  } else {\r
+    Fvb = FvDevice->Fvb;\r
+\r
+    Status  = Fvb->GetAttributes (Fvb, &FvbAttributes);\r
+    if (EFI_ERROR (Status)) {\r
+      return;\r
+    }\r
+\r
+    if ((FvbAttributes & EFI_FVB2_MEMORY_MAPPED) != 0) {\r
+      //\r
+      // Get volume base address\r
+      //\r
+      Status = Fvb->GetPhysicalAddress (Fvb, &BaseAddress);\r
+      if (EFI_ERROR (Status)) {\r
+        return;\r
+      }\r
+\r
+      //\r
+      // Get the authentication status propagated from PEI-phase to DXE.\r
+      //\r
+      Fv3Hob.Raw = GetHobList ();\r
+      while ((Fv3Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV3, Fv3Hob.Raw)) != NULL) {\r
+        if (Fv3Hob.FirmwareVolume3->BaseAddress == BaseAddress) {\r
+          FvDevice->AuthenticationStatus = Fv3Hob.FirmwareVolume3->AuthenticationStatus;\r
+          return;\r
+        }\r
+        Fv3Hob.Raw = GET_NEXT_HOB (Fv3Hob);\r
+      }\r
+    }\r
   }\r
 }\r
 \r
   }\r
 }\r
 \r
@@ -529,7 +562,7 @@ FvCheck (
       continue;\r
     }\r
     //\r
       continue;\r
     }\r
     //\r
-    // double check boundry\r
+    // double check boundary\r
     //\r
     if (TestLength < sizeof (EFI_FFS_FILE_HEADER)) {\r
       break;\r
     //\r
     if (TestLength < sizeof (EFI_FFS_FILE_HEADER)) {\r
       break;\r
@@ -570,7 +603,7 @@ FvCheck (
         DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &((EFI_FFS_FILE_HEADER *) Ptr)->Name));\r
         Ptr = Ptr + FFS_FILE2_SIZE (Ptr);\r
         //\r
         DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &((EFI_FFS_FILE_HEADER *) Ptr)->Name));\r
         Ptr = Ptr + FFS_FILE2_SIZE (Ptr);\r
         //\r
-        // Adjust Ptr to the next 8-byte aligned boundry.\r
+        // Adjust Ptr to the next 8-byte aligned boundary.\r
         //\r
         while (((UINTN) Ptr & 0x07) != 0) {\r
           Ptr++;\r
         //\r
         while (((UINTN) Ptr & 0x07) != 0) {\r
           Ptr++;\r
@@ -609,7 +642,7 @@ FvCheck (
       }\r
 \r
       //\r
       }\r
 \r
       //\r
-      // Adjust Ptr to the next 8-byte aligned boundry.\r
+      // Adjust Ptr to the next 8-byte aligned boundary.\r
       //\r
       while (((UINTN) Ptr & 0x07) != 0) {\r
         Ptr++;\r
       //\r
       while (((UINTN) Ptr & 0x07) != 0) {\r
         Ptr++;\r