From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.7618.1618832418539645427 for ; Mon, 19 Apr 2021 04:40:18 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=softfail (domain: linaro.org, ip: 217.140.110.172, mailfrom: sughosh.ganu@linaro.org) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1CB04ED1; Mon, 19 Apr 2021 04:40:17 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6CABF3F792; Mon, 19 Apr 2021 04:40:15 -0700 (PDT) From: "Sughosh Ganu" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Yuwei Chen , Sughosh Ganu Subject: [PATCH] BaseTools: GenerateCapsule.py: Add support for version 3 of FMP Image Header structure Date: Mon, 19 Apr 2021 17:10:04 +0530 Message-Id: <20210419114004.16505-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 Add support for the ImageCapsuleSupport field, introduced in version 3 of the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER structure. This structure member is used to indicate if the corresponding payload has support for authentication and dependency. Signed-off-by: Sughosh Ganu --- .../Source/Python/Capsule/GenerateCapsule.py | 5 +++- .../Common/Uefi/Capsule/FmpCapsuleHeader.py | 26 +++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py b/BaseTools/Source/Python/Capsule/GenerateCapsule.py index a8de988253..6419a2ac6f 100644 --- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py +++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py @@ -561,6 +561,7 @@ if __name__ == '__main__': print ('GenerateCapsule: error:' + str(Msg)) sys.exit (1) for SinglePayloadDescriptor in PayloadDescriptorList: + ImageCapsuleSupport = 0x0000000000000000 Result = SinglePayloadDescriptor.Payload try: FmpPayloadHeader.FwVersion = SinglePayloadDescriptor.FwVersion @@ -575,6 +576,7 @@ if __name__ == '__main__': if SinglePayloadDescriptor.UseDependency: CapsuleDependency.Payload = Result CapsuleDependency.DepexExp = SinglePayloadDescriptor.DepexExp + ImageCapsuleSupport |= 0x0000000000000002 Result = CapsuleDependency.Encode () if args.Verbose: CapsuleDependency.DumpInfo () @@ -607,13 +609,14 @@ if __name__ == '__main__': FmpAuthHeader.MonotonicCount = SinglePayloadDescriptor.MonotonicCount FmpAuthHeader.CertData = CertData FmpAuthHeader.Payload = Result + ImageCapsuleSupport |= 0x0000000000000001 Result = FmpAuthHeader.Encode () if args.Verbose: FmpAuthHeader.DumpInfo () except: print ('GenerateCapsule: error: can not encode FMP Auth Header') sys.exit (1) - FmpCapsuleHeader.AddPayload (SinglePayloadDescriptor.Guid, Result, HardwareInstance = SinglePayloadDescriptor.HardwareInstance, UpdateImageIndex = SinglePayloadDescriptor.UpdateImageIndex) + FmpCapsuleHeader.AddPayload (SinglePayloadDescriptor.Guid, Result, ImageCapsuleSupport, HardwareInstance = SinglePayloadDescriptor.HardwareInstance, UpdateImageIndex = SinglePayloadDescriptor.UpdateImageIndex) try: for EmbeddedDriver in EmbeddedDriverDescriptorList: FmpCapsuleHeader.AddEmbeddedDriver(EmbeddedDriver) diff --git a/BaseTools/Source/Python/Common/Uefi/Capsule/FmpCapsuleHeader.py b/BaseTools/Source/Python/Common/Uefi/Capsule/FmpCapsuleHeader.py index 91d24919c4..a2a5cf0db8 100644 --- a/BaseTools/Source/Python/Common/Uefi/Capsule/FmpCapsuleHeader.py +++ b/BaseTools/Source/Python/Common/Uefi/Capsule/FmpCapsuleHeader.py @@ -47,14 +47,19 @@ class FmpCapsuleImageHeaderClass (object): # /// therefore can be modified without changing the Auth data. # /// # UINT64 UpdateHardwareInstance; + # + # /// + # /// Bits which indicate authentication and depex information for the image that follows this structure + # /// + # UINT64 ImageCapsuleSupport # } EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER; # - # #define EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION 0x00000002 + # #define EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION 0x00000003 - _StructFormat = '= len (self._FmpCapsuleImageHeaderList): @@ -198,13 +207,14 @@ class FmpCapsuleHeaderClass (object): self._ItemOffsetList.append (Offset) Offset = Offset + len (EmbeddedDriver) Index = 1 - for (UpdateImageTypeId, Payload, VendorCodeBytes, HardwareInstance, UpdateImageIndex) in self._PayloadList: + for (UpdateImageTypeId, Payload, ImageCapsuleSupport, VendorCodeBytes, HardwareInstance, UpdateImageIndex) in self._PayloadList: FmpCapsuleImageHeader = FmpCapsuleImageHeaderClass () FmpCapsuleImageHeader.UpdateImageTypeId = UpdateImageTypeId FmpCapsuleImageHeader.UpdateImageIndex = UpdateImageIndex FmpCapsuleImageHeader.Payload = Payload FmpCapsuleImageHeader.VendorCodeBytes = VendorCodeBytes FmpCapsuleImageHeader.UpdateHardwareInstance = HardwareInstance + FmpCapsuleImageHeader.ImageCapsuleSupport = ImageCapsuleSupport FmpCapsuleImage = FmpCapsuleImageHeader.Encode () FmpCapsuleData = FmpCapsuleData + FmpCapsuleImage -- 2.17.1