From: Linus Wu <linusx...@intel.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4386
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 <guo.d...@intel.com> Cc: Ray Ni <ray...@intel.com> Cc: Sean Rhodes <sean@starlabs.systems> Cc: James Lu <james...@intel.com> Cc: Gua Guo <gua....@intel.com> Signed-off-by: Linus Wu <linusx...@intel.com> --- UefiPayloadPkg/UniversalPayloadBuild.py | 45 ++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py b/UefiPayloadPkg/UniversalPayloadBuild.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): self.Identifier = b'PLDH' self.HeaderLength = sizeof(UPLD_INFO_HEADER) - self.SpecRevision = 0x0009 + self.SpecRevision = 0x0070 self.Revision = 0x0000010105 self.ImageId = b'UEFI' self.ProducerId = b'INTEL' +def GenSpecRevision (Argument): + try: + (MajorStr, MinorStr) = Argument.split('.') + except: + raise argparse.ArgumentTypeError ('{} is not a valid SpecRevision format (Major[8-bits].Minor[8-bits]).'.format (Argument)) + # + # Spec Revision Bits 15 : 8 - Major Version. Bits 7 : 0 - Minor Version. + # + if len(MinorStr) > 0 and len(MinorStr) < 3: + try: + Minor = int(MinorStr, 16) if len(MinorStr) == 2 else (int(MinorStr, 16) << 4) + except: + raise argparse.ArgumentTypeError ('{} Minor version of SpecRevision is not a valid integer value.'.format (Argument)) + else: + raise argparse.ArgumentTypeError ('{} is not a valid SpecRevision format (Major[8-bits].Minor[8-bits]).'.format (Argument)) + + if len(MajorStr) > 0 and len(MajorStr) < 3: + try: + Major = int(MajorStr, 16) + except: + raise argparse.ArgumentTypeError ('{} Major version of SpecRevision is not a valid integer value.'.format (Argument)) + else: + raise argparse.ArgumentTypeError ('{} is not a valid SpecRevision format (Major[8-bits].Minor[8-bits]).'.format (Argument)) + + return int('0x{0:02x}{1:02x}'.format(Major, Minor), 0) + +def Validate32BitInteger (Argument): + try: + Value = int (Argument, 0) + except: + raise argparse.ArgumentTypeError ('{} is not a valid integer value.'.format (Argument)) + if Value < 0: + raise argparse.ArgumentTypeError ('{} is a negative value.'.format (Argument)) + if Value > 0xffffffff: + raise argparse.ArgumentTypeError ('{} is larger than 32-bits.'.format (Argument)) + return Value + def RunCommand(cmd): print(cmd) p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,cwd=os.environ['WORKSPACE']) @@ -111,6 +148,9 @@ def BuildUniversalPayload(Args, MacroList): # Buid Universal Payload Information Section ".upld_info" # upld_info_hdr = UPLD_INFO_HEADER() + upld_info_hdr.SpecRevision = Args.SpecRevision + upld_info_hdr.Revision = Args.Revision + upld_info_hdr.ProducerId = Args.ProducerId.encode()[:16] upld_info_hdr.ImageId = Args.ImageId.encode()[:16] upld_info_hdr.Attribute |= 1 if BuildTarget == "DEBUG" else 0 fp = open(UpldInfoFile, 'wb') @@ -156,6 +196,9 @@ def main(): parser.add_argument('-i', '--ImageId', type=str, help='Specify payload ID (16 bytes maximal).', default ='UEFI') parser.add_argument('-q', '--Quiet', action='store_true', help='Disable all build messages except FATAL ERRORS.') parser.add_argument("-p", "--pcd", action="append") + parser.add_argument("-s", "--SpecRevision", type=GenSpecRevision, default ='0.7', help='Indicates compliance with a revision of this specification in the BCD format.') + parser.add_argument("-r", "--Revision", type=Validate32BitInteger, default ='0x0000010105', help='Revision of the Payload binary. Major.Minor.Revision.Build') + parser.add_argument("-o", "--ProducerId", default ='INTEL', help='A null-terminated OEM-supplied string that identifies the payload producer (16 bytes maximal).') MacroList = {} args = parser.parse_args() if args.Macro is not None: -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102120): https://edk2.groups.io/g/devel/message/102120 Mute This Topic: https://groups.io/mt/97925255/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-