diff options
author | Wei6 Xu <wei6.xu@intel.com> | 2019-06-20 00:55:40 +0800 |
---|---|---|
committer | Zhang, Chao B <chao.b.zhang@intel.com> | 2019-06-20 19:49:30 +0800 |
commit | 8636f70b5a763ed1c03b292708f9c5543e531ea9 (patch) | |
tree | 3c5742807638df9e20c3a6eff5d679e96019729f /MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | |
parent | 6b32af2e105f9b5454a55b581f2dc365c5eb6397 (diff) | |
download | edk2-8636f70b5a763ed1c03b292708f9c5543e531ea9.zip edk2-8636f70b5a763ed1c03b292708f9c5543e531ea9.tar.gz edk2-8636f70b5a763ed1c03b292708f9c5543e531ea9.tar.bz2 |
MdeModulePkg: Add Capsule On Disk APIs into CapsuleLib.
https://github.com/tianocore/tianocore.github.io/wiki/UEFI-Capsule-
on-Disk-Introducation
CoDCheckCapsuleOnDiskFlag() is to check if CapsuleOnDisk flag in
"OsIndications" Variable is enabled. It is used to indicate whether
capsule on disk is provisioned in normal boot path.
CoDClearCapsuleOnDiskFlag() is to to clear CapsuleOnDisk flags,
including "OsIndications" and "BootNext" variable.
CoDRelocateCapsule() is to relocate the capsules from EFI system
partition. Depends on PcdCapsuleInRamSupport, there are two solutions
to relocate the capsule on disk images:
When Capsule In Ram is supported, the Capsule On Disk images are
relocated into memory, and call UpdateCapsule() service to deliver
the capsules.
When Capsule In Ram is not supported, the Capsule On Disk images are
relocated into a temp file which will be stored in root directory on
a platform specific storage device. CapsuleOnDiskLoadPei PEIM will
retrieve the capsules from the relocation temp file and report
capsule hobs for them.
CoDRemoveTempFile() is to remove the relocation temp file in the next
boot after capsules are processed.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
Diffstat (limited to 'MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c')
-rw-r--r-- | MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index f38ab69..95aa9de 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -10,7 +10,7 @@ ValidateFmpCapsule(), and DisplayCapsuleImage() receives untrusted input and
performs basic validation.
- Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -80,6 +80,7 @@ RecordCapsuleStatusVariable ( @param[in] PayloadIndex FMP payload index
@param[in] ImageHeader FMP image header
@param[in] FmpDevicePath DevicePath associated with the FMP producer
+ @param[in] CapFileName Capsule file name
@retval EFI_SUCCESS The capsule status variable is recorded.
@retval EFI_OUT_OF_RESOURCES No resource to record the capsule status variable.
@@ -90,7 +91,8 @@ RecordFmpCapsuleStatusVariable ( IN EFI_STATUS CapsuleStatus,
IN UINTN PayloadIndex,
IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader,
- IN EFI_DEVICE_PATH_PROTOCOL *FmpDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *FmpDevicePath, OPTIONAL
+ IN CHAR16 *CapFileName OPTIONAL
);
/**
@@ -110,6 +112,22 @@ UpdateImageProgress ( );
/**
+ Return if this capsule is a capsule name capsule, based upon CapsuleHeader.
+
+ @param[in] CapsuleHeader A pointer to EFI_CAPSULE_HEADER
+
+ @retval TRUE It is a capsule name capsule.
+ @retval FALSE It is not a capsule name capsule.
+**/
+BOOLEAN
+IsCapsuleNameCapsule (
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
+ )
+{
+ return CompareGuid (&CapsuleHeader->CapsuleGuid, &gEdkiiCapsuleOnDiskNameGuid);
+}
+
+/**
Return if this CapsuleGuid is a FMP capsule GUID or not.
@param[in] CapsuleGuid A pointer to EFI_GUID
@@ -1034,11 +1052,12 @@ StartFmpImage ( /**
Record FMP capsule status.
- @param[in] Handle A FMP handle.
+ @param[in] Handle A FMP handle.
@param[in] CapsuleHeader The capsule image header
@param[in] CapsuleStatus The capsule process stauts
@param[in] PayloadIndex FMP payload index
@param[in] ImageHeader FMP image header
+ @param[in] CapFileName Capsule file name
**/
VOID
RecordFmpCapsuleStatus (
@@ -1046,7 +1065,8 @@ RecordFmpCapsuleStatus ( IN EFI_CAPSULE_HEADER *CapsuleHeader,
IN EFI_STATUS CapsuleStatus,
IN UINTN PayloadIndex,
- IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader
+ IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader,
+ IN CHAR16 *CapFileName OPTIONAL
)
{
EFI_STATUS Status;
@@ -1070,7 +1090,8 @@ RecordFmpCapsuleStatus ( CapsuleStatus,
PayloadIndex,
ImageHeader,
- FmpDevicePath
+ FmpDevicePath,
+ CapFileName
);
//
@@ -1115,6 +1136,7 @@ RecordFmpCapsuleStatus ( This function need support nested FMP capsule.
@param[in] CapsuleHeader Points to a capsule header.
+ @param[in] CapFileName Capsule file name.
@param[out] ResetRequired Indicates whether reset is required or not.
@retval EFI_SUCESS Process Capsule Image successfully.
@@ -1126,6 +1148,7 @@ RecordFmpCapsuleStatus ( EFI_STATUS
ProcessFmpCapsuleImage (
IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ IN CHAR16 *CapFileName, OPTIONAL
OUT BOOLEAN *ResetRequired OPTIONAL
)
{
@@ -1145,7 +1168,7 @@ ProcessFmpCapsuleImage ( BOOLEAN Abort;
if (!IsFmpCapsuleGuid(&CapsuleHeader->CapsuleGuid)) {
- return ProcessFmpCapsuleImage ((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize), ResetRequired);
+ return ProcessFmpCapsuleImage ((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize), CapFileName, ResetRequired);
}
NotReady = FALSE;
@@ -1227,7 +1250,8 @@ ProcessFmpCapsuleImage ( CapsuleHeader,
EFI_NOT_READY,
Index - FmpCapsuleHeader->EmbeddedDriverCount,
- ImageHeader
+ ImageHeader,
+ CapFileName
);
continue;
}
@@ -1239,7 +1263,8 @@ ProcessFmpCapsuleImage ( CapsuleHeader,
EFI_ABORTED,
Index - FmpCapsuleHeader->EmbeddedDriverCount,
- ImageHeader
+ ImageHeader,
+ CapFileName
);
continue;
}
@@ -1262,7 +1287,8 @@ ProcessFmpCapsuleImage ( CapsuleHeader,
Status,
Index - FmpCapsuleHeader->EmbeddedDriverCount,
- ImageHeader
+ ImageHeader,
+ CapFileName
);
}
if (HandleBuffer != NULL) {
@@ -1414,6 +1440,13 @@ SupportCapsuleImage ( return EFI_SUCCESS;
}
+ //
+ // Check capsule file name capsule
+ //
+ if (IsCapsuleNameCapsule(CapsuleHeader)) {
+ return EFI_SUCCESS;
+ }
+
if (IsFmpCapsule(CapsuleHeader)) {
//
// Fake capsule header is valid case in QueryCapsuleCpapbilities().
@@ -1436,6 +1469,7 @@ SupportCapsuleImage ( Caution: This function may receive untrusted input.
@param[in] CapsuleHeader Points to a capsule header.
+ @param[in] CapFileName Capsule file name.
@param[out] ResetRequired Indicates whether reset is required or not.
@retval EFI_SUCESS Process Capsule Image successfully.
@@ -1447,6 +1481,7 @@ EFI_STATUS EFIAPI
ProcessThisCapsuleImage (
IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ IN CHAR16 *CapFileName, OPTIONAL
OUT BOOLEAN *ResetRequired OPTIONAL
)
{
@@ -1484,7 +1519,7 @@ ProcessThisCapsuleImage ( // Process EFI FMP Capsule
//
DEBUG((DEBUG_INFO, "ProcessFmpCapsuleImage ...\n"));
- Status = ProcessFmpCapsuleImage(CapsuleHeader, ResetRequired);
+ Status = ProcessFmpCapsuleImage(CapsuleHeader, CapFileName, ResetRequired);
DEBUG((DEBUG_INFO, "ProcessFmpCapsuleImage - %r\n", Status));
return Status;
@@ -1511,7 +1546,7 @@ ProcessCapsuleImage ( IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
- return ProcessThisCapsuleImage (CapsuleHeader, NULL);
+ return ProcessThisCapsuleImage (CapsuleHeader, NULL, NULL);
}
/**
|