From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by mx.groups.io with SMTP id smtpd.web08.8770.1618988546548520259 for ; Wed, 21 Apr 2021 00:02:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=dCaWLTzc; spf=pass (domain: linaro.org, ip: 209.85.166.171, mailfrom: sughosh.ganu@linaro.org) Received: by mail-il1-f171.google.com with SMTP id l19so30233277ilk.13 for ; Wed, 21 Apr 2021 00:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RK8mEVhxcKIjptT0zpjUKHj60uV3sSMEn0SOHatE4GM=; b=dCaWLTzcdsViybiB/3RTQQPQpO6/bAE//VG/ZnnnLgzi/iOvXCJNFVBKmf7mBWd3EE x9/GJ1y6uS5SPXrMtF53/Fg00AeoVjtd5rYNjucYP1JSfEhv/wmGG7np+a23KdwMDVIV LzDMV2EqEgXoONfG1I5QIWR8IOIn+ztd8z968SC9MoTLmL186bLo7gu/OwVrROR8XfA8 VcOWEAuH+6kOsjf8yVCt+24GCaTCWB/8WLeOHJTDspkHJBGweeplsINso3Kb2c0Cs/Hx /mfbDxY8yEVZuJS5ANo+e2s8rQ9rqPrujrXkqkS9/pBrw2glrwu5dGYnYtOAoKz2rXQa 2Mtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RK8mEVhxcKIjptT0zpjUKHj60uV3sSMEn0SOHatE4GM=; b=W1UdR74LGcFvILhpaI83iGt3HQNMFuugyUr7OOytf/2zfZQzTcVBd6o8Q+9+JRO0Zv W9S0Dnsdbi4ggyKYOPzaZNKPjmjgzfh66PHYOafv97JrAz7g8uxXuL48slfj7bO8wC5p kW1QwgZU6vMzs72B5PfWM4+zxHsIRA1WArfqR6Svlc/d+1rSWZ2i12no2vSBtE/Kcr5v haz/VkRjedz4MSNTMVP+CH89NC807Yt0aS2qA0xQvRtmCjRs2jzGKabNpX6i2Atx5HDL DgYLRf6WV2nnF/RM787JLzoUpc4QFKWhSxa4+pvgsw937LzJVR+/u/bQ0S+DYARA0efl 8G7A== X-Gm-Message-State: AOAM532MkXaBWPDow5ge5XPNXbIMiWdWBfVWYPbomApEQeSNxqjMEvTR dRajso7ZyAIVX29fggIKqK3OxzTwCcwokkIKEPcXcA== X-Google-Smtp-Source: ABdhPJxL65mK6mUvad2Sj56TeCZ5fSsX9g92zH9XhEHj6tevyHs17JeEBkZK9h+gqAq1nWRLJ7X7HJfCK+S5H8OBLMw= X-Received: by 2002:a92:1a12:: with SMTP id a18mr25308846ila.168.1618988545709; Wed, 21 Apr 2021 00:02:25 -0700 (PDT) MIME-Version: 1.0 References: <20210419114004.16505-1-sughosh.ganu@linaro.org> In-Reply-To: From: "Sughosh Ganu" Date: Wed, 21 Apr 2021 12:32:14 +0530 Message-ID: Subject: Re: [edk2-devel] [PATCH] BaseTools: GenerateCapsule.py: Add support for version 3 of FMP Image Header structure To: "Kinney, Michael D" Cc: "devel@edk2.groups.io" , "Feng, Bob C" , Liming Gao , "Chen, Christine" Content-Type: multipart/alternative; boundary="00000000000029c84f05c0762504" --00000000000029c84f05c0762504 Content-Type: text/plain; charset="UTF-8" hi Michael, Thanks for your review. On Tue, 20 Apr 2021 at 21:26, Kinney, Michael D wrote: > Hi, > > I think this patch is functional, but there are a few things that can be > improved. > > 1) We should not use of the hard coded constants for the > ImageCapsuleSupport values. > The UEFI spec has #defines for these values, and we need to figure out > how to add > those define values in the scope of the FMP Capsule Image Header. > Perhaps add the > values to FmpCapsuleImageHeaderClass in FmpCapsuleHeader.py: > > class FmpCapsuleImageHeaderClass (object): > > CAPSULE_SUPPORT_AUTHENTICATION = 0x0000000000000001 > CAPSULE_SUPPORT_DEPENDENCY = 0x0000000000000002 > > From GenerateCapsule.py, you can use these values to set > ImageCapsuleSupport. > > Value 0 is not defined by the UEFI Spec. Though that appears to be the > value used > for a raw payload without authentication or dependency information. > > Since GenerateCapsule does not import FmpCapsuleImageHeaderClass, these > defines > may have to be added to the FmpCapsuleHeaderClass instead. > Okay. I will make the changes as per your suggestion. > > 2) The ImageCapsuleSupport parameter is added in the middle of the python > function arguments. > Since this is a new field added at the end of the V3 structure, I > recommend we add arguments > at the end of the argument list. This will be an optional argument, so > any existing use > of these methods for V2 use cases will not be impacted. These python > methods can be > potentially used by other consumers, so we should always consider > backwards compatibility > when updating BaseTools/Source/Python/Common areas. > I believe that adding support for compatibility with previous versions will be a more involved effort. If you look at the code, the way it is right now, the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER structure currently supports version 2 -- there is no provision for generating a capsule with version 1 for example. So the way the code is structured right now, we can only support one version. So, if you are looking for having support for previous versions as well, I think that would require adding support for passing the structure version that we need, and then based on. this information, the structure would have certain fields present/absent. Would it be fine to add this field in the structure for now. If you think it necessary, support for multiple versions of the structure can be added as a separate exercise. Is my understanding of your comment correct, or am I missing something. -sughosh > > Thanks, > > Mike > > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of Sughosh > Ganu > > Sent: Monday, April 19, 2021 4:40 AM > > To: devel@edk2.groups.io > > Cc: Feng, Bob C ; Liming Gao < > gaoliming@byosoft.com.cn>; Chen, Christine ; > > Sughosh Ganu > > Subject: [edk2-devel] [PATCH] BaseTools: GenerateCapsule.py: Add support > for version 3 of FMP Image Header structure > > > > 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 = ' > + _StructFormat = ' > _StructSize = struct.calcsize (_StructFormat) > > > > - EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION = > 0x00000002 > > + EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION = > 0x00000003 > > > > def __init__ (self): > > self._Valid = False > > @@ -64,6 +69,7 @@ class FmpCapsuleImageHeaderClass (object): > > self.UpdateImageSize = 0 > > self.UpdateVendorCodeSize = 0 > > self.UpdateHardwareInstance = 0x0000000000000000 > > + self.ImageCapsuleSupport = 0x0000000000000000 > > self.Payload = b'' > > self.VendorCodeBytes = b'' > > > > @@ -78,7 +84,8 @@ class FmpCapsuleImageHeaderClass (object): > > 0,0,0, > > self.UpdateImageSize, > > self.UpdateVendorCodeSize, > > - self.UpdateHardwareInstance > > + self.UpdateHardwareInstance, > > + self.ImageCapsuleSupport > > ) > > self._Valid = True > > return FmpCapsuleImageHeader + self.Payload + > self.VendorCodeBytes > > @@ -86,7 +93,7 @@ class FmpCapsuleImageHeaderClass (object): > > def Decode (self, Buffer): > > if len (Buffer) < self._StructSize: > > raise ValueError > > - (Version, UpdateImageTypeId, UpdateImageIndex, r0, r1, r2, > UpdateImageSize, UpdateVendorCodeSize, > > UpdateHardwareInstance) = \ > > + (Version, UpdateImageTypeId, UpdateImageIndex, r0, r1, r2, > UpdateImageSize, UpdateVendorCodeSize, > > UpdateHardwareInstance, ImageCapsuleSupport) = \ > > struct.unpack ( > > self._StructFormat, > > Buffer[0:self._StructSize] > > @@ -105,6 +112,7 @@ class FmpCapsuleImageHeaderClass (object): > > self.UpdateImageSize = UpdateImageSize > > self.UpdateVendorCodeSize = UpdateVendorCodeSize > > self.UpdateHardwareInstance = UpdateHardwareInstance > > + self.ImageCapsuleSupport = ImageCapsuleSupport > > self.Payload = > Buffer[self._StructSize:self._StructSize + UpdateImageSize] > > self.VendorCodeBytes = Buffer[self._StructSize + > UpdateImageSize:] > > self._Valid = True > > @@ -119,6 +127,7 @@ class FmpCapsuleImageHeaderClass (object): > > print > ('EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER.UpdateImageSize = > {UpdateImageSize:08X}'.format > > (UpdateImageSize = self.UpdateImageSize)) > > print > ('EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER.UpdateVendorCodeSize = > {UpdateVendorCodeSize:08X}'.format > > (UpdateVendorCodeSize = self.UpdateVendorCodeSize)) > > print > ('EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER.UpdateHardwareInstance = > > {UpdateHardwareInstance:016X}'.format (UpdateHardwareInstance = > self.UpdateHardwareInstance)) > > + print > ('EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER.ImageCapsuleSupport = > {ImageCapsuleSupport:016X}'.format > > (ImageCapsuleSupport = self.ImageCapsuleSupport)) > > print ('sizeof (Payload) > = {Size:08X}'.format (Size = len > > (self.Payload))) > > print ('sizeof (VendorCodeBytes) > = {Size:08X}'.format (Size = len > > (self.VendorCodeBytes))) > > > > @@ -172,8 +181,8 @@ class FmpCapsuleHeaderClass (object): > > raise ValueError > > return self._EmbeddedDriverList[Index] > > > > - def AddPayload (self, UpdateImageTypeId, Payload = b'', > VendorCodeBytes = b'', HardwareInstance = 0, UpdateImageIndex > > = 1): > > - self._PayloadList.append ((UpdateImageTypeId, Payload, > VendorCodeBytes, HardwareInstance, UpdateImageIndex)) > > + def AddPayload (self, UpdateImageTypeId, Payload = b'', > ImageCapsuleSupport = 0, VendorCodeBytes = b'', > > HardwareInstance = 0, UpdateImageIndex = 1): > > + self._PayloadList.append ((UpdateImageTypeId, Payload, > ImageCapsuleSupport, VendorCodeBytes, HardwareInstance, > > UpdateImageIndex)) > > > > def GetFmpCapsuleImageHeader (self, Index): > > if Index >= 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 > > > > > > > > > > > > --00000000000029c84f05c0762504 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
hi Michael,
Thanks for your review.
On Tue, = 20 Apr 2021 at 21:26, Kinney, Michael D <michael.d.kinney@intel.com> wrote:
Hi,

