UefiPayloadPkg:Add new build commands for UniversalPayload

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4375

add '-pb' command of build bios with exist PreUniversalPayload file.
    '-e'  command of olny build the UniversalPayloadentry file.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: KasimX Liu <kasimx.liu@intel.com>
This commit is contained in:
KasimX Liu 2023-03-16 14:25:52 +08:00 committed by mergify[bot]
parent 3e3be2cbc2
commit cdf6ff1719
1 changed files with 42 additions and 36 deletions

View File

@ -102,6 +102,8 @@ def BuildUniversalPayload(Args, MacroList):
ObjCopyFlag = "elf32-i386" ObjCopyFlag = "elf32-i386"
EntryOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ElfToolChain), os.path.normpath("IA32/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry/DEBUG/UniversalPayloadEntry.dll")) EntryOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ElfToolChain), os.path.normpath("IA32/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry/DEBUG/UniversalPayloadEntry.dll"))
if Args.PreBuildUplBinary is not None:
EntryOutputDir = os.path.abspath(Args.PreBuildUplBinary)
EntryModuleInf = os.path.normpath("UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf") EntryModuleInf = os.path.normpath("UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf")
DscPath = os.path.normpath("UefiPayloadPkg/UefiPayloadPkg.dsc") DscPath = os.path.normpath("UefiPayloadPkg/UefiPayloadPkg.dsc")
DxeFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ToolChain), os.path.normpath("FV/DXEFV.Fv")) DxeFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ToolChain), os.path.normpath("FV/DXEFV.Fv"))
@ -132,18 +134,19 @@ def BuildUniversalPayload(Args, MacroList):
# #
# Building DXE core and DXE drivers as DXEFV. # Building DXE core and DXE drivers as DXEFV.
# #
BuildPayload = "build -p {} -b {} -a X64 -t {} -y {} {}".format (DscPath, BuildTarget, ToolChain, PayloadReportPath, Quiet) if Args.BuildEntryOnly == False:
BuildPayload += Pcds BuildPayload = "build -p {} -b {} -a X64 -t {} -y {} {}".format (DscPath, BuildTarget, ToolChain, PayloadReportPath, Quiet)
BuildPayload += Defines BuildPayload += Pcds
RunCommand(BuildPayload) BuildPayload += Defines
RunCommand(BuildPayload)
# #
# Building Universal Payload entry. # Building Universal Payload entry.
# #
BuildModule = "build -p {} -b {} -a {} -m {} -t {} -y {} {}".format (DscPath, BuildTarget, BuildArch, EntryModuleInf, ElfToolChain, ModuleReportPath, Quiet) if Args.PreBuildUplBinary is None:
BuildModule += Pcds BuildModule = "build -p {} -b {} -a {} -m {} -t {} -y {} {}".format (DscPath, BuildTarget, BuildArch, EntryModuleInf, ElfToolChain, ModuleReportPath, Quiet)
BuildModule += Defines BuildModule += Pcds
RunCommand(BuildModule) BuildModule += Defines
RunCommand(BuildModule)
# #
# Buid Universal Payload Information Section ".upld_info" # Buid Universal Payload Information Section ".upld_info"
# #
@ -157,33 +160,34 @@ def BuildUniversalPayload(Args, MacroList):
fp.write(bytearray(upld_info_hdr)) fp.write(bytearray(upld_info_hdr))
fp.close() fp.close()
# if Args.BuildEntryOnly == False:
# Copy the DXEFV as a section in elf format Universal Payload entry. #
# # Copy the DXEFV as a section in elf format Universal Payload entry.
remove_section = '"{}" -I {} -O {} --remove-section .upld_info --remove-section .upld.uefi_fv --remove-section .upld.bds_fv {}'.format ( #
LlvmObjcopyPath, remove_section = '"{}" -I {} -O {} --remove-section .upld_info --remove-section .upld.uefi_fv --remove-section .upld.bds_fv {}'.format (
ObjCopyFlag, LlvmObjcopyPath,
ObjCopyFlag, ObjCopyFlag,
EntryOutputDir ObjCopyFlag,
) EntryOutputDir
add_section = '"{}" -I {} -O {} --add-section .upld_info={} --add-section .upld.uefi_fv={} --add-section .upld.bds_fv={} {}'.format ( )
LlvmObjcopyPath, add_section = '"{}" -I {} -O {} --add-section .upld_info={} --add-section .upld.uefi_fv={} --add-section .upld.bds_fv={} {}'.format (
ObjCopyFlag, LlvmObjcopyPath,
ObjCopyFlag, ObjCopyFlag,
UpldInfoFile, ObjCopyFlag,
DxeFvOutputDir, UpldInfoFile,
BdsFvOutputDir, DxeFvOutputDir,
EntryOutputDir BdsFvOutputDir,
) EntryOutputDir
set_section = '"{}" -I {} -O {} --set-section-alignment .upld_info=4 --set-section-alignment .upld.uefi_fv=16 --set-section-alignment .upld.bds_fv=16 {}'.format ( )
LlvmObjcopyPath, set_section = '"{}" -I {} -O {} --set-section-alignment .upld_info=4 --set-section-alignment .upld.uefi_fv=16 --set-section-alignment .upld.bds_fv=16 {}'.format (
ObjCopyFlag, LlvmObjcopyPath,
ObjCopyFlag, ObjCopyFlag,
EntryOutputDir ObjCopyFlag,
) EntryOutputDir
RunCommand(remove_section) )
RunCommand(add_section) RunCommand(remove_section)
RunCommand(set_section) RunCommand(add_section)
RunCommand(set_section)
shutil.copy (EntryOutputDir, os.path.join(BuildDir, 'UniversalPayload.elf')) shutil.copy (EntryOutputDir, os.path.join(BuildDir, 'UniversalPayload.elf'))
@ -199,6 +203,8 @@ def main():
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("-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("-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).') parser.add_argument("-o", "--ProducerId", default ='INTEL', help='A null-terminated OEM-supplied string that identifies the payload producer (16 bytes maximal).')
parser.add_argument("-e", "--BuildEntryOnly", action='store_true', help='Build UniversalPayload Entry file')
parser.add_argument("-pb", "--PreBuildUplBinary", default=None, help='Specify the UniversalPayload file')
MacroList = {} MacroList = {}
args = parser.parse_args() args = parser.parse_args()
if args.Macro is not None: if args.Macro is not None: