From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.12666.1632611541946699213 for ; Sat, 25 Sep 2021 16:12:22 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: guo.dong@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10118"; a="211389756" X-IronPort-AV: E=Sophos;i="5.85,322,1624345200"; d="scan'208";a="211389756" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2021 16:12:21 -0700 X-IronPort-AV: E=Sophos;i="5.85,322,1624345200"; d="scan'208";a="586419141" Received: from gdong1-mobl1.amr.corp.intel.com ([10.255.67.241]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2021 16:12:20 -0700 From: "Guo Dong" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You Subject: [`edk2-devel][PATCH v2] UefiPayloadPkg: Add ".upld_info" in universal payload Date: Sat, 25 Sep 2021 16:12:11 -0700 Message-Id: <20210925231211.221-1-guo.dong@intel.com> X-Mailer: git-send-email 2.32.0.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Guo Dong V2: Use LittleEndianStructure by review comment. >>From the universal scalable firmware payload requirement V0.75, Payload must have Universal Payload Information Section ".upld_info" So update the build tool to add this section. Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Signed-off-by: Guo Dong --- UefiPayloadPkg/UniversalPayloadBuild.py | 42 +++++++++++++++++++++++++++++= ++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py b/UefiPayloadPkg/Unive= rsalPayloadBuild.py index b78c6a7620..e624ec5874 100644 --- a/UefiPayloadPkg/UniversalPayloadBuild.py +++ b/UefiPayloadPkg/UniversalPayloadBuild.py @@ -10,6 +10,31 @@ import subprocess import os=0D import shutil=0D import sys=0D +from ctypes import *=0D +=0D +sys.dont_write_bytecode =3D True=0D +=0D +class UPLD_INFO_HEADER(LittleEndianStructure):=0D + _pack_ =3D 1=0D + _fields_ =3D [=0D + ('Identifier', ARRAY(c_char, 4)),=0D + ('HeaderLength', c_uint32),=0D + ('SpecRevision', c_uint16),=0D + ('Reserved', c_uint16),=0D + ('Revision', c_uint32),=0D + ('Attribute', c_uint32),=0D + ('Capability', c_uint32),=0D + ('ProducerId', ARRAY(c_char, 16)),=0D + ('ImageId', ARRAY(c_char, 16)),=0D + ]=0D +=0D + def __init__(self):=0D + self.Identifier =3D b'UPLD'=0D + self.HeaderLength =3D sizeof(UPLD_INFO_HEADER)=0D + self.HeaderRevision =3D 0x0075=0D + self.Revision =3D 0x0000010105=0D + self.ImageId =3D b'UEFI'=0D + self.ProducerId =3D b'INTEL'=0D =0D def RunCommand(cmd):=0D print(cmd)=0D @@ -37,6 +62,7 @@ def BuildUniversalPayload(Args, MacroList): EntryOutputDir =3D os.path.join(BuildDir, f"{BuildTarget}_{ElfToolChai= n}", os.path.normpath("X64/UefiPayloadPkg/UefiPayloadEntry/UniversalPayload= Entry/DEBUG/UniversalPayloadEntry.dll"))=0D PayloadReportPath =3D os.path.join(BuildDir, "UefiUniversalPayload.txt= ")=0D ModuleReportPath =3D os.path.join(BuildDir, "UefiUniversalPayloadEntry= .txt")=0D + UpldInfoFile =3D os.path.join(BuildDir, "UniversalPayloadInfo.bin")=0D =0D if "CLANG_BIN" in os.environ:=0D LlvmObjcopyPath =3D os.path.join(os.environ["CLANG_BIN"], "llvm-ob= jcopy")=0D @@ -65,12 +91,21 @@ def BuildUniversalPayload(Args, MacroList): BuildModule +=3D Defines=0D RunCommand(BuildModule)=0D =0D + #=0D + # Buid Universal Payload Information Section ".upld_info"=0D + #=0D + upld_info_hdr =3D UPLD_INFO_HEADER()=0D + upld_info_hdr.ImageId =3D Args.ImageId.encode()[:16]=0D + fp =3D open(UpldInfoFile, 'wb')=0D + fp.write(bytearray(upld_info_hdr))=0D + fp.close()=0D +=0D #=0D # Copy the DXEFV as a section in elf format Universal Payload entry.=0D #=0D - remove_section =3D '"%s" -I elf64-x86-64 -O elf64-x86-64 --remove-sect= ion .upld.uefi_fv %s'%(LlvmObjcopyPath, EntryOutputDir)=0D - add_section =3D '"%s" -I elf64-x86-64 -O elf64-x86-64 --add-section .u= pld.uefi_fv=3D%s %s'%(LlvmObjcopyPath, FvOutputDir, EntryOutputDir)=0D - set_section =3D '"%s" -I elf64-x86-64 -O elf64-x86-64 --set-section-al= ignment .upld.uefi_fv=3D16 %s'%(LlvmObjcopyPath, EntryOutputDir)=0D + remove_section =3D '"%s" -I elf64-x86-64 -O elf64-x86-64 --remove-sect= ion .upld_info --remove-section .upld.uefi_fv %s'%(LlvmObjcopyPath, EntryOu= tputDir)=0D + add_section =3D '"%s" -I elf64-x86-64 -O elf64-x86-64 --add-section= .upld_info=3D%s --add-section .upld.uefi_fv=3D%s %s'%(LlvmObjcopyPath, Upl= dInfoFile, FvOutputDir, EntryOutputDir)=0D + set_section =3D '"%s" -I elf64-x86-64 -O elf64-x86-64 --set-section= -alignment .upld.upld_info=3D16 --set-section-alignment .upld.uefi_fv=3D16 = %s'%(LlvmObjcopyPath, EntryOutputDir)=0D RunCommand(remove_section)=0D RunCommand(add_section)=0D RunCommand(set_section)=0D @@ -82,6 +117,7 @@ def main(): parser.add_argument('-t', '--ToolChain')=0D parser.add_argument('-b', '--Target', default=3D'DEBUG')=0D parser.add_argument("-D", "--Macro", action=3D"append", default=3D["UN= IVERSAL_PAYLOAD=3DTRUE"])=0D + parser.add_argument('-i', '--ImageId', type=3Dstr, help=3D'Specify pay= load ID (16 bytes maximal).', default =3D'UEFI')=0D MacroList =3D {}=0D args =3D parser.parse_args()=0D if args.Macro is not None:=0D --=20 2.32.0.windows.2