From nobody Sun May 5 19:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+91583+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91583+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1658325681; cv=none; d=zohomail.com; s=zohoarc; b=J7PcNCL+6oMkAAdMNNdtC+jndp6nxgxExjQYDDLzF1/7kDn3pWw3Cn5Mx+IAyXphj/7pWwE/GjYU8AqDaAYesb9qzYbT5S2oQAAA0Fql2+nBPjZeYE4AVk/In/VyvBaapeTY/cur1m94xcfnYYxJqxDxj+4lVlaOeg+pdXZy8Z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658325681; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=ahvvAlZ7NCMYDT4HnLZTts4aaYNxG2xRDRS5DJFGI2g=; b=iMz7JUjh/XJ7p30RmQucPqVPCpfXC/soaRa4XOrTSYGm8ecmgTI1BTQyCloXf208WBRhAfcgCdWx58fGDx5o2cQpi58OEHodZKiVGNLQcBR46IC+bpPP1WydBu0IGItMbNjTqzoGImioyT/RS/KJe0p+9XVZyaX6KkrPd7Ax7Tc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91583+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1658325681644474.16958582188227; Wed, 20 Jul 2022 07:01:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BcLvYY1788612xrvPa0oeh99; Wed, 20 Jul 2022 07:01:21 -0700 X-Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mx.groups.io with SMTP id smtpd.web08.54312.1658325680428562690 for ; Wed, 20 Jul 2022 07:01:20 -0700 X-Received: by mail-lf1-f53.google.com with SMTP id bf9so30340869lfb.13 for ; Wed, 20 Jul 2022 07:01:20 -0700 (PDT) X-Gm-Message-State: ybBTAZ6ZVsl9nFVUCYXu55iLx1787277AA= X-Google-Smtp-Source: AGRyM1sAte5VYZSCxRCi86VmvT/BysqxUcueRJD2gkcXpUyYwKOjUI2cDbqPa/ZRT4iOZErGFves+A== X-Received: by 2002:a05:6512:228d:b0:489:2309:fd63 with SMTP id f13-20020a056512228d00b004892309fd63mr21851693lfu.232.1658325678356; Wed, 20 Jul 2022 07:01:18 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 3-20020ac25f03000000b004790a4ce3e5sm3843211lfq.278.2022.07.20.07.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 07:01:17 -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: [edk2-devel] [PATCH] BaseTools: Add support for SUBTYPE_GUID section generation Date: Wed, 20 Jul 2022 17:01:17 +0300 Message-Id: <20220720140117.23721-1-aladyshev22@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,aladyshev22@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658325681; bh=JhDsKFkG+DW2ppCUIHHk0Q8sXrQDyOmJtELPhmrP2s8=; h=Cc:Date:From:Reply-To:Subject:To; b=ee3eJVBK5mDrWR3b1CLYNdda+sMLNty9naPjI2Ij0w7HQOJM0WX8APjogpwagqscWaz amJg4HQPJzq276XkcMQ+TBlqfsm6OZXGQWbX2mmvS+gKg9em1IP/mZDCMS10uVgDMqXc4 /pU/aFINTkVy8CosrCN4chTqdiY+kYBC0Nk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658325683379100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Bob Feng --- .../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 self.IncludeFvSection =3D False =20 +## SubType GUID section data in FDF +# +# +class SubTypeGuidSectionClassObject (SectionClassObject) : + ## The constructor + # + # @param self The object pointer + # + def __init__(self): + SectionClassObject.__init__(self) + self.SubTypeGuid =3D None + ## UI section data in FDF # # diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index 5c8263f9bc..aa18fef09e 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 from .CompressSection import CompressSection from .GuidSection import GuidSection +from .SubTypeGuidSection import SubTypeGuidSection from .Capsule import EFI_CERT_TYPE_PKCS7_GUID, EFI_CERT_TYPE_RSA2048_SHA25= 6_GUID, Capsule from .CapsuleData import CapsuleFfs, CapsulePayload, CapsuleFv, CapsuleFd,= CapsuleAnyFile, CapsuleAfile from .RuleComplexFile import RuleComplexFile @@ -2892,6 +2893,27 @@ class FdfParser: DepexSectionObj.Expression =3D self._SkippedChars.rstrip(T_CHA= R_BRACE_R) Obj.SectionList.append(DepexSectionObj) =20 + elif self._IsKeyword("SUBTYPE_GUID"): + if AlignValue =3D=3D 'Auto': + raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) + SubTypeGuidValue =3D None + if not self._GetNextGuid(): + raise Warning.Expected("GUID", self.FileName, self.Current= LineNumber) + else: + SubTypeGuidValue =3D self._Token + + if not self._IsToken(TAB_EQUAL_SPLIT): + raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + if not self._GetNextToken(): + raise Warning.Expected("section file path", self.FileName,= self.CurrentLineNumber) + FileName =3D self._Token + + SubTypeGuidSectionObj =3D SubTypeGuidSection() + SubTypeGuidSectionObj.Alignment =3D AlignValue + SubTypeGuidSectionObj.SubTypeGuid =3D SubTypeGuidValue + SubTypeGuidSectionObj.SectFileName =3D FileName + Obj.SectionList.append(SubTypeGuidSectionObj) + else: if not self._GetNextWord(): raise Warning.Expected("section type", self.FileName, self= .CurrentLineNumber) 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 +# process Subtype GUIDed section generation +# +# Copyright (c) 2022, Konstantin Aladyshev +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +## +# Import Modules +# +from __future__ import absolute_import +from . import Section +import subprocess +from .Ffs import SectionSuffix +import Common.LongFilePathOs as os +from .GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import FindExtendTool +from CommonDataClass.FdfClass import SubTypeGuidSectionClassObject +import sys +from Common import EdkLogger +from Common.BuildToolError import * +from .FvImageSection import FvImageSection +from Common.LongFilePathSupport import OpenLongFilePath as open +from Common.DataType import * + +## generate SubType GUIDed section +# +# +class SubTypeGuidSection(SubTypeGuidSectionClassObject) : + + ## The constructor + # + # @param self The object pointer + # + def __init__(self): + SubTypeGuidSectionClassObject.__init__(self) + + ## GenSection() method + # + # Generate GUIDed section + # + # @param self The object pointer + # @param OutputPath Where to place output file + # @param ModuleName Which module this section belongs to + # @param SecNum Index of section + # @param KeyStringList Filter for inputs of section generation + # @param FfsInf FfsInfStatement object that contains this sect= ion data + # @param Dict dictionary contains macro and its value + # @retval tuple (Generated file name, section alignment) + # + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3DNone, IsMakefile=3DFalse): + # + # Generate all section + # + self.KeyStringList =3D KeyStringList + self.CurrentArchList =3D GenFdsGlobalVariable.ArchList + if FfsInf is not None: + self.Alignment =3D FfsInf.__ExtendMacro__(self.Alignment) + self.SubTypeGuid =3D FfsInf.__ExtendMacro__(self.SubTypeGuid) + self.SectionType =3D FfsInf.__ExtendMacro__(self.SectionType) + self.CurrentArchList =3D [FfsInf.CurrentArch] + + if Dict is None: + Dict =3D {} + + self.SectFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(s= elf.SectFileName) + self.SectFileName =3D GenFdsGlobalVariable.MacroExtend(self.SectFi= leName, Dict) + + OutputFile =3D os.path.join(OutputPath, ModuleName + SUP_MODULE_SE= C + SecNum + SectionSuffix.get("SUBTYPE_GUID")) + GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileNam= e], 'EFI_SECTION_FREEFORM_SUBTYPE_GUID', Guid=3Dself.SubTypeGuid, IsMakefil= e=3DIsMakefile) + + OutputFileList =3D [] + OutputFileList.append(OutputFile) + return OutputFileList, self.Alignment + --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91583): https://edk2.groups.io/g/devel/message/91583 Mute This Topic: https://groups.io/mt/92504973/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-