Skip to content

Commit

Permalink
FmpDevicePkg/FmpDxe: Add PcdFmpDeviceImageTypeIdGuid
Browse files Browse the repository at this point in the history
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1525

Add PCD PcdFmpDeviceImageTypeIdGuid that contains an Image
Type ID GUID value that is used if one is not provided by
FmpDeviceLib. If this PCD is not a valid GUID value,  then
gEfiCallerIdGuid is used.

Update FmpDevicePkg DSC to use PcdFmpDeviceImageTypeIdGuid
as a PatchableInModule PCD.

This content is based on the following commit.

microsoft/mu_tiano_plus@a2c7da8#diff-025d4889f6d3a482b49638a25e432d6d

Cc: Sean Brogan <[email protected]>
Cc: Michael Turner <[email protected]>
Cc: Bret Barkelew <[email protected]>
Cc: Liming Gao <[email protected]>
Signed-off-by: Michael D Kinney <[email protected]>
Reviewed-by: Eric Jin <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
  • Loading branch information
ericjin authored and lgao4 committed Aug 15, 2019
1 parent e096167 commit 278c3d4
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 6 deletions.
5 changes: 5 additions & 0 deletions FmpDevicePkg/FmpDevicePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
# @Prompt Firmware Device Watchdog Time in Seconds.
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressWatchdogTimeInSeconds|0x0|UINT8|0x4000000D

## The Image Type ID to use if one is not provided by FmpDeviceLib. If this
# PCD is not a valid GUID value, then gEfiCallerIdGuid is used.
# @Prompt Firmware Device Image Type ID
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid|{0}|VOID*|0x40000010

[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## One or more PKCS7 certificates used to verify a firmware device capsule
# update image. Encoded using the Variable-Length Opaque Data format of RFC
Expand Down
25 changes: 25 additions & 0 deletions FmpDevicePkg/FmpDevicePkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
[LibraryClasses.ARM]
ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf

[PcdsPatchableInModule]
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid|{0}

[Components]
#
# Libraries
Expand All @@ -89,6 +92,17 @@
# FILE_GUID is used as ESRT GUID
#
FILE_GUID = $(SYSTEM_FMP_ESRT_GUID)
<PcdsFixedAtBuild>
#
# Unicode name string that is used to populate FMP Image Descriptor for this capsule update module
#
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName|L"Sample Firmware Device"
#
# Certificates used to authenticate capsule update image
#
!include BaseTools/Source/Python/Pkcs7Sign/TestRoot.cer.gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr.inc
<PcdsPatchableInModule>
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid|{GUID("$(SYSTEM_FMP_ESRT_GUID)")}
<LibraryClasses>
#
# Use CapsuleUpdatePolicyLib that calls the Capsule Update Policy Protocol.
Expand All @@ -104,6 +118,17 @@
# FILE_GUID is used as ESRT GUID
#
FILE_GUID = $(DEVICE_FMP_ESRT_GUID)
<PcdsFixedAtBuild>
#
# Unicode name string that is used to populate FMP Image Descriptor for this capsule update module
#
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName|L"Sample Firmware Device"
#
# Certificates used to authenticate capsule update image
#
!include BaseTools/Source/Python/Pkcs7Sign/TestRoot.cer.gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr.inc
<PcdsPatchableInModule>
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid|{GUID("$(DEVICE_FMP_ESRT_GUID)")}
<LibraryClasses>
#
# Directly use a platform specific CapsuleUpdatePolicyLib instance.
Expand Down
6 changes: 5 additions & 1 deletion FmpDevicePkg/FmpDevicePkg.uni
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Capsules. The behavior of the Firmware Management Protocol instance is
// customized using libraries and PCDs.
//
// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
// Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
Expand Down Expand Up @@ -53,6 +53,10 @@
"value of 0 disables the watchdog timer. The default value is 0 (watchdog"
"disabled)."

#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceImageTypeIdGuid_PROMPT #language en-US "Firmware Device Image Type ID."
#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceImageTypeIdGuid_HELP #language en-US "The Image Type ID to use if one is not provided by FmpDeviceLib. If this"
"PCD is not a valid GUID value, then gEfiCallerIdGuid is used."

#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_PROMPT #language en-US "One or more XDR encoded PKCS7 certificates used to verify firmware device capsule update images"
#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_HELP #language en-US "Provides one or more PKCS7 certificates used to verify a firmware device"
"capsule update image. This PCD is encoded using the Variable-Length Opaque"
Expand Down
20 changes: 15 additions & 5 deletions FmpDevicePkg/FmpDxe/FmpDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ FmpDxeProgress (
/**
Returns a pointer to the ImageTypeId GUID value. An attempt is made to get
the GUID value from the FmpDeviceLib. If the FmpDeviceLib does not provide
a GUID value, then gEfiCallerIdGuid is returned.
a GUID value, then PcdFmpDeviceImageTypeIdGuid is used. If the size of
PcdFmpDeviceImageTypeIdGuid is not the size of EFI_GUID, then gEfiCallerIdGuid
is returned.
@retval The ImageTypeId GUID
Expand All @@ -159,18 +161,26 @@ GetImageTypeIdGuid (
{
EFI_STATUS Status;
EFI_GUID *FmpDeviceLibGuid;
UINTN ImageTypeIdGuidSize;

FmpDeviceLibGuid = NULL;
Status = FmpDeviceGetImageTypeIdGuidPtr (&FmpDeviceLibGuid);
if (EFI_ERROR (Status)) {
if (Status != EFI_UNSUPPORTED) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid error %r\n", mImageIdName, Status));
}
return &gEfiCallerIdGuid;
}
if (FmpDeviceLibGuid == NULL) {
} else if (FmpDeviceLibGuid == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n", mImageIdName));
return &gEfiCallerIdGuid;
Status = EFI_NOT_FOUND;
}
if (EFI_ERROR (Status)) {
ImageTypeIdGuidSize = PcdGetSize (PcdFmpDeviceImageTypeIdGuid);
if (ImageTypeIdGuidSize == sizeof (EFI_GUID)) {
FmpDeviceLibGuid = (EFI_GUID *)PcdGetPtr (PcdFmpDeviceImageTypeIdGuid);
} else {
DEBUG ((DEBUG_INFO, "FmpDxe(%s): Fall back to ImageTypeIdGuid of gEfiCallerIdGuid\n", mImageIdName));
FmpDeviceLibGuid = &gEfiCallerIdGuid;
}
}
return FmpDeviceLibGuid;
}
Expand Down
1 change: 1 addition & 0 deletions FmpDevicePkg/FmpDxe/FmpDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor ## CONSUMES
gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr ## CONSUMES
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceTestKeySha256Digest ## CONSUMES
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## SOMETIMES_PRODUCES

[Depex]
Expand Down
1 change: 1 addition & 0 deletions FmpDevicePkg/FmpDxe/FmpDxeLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor ## CONSUMES
gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr ## CONSUMES
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceTestKeySha256Digest ## CONSUMES
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## SOMETIMES_PRODUCES

[Depex]
Expand Down

0 comments on commit 278c3d4

Please sign in to comment.