]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FmpDevicePkg/FmpDxe/FmpDxe.c
FmpDevicePkg FmpDxe: Initialize DeviceLibLowestSupportedVersion
[mirror_edk2.git] / FmpDevicePkg / FmpDxe / FmpDxe.c
index 94fdf5608529c63254249c446584f29a88b004d5..095cebaa750771af7bab61b71f2486815e9274d1 100644 (file)
@@ -89,6 +89,13 @@ UINT64  mImageId      = 0x1;
 CHAR16  *mVersionName = NULL;\r
 \r
 EFI_EVENT  mFmpDeviceLockEvent;\r
+//\r
+// Indicates if an attempt has been made to lock a \r
+// FLASH storage device by calling FmpDeviceLock().\r
+// A FLASH storage device may not support being locked,\r
+// so this variable is set to TRUE even if FmpDeviceLock()\r
+// returns an error.\r
+//\r
 BOOLEAN    mFmpDeviceLocked = FALSE;\r
 \r
 /**\r
@@ -222,6 +229,7 @@ GetLowestSupportedVersion (
   //\r
   // Check the FmpDeviceLib\r
   //\r
+  DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;\r
   Status = FmpDeviceGetLowestSupportedVersion (&DeviceLibLowestSupportedVersion);\r
   if (EFI_ERROR (Status)) {\r
     DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;\r
@@ -898,6 +906,9 @@ SetTheImage (
   UINT32      AllHeaderSize;\r
   UINT32      IncommingFwVersion;\r
   UINT32      LastAttemptStatus;\r
+  EFI_STATUS  GetAttributesStatus;\r
+  UINT64      AttributesSupported;\r
+  UINT64      AttributesSetting;\r
 \r
   Status             = EFI_SUCCESS;\r
   Updateable         = 0;\r
@@ -918,7 +929,7 @@ SetTheImage (
   //\r
   if (mFmpDeviceLocked) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Device is already locked.  Can't update.\n"));\r
-    Status = EFI_ACCESS_DENIED;\r
+    Status = EFI_UNSUPPORTED;\r
     goto cleanup;\r
   }\r
 \r
@@ -1110,10 +1121,14 @@ SetTheImage (
 \r
   //\r
   // Set flag so the descriptor is repopulated\r
-  // This only applied to devices that do not require system reboot\r
+  // This is only applied to devices that do not require reset\r
   //\r
-  if (!PcdGetBool (PcdFmpDeviceSystemResetRequired)) {\r
-    mDescriptorPopulated = FALSE;\r
+  GetAttributesStatus = FmpDeviceGetAttributes (&AttributesSupported, &AttributesSetting);\r
+  if (!EFI_ERROR (GetAttributesStatus)) {\r
+    if (((AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED) == 0) ||\r
+        ((AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED) == 0)) {\r
+      mDescriptorPopulated = FALSE;\r
+    }\r
   }\r
 \r
 cleanup:\r