]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c
Fix some bugs in DSC/INF file Nt32 platform
[mirror_edk2.git] / Nt32Pkg / FvbServicesRuntimeDxe / FWBlockService.c
index c2245f48c9918f5ee3b1903878310edd62933947..a95d3b400d519c1354a5bad322a648f11b0d33fb 100644 (file)
@@ -740,6 +740,7 @@ Returns:
   UINT32              OldStatus;\r
   UINT32              NewStatus;\r
   EFI_STATUS          Status;\r
+  EFI_FVB_ATTRIBUTES  UnchangedAttributes;\r
 \r
   //\r
   // Find the right instance of the FVB private data\r
@@ -758,6 +759,24 @@ Returns:
   OldStatus     = OldAttributes & EFI_FVB2_STATUS;\r
   NewStatus     = *Attributes & EFI_FVB2_STATUS;\r
 \r
+  UnchangedAttributes = EFI_FVB2_READ_DISABLED_CAP  | \\r
+                        EFI_FVB2_READ_ENABLED_CAP   | \\r
+                        EFI_FVB2_WRITE_DISABLED_CAP | \\r
+                        EFI_FVB2_WRITE_ENABLED_CAP  | \\r
+                        EFI_FVB2_LOCK_CAP           | \\r
+                        EFI_FVB2_STICKY_WRITE       | \\r
+                        EFI_FVB2_MEMORY_MAPPED      | \\r
+                        EFI_FVB2_ERASE_POLARITY     | \\r
+                        EFI_FVB2_READ_LOCK_CAP      | \\r
+                        EFI_FVB2_WRITE_LOCK_CAP     | \\r
+                        EFI_FVB2_ALIGNMENT;\r
+\r
+  //\r
+  // Some attributes of FV is read only can *not* be set\r
+  //\r
+  if ((OldAttributes & UnchangedAttributes) ^ (*Attributes & UnchangedAttributes)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
   //\r
   // If firmware volume is locked, no status bit can be updated\r
   //\r
@@ -1088,7 +1107,7 @@ Returns:
 \r
   FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
 \r
-  return FvbWriteBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ());\r
+  return FvbWriteBlock (FvbDevice->Instance, (EFI_LBA)Lba, (UINTN)Offset, NumBytes, (UINT8 *)Buffer, mFvbModuleGlobal, EfiGoneVirtual ());\r
 }\r
 \r
 EFI_STATUS\r