* [PATCH] UefiPayloadPkg: Support more input parameter
@ 2023-03-29 10:20 linusx.wu
2023-03-29 10:22 ` Guo, Gua
2023-03-29 10:52 ` Guo, Gua
0 siblings, 2 replies; 3+ messages in thread
From: linusx.wu @ 2023-03-29 10:20 UTC (permalink / raw)
To: devel; +Cc: Linus Wu, Guo Dong, Ray Ni, Sean Rhodes, James Lu, Gua Guo
From: Linus Wu <linusx.wu@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.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Linus Wu <linusx.wu@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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] UefiPayloadPkg: Support more input parameter
2023-03-29 10:20 [PATCH] UefiPayloadPkg: Support more input parameter linusx.wu
@ 2023-03-29 10:22 ` Guo, Gua
2023-03-29 10:52 ` Guo, Gua
1 sibling, 0 replies; 3+ messages in thread
From: Guo, Gua @ 2023-03-29 10:22 UTC (permalink / raw)
To: Wu, LinusX, devel@edk2.groups.io
Cc: Dong, Guo, Ni, Ray, Rhodes, Sean, Lu, James
Reviewed-by: Gua Guo <gua.guo@intel.com>
-----Original Message-----
From: Wu, LinusX <linusx.wu@intel.com>
Sent: Wednesday, March 29, 2023 6:21 PM
To: devel@edk2.groups.io
Cc: Wu, LinusX <linusx.wu@intel.com>; Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Rhodes, Sean <sean@starlabs.systems>; Lu, James <james.lu@intel.com>; Guo, Gua <gua.guo@intel.com>
Subject: [PATCH] UefiPayloadPkg: Support more input parameter
From: Linus Wu <linusx.wu@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.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Linus Wu <linusx.wu@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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] UefiPayloadPkg: Support more input parameter
2023-03-29 10:20 [PATCH] UefiPayloadPkg: Support more input parameter linusx.wu
2023-03-29 10:22 ` Guo, Gua
@ 2023-03-29 10:52 ` Guo, Gua
1 sibling, 0 replies; 3+ messages in thread
From: Guo, Gua @ 2023-03-29 10:52 UTC (permalink / raw)
To: Wu, LinusX, devel@edk2.groups.io
Cc: Dong, Guo, Ni, Ray, Rhodes, Sean, Lu, James
Reviewed-by: Gua Guo <gua.guo@intel.com>
-----Original Message-----
From: Wu, LinusX <linusx.wu@intel.com>
Sent: Wednesday, March 29, 2023 6:52 PM
To: devel@edk2.groups.io
Cc: Wu, LinusX <linusx.wu@intel.com>; Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Rhodes, Sean <sean@starlabs.systems>; Lu, James <james.lu@intel.com>; Guo, Gua <gua.guo@intel.com>
Subject: [PATCH] UefiPayloadPkg: Support more input parameter
From: Linus Wu <linusx.wu@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.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Linus Wu <linusx.wu@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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-29 10:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-29 10:20 [PATCH] UefiPayloadPkg: Support more input parameter linusx.wu
2023-03-29 10:22 ` Guo, Gua
2023-03-29 10:52 ` Guo, Gua
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox