Use right LBA to get the backed up WorkSpace in spare block.
authorStar Zeng <star.zeng@intel.com>
Fri, 7 Jun 2013 02:38:00 +0000 (02:38 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 7 Jun 2013 02:38:00 +0000 (02:38 +0000)
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14398 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c

index c5f41d7..2e4052c 100644 (file)
@@ -2,7 +2,7 @@
 \r
   Internal generic functions to operate flash block.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -411,7 +411,7 @@ FlushSpareBlockToBootBlock (
     return EFI_ABORTED;\r
   }\r
   //\r
-  // Write memory buffer currenet spare block. Still top block.\r
+  // Write memory buffer to current spare block. Still top block.\r
   //\r
   Ptr = Buffer;\r
   for (Index = 0; Index < FtwDevice->NumberOfSpareBlock; Index += 1) {\r
@@ -1147,6 +1147,7 @@ InitFtwProtocol (
   EFI_FAULT_TOLERANT_WRITE_HEADER     *FtwHeader;\r
   UINTN                               Offset;\r
   EFI_HANDLE                          FvbHandle;\r
+  EFI_LBA                             WorkSpaceLbaOffset;\r
 \r
   //\r
   // Find the right SMM Fvb protocol instance for FTW.\r
@@ -1188,10 +1189,11 @@ InitFtwProtocol (
     //\r
     // Read from spare block\r
     //\r
+    WorkSpaceLbaOffset = FtwDevice->FtwWorkSpaceLba - FtwDevice->FtwWorkBlockLba;\r
     Length = FtwDevice->FtwWorkSpaceSize;\r
     Status = FtwDevice->FtwBackupFvb->Read (\r
                     FtwDevice->FtwBackupFvb,\r
-                    FtwDevice->FtwSpareLba,\r
+                    FtwDevice->FtwSpareLba + WorkSpaceLbaOffset,\r
                     FtwDevice->FtwWorkSpaceBase,\r
                     &Length,\r
                     FtwDevice->FtwWorkSpace\r