I think this patch is functional, but there are a few things that can be i= mproved.

1) We should not use of the hard coded constants for the ImageCapsuleSuppo= rt values.
=C2=A0 =C2=A0The UEFI spec has #defines for these values, and we need to f= igure out how to add
=C2=A0 =C2=A0those define values in the scope of the FMP Capsule Image Hea= der.=C2=A0 Perhaps add the
=C2=A0 =C2=A0values to FmpCapsuleImageHeaderClass in FmpCapsuleHeader.py:<= br>
class FmpCapsuleImageHeaderClass (object):

=C2=A0 =C2=A0 CAPSULE_SUPPORT_AUTHENTICATION =3D 0x0000000000000001
=C2=A0 =C2=A0 CAPSULE_SUPPORT_DEPENDENCY=C2=A0 =C2=A0 =C2=A0=3D 0x00000000= 00000002

=C2=A0 =C2=A0From GenerateCapsule.py, you can use these values to set Imag= eCapsuleSupport.

=C2=A0 =C2=A0Value 0 is not defined by the UEFI Spec.=C2=A0 Though that ap= pears to be the value used
=C2=A0 =C2=A0for a raw payload without authentication or dependency inform= ation.

=C2=A0 =C2=A0Since GenerateCapsule does not import FmpCapsuleImageHeaderCl= ass, these defines
=C2=A0 =C2=A0may have to be added to the FmpCapsuleHeaderClass instead.

