]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FmpDevicePkg/FmpDxe/FmpDxe.c
FmpDevicePkg/FmpDxe: Call FmpDeviceLib WithStatus() functions
[mirror_edk2.git] / FmpDevicePkg / FmpDxe / FmpDxe.c
index de7f1fe53e327a387f8b99592f9d892e03d08796..6b0675ea38f807e64ee0947a28fc1c842e830a95 100644 (file)
@@ -1025,9 +1025,24 @@ CheckTheImageInternal (
   //\r
   // FmpDeviceLib CheckImage function to do any specific checks\r
   //\r
-  Status = FmpDeviceCheckImage ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdatable);\r
+  Status = FmpDeviceCheckImageWithStatus ((((UINT8 *) Image) + AllHeaderSize), RawSize, ImageUpdatable, LastAttemptStatus);\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", mImageIdName, Status));\r
+\r
+    //\r
+    // LastAttemptStatus returned from the device library should fall within the designated error range\r
+    // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]\r
+    //\r
+    if ((*LastAttemptStatus < LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE) ||\r
+        (*LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE)) {\r
+      DEBUG (\r
+        (DEBUG_ERROR,\r
+        "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",\r
+        mImageIdName,\r
+        *LastAttemptStatus)\r
+        );\r
+      *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;\r
+    }\r
   }\r
 \r
 cleanup:\r
@@ -1353,16 +1368,33 @@ SetTheImage (
   //\r
   //Copy the requested image to the firmware using the FmpDeviceLib\r
   //\r
-  Status = FmpDeviceSetImage (\r
-             (((UINT8 *)Image) + AllHeaderSize),\r
+  Status = FmpDeviceSetImageWithStatus (\r
+             (((UINT8 *) Image) + AllHeaderSize),\r
              ImageSize - AllHeaderSize,\r
              VendorCode,\r
              FmpDxeProgress,\r
              IncomingFwVersion,\r
-             AbortReason\r
+             AbortReason,\r
+             &LastAttemptStatus\r
              );\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() SetImage from FmpDeviceLib failed. Status =  %r.\n", mImageIdName, Status));\r
+\r
+    //\r
+    // LastAttemptStatus returned from the device library should fall within the designated error range\r
+    // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]\r
+    //\r
+    if ((LastAttemptStatus < LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE) ||\r
+        (LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE)) {\r
+      DEBUG (\r
+        (DEBUG_ERROR,\r
+        "FmpDxe(%s): SetTheImage() - LastAttemptStatus %d from FmpDeviceSetImageWithStatus() is invalid.\n",\r
+        mImageIdName,\r
+        LastAttemptStatus)\r
+        );\r
+      LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;\r
+    }\r
+\r
     goto cleanup;\r
   }\r
 \r