]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c
MdeModulePkg Variable: Make sure no more than one Variable HOB
[mirror_edk2.git] / Nt32Pkg / FvbServicesRuntimeDxe / FWBlockService.c
index 350672448fa4ed55796fdb4e246528b3848a26c5..03f1f44dafde5b3145f86859cb1d439f3ccdbd67 100644 (file)
@@ -1,7 +1,7 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\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
 http://opensource.org/licenses/bsd-license.php\r
@@ -945,19 +945,15 @@ Returns:
       break;\r
     }\r
 \r
-    NumOfLba = VA_ARG (args, UINT32);\r
+    NumOfLba = VA_ARG (args, UINTN);\r
 \r
     //\r
     // Check input parameters\r
     //\r
-    if (NumOfLba == 0) {\r
+    if ((NumOfLba == 0) || ((StartingLba + NumOfLba) > NumOfBlocks)) {\r
       VA_END (args);\r
       return EFI_INVALID_PARAMETER;\r
     }\r
-\r
-    if ((StartingLba + NumOfLba) > NumOfBlocks) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
   } while (1);\r
 \r
   VA_END (args);\r
@@ -969,7 +965,7 @@ Returns:
       break;\r
     }\r
 \r
-    NumOfLba = VA_ARG (args, UINT32);\r
+    NumOfLba = VA_ARG (args, UINTN);\r
 \r
     while (NumOfLba > 0) {\r
       Status = FvbEraseBlock (FvbDevice->Instance, StartingLba, mFvbModuleGlobal, EfiGoneVirtual ());\r
@@ -1104,10 +1100,6 @@ Returns:
 \r
 --*/\r
 {\r
-  UINT16  *Ptr;\r
-  UINT16  HeaderLength;\r
-  UINT16  Checksum;\r
-\r
   //\r
   // Verify the header revision, header signature, length\r
   // Length of FvBlock cannot be 2**64-1\r
@@ -1124,26 +1116,10 @@ Returns:
   //\r
   // Verify the header checksum\r
   //\r
-  HeaderLength  = (UINT16) (FwVolHeader->HeaderLength / 2);\r
-  Ptr           = (UINT16 *) FwVolHeader;\r
-  Checksum      = 0;\r
-  while (HeaderLength > 0) {\r
-    Checksum = (UINT16)(Checksum + (*Ptr));\r
-    HeaderLength--;\r
-    Ptr++;\r
-  }\r
-\r
-  if (Checksum != 0) {\r
+  if (CalculateCheckSum16 ((UINT16 *) FwVolHeader, FwVolHeader->HeaderLength) != 0) {\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
-  //\r
-  // PI specification defines the name guid of FV exists in extension header.\r
-  //\r
-  if (FwVolHeader->ExtHeaderOffset == 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  \r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -1180,7 +1156,7 @@ Returns:
   UINTN                               NumOfBlocks;\r
   EFI_PEI_HOB_POINTERS                FvHob;\r
 \r
-   //\r
+  //\r
   // Get the DXE services table\r
   //\r
   DxeServices = gDS;\r
@@ -1359,7 +1335,7 @@ Returns:
                       &gEfiFirmwareVolumeBlockProtocolGuid,\r
                       &FvbDevice->FwVolBlockInstance,\r
                       &gEfiDevicePathProtocolGuid,\r
-                      &FvbDevice->DevicePath,\r
+                      FvbDevice->DevicePath,\r
                       NULL\r
                       );\r
       ASSERT_EFI_ERROR (Status);\r