]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Remove the FV header assumption in variable driver.
authorDong Guo <guo.dong@intel.com>
Wed, 31 Dec 2014 01:46:50 +0000 (01:46 +0000)
committergdong1 <gdong1@Edk2>
Wed, 31 Dec 2014 01:46:50 +0000 (01:46 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dong Guo <guo.dong@intel.com>
Reviewed-by: Gao Liming <liming.gao@intel.com>
Reviewed-by: Zeng Star <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16564 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c

index b545a05530b5e0ee780b181bda3909612526c874..3dac84a6b9dbfb49a775941af4972faaf987060a 100644 (file)
@@ -3370,10 +3370,10 @@ GetFvbInfoByAddress (
   UINTN                                   Index;\r
   EFI_PHYSICAL_ADDRESS                    FvbBaseAddress;\r
   EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL      *Fvb;\r
-  EFI_FIRMWARE_VOLUME_HEADER              *FwVolHeader;\r
   EFI_FVB_ATTRIBUTES_2                    Attributes;\r
\r
-  Fvb = NULL;\r
+  UINTN                                   BlockSize;\r
+  UINTN                                   NumberOfBlocks;\r
+\r
   HandleBuffer = NULL;\r
 \r
   //\r
@@ -3400,9 +3400,9 @@ GetFvbInfoByAddress (
     //\r
     Status = Fvb->GetAttributes (Fvb, &Attributes);\r
     if (EFI_ERROR (Status) || ((Attributes & EFI_FVB2_WRITE_STATUS) == 0)) {\r
-      continue;     \r
+      continue;\r
     }\r
-    \r
+\r
     //\r
     // Compare the address and select the right one.\r
     //\r
@@ -3411,8 +3411,15 @@ GetFvbInfoByAddress (
       continue;\r
     }\r
 \r
-    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvbBaseAddress);\r
-    if ((Address >= FvbBaseAddress) && (Address < (FvbBaseAddress + FwVolHeader->FvLength))) {\r
+    //\r
+    // Assume one FVB has one type of BlockSize.\r
+    //\r
+    Status = Fvb->GetBlockSize (Fvb, 0, &BlockSize, &NumberOfBlocks);\r
+    if (EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
+    if ((Address >= FvbBaseAddress) && (Address < (FvbBaseAddress + BlockSize * NumberOfBlocks))) {\r
       if (FvbHandle != NULL) {\r
         *FvbHandle  = HandleBuffer[Index];\r
       }\r