From nobody Tue May 7 10:46:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1520039544118951.9612613070698; Fri, 2 Mar 2018 17:12:24 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 69FC12250EDE3; Fri, 2 Mar 2018 17:06:12 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3157E22492727 for ; Fri, 2 Mar 2018 17:06:10 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 17:12:20 -0800 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga001.jf.intel.com with ESMTP; 02 Mar 2018 17:12:19 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,414,1515484800"; d="scan'208";a="35549562" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Sat, 3 Mar 2018 09:12:18 +0800 Message-Id: <1520039538-11204-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [Patch V2] BaseTools: DSC Components section support flexible PCD X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yunhua Feng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Yunhua Feng DSC Components section support flexible PCD, and for binary driver, we need patch this value. Update the split char ',' not ', ' because some value may have space, while others may not have this space. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao --- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 15 +++++++++++++++ BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/= Source/Python/GenFds/FfsInfStatement.py index b0b242b..dfff892 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -44,10 +44,11 @@ from PatchPcdValue.PatchPcdValue import PatchBinaryFile from Common.LongFilePathSupport import CopyLongFilePath from Common.LongFilePathSupport import OpenLongFilePath as open import Common.GlobalData as GlobalData from DepexSection import DepexSection from Common.Misc import SaveFileOnChange +from Common.Expression import * =20 ## generate FFS from INF # # class FfsInfStatement(FfsInfStatementClassObject): @@ -277,10 +278,24 @@ class FfsInfStatement(FfsInfStatementClassObject): BuildOptionOverride =3D True break =20 if not DscOverride and not FdfOverride and not BuildOptionOver= ride: continue + + # Support Flexible PCD format + if DefaultValue: + try: + DefaultValue =3D ValueExpressionEx(DefaultValue, Pcd.D= atumType, Platform._GuidDict)(True) + except BadExpression: + EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] V= alue "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValue), File= =3Dself.InfFileName) + + if Pcd.DefaultValue: + try: + Pcd.DefaultValue =3D ValueExpressionEx(Pcd.DefaultValu= e, Pcd.DatumType, Platform._GuidDict)(True) + except BadExpression: + EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] V= alue "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DefaultValue),Fil= e=3Dself.InfFileName) + # Check value, if value are equal, no need to patch if Pcd.DatumType =3D=3D "VOID*": if Pcd.DefaultValue =3D=3D DefaultValue or DefaultValue in= [None, '']: continue # Get the string size from FDF or DSC diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseT= ools/Source/Python/PatchPcdValue/PatchPcdValue.py index 882da81..942ba88 100644 --- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py +++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py @@ -159,14 +159,15 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, = ValueString, MaxSize=3D0): Index =3D Index + 2 elif ValueString.startswith("{") and ValueString.endswith("}"): # # Patch {0x1, 0x2, ...} byte by byte # - ValueList =3D ValueString[1 : len(ValueString) - 1].split(', ') + ValueList =3D ValueString[1 : len(ValueString) - 1].split(',') Index =3D 0 try: for ByteString in ValueList: + ByteString =3D ByteString.strip() if ByteString.upper().startswith('0X'): ByteValue =3D int(ByteString, 16) else: ByteValue =3D int(ByteString) ByteList[ValueOffset + Index] =3D ByteValue % 0x100 --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel