TianoCore EDK2 master
|
#include <PiDxe.h>
#include <IndustryStandard/WindowsUxCapsule.h>
#include <Guid/FmpCapsule.h>
#include <Guid/SystemResourceTable.h>
#include <Guid/EventGroup.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/CapsuleLib.h>
#include <Library/DevicePathLib.h>
#include <Library/UefiLib.h>
#include <Library/BmpSupportLib.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/EsrtManagement.h>
#include <Protocol/FirmwareManagement.h>
#include <Protocol/FirmwareManagementProgress.h>
#include <Protocol/DevicePath.h>
Go to the source code of this file.
Variables | |
EFI_SYSTEM_RESOURCE_TABLE * | mEsrtTable = NULL |
BOOLEAN | mDxeCapsuleLibEndOfDxe = FALSE |
EFI_EVENT | mDxeCapsuleLibEndOfDxeEvent = NULL |
EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL * | mFmpProgress = NULL |
BOOLEAN | mDxeCapsuleLibIsExitBootService = FALSE |
DXE capsule library.
Caution: This module requires additional review when modified. This module will have external input - capsule image. This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow.
SupportCapsuleImage(), ProcessCapsuleImage(), IsValidCapsuleHeader(), ValidateFmpCapsule(), and DisplayCapsuleImage() receives untrusted input and performs basic validation.
Copyright (c) 2016 - 2024, Intel Corporation. All rights reserved.
Copyright (c) 2024, Ampere Computing LLC. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file DxeCapsuleLib.c.
EFI_STATUS DisplayCapsuleImage | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader | ) |
Those capsules supported by the firmwares.
Caution: This function may receive untrusted input.
[in] | CapsuleHeader | Points to a capsule header. |
EFI_SUCESS | Input capsule is supported by firmware. |
EFI_UNSUPPORTED | Input capsule is not supported by the firmware. |
Definition at line 348 of file DxeCapsuleLib.c.
VOID DumpAllFmpInfo | ( | VOID | ) |
Dump all FMP information.
Definition at line 555 of file DxeCapsuleLib.c.
VOID DumpFmpCapsule | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader | ) |
Dump a non-nested FMP capsule.
[in] | CapsuleHeader | A pointer to CapsuleHeader |
Definition at line 511 of file DxeCapsuleLib.c.
VOID DumpFmpImageInfo | ( | IN UINTN | ImageInfoSize, |
IN EFI_FIRMWARE_IMAGE_DESCRIPTOR * | ImageInfo, | ||
IN UINT32 | DescriptorVersion, | ||
IN UINT8 | DescriptorCount, | ||
IN UINTN | DescriptorSize, | ||
IN UINT32 | PackageVersion, | ||
IN CHAR16 * | PackageVersionName | ||
) |
Dump FMP information.
[in] | ImageInfoSize | The size of ImageInfo, in bytes. |
[in] | ImageInfo | A pointer to EFI_FIRMWARE_IMAGE_DESCRIPTOR. |
[in] | DescriptorVersion | The version of EFI_FIRMWARE_IMAGE_DESCRIPTOR. |
[in] | DescriptorCount | The count of EFI_FIRMWARE_IMAGE_DESCRIPTOR. |
[in] | DescriptorSize | The size of an individual EFI_FIRMWARE_IMAGE_DESCRIPTOR, in bytes. |
[in] | PackageVersion | The version of package. |
[in] | PackageVersionName | The version name of package. |
Definition at line 458 of file DxeCapsuleLib.c.
EFI_STATUS EFIAPI DxeCapsuleLibConstructor | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
The constructor function.
[in] | ImageHandle | The firmware allocated handle for the EFI image. |
[in] | SystemTable | A pointer to the EFI System Table. |
EFI_SUCCESS | The constructor successfully . |
Definition at line 1650 of file DxeCapsuleLib.c.
EFI_STATUS EFIAPI DxeCapsuleLibDestructor | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
The destructor function closes the End of DXE event.
ImageHandle | The firmware allocated handle for the EFI image. |
SystemTable | A pointer to the EFI System Table. |
EFI_SUCCESS | The destructor completed successfully. |
Definition at line 1682 of file DxeCapsuleLib.c.
Callback function executed when the EndOfDxe event group is signaled.
[in] | Event | Event whose notification function is being invoked. |
[in] | Context | The pointer to the notification function's context, which is implementation-dependent. |
Definition at line 1632 of file DxeCapsuleLib.c.
EFI_STATUS GetFmpHandleBufferByType | ( | IN EFI_GUID * | UpdateImageTypeId, |
IN UINT64 | UpdateHardwareInstance, | ||
OUT UINTN *NoHandles | OPTIONAL, | ||
OUT EFI_HANDLE **HandleBuf | OPTIONAL, | ||
OUT BOOLEAN **ResetRequiredBuf | OPTIONAL | ||
) |
Get FMP handle by ImageTypeId and HardwareInstance.
[in] | UpdateImageTypeId | Used to identify device firmware targeted by this update. |
[in] | UpdateHardwareInstance | The HardwareInstance to target with this update. |
[out] | NoHandles | The number of handles returned in HandleBuf. |
[out] | HandleBuf | A pointer to the buffer to return the requested array of handles. |
[out] | ResetRequiredBuf | A pointer to the buffer to return reset required flag for the requested array of handles. |
EFI_SUCCESS | The array of handles and their reset required flag were returned in HandleBuf and ResetRequiredBuf, and the number of handles in HandleBuf was returned in NoHandles. |
EFI_NOT_FOUND | No handles match the search. |
EFI_OUT_OF_RESOURCES | There is not enough pool memory to store the matching results. |
Definition at line 669 of file DxeCapsuleLib.c.
UINT32 GetFmpImageInfoDescriptorVer | ( | IN EFI_HANDLE | Handle | ) |
Return FmpImageInfoDescriptorVer by an FMP handle.
[in] | Handle | A FMP handle. |
Definition at line 853 of file DxeCapsuleLib.c.
VOID InitCapsuleVariable | ( | VOID | ) |
Initialize capsule related variables.
Definition at line 495 of file DxeCapsuleReportLib.c.
BOOLEAN IsCapsuleNameCapsule | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader | ) |
Return if this capsule is a capsule name capsule, based upon CapsuleHeader.
[in] | CapsuleHeader | A pointer to EFI_CAPSULE_HEADER |
TRUE | It is a capsule name capsule. |
FALSE | It is not a capsule name capsule. |
Definition at line 125 of file DxeCapsuleLib.c.
BOOLEAN IsFmpCapsule | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader | ) |
Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader.
[in] | CapsuleHeader | A pointer to EFI_CAPSULE_HEADER |
TRUE | It is a system FMP. |
FALSE | It is a device FMP. |
Definition at line 1473 of file DxeCapsuleLib.c.
Return if this CapsuleGuid is a FMP capsule GUID or not.
[in] | CapsuleGuid | A pointer to EFI_GUID |
Definition at line 141 of file DxeCapsuleLib.c.
BOOLEAN IsNestedFmpCapsule | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader | ) |
Return if there is a FMP header below capsule header.
[in] | CapsuleHeader | A pointer to EFI_CAPSULE_HEADER |
TRUE | There is a FMP header below capsule header. |
FALSE | There is not a FMP header below capsule header |
Definition at line 1385 of file DxeCapsuleLib.c.
BOOLEAN IsValidCapsuleHeader | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader, |
IN UINT64 | CapsuleSize | ||
) |
Validate if it is valid capsule header
Caution: This function may receive untrusted input.
This function assumes the caller provided correct CapsuleHeader pointer and CapsuleSize.
This function validates the fields in EFI_CAPSULE_HEADER.
[in] | CapsuleHeader | Points to a capsule header. |
[in] | CapsuleSize | Size of the whole capsule image. |
Definition at line 167 of file DxeCapsuleLib.c.
EFI_STATUS EFIAPI ProcessCapsuleImage | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader | ) |
The firmware implements to process the capsule image.
Caution: This function may receive untrusted input.
[in] | CapsuleHeader | Points to a capsule header. |
EFI_SUCESS | Process Capsule Image successfully. |
EFI_UNSUPPORTED | Capsule image is not supported by the firmware. |
EFI_VOLUME_CORRUPTED | FV volume in the capsule is corrupted. |
EFI_OUT_OF_RESOURCES | Not enough memory. |
Definition at line 1616 of file DxeCapsuleLib.c.
EFI_STATUS ProcessFmpCapsuleImage | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader, |
IN CHAR16 *CapFileName | OPTIONAL, | ||
OUT BOOLEAN *ResetRequired | OPTIONAL | ||
) |
Process Firmware management protocol data capsule.
This function assumes the caller validated the capsule by using ValidateFmpCapsule(), so that all fields in EFI_CAPSULE_HEADER, EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER and EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER are correct.
This function need support nested FMP capsule.
[in] | CapsuleHeader | Points to a capsule header. |
[in] | CapFileName | Capsule file name. |
[out] | ResetRequired | Indicates whether reset is required or not. |
EFI_SUCESS | Process Capsule Image successfully. |
EFI_UNSUPPORTED | Capsule image is not supported by the firmware. |
EFI_VOLUME_CORRUPTED | FV volume in the capsule is corrupted. |
EFI_OUT_OF_RESOURCES | Not enough memory. |
EFI_NOT_READY | No FMP protocol to handle this FMP capsule. |
UpdateHardwareInstance field was added in Version 2
Definition at line 1204 of file DxeCapsuleLib.c.
EFI_STATUS EFIAPI ProcessThisCapsuleImage | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader, |
IN CHAR16 *CapFileName | OPTIONAL, | ||
OUT BOOLEAN *ResetRequired | OPTIONAL | ||
) |
The firmware implements to process the capsule image.
Caution: This function may receive untrusted input.
[in] | CapsuleHeader | Points to a capsule header. |
[in] | CapFileName | Capsule file name. |
[out] | ResetRequired | Indicates whether reset is required or not. |
EFI_SUCESS | Process Capsule Image successfully. |
EFI_UNSUPPORTED | Capsule image is not supported by the firmware. |
EFI_VOLUME_CORRUPTED | FV volume in the capsule is corrupted. |
EFI_OUT_OF_RESOURCES | Not enough memory. |
Definition at line 1553 of file DxeCapsuleLib.c.
EFI_STATUS RecordCapsuleStatusVariable | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader, |
IN EFI_STATUS | CapsuleStatus | ||
) |
Record capsule status variable.
[in] | CapsuleHeader | The capsule image header |
[in] | CapsuleStatus | The capsule process stauts |
EFI_SUCCESS | The capsule status variable is recorded. |
EFI_OUT_OF_RESOURCES | No resource to record the capsule status variable. |
Record capsule status variable and to local cache.
[in] | CapsuleHeader | The capsule image header |
[in] | CapsuleStatus | The capsule process stauts |
EFI_SUCCESS | The capsule status variable is recorded. |
EFI_OUT_OF_RESOURCES | No resource to record the capsule status variable. |
Definition at line 199 of file DxeCapsuleReportLib.c.
VOID RecordFmpCapsuleStatus | ( | IN EFI_HANDLE Handle | OPTIONAL, |
IN EFI_CAPSULE_HEADER * | CapsuleHeader, | ||
IN EFI_STATUS | CapsuleStatus, | ||
IN UINTN | PayloadIndex, | ||
IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER * | ImageHeader, | ||
IN CHAR16 *CapFileName | OPTIONAL | ||
) |
Record FMP capsule status.
[in] | Handle | A FMP handle. |
[in] | CapsuleHeader | The capsule image header |
[in] | CapsuleStatus | The capsule process stauts |
[in] | PayloadIndex | FMP payload index |
[in] | ImageHeader | FMP image header |
[in] | CapFileName | Capsule file name |
Definition at line 1117 of file DxeCapsuleLib.c.
EFI_STATUS RecordFmpCapsuleStatusVariable | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader, |
IN EFI_STATUS | CapsuleStatus, | ||
IN UINTN | PayloadIndex, | ||
IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER * | ImageHeader, | ||
IN EFI_DEVICE_PATH_PROTOCOL *FmpDevicePath | OPTIONAL, | ||
IN CHAR16 *CapFileName | OPTIONAL | ||
) |
Record FMP capsule status variable.
[in] | CapsuleHeader | The capsule image header |
[in] | CapsuleStatus | The capsule process stauts |
[in] | PayloadIndex | FMP payload index |
[in] | ImageHeader | FMP image header |
[in] | FmpDevicePath | DevicePath associated with the FMP producer |
[in] | CapFileName | Capsule file name |
EFI_SUCCESS | The capsule status variable is recorded. |
EFI_OUT_OF_RESOURCES | No resource to record the capsule status variable. |
Record FMP capsule status variable and to local cache.
[in] | CapsuleHeader | The capsule image header |
[in] | CapsuleStatus | The capsule process stauts |
[in] | PayloadIndex | FMP payload index |
[in] | ImageHeader | FMP image header |
[in] | FmpDevicePath | DevicePath associated with the FMP producer |
[in] | CapFileName | Capsule file name |
EFI_SUCCESS | The capsule status variable is recorded. |
EFI_OUT_OF_RESOURCES | No resource to record the capsule status variable. |
Definition at line 236 of file DxeCapsuleReportLib.c.
EFI_STATUS SetFmpImageData | ( | IN EFI_HANDLE | Handle, |
IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER * | ImageHeader, | ||
IN UINTN | PayloadIndex | ||
) |
Set FMP image data.
[in] | Handle | A FMP handle. |
[in] | ImageHeader | The payload image header. |
[in] | PayloadIndex | The index of the payload. |
Definition at line 925 of file DxeCapsuleLib.c.
EFI_STATUS StartFmpImage | ( | IN VOID * | ImageBuffer, |
IN UINTN | ImageSize | ||
) |
Start a UEFI image in the FMP payload.
[in] | ImageBuffer | A pointer to the memory location containing a copy of the image to be loaded.. |
[in] | ImageSize | The size in bytes of ImageBuffer. |
Definition at line 1043 of file DxeCapsuleLib.c.
EFI_STATUS EFIAPI SupportCapsuleImage | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader | ) |
Those capsules supported by the firmwares.
Caution: This function may receive untrusted input.
[in] | CapsuleHeader | Points to a capsule header. |
EFI_SUCESS | Input capsule is supported by firmware. |
EFI_UNSUPPORTED | Input capsule is not supported by the firmware. |
EFI_INVALID_PARAMETER | Input capsule layout is not correct |
Definition at line 1501 of file DxeCapsuleLib.c.
EFI_STATUS EFIAPI UpdateImageProgress | ( | IN UINTN | Completion | ) |
Function indicate the current completion progress of the firmware update. Platform may override with own specific progress function.
[in] | Completion | A value between 1 and 100 indicating the current completion progress of the firmware update |
EFI_SUCESS | The capsule update progress was updated. |
EFI_INVALID_PARAMETER | Completion is greater than 100%. |
Definition at line 167 of file DxeCapsuleProcessLib.c.
EFI_STATUS ValidateFmpCapsule | ( | IN EFI_CAPSULE_HEADER * | CapsuleHeader, |
OUT UINT16 *EmbeddedDriverCount | OPTIONAL | ||
) |
Validate Fmp capsules layout.
Caution: This function may receive untrusted input.
This function assumes the caller validated the capsule by using IsValidCapsuleHeader(), so that all fields in EFI_CAPSULE_HEADER are correct. The capsule buffer size is CapsuleHeader->CapsuleImageSize.
This function validates the fields in EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER and EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER.
This function need support nested FMP capsule.
[in] | CapsuleHeader | Points to a capsule header. |
[out] | EmbeddedDriverCount | The EmbeddedDriverCount in the FMP capsule. |
EFI_SUCESS | Input capsule is a correct FMP capsule. |
EFI_INVALID_PARAMETER | Input capsule is not a correct FMP capsule. |
Definition at line 204 of file DxeCapsuleLib.c.
BOOLEAN mDxeCapsuleLibEndOfDxe = FALSE |
Definition at line 47 of file DxeCapsuleLib.c.
Definition at line 48 of file DxeCapsuleLib.c.
BOOLEAN mDxeCapsuleLibIsExitBootService = FALSE |
Definition at line 52 of file DxeCapsuleLib.c.
EFI_SYSTEM_RESOURCE_TABLE* mEsrtTable = NULL |
Definition at line 45 of file DxeCapsuleLib.c.
EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL* mFmpProgress = NULL |
Firmware Management Protocol instance that is initialized in the entry point from PCD settings.
Definition at line 50 of file DxeCapsuleLib.c.