]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c
OvmfPkg/PlatformBootManagerLib: minimize the set of connected devices
[mirror_edk2.git] / Nt32Pkg / FvbServicesRuntimeDxe / FWBlockService.c
index 8d1b7e3c28818a7a44abf26e4fd149ed6d3e57dd..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
@@ -29,7 +29,6 @@ Revision History
 //\r
 #include <Guid/EventGroup.h>\r
 #include <Protocol/FirmwareVolumeBlock.h>\r
-#include <Guid/AlternateFvBlock.h>\r
 #include <Protocol/DevicePath.h>\r
 //\r
 // The Library classes this module consumes\r
@@ -946,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
@@ -970,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
@@ -1105,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
@@ -1125,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
@@ -1181,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
@@ -1360,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
@@ -1390,15 +1365,6 @@ Returns:
       ASSERT (FALSE);\r
     }\r
 \r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &FwbHandle,\r
-                    &gEfiAlternateFvBlockGuid,\r
-                    NULL,\r
-                    NULL\r
-                    );\r
-\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
     FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
       (\r
         (UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength +\r