From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by mx.groups.io with SMTP id smtpd.web09.9887.1661854767562122882 for ; Tue, 30 Aug 2022 03:19:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iCVfDoFE; spf=pass (domain: gmail.com, ip: 209.85.167.50, mailfrom: aladyshev22@gmail.com) Received: by mail-lf1-f50.google.com with SMTP id bt10so14871852lfb.1 for ; Tue, 30 Aug 2022 03:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=JrjojLRspGGKj26qOl71wZkF7sFASsG+mEMX58+9Nxc=; b=iCVfDoFESlEJlFc6ipIdNhlhcbwQSdTqRy6ZJbusVT9WtB+AI7yfAK8cTmQzZgpkF9 vKVqS1e/tCVaiU3QSev09i6ODh1KSpBqd2V8IjS2VcpKDvUfSVgf6EHI1GDwzAKmmWMp NkKYpEOTPmKnMx7pGe0WBP6dztzQM9a7nRVc28/n3sdmCVE1k7Zk0XhMFPbP8+l81KuD /GBpBt1hPx2fum6SuD4swYFwomhQlyzEMoL7pIM3JHKlB+Js5nLxGha0+1App+30Z5sJ IbxAebScl7hOCtp0PbxYrg/qj9aPUljqI0sODzJ3RSGELp26ls3E0BENiAUi4dt0MzXk wRYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=JrjojLRspGGKj26qOl71wZkF7sFASsG+mEMX58+9Nxc=; b=GjmKKQNvFayxfaz8QJihvHGkN2kbkAnCf8AWCTvVUEYqKImj2/d5XFkupxnDVeRUhc hBX6OTyEaArro4MGCUMFqfikmR9pfJLV8YrUf7jx+ZwjDBGFmX9MgYup9Hr2e4Po0kew cJXJTclaVi9oqsOiT6OeiYhQXXuX0za9sX/fYbTnIzjt+gv3R6iZZGqFurgegN1x73h1 r/y4VLgoEcD876ibac8MdkPESaYH0NIXCHIkWYr+5u/bwQvEClV1T5xiv4Drakz9ffnr DlBawunpbb3tKU/DUV1DkBfY0Y1mWI41nqkvbGoqZOUU6DKcmW1M2wlJiIut5gb2ox9Y 6d9g== X-Gm-Message-State: ACgBeo26kszJQ7qS5m7q9l12Gwnz1fmvyr/11tuDOBJwpbsP1iiuIhpQ VMyan4O6Ts8UdyDLCu1HxCIwwtTy0Zc= X-Google-Smtp-Source: AA6agR54w0MmiELEI41YYOXzzc9pv7IO5ffFe+u2rjC7Azgvdgx/lAHdk6GockDLy8y69QFAAIL60w== X-Received: by 2002:a05:6512:33d1:b0:494:6876:8a01 with SMTP id d17-20020a05651233d100b0049468768a01mr3173812lfg.252.1661854765601; Tue, 30 Aug 2022 03:19:25 -0700 (PDT) Return-Path: Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id a1-20020ac25201000000b0048b26d4bb64sm1578290lfl.40.2022.08.30.03.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 03:19:25 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: bob.c.feng@intel.com, gaoliming@byosoft.com.cn, yuwei.chen@intel.com, Konstantin Aladyshev Subject: [PATCH v2] BaseTools: Add support for SUBTYPE_GUID section generation Date: Tue, 30 Aug 2022 13:19:25 +0300 Message-Id: <20220830101926.18453-1-aladyshev22@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable EFI_SECTION_FREEFORM_SUBTYPE_GUID is a leaf section type that contains a single EFI_GUID in the header to describe the raw data. Currently is is not possible to generate such section. This patch adds initial support for the generation of such sections. The added syntax for this type of section corresponds to EDKII "[FV] section" documentation from the FDF Specification: ``` SECTION SUBTYPE_GUID =3D ``` Signed-off-by: Konstantin Aladyshev --- .../Source/Python/CommonDataClass/FdfClass.py | 12 +++ BaseTools/Source/Python/GenFds/FdfParser.py | 22 ++++++ .../Python/GenFds/SubTypeGuidSection.py | 76 +++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 BaseTools/Source/Python/GenFds/SubTypeGuidSection.py diff --git a/BaseTools/Source/Python/CommonDataClass/FdfClass.py b/BaseTool= s/Source/Python/CommonDataClass/FdfClass.py index 2fbb7b436a..c8cfdaae32 100644 --- a/BaseTools/Source/Python/CommonDataClass/FdfClass.py +++ b/BaseTools/Source/Python/CommonDataClass/FdfClass.py @@ -190,6 +190,18 @@ class GuidSectionClassObject (SectionClassObject) : self.FvParentAddr =3D None=0D self.IncludeFvSection =3D False=0D =0D +## SubType GUID section data in FDF=0D +#=0D +#=0D +class SubTypeGuidSectionClassObject (SectionClassObject) :=0D + ## The constructor=0D + #=0D + # @param self The object pointer=0D + #=0D + def __init__(self):=0D + SectionClassObject.__init__(self)=0D + self.SubTypeGuid =3D None=0D +=0D ## UI section data in FDF=0D #=0D #=0D diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index 693e62de7e..a9a14ca2bb 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -42,6 +42,7 @@ from .DataSection import DataSection from .DepexSection import DepexSection=0D from .CompressSection import CompressSection=0D from .GuidSection import GuidSection=0D +from .SubTypeGuidSection import SubTypeGuidSection=0D from .Capsule import EFI_CERT_TYPE_PKCS7_GUID, EFI_CERT_TYPE_RSA2048_SHA25= 6_GUID, Capsule=0D from .CapsuleData import CapsuleFfs, CapsulePayload, CapsuleFv, CapsuleFd,= CapsuleAnyFile, CapsuleAfile=0D from .RuleComplexFile import RuleComplexFile=0D @@ -2892,6 +2893,27 @@ class FdfParser: DepexSectionObj.Expression =3D self._SkippedChars.rstrip(T_CHA= R_BRACE_R)=0D Obj.SectionList.append(DepexSectionObj)=0D =0D + elif self._IsKeyword("SUBTYPE_GUID"):=0D + if AlignValue =3D=3D 'Auto':=0D + raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber)=0D + SubTypeGuidValue =3D None=0D + if not self._GetNextGuid():=0D + raise Warning.Expected("GUID", self.FileName, self.Current= LineNumber)=0D + else:=0D + SubTypeGuidValue =3D self._Token=0D +=0D + if not self._IsToken(TAB_EQUAL_SPLIT):=0D + raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber)=0D + if not self._GetNextToken():=0D + raise Warning.Expected("section file path", self.FileName,= self.CurrentLineNumber)=0D + FileName =3D self._Token=0D +=0D + SubTypeGuidSectionObj =3D SubTypeGuidSection()=0D + SubTypeGuidSectionObj.Alignment =3D AlignValue=0D + SubTypeGuidSectionObj.SubTypeGuid =3D SubTypeGuidValue=0D + SubTypeGuidSectionObj.SectFileName =3D FileName=0D + Obj.SectionList.append(SubTypeGuidSectionObj)=0D +=0D else:=0D if not self._GetNextWord():=0D raise Warning.Expected("section type", self.FileName, self= .CurrentLineNumber)=0D diff --git a/BaseTools/Source/Python/GenFds/SubTypeGuidSection.py b/BaseToo= ls/Source/Python/GenFds/SubTypeGuidSection.py new file mode 100644 index 0000000000..d522380117 --- /dev/null +++ b/BaseTools/Source/Python/GenFds/SubTypeGuidSection.py @@ -0,0 +1,76 @@ +## @file=0D +# process Subtype GUIDed section generation=0D +#=0D +# Copyright (c) 2022, Konstantin Aladyshev =0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +=0D +##=0D +# Import Modules=0D +#=0D +from __future__ import absolute_import=0D +from . import Section=0D +import subprocess=0D +from .Ffs import SectionSuffix=0D +import Common.LongFilePathOs as os=0D +from .GenFdsGlobalVariable import GenFdsGlobalVariable=0D +from .GenFdsGlobalVariable import FindExtendTool=0D +from CommonDataClass.FdfClass import SubTypeGuidSectionClassObject=0D +import sys=0D +from Common import EdkLogger=0D +from Common.BuildToolError import *=0D +from .FvImageSection import FvImageSection=0D +from Common.LongFilePathSupport import OpenLongFilePath as open=0D +from Common.DataType import *=0D +=0D +## generate SubType GUIDed section=0D +#=0D +#=0D +class SubTypeGuidSection(SubTypeGuidSectionClassObject) :=0D +=0D + ## The constructor=0D + #=0D + # @param self The object pointer=0D + #=0D + def __init__(self):=0D + SubTypeGuidSectionClassObject.__init__(self)=0D +=0D + ## GenSection() method=0D + #=0D + # Generate GUIDed section=0D + #=0D + # @param self The object pointer=0D + # @param OutputPath Where to place output file=0D + # @param ModuleName Which module this section belongs to=0D + # @param SecNum Index of section=0D + # @param KeyStringList Filter for inputs of section generation=0D + # @param FfsInf FfsInfStatement object that contains this sect= ion data=0D + # @param Dict dictionary contains macro and its value=0D + # @retval tuple (Generated file name, section alignment)=0D + #=0D + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3DNone, IsMakefile=3DFalse):=0D + #=0D + # Generate all section=0D + #=0D + self.KeyStringList =3D KeyStringList=0D + self.CurrentArchList =3D GenFdsGlobalVariable.ArchList=0D + if FfsInf is not None:=0D + self.Alignment =3D FfsInf.__ExtendMacro__(self.Alignment)=0D + self.SubTypeGuid =3D FfsInf.__ExtendMacro__(self.SubTypeGuid)= =0D + self.SectionType =3D FfsInf.__ExtendMacro__(self.SectionType)= =0D + self.CurrentArchList =3D [FfsInf.CurrentArch]=0D +=0D + if Dict is None:=0D + Dict =3D {}=0D +=0D + self.SectFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(s= elf.SectFileName)=0D + self.SectFileName =3D GenFdsGlobalVariable.MacroExtend(self.SectFi= leName, Dict)=0D +=0D + OutputFile =3D os.path.join(OutputPath, ModuleName + SUP_MODULE_SE= C + SecNum + SectionSuffix.get("SUBTYPE_GUID"))=0D + GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileNam= e], 'EFI_SECTION_FREEFORM_SUBTYPE_GUID', Guid=3Dself.SubTypeGuid, IsMakefil= e=3DIsMakefile)=0D +=0D + OutputFileList =3D []=0D + OutputFileList.append(OutputFile)=0D + return OutputFileList, self.Alignment=0D +=0D --=20 2.25.1