Okay. I will make the changes as per your= suggestion.
=C2=A0

2) The ImageCapsuleSupport parameter is added in the middle of the python = function arguments.
=C2=A0 =C2=A0Since this is a new field added at the end of the V3 structur= e, I recommend we add arguments
=C2=A0 =C2=A0at the end of the argument list.=C2=A0 This will be an option= al argument, so any existing use
=C2=A0 =C2=A0of these methods for V2 use cases will not be impacted.=C2=A0= These python methods can be
=C2=A0 =C2=A0potentially used by other consumers, so we should always cons= ider backwards compatibility
=C2=A0 =C2=A0when updating BaseTools/Source/Python/Common areas.

I believe that adding support for compatibility = with previous versions will be a more involved effort. If you look at the c= ode, the way it is right now, the=C2=A0EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAG= E_HEADER structure currently supports version 2 -- there is no provision fo= r generating a capsule with version 1 for example. So the way the code is s= tructured right now, we can only support one version. So, if you are lookin= g for having support for previous versions as well, I think that would requ= ire adding support for passing the structure version that we need, and then= based on. this information, the structure would have certain fields presen= t/absent. Would it be fine to add this field in the structure for now. If y= ou think it necessary, support for multiple versions of the structure can b= e added as a separate exercise. Is my understanding of your comment correct= , or am I missing something.

