]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
Use right LBA to get the backed up WorkSpace in spare block.
[mirror_edk2.git] / MdeModulePkg / Universal / FaultTolerantWriteDxe / FtwMisc.c
index f1d64942b47c294cfad2fe5ad19e55f85ccaeced..2e4052c1ead0001b98fab73613c0b428f7074511 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
@@ -1174,6 +1175,8 @@ InitFtwProtocol (
   FtwDevice->FtwLastWriteHeader = NULL;\r
   FtwDevice->FtwLastWriteRecord = NULL;\r
 \r
+  InitializeLocalWorkSpaceHeader ();\r
+\r
   //\r
   // Refresh the working space data from working block\r
   //\r
@@ -1186,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