]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FmpDevicePkg/FmpDxe/FmpDxe.c
FmpDevicePkg/FmpDxe: Improve set image path Last Attempt Status granularity
[mirror_edk2.git] / FmpDevicePkg / FmpDxe / FmpDxe.c
index bc11faa2bfaaadc31021a62f078bf69c065df2b6..b7fd9c93aea0cee0115dd274f3bffbea3a6b8f1b 100644 (file)
@@ -1138,6 +1138,7 @@ SetTheImage (
   if (This == NULL) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - This is NULL.\n", mImageIdName));\r
     Status = EFI_INVALID_PARAMETER;\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING;\r
     goto cleanup;\r
   }\r
 \r
@@ -1163,6 +1164,7 @@ SetTheImage (
   //\r
   if (Private->FmpDeviceLocked) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Device is already locked.  Can't update.\n", mImageIdName));\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_DEVICE_LOCKED;\r
     Status = EFI_UNSUPPORTED;\r
     goto cleanup;\r
   }\r
@@ -1170,12 +1172,9 @@ SetTheImage (
   //\r
   // Call check image to verify the image\r
   //\r
-  Status = CheckTheImage (This, ImageIndex, Image, ImageSize, &Updateable);\r
+  Status = CheckTheImageInternal (This, ImageIndex, Image, ImageSize, &Updateable, &LastAttemptStatus);\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Check The Image failed with %r.\n", mImageIdName, Status));\r
-    if (Status == EFI_SECURITY_VIOLATION) {\r
-      LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR;\r
-    }\r
     goto cleanup;\r
   }\r
 \r
@@ -1191,6 +1190,7 @@ SetTheImage (
   FmpHeader = GetFmpHeader ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, DependenciesSize, &FmpPayloadSize );\r
   if (FmpHeader == NULL) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetFmpHeader failed.\n", mImageIdName));\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER;\r
     Status = EFI_ABORTED;\r
     goto cleanup;\r
   }\r
@@ -1218,6 +1218,7 @@ SetTheImage (
 \r
   if (Progress == NULL) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Invalid progress callback\n", mImageIdName));\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROGRESS_CALLBACK_ERROR;\r
     Status = EFI_INVALID_PARAMETER;\r
     goto cleanup;\r
   }\r
@@ -1238,6 +1239,7 @@ SetTheImage (
   Status = CheckSystemPower (&BooleanValue);\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemPower - API call failed %r.\n", mImageIdName, Status));\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_POWER_API;\r
     goto cleanup;\r
   }\r
   if (!BooleanValue) {\r
@@ -1258,10 +1260,12 @@ SetTheImage (
   Status = CheckSystemThermal (&BooleanValue);\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemThermal - API call failed %r.\n", mImageIdName, Status));\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_THERMAL_API;\r
     goto cleanup;\r
   }\r
   if (!BooleanValue) {\r
     Status = EFI_ABORTED;\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_THERMAL;\r
     DEBUG (\r
       (DEBUG_ERROR,\r
       "FmpDxe(%s): SetTheImage() - CheckSystemThermal - returned False.  Update not allowed due to System Thermal.\n", mImageIdName)\r
@@ -1277,10 +1281,12 @@ SetTheImage (
   Status = CheckSystemEnvironment (&BooleanValue);\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - API call failed %r.\n", mImageIdName, Status));\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_ENV_API;\r
     goto cleanup;\r
   }\r
   if (!BooleanValue) {\r
     Status = EFI_ABORTED;\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_SYSTEM_ENV;\r
     DEBUG (\r
       (DEBUG_ERROR,\r
       "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - returned False.  Update not allowed due to System Environment.\n", mImageIdName)\r
@@ -1302,12 +1308,14 @@ SetTheImage (
   Status = GetFmpPayloadHeaderSize (FmpHeader, FmpPayloadSize, &FmpHeaderSize);\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetFmpPayloadHeaderSize failed %r.\n", mImageIdName, Status));\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_SIZE;\r
     goto cleanup;\r
   }\r
 \r
   AllHeaderSize = GetAllHeaderSize ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize + DependenciesSize);\r
   if (AllHeaderSize == 0) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetAllHeaderSize failed.\n", mImageIdName));\r
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE;\r
     Status = EFI_ABORTED;\r
     goto cleanup;\r
   }\r
@@ -1372,6 +1380,7 @@ cleanup:
   mProgressFunc = NULL;\r
 \r
   if (Private != NULL) {\r
+    DEBUG ((DEBUG_INFO, "FmpDxe(%s): SetTheImage() LastAttemptStatus: %u.\n", mImageIdName, LastAttemptStatus));\r
     SetLastAttemptStatusInVariable (Private, LastAttemptStatus);\r
   }\r
 \r