-sughosh=C2=A0
<= div>=C2=A0

Thanks,

Mike

> -----Original Message-----
> From: devel= @edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sughosh Ganu
> Sent: Monday, April 19, 2021 4:40 AM
> To: devel@e= dk2.groups.io
> Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; = Chen, Christine <yuwei.chen@intel.com>;
> Sughosh Ganu <sughosh.ganu@linaro.org>
> Subject: [edk2-devel] [PATCH] BaseTools: GenerateCapsule.py: Add supp= ort for version 3 of FMP Image Header structure
>
> 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 <sughosh.ganu@linaro.org>
> ---
>=C2=A0 .../Source/Python/Capsule/GenerateCapsule.py=C2=A0 |=C2=A0 5 ++= +-
>=C2=A0 .../Common/Uefi/Capsule/FmpCapsuleHeader.py=C2=A0 =C2=A0| 26 ++= +++++++++++------
>=C2=A0 2 files changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py b/Bas= eTools/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__ =3D=3D '__main__':
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print (= 'GenerateCapsule: error:' + str(Msg))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sys.exi= t (1)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for SinglePayloadDescriptor in Payl= oadDescriptorList:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ImageCapsuleSupport =3D 0x= 0000000000000000
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Result =3D SinglePayl= oadDescriptor.Payload
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 try:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpPayl= oadHeader.FwVersion=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D Sin= glePayloadDescriptor.FwVersion
> @@ -575,6 +576,7 @@ if __name__ =3D=3D '__main__':
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if SinglePayloadDescr= iptor.UseDependency:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Capsule= Dependency.Payload =3D Result
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Capsule= Dependency.DepexExp =3D SinglePayloadDescriptor.DepexExp
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ImageCapsule= Support=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=3D 0x0000000000000002
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Result = = =3D CapsuleDependency.Encode ()
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if args= .Verbose:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 CapsuleDependency.DumpInfo ()
> @@ -607,13 +609,14 @@ if __name__ =3D=3D '__main__':
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 FmpAuthHeader.MonotonicCount =3D SinglePayloadDescriptor.MonotonicC= ount
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 FmpAuthHeader.CertData=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D CertData
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 FmpAuthHeader.Payload=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D Result
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ImageCapsuleSupport=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=3D 0x000000000= 0000001
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 Result =3D FmpAuthHeader.Encode ()
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 if args.Verbose:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 =C2=A0 =C2=A0 FmpAuthHeader.DumpInfo ()
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 except:=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 print ('GenerateCapsule: error: can not encode FMP Auth Header&= #39;)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 sys.exit (1)
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleHeader.AddPayloa= d (SinglePayloadDescriptor.Guid, Result, HardwareInstance =3D
> SinglePayloadDescriptor.HardwareInstance, UpdateImageIndex =3D Single= PayloadDescriptor.UpdateImageIndex)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleHeader.AddPayloa= d (SinglePayloadDescriptor.Guid, Result, ImageCapsuleSupport, HardwareInsta= nce =3D
> SinglePayloadDescriptor.HardwareInstance, UpdateImageIndex =3D Single= PayloadDescriptor.UpdateImageIndex)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 try:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for EmbeddedDriver in= EmbeddedDriverDescriptorList:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCaps= uleHeader.AddEmbeddedDriver(EmbeddedDriver)
> diff --git a/BaseTools/Source/Python/Common/Uefi/Capsule/FmpCapsuleHe= ader.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):
>=C2=A0 =C2=A0 =C2=A0 #=C2=A0 =C2=A0/// therefore can be modified witho= ut changing the Auth data.
>=C2=A0 =C2=A0 =C2=A0 #=C2=A0 =C2=A0///
>=C2=A0 =C2=A0 =C2=A0 #=C2=A0 =C2=A0UINT64=C2=A0 =C2=A0UpdateHardwareIn= stance;
> +=C2=A0 =C2=A0 #
> +=C2=A0 =C2=A0 #=C2=A0 =C2=A0///
> +=C2=A0 =C2=A0 #=C2=A0 =C2=A0/// Bits which indicate authentication a= nd depex information for the image that follows this structure
> +=C2=A0 =C2=A0 #=C2=A0 =C2=A0///
> +=C2=A0 =C2=A0 #=C2=A0 =C2=A0UINT64=C2=A0 =C2=A0ImageCapsuleSupport >=C2=A0 =C2=A0 =C2=A0 # } EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER;=
>=C2=A0 =C2=A0 =C2=A0 #
> -=C2=A0 =C2=A0 #=C2=A0 #define EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_= HEADER_INIT_VERSION 0x00000002
> +=C2=A0 =C2=A0 #=C2=A0 #define EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_= HEADER_INIT_VERSION 0x00000003
>
> -=C2=A0 =C2=A0 _StructFormat =3D '<I16sB3BIIQ'
> +=C2=A0 =C2=A0 _StructFormat =3D '<I16sB3BIIQQ'
>=C2=A0 =C2=A0 =C2=A0 _StructSize=C2=A0 =C2=A0=3D struct.calcsize (_Str= uctFormat)
>
> -=C2=A0 =C2=A0 EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERS= ION =3D 0x00000002
> +=C2=A0 =C2=A0 EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERS= ION =3D 0x00000003
>
>=C2=A0 =C2=A0 =C2=A0 def __init__ (self):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._Valid=C2=A0 =C2=A0 =C2=A0 =C2= = =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D False
> @@ -64,6 +69,7 @@ class FmpCapsuleImageHeaderClass (object):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.UpdateImageSize=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =3D 0
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.UpdateVendorCodeSize=C2=A0 =C2= = =A0=3D 0
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.UpdateHardwareInstance =3D 0x0= 000000000000000
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.ImageCapsuleSupport=C2=A0 =C2=A0 = =3D 0x0000000000000000
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.Payload=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D b''
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.VendorCodeBytes=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =3D b''
>
> @@ -78,7 +84,8 @@ class FmpCapsuleImageHeaderClass (object):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A00,0,0,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0self.UpdateImageSize,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0self.UpdateVendorCodeSize,
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0self.UpdateHardwareInstance
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0self.UpdateHardwareInstance,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0self.ImageCapsuleSupport
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._Valid =3D True
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return FmpCapsuleImageHeader + self= .Payload + self.VendorCodeBytes
> @@ -86,7 +93,7 @@ class FmpCapsuleImageHeaderClass (object):
>=C2=A0 =C2=A0 =C2=A0 def Decode (self, Buffer):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if len (Buffer) < self._StructSi= ze:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise ValueError
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 (Version, UpdateImageTypeId, UpdateImage= Index, r0, r1, r2, UpdateImageSize, UpdateVendorCodeSize,
> UpdateHardwareInstance) =3D \
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (Version, UpdateImageTypeId, UpdateImage= Index, r0, r1, r2, UpdateImageSize, UpdateVendorCodeSize,
> UpdateHardwareInstance, ImageCapsuleSupport) =3D \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct.unpack (
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 =C2=A0self._StructFormat,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 =C2=A0Buffer[0:self._StructSize]
> @@ -105,6 +112,7 @@ class FmpCapsuleImageHeaderClass (object):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.UpdateImageSize=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =3D UpdateImageSize
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.UpdateVendorCodeSize=C2=A0 =C2= = =A0=3D UpdateVendorCodeSize
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.UpdateHardwareInstance =3D Upd= ateHardwareInstance
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.ImageCapsuleSupport=C2=A0 =C2=A0 = =3D ImageCapsuleSupport
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.Payload=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D Buffer[self._StructSize:self._Struc= tSize + UpdateImageSize]
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.VendorCodeBytes=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =3D Buffer[self._StructSize + UpdateImageSize:]
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._Valid=C2=A0 =C2=A0 =C2=A0 =C2= = =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D True
> @@ -119,6 +127,7 @@ class FmpCapsuleImageHeaderClass (object):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print ('EFI_FIRMWARE_MANAGEMENT= _CAPSULE_IMAGE_HEADER.UpdateImageSize=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D {Updat= eImageSize:08X}'.format
> (UpdateImageSize =3D self.UpdateImageSize))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print ('EFI_FIRMWARE_MANAGEMENT= _CAPSULE_IMAGE_HEADER.UpdateVendorCodeSize=C2=A0 =C2=A0=3D {UpdateVendorCod= eSize:08X}'.format
> (UpdateVendorCodeSize =3D self.UpdateVendorCodeSize))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print ('EFI_FIRMWARE_MANAGEMENT= _CAPSULE_IMAGE_HEADER.UpdateHardwareInstance =3D
> {UpdateHardwareInstance:016X}'.format (UpdateHardwareInstance =3D= self.UpdateHardwareInstance))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 print ('EFI_FIRMWARE_MANAGEMENT_CAPS= ULE_IMAGE_HEADER.ImageCapsuleSupport=C2=A0 =C2=A0 =3D {ImageCapsuleSupport:= 016X}'.format
> (ImageCapsuleSupport =3D self.ImageCapsuleSupport))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print ('sizeof (Payload)=C2=A0 = = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D {Size:08X}'.format (Size =3D len
> (self.Payload)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print ('sizeof (VendorCodeBytes= )=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = = =C2=A0 =3D {Size:08X}'.format (Size =3D len
> (self.VendorCodeBytes)))
>
> @@ -172,8 +181,8 @@ class FmpCapsuleHeaderClass (object):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise ValueError
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return self._EmbeddedDriverList[Ind= ex]
>
> -=C2=A0 =C2=A0 def AddPayload (self, UpdateImageTypeId, Payload =3D b= '', VendorCodeBytes =3D b'', HardwareInstance =3D 0, Update= ImageIndex
> =3D 1):
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._PayloadList.append ((UpdateImageTy= peId, Payload, VendorCodeBytes, HardwareInstance, UpdateImageIndex))
> +=C2=A0 =C2=A0 def AddPayload (self, UpdateImageTypeId, Payload =3D b= '', ImageCapsuleSupport =3D 0, VendorCodeBytes =3D b'',
> HardwareInstance =3D 0, UpdateImageIndex =3D 1):
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._PayloadList.append ((UpdateImageTy= peId, Payload, ImageCapsuleSupport, VendorCodeBytes, HardwareInstance,
> UpdateImageIndex))
>
>=C2=A0 =C2=A0 =C2=A0 def GetFmpCapsuleImageHeader (self, Index):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if Index >=3D len (self._FmpCaps= uleImageHeaderList):
> @@ -198,13 +207,14 @@ class FmpCapsuleHeaderClass (object):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._ItemOffsetList.= append (Offset)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Offset =3D Offset + l= en (EmbeddedDriver)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Index =3D 1
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (UpdateImageTypeId, Payload, VendorC= odeBytes, HardwareInstance, UpdateImageIndex) in self._PayloadList:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (UpdateImageTypeId, Payload, ImageCa= psuleSupport, VendorCodeBytes, HardwareInstance, UpdateImageIndex) in
> self._PayloadList:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleImageHeader= =3D FmpCapsuleImageHeaderClass ()
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleImageHeader= .UpdateImageTypeId=C2=A0 =C2=A0 =C2=A0 =3D UpdateImageTypeId
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleImageHeader= .UpdateImageIndex=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D UpdateImageIndex
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleImageHeader= .Payload=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D Payload=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleImageHeader= .VendorCodeBytes=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D VendorCodeBytes
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleImageHeader= .UpdateHardwareInstance =3D HardwareInstance
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleImageHeader.Imag= eCapsuleSupport=C2=A0 =C2=A0 =3D ImageCapsuleSupport
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleImage =3D F= mpCapsuleImageHeader.Encode ()
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FmpCapsuleData =3D Fm= pCapsuleData + FmpCapsuleImage
>
> --
> 2.17.1
>
>
>
>
>

--00000000000029c84f05c0762504--