From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.20978.1680085263627154979 for ; Wed, 29 Mar 2023 03:21:03 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=jkTGu6ta; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: linusx.wu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680085263; x=1711621263; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BAhQV8nieighyX1wkCrlK9XTtfHvIwZklqTQAJFU8Hs=; b=jkTGu6taq+gRXFMM/WilWwuELAwHluDW6CfTAIvCpGdIZntzzxNMHznH 7vWVM2vTdY4ljcrOHUJKFsVTZPm0hkn9J2NIC8j2qX1BmrYk1q4GHZfzK jT85M9vbIZQLUDyju1ceLXwrYYF062qsTJSaX0Lijqrw+qB6XQZOv9wh8 vt41sq4CNGLtbYzMYgW72gy5v0EIbST5/spanx4KDRV0y5Cj9iG4gvkzd n3VZmUEJLC9N6gtIzc0JnZ0MhmXPnYevzPICke2OYxL4sYBJsNV+f5Da2 o656H+rLLylCaNkN/iQ0MgooV3sAhMk2eQgRH0OaGgZmzU7/0kcs9VqQp Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="427112946" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="427112946" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 03:21:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="808145117" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="808145117" Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by orsmga004.jf.intel.com with ESMTP; 29 Mar 2023 03:21:00 -0700 From: linusx.wu@intel.com To: devel@edk2.groups.io Cc: Linus Wu , Guo Dong , Ray Ni , Sean Rhodes , James Lu , Gua Guo Subject: [PATCH] UefiPayloadPkg: Support more input parameter Date: Wed, 29 Mar 2023 18:20:57 +0800 Message-Id: <29d9e1b5a1b44b615c8a7e4fa78b60e76c22aa06.1680082801.git.linusx.wu@intel.com> X-Mailer: git-send-email 2.39.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Linus Wu REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4386 Add additional input parameter support --SpecRevision: user input spec version --Revision: user input revision --ProducerId: producer company name 1. UniversalPayloadBuild.py 2. Downgrade spec revision from 0.9 to 0.7 Cc: Guo Dong Cc: Ray Ni Cc: Sean Rhodes Cc: James Lu Cc: Gua Guo Signed-off-by: Linus Wu --- UefiPayloadPkg/UniversalPayloadBuild.py | 45 ++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py b/UefiPayloadPkg/Unive= rsalPayloadBuild.py index 522855eba4..7cd04fdceb 100644 --- a/UefiPayloadPkg/UniversalPayloadBuild.py +++ b/UefiPayloadPkg/UniversalPayloadBuild.py @@ -31,11 +31,48 @@ class UPLD_INFO_HEADER(LittleEndianStructure): def __init__(self):=0D self.Identifier =3D b'PLDH'=0D self.HeaderLength =3D sizeof(UPLD_INFO_HEADER)=0D - self.SpecRevision =3D 0x0009=0D + self.SpecRevision =3D 0x0070=0D self.Revision =3D 0x0000010105=0D self.ImageId =3D b'UEFI'=0D self.ProducerId =3D b'INTEL'=0D =0D +def GenSpecRevision (Argument):=0D + try:=0D + (MajorStr, MinorStr) =3D Argument.split('.')=0D + except:=0D + raise argparse.ArgumentTypeError ('{} is not a valid SpecRevision = format (Major[8-bits].Minor[8-bits]).'.format (Argument))=0D + #=0D + # Spec Revision Bits 15 : 8 - Major Version. Bits 7 : 0 - Minor Versio= n.=0D + #=0D + if len(MinorStr) > 0 and len(MinorStr) < 3:=0D + try:=0D + Minor =3D int(MinorStr, 16) if len(MinorStr) =3D=3D 2 else (in= t(MinorStr, 16) << 4)=0D + except:=0D + raise argparse.ArgumentTypeError ('{} Minor version of SpecRev= ision is not a valid integer value.'.format (Argument))=0D + else:=0D + raise argparse.ArgumentTypeError ('{} is not a valid SpecRevision = format (Major[8-bits].Minor[8-bits]).'.format (Argument))=0D +=0D + if len(MajorStr) > 0 and len(MajorStr) < 3:=0D + try:=0D + Major =3D int(MajorStr, 16)=0D + except:=0D + raise argparse.ArgumentTypeError ('{} Major version of SpecRev= ision is not a valid integer value.'.format (Argument))=0D + else:=0D + raise argparse.ArgumentTypeError ('{} is not a valid SpecRevision = format (Major[8-bits].Minor[8-bits]).'.format (Argument))=0D +=0D + return int('0x{0:02x}{1:02x}'.format(Major, Minor), 0)=0D +=0D +def Validate32BitInteger (Argument):=0D + try:=0D + Value =3D int (Argument, 0)=0D + except:=0D + raise argparse.ArgumentTypeError ('{} is not a valid integer value= .'.format (Argument))=0D + if Value < 0:=0D + raise argparse.ArgumentTypeError ('{} is a negative value.'.format= (Argument))=0D + if Value > 0xffffffff:=0D + raise argparse.ArgumentTypeError ('{} is larger than 32-bits.'.for= mat (Argument))=0D + return Value=0D +=0D def RunCommand(cmd):=0D print(cmd)=0D p =3D subprocess.Popen(cmd, shell=3DTrue, stdout=3Dsubprocess.PIPE, st= derr=3Dsubprocess.STDOUT,cwd=3Dos.environ['WORKSPACE'])=0D @@ -111,6 +148,9 @@ def BuildUniversalPayload(Args, MacroList): # Buid Universal Payload Information Section ".upld_info"=0D #=0D upld_info_hdr =3D UPLD_INFO_HEADER()=0D + upld_info_hdr.SpecRevision =3D Args.SpecRevision=0D + upld_info_hdr.Revision =3D Args.Revision=0D + upld_info_hdr.ProducerId =3D Args.ProducerId.encode()[:16]=0D upld_info_hdr.ImageId =3D Args.ImageId.encode()[:16]=0D upld_info_hdr.Attribute |=3D 1 if BuildTarget =3D=3D "DEBUG" else 0=0D fp =3D open(UpldInfoFile, 'wb')=0D @@ -156,6 +196,9 @@ def main(): parser.add_argument('-i', '--ImageId', type=3Dstr, help=3D'Specify pay= load ID (16 bytes maximal).', default =3D'UEFI')=0D parser.add_argument('-q', '--Quiet', action=3D'store_true', help=3D'Di= sable all build messages except FATAL ERRORS.')=0D parser.add_argument("-p", "--pcd", action=3D"append")=0D + parser.add_argument("-s", "--SpecRevision", type=3DGenSpecRevision, de= fault =3D'0.7', help=3D'Indicates compliance with a revision of this specif= ication in the BCD format.')=0D + parser.add_argument("-r", "--Revision", type=3DValidate32BitInteger, d= efault =3D'0x0000010105', help=3D'Revision of the Payload binary. Major.Min= or.Revision.Build')=0D + parser.add_argument("-o", "--ProducerId", default =3D'INTEL', help=3D'= A null-terminated OEM-supplied string that identifies the payload producer = (16 bytes maximal).')=0D MacroList =3D {}=0D args =3D parser.parse_args()=0D if args.Macro is not None:=0D --=20 2.39.1.windows.1