TianoCore EDK2 master
|
#include <PiDxe.h>
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseCryptLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiLib.h>
#include <Library/PrintLib.h>
#include <Library/FmpAuthenticationLib.h>
#include <Library/FmpDeviceLib.h>
#include <Library/FmpPayloadHeaderLib.h>
#include <Library/CapsuleUpdatePolicyLib.h>
#include <Library/FmpDependencyLib.h>
#include <Library/FmpDependencyCheckLib.h>
#include <Library/FmpDependencyDeviceLib.h>
#include <Protocol/FirmwareManagement.h>
#include <Protocol/FirmwareManagementProgress.h>
#include <Guid/SystemResourceTable.h>
#include <Guid/EventGroup.h>
#include <LastAttemptStatus.h>
#include <FmpLastAttemptStatus.h>
#include <Library/VariablePolicyHelperLib.h>
Go to the source code of this file.
Data Structures | |
struct | FIRMWARE_MANAGEMENT_PRIVATE_DATA |
Macros | |
#define | VERSION_STRING_NOT_SUPPORTED L"VERSION STRING NOT SUPPORTED" |
#define | VERSION_STRING_NOT_AVAILABLE L"VERSION STRING NOT AVAILABLE" |
#define | FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('f','m','p','p') |
#define | FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS(a) CR (a, FIRMWARE_MANAGEMENT_PRIVATE_DATA, Fmp, FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE) |
Functions | |
VOID | DetectTestKey (VOID) |
EFI_STATUS EFIAPI | GetTheImageInfo (IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN OUT UINTN *ImageInfoSize, IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo, OUT UINT32 *DescriptorVersion, OUT UINT8 *DescriptorCount, OUT UINTN *DescriptorSize, OUT UINT32 *PackageVersion, OUT CHAR16 **PackageVersionName) |
EFI_STATUS EFIAPI | GetTheImage (IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN OUT VOID *Image, IN OUT UINTN *ImageSize) |
EFI_STATUS EFIAPI | CheckTheImage (IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable) |
EFI_STATUS EFIAPI | SetTheImage (IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, IN CONST VOID *VendorCode, IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OUT CHAR16 **AbortReason) |
EFI_STATUS EFIAPI | GetPackageInfo (IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, OUT UINT32 *PackageVersion, OUT CHAR16 **PackageVersionName, OUT UINT32 *PackageVersionNameMaxLen, OUT UINT64 *AttributesSupported, OUT UINT64 *AttributesSetting) |
EFI_STATUS EFIAPI | SetPackageInfo (IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN CONST VOID *Image, IN UINTN ImageSize, IN CONST VOID *VendorCode, IN UINT32 PackageVersion, IN CONST CHAR16 *PackageVersionName) |
Variables | |
CHAR16 * | mImageIdName |
Produces a Firmware Management Protocol that supports updates to a firmware image stored in a firmware device with platform and firmware device specific information provided through PCDs and libraries.
Copyright (c) Microsoft Corporation.
Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file FmpDxe.h.
#define FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS | ( | a | ) | CR (a, FIRMWARE_MANAGEMENT_PRIVATE_DATA, Fmp, FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE) |
#define FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('f','m','p','p') |
#define VERSION_STRING_NOT_AVAILABLE L"VERSION STRING NOT AVAILABLE" |
#define VERSION_STRING_NOT_SUPPORTED L"VERSION STRING NOT SUPPORTED" |
EFI_STATUS EFIAPI CheckTheImage | ( | IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL * | This, |
IN UINT8 | ImageIndex, | ||
IN CONST VOID * | Image, | ||
IN UINTN | ImageSize, | ||
OUT UINT32 * | ImageUpdatable | ||
) |
Checks if the firmware image is valid for the device.
This function allows firmware update application to validate the firmware image without invoking the SetImage() first.
[in] | This | A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. |
[in] | ImageIndex | A unique number identifying the firmware image(s) within the device. The number is between 1 and DescriptorCount. |
[in] | Image | Points to the new image. |
[in] | ImageSize | Size of the new image in bytes. |
[out] | ImageUpdatable | Indicates if the new image is valid for update. It also provides, if available, additional information if the image is invalid. |
EFI_SUCCESS | The image was successfully checked. |
EFI_ABORTED | The operation is aborted. |
EFI_INVALID_PARAMETER | The Image was NULL. |
EFI_UNSUPPORTED | The operation is not supported. |
EFI_SECURITY_VIOLATION | The operation could not be performed due to an authentication failure. |
VOID DetectTestKey | ( | VOID | ) |
Check to see if any of the keys in PcdFmpDevicePkcs7CertBufferXdr matches the test key. PcdFmpDeviceTestKeySha256Digest contains the SHA256 hash of the test key. For each key in PcdFmpDevicePkcs7CertBufferXdr, compute the SHA256 hash and compare it to PcdFmpDeviceTestKeySha256Digest. If the SHA256 hash matches or there is then error computing the SHA256 hash, then set PcdTestKeyUsed to TRUE. Skip this check if PcdTestKeyUsed is already TRUE or PcdFmpDeviceTestKeySha256Digest is not exactly SHA256_DIGEST_SIZE bytes.
Definition at line 23 of file DetectTestKey.c.
EFI_STATUS EFIAPI GetPackageInfo | ( | IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL * | This, |
OUT UINT32 * | PackageVersion, | ||
OUT CHAR16 ** | PackageVersionName, | ||
OUT UINT32 * | PackageVersionNameMaxLen, | ||
OUT UINT64 * | AttributesSupported, | ||
OUT UINT64 * | AttributesSetting | ||
) |
Returns information about the firmware package.
This function returns package information.
[in] | This | A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. |
[out] | PackageVersion | A version number that represents all the firmware images in the device. The format is vendor specific and new version must have a greater value than the old version. If PackageVersion is not supported, the value is 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version comparison is to be performed using PackageVersionName. A value of 0xFFFFFFFD indicates that package version update is in progress. |
[out] | PackageVersionName | A pointer to a pointer to a null-terminated string representing the package version name. The buffer is allocated by this function with AllocatePool(), and it is the caller's responsibility to free it with a call to FreePool(). |
[out] | PackageVersionNameMaxLen | The maximum length of package version name if device supports update of package version name. A value of 0 indicates the device does not support update of package version name. Length is the number of Unicode characters, including the terminating null character. |
[out] | AttributesSupported | Package attributes that are supported by this device. See 'Package Attribute Definitions' for possible returned values of this parameter. A value of 1 indicates the attribute is supported and the current setting value is indicated in AttributesSetting. A value of 0 indicates the attribute is not supported and the current setting value in AttributesSetting is meaningless. |
[out] | AttributesSetting | Package attributes. See 'Package Attribute Definitions' for possible returned values of this parameter |
EFI_SUCCESS | The package information was successfully returned. |
EFI_UNSUPPORTED | The operation is not supported. |
EFI_STATUS EFIAPI GetTheImage | ( | IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL * | This, |
IN UINT8 | ImageIndex, | ||
IN OUT VOID * | Image, | ||
IN OUT UINTN * | ImageSize | ||
) |
Retrieves a copy of the current firmware image of the device.
This function allows a copy of the current firmware image to be created and saved. The saved copy could later been used, for example, in firmware image recovery or rollback.
[in] | This | A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. |
[in] | ImageIndex | A unique number identifying the firmware image(s) within the device. The number is between 1 and DescriptorCount. |
[in,out] | Image | Points to the buffer where the current image is copied to. |
[in,out] | ImageSize | On entry, points to the size of the buffer pointed to by Image, in bytes. On return, points to the length of the image, in bytes. |
EFI_SUCCESS | The device was successfully updated with the new image. |
EFI_BUFFER_TOO_SMALL | The buffer specified by ImageSize is too small to hold the image. The current buffer size needed to hold the image is returned in ImageSize. |
EFI_INVALID_PARAMETER | The Image was NULL. |
EFI_NOT_FOUND | The current image is not copied to the buffer. |
EFI_UNSUPPORTED | The operation is not supported. |
EFI_SECURITY_VIOLATION | The operation could not be performed due to an authentication failure. |
EFI_STATUS EFIAPI GetTheImageInfo | ( | IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL * | This, |
IN OUT UINTN * | ImageInfoSize, | ||
IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR * | ImageInfo, | ||
OUT UINT32 * | DescriptorVersion, | ||
OUT UINT8 * | DescriptorCount, | ||
OUT UINTN * | DescriptorSize, | ||
OUT UINT32 * | PackageVersion, | ||
OUT CHAR16 ** | PackageVersionName | ||
) |
Returns information about the current firmware image(s) of the device.
This function allows a copy of the current firmware image to be created and saved. The saved copy could later been used, for example, in firmware image recovery or rollback.
[in] | This | A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. |
[in,out] | ImageInfoSize | A pointer to the size, in bytes, of the ImageInfo buffer. On input, this is the size of the buffer allocated by the caller. On output, it is the size of the buffer returned by the firmware if the buffer was large enough, or the size of the buffer needed to contain the image(s) information if the buffer was too small. |
[in,out] | ImageInfo | A pointer to the buffer in which firmware places the current image(s) information. The information is an array of EFI_FIRMWARE_IMAGE_DESCRIPTORs. |
[out] | DescriptorVersion | A pointer to the location in which firmware returns the version number associated with the EFI_FIRMWARE_IMAGE_DESCRIPTOR. |
[out] | DescriptorCount | A pointer to the location in which firmware returns the number of descriptors or firmware images within this device. |
[out] | DescriptorSize | A pointer to the location in which firmware returns the size, in bytes, of an individual EFI_FIRMWARE_IMAGE_DESCRIPTOR. |
[out] | PackageVersion | A version number that represents all the firmware images in the device. The format is vendor specific and new version must have a greater value than the old version. If PackageVersion is not supported, the value is 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version comparison is to be performed using PackageVersionName. A value of 0xFFFFFFFD indicates that package version update is in progress. |
[out] | PackageVersionName | A pointer to a pointer to a null-terminated string representing the package version name. The buffer is allocated by this function with AllocatePool(), and it is the caller's responsibility to free it with a call to FreePool(). |
EFI_SUCCESS | The device was successfully updated with the new image. |
EFI_BUFFER_TOO_SMALL | The ImageInfo buffer was too small. The current buffer size needed to hold the image(s) information is returned in ImageInfoSize. |
EFI_INVALID_PARAMETER | ImageInfoSize is NULL. |
EFI_DEVICE_ERROR | Valid information could not be returned. Possible corrupted image. |
EFI_STATUS EFIAPI SetPackageInfo | ( | IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL * | This, |
IN CONST VOID * | Image, | ||
IN UINTN | ImageSize, | ||
IN CONST VOID * | VendorCode, | ||
IN UINT32 | PackageVersion, | ||
IN CONST CHAR16 * | PackageVersionName | ||
) |
Updates information about the firmware package.
This function updates package information. This function returns EFI_UNSUPPORTED if the package information is not updatable. VendorCode enables vendor to implement vendor-specific package information update policy. Null if the caller did not specify this policy or use the default policy.
[in] | This | A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. |
[in] | Image | Points to the authentication image. Null if authentication is not required. |
[in] | ImageSize | Size of the authentication image in bytes. 0 if authentication is not required. |
[in] | VendorCode | This enables vendor to implement vendor-specific firmware image update policy. Null indicates the caller did not specify this policy or use the default policy. |
[in] | PackageVersion | The new package version. |
[in] | PackageVersionName | A pointer to the new null-terminated Unicode string representing the package version name. The string length is equal to or less than the value returned in PackageVersionNameMaxLen. |
EFI_SUCCESS | The device was successfully updated with the new package information. |
EFI_INVALID_PARAMETER | The PackageVersionName length is longer than the value returned in PackageVersionNameMaxLen. |
EFI_UNSUPPORTED | The operation is not supported. |
EFI_SECURITY_VIOLATION | The operation could not be performed due to an authentication failure. |
EFI_STATUS EFIAPI SetTheImage | ( | IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL * | This, |
IN UINT8 | ImageIndex, | ||
IN CONST VOID * | Image, | ||
IN UINTN | ImageSize, | ||
IN CONST VOID * | VendorCode, | ||
IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS | Progress, | ||
OUT CHAR16 ** | AbortReason | ||
) |
Updates the firmware image of the device.
This function updates the hardware with the new firmware image. This function returns EFI_UNSUPPORTED if the firmware image is not updatable. If the firmware image is updatable, the function should perform the following minimal validations before proceeding to do the firmware image update.
VendorCode enables vendor to implement vendor-specific firmware image update policy. Null if the caller did not specify the policy or use the default policy. As an example, vendor can implement a policy to allow an option to force a firmware image update when the abort reason is due to the new firmware image version is older than the current firmware image version or bad image checksum. Sensitive operations such as those wiping the entire firmware image and render the device to be non-functional should be encoded in the image itself rather than passed with the VendorCode. AbortReason enables vendor to have the option to provide a more detailed description of the abort reason to the caller.
[in] | This | A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. |
[in] | ImageIndex | A unique number identifying the firmware image(s) within the device. The number is between 1 and DescriptorCount. |
[in] | Image | Points to the new image. |
[in] | ImageSize | Size of the new image in bytes. |
[in] | VendorCode | This enables vendor to implement vendor-specific firmware image update policy. Null indicates the caller did not specify the policy or use the default policy. |
[in] | Progress | A function used by the driver to report the progress of the firmware update. |
[out] | AbortReason | A pointer to a pointer to a null-terminated string providing more details for the aborted operation. The buffer is allocated by this function with AllocatePool(), and it is the caller's responsibility to free it with a call to FreePool(). |
EFI_SUCCESS | The device was successfully updated with the new image. |
EFI_ABORTED | The operation is aborted. |
EFI_INVALID_PARAMETER | The Image was NULL. |
EFI_UNSUPPORTED | The operation is not supported. |
EFI_SECURITY_VIOLATION | The operation could not be performed due to an authentication failure. |