]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FmpDevicePkg/FmpDxe/FmpDxe.c
FmpDevicePkg FmpDxe: Use Attributes to know whether reset is required
[mirror_edk2.git] / FmpDevicePkg / FmpDxe / FmpDxe.c
index 091f950b95b23a7a2811b3060748ba04395c023f..3544afd3dee744131f2bd3f1b129ff36ba64b4b3 100644 (file)
@@ -480,7 +480,7 @@ cleanup:
   @retval EFI_INVALID_PARAMETER  The Image was NULL.\r
   @retval EFI_NOT_FOUND          The current image is not copied to the buffer.\r
   @retval EFI_UNSUPPORTED        The operation is not supported.\r
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to an authentication failure.\r
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to an authentication failure.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -497,6 +497,15 @@ GetTheImage (
 \r
   Status = EFI_SUCCESS;\r
 \r
+  //\r
+  // Check to make sure index is 1 (only 1 image for this device)\r
+  //\r
+  if (ImageIndex != 1) {\r
+    DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n"));\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto cleanup;\r
+  }\r
+\r
   if ((ImageSize == NULL)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is NULL.\n"));\r
     Status = EFI_INVALID_PARAMETER;\r
@@ -523,16 +532,6 @@ GetTheImage (
     goto cleanup;\r
   }\r
 \r
-  //\r
-  // Check to make sure index is 1 (only 1 image for this device)\r
-  //\r
-  if (ImageIndex != 1) {\r
-    DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n"));\r
-    Status = EFI_INVALID_PARAMETER;\r
-    goto cleanup;\r
-  }\r
-\r
-\r
   Status = FmpDeviceGetImage (Image, ImageSize);\r
 cleanup:\r
 \r
@@ -626,9 +625,10 @@ GetAllHeaderSize (
                                  if available, additional information if the image is invalid.\r
 \r
   @retval EFI_SUCCESS            The image was successfully checked.\r
+  @retval EFI_ABORTED            The operation is aborted.\r
   @retval EFI_INVALID_PARAMETER  The Image was NULL.\r
   @retval EFI_UNSUPPORTED        The operation is not supported.\r
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to an authentication failure.\r
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to an authentication failure.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -874,7 +874,7 @@ cleanup:
   @retval EFI_ABORTED            The operation is aborted.\r
   @retval EFI_INVALID_PARAMETER  The Image was NULL.\r
   @retval EFI_UNSUPPORTED        The operation is not supported.\r
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to an authentication failure.\r
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to an authentication failure.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -898,6 +898,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
@@ -1110,10 +1113,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
@@ -1121,10 +1128,12 @@ cleanup:
   mProgressSupported = FALSE;\r
   SetLastAttemptStatusInVariable (LastAttemptStatus);\r
 \r
-  //\r
-  // Set progress to 100 after everything is done including recording Status.\r
-  //\r
-  Progress (100);\r
+  if (Progress != NULL) {\r
+    //\r
+    // Set progress to 100 after everything is done including recording Status.\r
+    //\r
+    Progress (100);\r
+  }\r
 \r
   return Status;\r
 }\r
@@ -1203,7 +1212,7 @@ GetPackageInfo (
   @retval EFI_INVALID_PARAMETER  The PackageVersionName length is longer than the value\r
                                  returned in PackageVersionNameMaxLen.\r
   @retval EFI_UNSUPPORTED        The operation is not supported.\r
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to an authentication failure.\r
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to an authentication failure.\r
 \r
 **/\r
 EFI_STATUS\r