From: "Michael Kubacki" <michael.kubacki@outlook.com>
To: devel@edk2.groups.io
Cc: Liming Gao <liming.gao@intel.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Guomin Jiang <guomin.jiang@intel.com>,
Wei6 Xu <wei6.xu@intel.com>
Subject: [PATCH v1 7/7] FmpDevicePkg/FmpDeviceLib: Add Last Attempt Status to Check/Set API
Date: Fri, 7 Aug 2020 00:15:26 -0700 [thread overview]
Message-ID: <MWHPR07MB3440FCA528161CBF8D1BC318E9490@MWHPR07MB3440.namprd07.prod.outlook.com> (raw)
In-Reply-To: <20200807071526.1837-1-michael.kubacki@outlook.com>
From: Michael Kubacki <michael.kubacki@microsoft.com>
Provides the ability for a given FMP device library instance to
return a Last Attempt Status code during FmpDeviceCheckImage()
and FmpDeviceSetImage().
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
FmpDevicePkg/FmpDxe/FmpDxe.c | 36 +++++++++++++++-
FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c | 42 ++++++++++++-------
FmpDevicePkg/Include/LastAttemptStatus.h | 6 ++-
FmpDevicePkg/Include/Library/FmpDeviceLib.h | 44 +++++++++++++-------
4 files changed, 97 insertions(+), 31 deletions(-)
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 84a8e15cfc17..9f55e6ba5f5d 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -1020,14 +1020,32 @@ CheckTheImageInternal (
}
RawSize = ImageSize - AllHeaderSize;
+ //
+ // Set LastAttemptStatus to successful prior to getting any potential error codes from FmpDeviceLib
+ //
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
+
//
// FmpDeviceLib CheckImage function to do any specific checks
//
- Status = FmpDeviceCheckImage ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdatable);
+ Status = FmpDeviceCheckImage ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdatable, LastAttemptStatus);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", mImageIdName, Status));
}
+ //
+ // LastAttemptStatus returned from the device library should either be a generic UEFI Specification defined value or
+ // fall within the designated LAST_ATTEMPT_STATUS_LIBRARY_ERROR range
+ //
+ if (
+ (*LastAttemptStatus < LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERROR_CODE &&
+ *LastAttemptStatus >= LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MIN) ||
+ (*LastAttemptStatus > LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERROR_CODE)) {
+ DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - LastAttemptStatus from FmpDeviceCheckImage is invalid.\n", mImageIdName));
+ ASSERT (FALSE);
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
+ }
+
cleanup:
return Status;
}
@@ -1356,8 +1374,22 @@ SetTheImage (
VendorCode,
FmpDxeProgress,
IncomingFwVersion,
- AbortReason
+ AbortReason,
+ &LastAttemptStatus
);
+ //
+ // LastAttemptStatus returned from the device library should either be a generic UEFI Specification defined value or
+ // fall within the designated LAST_ATTEMPT_STATUS_LIBRARY_ERROR range
+ //
+ if (
+ (LastAttemptStatus < LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERROR_CODE &&
+ LastAttemptStatus >= LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MIN) ||
+ (LastAttemptStatus > LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERROR_CODE)) {
+ DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - LastAttemptStatus from FmpDeviceSetImage is invalid.\n", mImageIdName));
+ ASSERT (FALSE);
+ LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
+ }
+
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() SetImage from FmpDeviceLib failed. Status = %r.\n", mImageIdName, Status));
goto cleanup;
diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
index 316de12e910c..d08b5b82d42f 100644
--- a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
+++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
@@ -2,7 +2,7 @@
Provides firmware device specific services to support updates of a firmware
image stored in a firmware device.
- Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+ Copyright (c) Microsoft Corporation.<BR>
Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -380,17 +380,22 @@ FmpDeviceGetImage (
function allows firmware update operation to validate the firmware image
before FmpDeviceSetImage() is called.
- @param[in] Image Points to a new firmware image.
- @param[in] ImageSize Size, in bytes, of a new firmware image.
- @param[out] ImageUpdatable Indicates if a new firmware image is valid for
- a firmware update to the firmware device. The
- following values from the Firmware Management
- Protocol are supported:
- IMAGE_UPDATABLE_VALID
- IMAGE_UPDATABLE_INVALID
- IMAGE_UPDATABLE_INVALID_TYPE
- IMAGE_UPDATABLE_INVALID_OLD
- IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
+ @param[in] Image Points to a new firmware image.
+ @param[in] ImageSize Size, in bytes, of a new firmware image.
+ @param[out] ImageUpdatable Indicates if a new firmware image is valid for
+ a firmware update to the firmware device. The
+ following values from the Firmware Management
+ Protocol are supported:
+ IMAGE_UPDATABLE_VALID
+ IMAGE_UPDATABLE_INVALID
+ IMAGE_UPDATABLE_INVALID_TYPE
+ IMAGE_UPDATABLE_INVALID_OLD
+ IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
+ @param[out] LastAttemptStatus A pointer to a UINT32 that holds the last attempt
+ status to report back to the ESRT table in case
+ of error. The return status code must fall in the range of
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERROR_CODE to
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERROR_CODE.
@retval EFI_SUCCESS The image was successfully checked. Additional
status information is returned in
@@ -404,7 +409,8 @@ EFIAPI
FmpDeviceCheckImage (
IN CONST VOID *Image,
IN UINTN ImageSize,
- OUT UINT32 *ImageUpdatable
+ OUT UINT32 *ImageUpdatable,
+ OUT UINT32 *LastAttemptStatus
)
{
return EFI_SUCCESS;
@@ -453,6 +459,13 @@ FmpDeviceCheckImage (
EFI_BOOT_SERVICES.AllocatePool(). It is the
caller's responsibility to free this buffer with
EFI_BOOT_SERVICES.FreePool().
+ @param[out] LastAttemptStatus A pointer to a UINT32 that holds the last attempt
+ status to report back to the ESRT table in case
+ of error. Will only be checked when this funtions
+ returns error. Returned status code falls outside of
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERROR_CODE and
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERROR_CODE
+ will be converted to LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL
@retval EFI_SUCCESS The firmware device was successfully updated
with the new firmware image.
@@ -470,7 +483,8 @@ FmpDeviceSetImage (
IN CONST VOID *VendorCode, OPTIONAL
IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIONAL
IN UINT32 CapsuleFwVersion,
- OUT CHAR16 **AbortReason
+ OUT CHAR16 **AbortReason,
+ OUT UINT32 *LastAttemptStatus
)
{
return EFI_UNSUPPORTED;
diff --git a/FmpDevicePkg/Include/LastAttemptStatus.h b/FmpDevicePkg/Include/LastAttemptStatus.h
index df9b60b2bbb0..01e96b23edad 100644
--- a/FmpDevicePkg/Include/LastAttemptStatus.h
+++ b/FmpDevicePkg/Include/LastAttemptStatus.h
@@ -36,6 +36,7 @@
// The following last attempt status code ranges are defined for the following corresponding component:
// * LAST_ATTEMPT_STATUS_DRIVER - FMP driver
// * LAST_ATTEMPT_STATUS_DEPENDENCY - FMP dependency functionality
+// * LAST_ATTEMPT_STATUS_LIBRARY - FMP device library instances
//
enum LAST_ATTEMPT_STATUS_EXPANDED_ERROR_LIST
{
@@ -71,7 +72,10 @@ enum LAST_ATTEMPT_STATUS_EXPANDED_ERROR_LIST
LAST_ATTEMPT_STATUS_DEPENDENCY_ERROR_FMP_NOT_FOUND ,
LAST_ATTEMPT_STATUS_DEPENDENCY_ERROR_PUSH_FAILURE ,
LAST_ATTEMPT_STATUS_DEPENDENCY_ERROR_POP_FAILURE ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_ERROR_MAX_ERROR_CODE = LAST_ATTEMPT_STATUS_DEPENDENCY_MAX_ERROR_CODE_VALUE
+ LAST_ATTEMPT_STATUS_DEPENDENCY_ERROR_MAX_ERROR_CODE = LAST_ATTEMPT_STATUS_DEPENDENCY_MAX_ERROR_CODE_VALUE,
+
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERROR_CODE ,
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERROR_CODE = LAST_ATTEMPT_STATUS_LIBRARY_MAX_ERROR_CODE_VALUE
};
#endif
diff --git a/FmpDevicePkg/Include/Library/FmpDeviceLib.h b/FmpDevicePkg/Include/Library/FmpDeviceLib.h
index 9a89f5c2eec5..163714654d60 100644
--- a/FmpDevicePkg/Include/Library/FmpDeviceLib.h
+++ b/FmpDevicePkg/Include/Library/FmpDeviceLib.h
@@ -2,7 +2,7 @@
Provides firmware device specific services to support updates of a firmware
image stored in a firmware device.
- Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+ Copyright (c) Microsoft Corporation.<BR>
Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -12,6 +12,8 @@
#ifndef __FMP_DEVICE_LIB__
#define __FMP_DEVICE_LIB__
+#include <Guid/SystemResourceTable.h>
+#include <LastAttemptStatus.h>
#include <Protocol/FirmwareManagement.h>
/**
@@ -376,17 +378,22 @@ FmpDeviceGetImage (
function allows firmware update operation to validate the firmware image
before FmpDeviceSetImage() is called.
- @param[in] Image Points to a new firmware image.
- @param[in] ImageSize Size, in bytes, of a new firmware image.
- @param[out] ImageUpdatable Indicates if a new firmware image is valid for
- a firmware update to the firmware device. The
- following values from the Firmware Management
- Protocol are supported:
- IMAGE_UPDATABLE_VALID
- IMAGE_UPDATABLE_INVALID
- IMAGE_UPDATABLE_INVALID_TYPE
- IMAGE_UPDATABLE_INVALID_OLD
- IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
+ @param[in] Image Points to a new firmware image.
+ @param[in] ImageSize Size, in bytes, of a new firmware image.
+ @param[out] ImageUpdatable Indicates if a new firmware image is valid for
+ a firmware update to the firmware device. The
+ following values from the Firmware Management
+ Protocol are supported:
+ IMAGE_UPDATABLE_VALID
+ IMAGE_UPDATABLE_INVALID
+ IMAGE_UPDATABLE_INVALID_TYPE
+ IMAGE_UPDATABLE_INVALID_OLD
+ IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
+ @param[out] LastAttemptStatus A pointer to a UINT32 that holds the last attempt
+ status to report back to the ESRT table in case
+ of error. The return status code must fall in the range of
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERROR_CODE to
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERROR_CODE.
@retval EFI_SUCCESS The image was successfully checked. Additional
status information is returned in
@@ -400,7 +407,8 @@ EFIAPI
FmpDeviceCheckImage (
IN CONST VOID *Image,
IN UINTN ImageSize,
- OUT UINT32 *ImageUpdatable
+ OUT UINT32 *ImageUpdatable,
+ OUT UINT32 *LastAttemptStatus
);
/**
@@ -446,6 +454,13 @@ FmpDeviceCheckImage (
EFI_BOOT_SERVICES.AllocatePool(). It is the
caller's responsibility to free this buffer with
EFI_BOOT_SERVICES.FreePool().
+ @param[out] LastAttemptStatus A pointer to a UINT32 that holds the last attempt
+ status to report back to the ESRT table in case
+ of error. Will only be checked when this funtions
+ returns error. Returned status code falls outside of
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERROR_CODE and
+ LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERROR_CODE
+ will be converted to LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL
@retval EFI_SUCCESS The firmware device was successfully updated
with the new firmware image.
@@ -463,7 +478,8 @@ FmpDeviceSetImage (
IN CONST VOID *VendorCode, OPTIONAL
IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIONAL
IN UINT32 CapsuleFwVersion,
- OUT CHAR16 **AbortReason
+ OUT CHAR16 **AbortReason,
+ OUT UINT32 *LastAttemptStatus
);
/**
--
2.28.0.windows.1
prev parent reply other threads:[~2020-08-07 7:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200807071526.1837-1-michael.kubacki@outlook.com>
2020-08-07 7:15 ` [PATCH v1 1/7] FmpDevicePkg/SystemResourceTable.h: Add vendor range values Michael Kubacki
2020-08-07 7:15 ` [PATCH v1 2/7] FmpDevicePkg: Add LastAttemptStatus.h Michael Kubacki
2020-08-07 7:15 ` [PATCH v1 3/7] FmpDevicePkg/FmpDxe: Add check image path Last Attempt Status capability Michael Kubacki
2020-08-07 7:15 ` [PATCH v1 4/7] FmpDevicePkg/FmpDxe: Improve set image path Last Attempt Status granularity Michael Kubacki
2020-08-07 7:15 ` [PATCH v1 5/7] FmpDevicePkg/LastAttemptStatus.h: Add dependency range codes Michael Kubacki
2020-08-07 7:15 ` [PATCH v1 6/7] FmpDevicePkg: Add Last Attempt Status support to dependency libs Michael Kubacki
2020-08-07 7:15 ` Michael Kubacki [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MWHPR07MB3440FCA528161CBF8D1BC318E9490@MWHPR07MB3440.namprd07.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox