]> xenbits.xensource.com Git - ovmf.git/commitdiff
UefiPayloadPkg: Support more input parameter
authorLinus Wu <linusx.wu@intel.com>
Wed, 29 Mar 2023 02:26:00 +0000 (10:26 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 30 Mar 2023 02:25:13 +0000 (02:25 +0000)
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>
UefiPayloadPkg/UniversalPayloadBuild.py

index 522855eba44d54606643c554c948336c5d573d5c..7cd04fdceba913ef090d70f1b54fa4a4ead3d7bb 100644 (file)
@@ -31,11 +31,48 @@ class UPLD_INFO_HEADER(LittleEndianStructure):
     def __init__(self):\r
         self.Identifier     =  b'PLDH'\r
         self.HeaderLength   = sizeof(UPLD_INFO_HEADER)\r
-        self.SpecRevision   = 0x0009\r
+        self.SpecRevision   = 0x0070\r
         self.Revision       = 0x0000010105\r
         self.ImageId        = b'UEFI'\r
         self.ProducerId     = b'INTEL'\r
 \r
+def GenSpecRevision (Argument):\r
+    try:\r
+        (MajorStr, MinorStr) = Argument.split('.')\r
+    except:\r
+        raise argparse.ArgumentTypeError ('{} is not a valid SpecRevision format (Major[8-bits].Minor[8-bits]).'.format (Argument))\r
+    #\r
+    # Spec Revision Bits 15 : 8 - Major Version. Bits 7 : 0 - Minor Version.\r
+    #\r
+    if len(MinorStr) > 0 and len(MinorStr) < 3:\r
+        try:\r
+            Minor = int(MinorStr, 16) if len(MinorStr) == 2 else (int(MinorStr, 16) << 4)\r
+        except:\r
+            raise argparse.ArgumentTypeError ('{} Minor version of SpecRevision is not a valid integer value.'.format (Argument))\r
+    else:\r
+        raise argparse.ArgumentTypeError ('{} is not a valid SpecRevision format (Major[8-bits].Minor[8-bits]).'.format (Argument))\r
+\r
+    if len(MajorStr) > 0 and len(MajorStr) < 3:\r
+        try:\r
+            Major = int(MajorStr, 16)\r
+        except:\r
+            raise argparse.ArgumentTypeError ('{} Major version of SpecRevision is not a valid integer value.'.format (Argument))\r
+    else:\r
+        raise argparse.ArgumentTypeError ('{} is not a valid SpecRevision format (Major[8-bits].Minor[8-bits]).'.format (Argument))\r
+\r
+    return int('0x{0:02x}{1:02x}'.format(Major, Minor), 0)\r
+\r
+def Validate32BitInteger (Argument):\r
+    try:\r
+        Value = int (Argument, 0)\r
+    except:\r
+        raise argparse.ArgumentTypeError ('{} is not a valid integer value.'.format (Argument))\r
+    if Value < 0:\r
+        raise argparse.ArgumentTypeError ('{} is a negative value.'.format (Argument))\r
+    if Value > 0xffffffff:\r
+        raise argparse.ArgumentTypeError ('{} is larger than 32-bits.'.format (Argument))\r
+    return Value\r
+\r
 def RunCommand(cmd):\r
     print(cmd)\r
     p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,cwd=os.environ['WORKSPACE'])\r
@@ -111,6 +148,9 @@ def BuildUniversalPayload(Args, MacroList):
     # Buid Universal Payload Information Section ".upld_info"\r
     #\r
     upld_info_hdr = UPLD_INFO_HEADER()\r
+    upld_info_hdr.SpecRevision = Args.SpecRevision\r
+    upld_info_hdr.Revision = Args.Revision\r
+    upld_info_hdr.ProducerId = Args.ProducerId.encode()[:16]\r
     upld_info_hdr.ImageId = Args.ImageId.encode()[:16]\r
     upld_info_hdr.Attribute |= 1 if BuildTarget == "DEBUG" else 0\r
     fp = open(UpldInfoFile, 'wb')\r
@@ -156,6 +196,9 @@ def main():
     parser.add_argument('-i', '--ImageId', type=str, help='Specify payload ID (16 bytes maximal).', default ='UEFI')\r
     parser.add_argument('-q', '--Quiet', action='store_true', help='Disable all build messages except FATAL ERRORS.')\r
     parser.add_argument("-p", "--pcd", action="append")\r
+    parser.add_argument("-s", "--SpecRevision", type=GenSpecRevision, default ='0.7', help='Indicates compliance with a revision of this specification in the BCD format.')\r
+    parser.add_argument("-r", "--Revision", type=Validate32BitInteger, default ='0x0000010105', help='Revision of the Payload binary. Major.Minor.Revision.Build')\r
+    parser.add_argument("-o", "--ProducerId", default ='INTEL', help='A null-terminated OEM-supplied string that identifies the payload producer (16 bytes maximal).')\r
     MacroList = {}\r
     args = parser.parse_args()\r
     if args.Macro is not None:\r