From nobody Sat May 18 08:47:01 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+92975+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+92975+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661854769; cv=none; d=zohomail.com; s=zohoarc; b=TpAz7J9tx3PG6V6tlw3IHes3UOE5SWE9Ag0wuvL91bZrG9/lOBvv3fkoHYo8R3mVBxXgLDRhyF53mTP4T/jdXxZYpULnHpkmrPthJ7v4k2xGWN7Lox7/41ps13umHwtd3OUB27gN6mtk9znaO74STTNWduGoWm85cFiQpNhEcP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661854769; 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=GzG+zzlUhcSRYWh6l+jDuDItewiCq9pcJWwW1RMMZxE=; b=RcGUNV0q80UC8ZqOkbttqpg5NA6UzmphlkjGYHZCBcoikXetFJzKmEHW7LLe5gSEkZe7YF01Qe2rjx+hxsero3YQJ5yHakb50p2fPrZ8MrexwMP98vWYIpHPtVJj9UOCMB7HeWc4R/10j3hGL2Rm7c2A/pwWxa3OgzpQskex4us= 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+92975+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 1661854769900478.08059704087384; Tue, 30 Aug 2022 03:19:29 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id MZ4TYY1788612x1fNIbly5Go; Tue, 30 Aug 2022 03:19:28 -0700 X-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 X-Received: by mail-lf1-f50.google.com with SMTP id bt10so14871852lfb.1 for ; Tue, 30 Aug 2022 03:19:27 -0700 (PDT) X-Gm-Message-State: Ujxakyseq8Ak0NFGg9flKtKEx1787277AA= 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) X-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: [edk2-devel] [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> 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=1661854768; bh=e/qn3M1w0odCGc1cohZP17xC0jlBLngtCDQQRD25knE=; h=Cc:Date:From:Reply-To:Subject:To; b=F8kVAJlo6smDg4d91Acigi5Xq0flszg2We7/WK3EaTDRS3pieVXmFWGZcIlI5KNx6qs FsRY3nSOaj6W/W112uw15aXlHbSYm7hdeSzVaL57chTiezGvrdN4wU1GnMI55uhitbHpe FMH3rbTwn6y/1B0yj1egkCSfPmAyR84sczo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1661854771485100001 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 --- .../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 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 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 (#92975): https://edk2.groups.io/g/devel/message/92975 Mute This Topic: https://groups.io/mt/93345705/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-