mirror of https://github.com/acidanthera/audk.git
UefiPayloadPkg: Support more input parameter
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.dong@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Sean Rhodes <sean@starlabs.systems> Cc: James Lu <james.lu@intel.com> Reviewed-by: Gua Guo <gua.guo@intel.com> Signed-off-by: Linus Wu <linusx.wu@intel.com>
This commit is contained in:
parent
f92a9dce10
commit
e3e88d90e8
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue