]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
Add more exact SMM check in SmmFaultTolerantWriteHandler.
[mirror_edk2.git] / MdeModulePkg / Universal / FaultTolerantWriteDxe / FtwMisc.c
index dc110a226d9eeb5bd8be9decd5280a6594b34b87..f1d64942b47c294cfad2fe5ad19e55f85ccaeced 100644 (file)
@@ -2,7 +2,7 @@
 \r
   Internal generic functions to operate flash block.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, 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
@@ -572,6 +572,9 @@ FlushSpareBlockToWorkingBlock (
   if (Buffer == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
+\r
+  WorkSpaceLbaOffset = FtwDevice->FtwWorkSpaceLba - FtwDevice->FtwWorkBlockLba;\r
+\r
   //\r
   // To guarantee that the WorkingBlockValid is set on spare block\r
   //\r
@@ -581,7 +584,7 @@ FlushSpareBlockToWorkingBlock (
   //\r
   FtwUpdateFvState (\r
     FtwDevice->FtwBackupFvb,\r
-    FtwDevice->FtwWorkSpaceLba,\r
+    FtwDevice->FtwSpareLba + WorkSpaceLbaOffset,\r
     FtwDevice->FtwWorkSpaceBase + sizeof (EFI_GUID) + sizeof (UINT32),\r
     WORKING_BLOCK_VALID\r
     );\r
@@ -608,7 +611,6 @@ FlushSpareBlockToWorkingBlock (
   //\r
   // Clear the CRC and STATE, copy data from spare to working block.\r
   //\r
-  WorkSpaceLbaOffset = FtwDevice->FtwWorkSpaceLba - FtwDevice->FtwWorkBlockLba;\r
   WorkingBlockHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) (Buffer + (UINTN) WorkSpaceLbaOffset * FtwDevice->BlockSize + FtwDevice->FtwWorkSpaceBase);\r
   InitWorkSpaceHeader (WorkingBlockHeader);\r
   WorkingBlockHeader->WorkingBlockValid   = FTW_ERASE_POLARITY;\r
@@ -777,7 +779,7 @@ FtwGetLastWriteHeader (
     //\r
     // If Offset exceed the FTW work space boudary, return error.\r
     //\r
-    if (Offset > FtwWorkSpaceSize) {\r
+    if (Offset >= FtwWorkSpaceSize) {\r
       *FtwWriteHeader = FtwHeader;\r
       return EFI_ABORTED;\r
     }\r