From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 7098121D2BEF6 for ; Wed, 31 Jan 2018 00:54:34 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2018 01:00:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,439,1511856000"; d="scan'208";a="170535020" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga004.jf.intel.com with ESMTP; 31 Jan 2018 01:00:09 -0800 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 31 Jan 2018 01:00:09 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 31 Jan 2018 01:00:08 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by shsmsx102.ccr.corp.intel.com ([169.254.2.124]) with mapi id 14.03.0319.002; Wed, 31 Jan 2018 17:00:06 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Update BPDG to support L'' and '' format as VPD Pcd Value Thread-Index: AQHTmd3ierj0gGJDHUi8rBDtnQ0Gb6ONsAiw Date: Wed, 31 Jan 2018 09:00:06 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1B9E1D@SHSMSX104.ccr.corp.intel.com> References: <1517325626-10712-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1517325626-10712-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Update BPDG to support L'' and '' format as VPD Pcd Value 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: , X-List-Received-Date: Wed, 31 Jan 2018 08:54:34 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >Yonghong Zhu >Sent: Tuesday, January 30, 2018 11:20 PM >To: edk2-devel@lists.01.org >Subject: [edk2] [Patch] BaseTools: Update BPDG to support L'' and '' forma= t as >VPD Pcd Value > >Current Pcd value support flexible format, this patch add support for >BPDG Tool to support L'' and '' format. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Yonghong Zhu >--- > BaseTools/Source/Python/BPDG/GenVpd.py | 32 ++++++++++++++++++---- >---------- > BaseTools/Source/Python/Common/Misc.py | 6 +++--- > 2 files changed, 21 insertions(+), 17 deletions(-) > >diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py >b/BaseTools/Source/Python/BPDG/GenVpd.py >index 9861e7d..612400d 100644 >--- a/BaseTools/Source/Python/BPDG/GenVpd.py >+++ b/BaseTools/Source/Python/BPDG/GenVpd.py >@@ -59,11 +59,11 @@ class PcdEntry: > EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, > "Invalid PCD format(Name: %s File: %s Line: %= s), no PcdSize >specified!" % (self.PcdCName, self.FileName, self.Lineno)) > > self._GenOffsetValue () > >- ## Analyze the string value to judge the PCD's datum type euqal to Bo= olean >or not. >+ ## Analyze the string value to judge the PCD's datum type equal to >Boolean or not. > # > # @param ValueString PCD's value > # @param Size PCD's size > # > # @retval True PCD's datum type is Boolean >@@ -162,42 +162,45 @@ class PcdEntry: > "Invalid size or value for PCD %s to pack(Fil= e: %s Line: %s)." % >(self.PcdCName, self.FileName, self.Lineno)) > > ## Pack VOID* type VPD PCD's value form string to binary type. > # > # The VOID* type of string divided into 3 sub-type: >- # 1: L"String", Unicode type string. >- # 2: "String", Ascii type string. >+ # 1: L"String"/L'String', Unicode type string. >+ # 2: "String"/'String', Ascii type string. > # 3: {bytearray}, only support byte-array. > # > # @param ValueString The Integer type string for pack. > # > def _PackPtrValue(self, ValueString, Size): >- if ValueString.startswith('L"'): >+ if ValueString.startswith('L"') or ValueString.startswith("L'"): > self._PackUnicode(ValueString, Size) > elif ValueString.startswith('{') and ValueString.endswith('}'): > self._PackByteArray(ValueString, Size) >- elif ValueString.startswith('"') and ValueString.endswith('"'): >+ elif (ValueString.startswith('"') and ValueString.endswith('"')) = or >(ValueString.startswith("'") and ValueString.endswith("'")): > self._PackString(ValueString, Size) > else: > EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, > "Invalid VOID* type PCD %s value %s (File: %s= Line: %s)" % >(self.PcdCName, ValueString, self.FileName, self.Lineno)) > > ## Pack an Ascii PCD value. > # >- # An Ascii string for a PCD should be in format as "". >+ # An Ascii string for a PCD should be in format as ""/''. > # > def _PackString(self, ValueString, Size): > if (Size < 0): > EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, > "Invalid parameter Size %s of PCD %s!(File: %= s Line: %s)" % >(self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno)) > if (ValueString =3D=3D ""): > EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Inval= id >parameter ValueString %s of PCD %s!(File: %s Line: %s)" % >(self.PcdUnpackValue, self.PcdCName, self.FileName, self.Lineno)) >- if (len(ValueString) < 2): >- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "For >PCD: %s ,ASCII string %s at least contains two!(File: %s Line: %s)" % >(self.PcdCName, self.PcdUnpackValue, self.FileName, self.Lineno)) >+ >+ QuotedFlag =3D True >+ if ValueString.startswith("'"): >+ QuotedFlag =3D False > > ValueString =3D ValueString[1:-1] >- if len(ValueString) + 1 > Size: >+ # No null-terminator in 'string' >+ if (QuotedFlag and len(ValueString) + 1 > Size) or (not QuotedFla= g and >len(ValueString) > Size): > EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW, > "PCD value string %s is exceed to size %d(Fil= e: %s Line: %s)" % >(ValueString, Size, self.FileName, self.Lineno)) > try: > self.PcdValue =3D pack('%ds' % Size, ValueString) > except: >@@ -256,23 +259,24 @@ class PcdEntry: > > self.PcdValue =3D ReturnArray.tolist() > > ## Pack a unicode PCD value into byte array. > # >- # A unicode string for a PCD should be in format as L"". >+ # A unicode string for a PCD should be in format as L""/L''. > # > def _PackUnicode(self, UnicodeString, Size): > if (Size < 0): > EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Inval= id >parameter Size %s of PCD %s!(File: %s Line: %s)" % \ > (self.PcdBinSize, self.PcdCName, self.FileNa= me, self.Lineno)) >- if (len(UnicodeString) < 3): >- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "For >PCD: %s ,ASCII string %s at least contains two!(File: %s Line: %s)" % \ >- (self.PcdCName, self.PcdUnpackValue, self.Fil= eName, >self.Lineno)) > >+ QuotedFlag =3D True >+ if UnicodeString.startswith("L'"): >+ QuotedFlag =3D False > UnicodeString =3D UnicodeString[2:-1] > >- if (len(UnicodeString) + 1) * 2 > Size: >+ # No null-terminator in L'string' >+ if (QuotedFlag and (len(UnicodeString) + 1) * 2 > Size) or (not >QuotedFlag and len(UnicodeString) * 2 > Size): > EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW, > "The size of unicode string %s is too larger = for size %s(File: %s >Line: %s)" % \ > (UnicodeString, Size, self.FileName, self.Lin= eno)) > > ReturnArray =3D array.array('B') >diff --git a/BaseTools/Source/Python/Common/Misc.py >b/BaseTools/Source/Python/Common/Misc.py >index a8ed718..ef52154 100644 >--- a/BaseTools/Source/Python/Common/Misc.py >+++ b/BaseTools/Source/Python/Common/Misc.py >@@ -1,9 +1,9 @@ > ## @file > # Common routines used by all tools > # >-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
>+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the B= SD >License > # which accompanies this distribution. The full text of the license may = be >found at > # http://opensource.org/licenses/bsd-license.php > # >@@ -1816,14 +1816,14 @@ def AnalyzeVpdPcdData(Setting): > # > def CheckPcdDatum(Type, Value): > if Type =3D=3D "VOID*": > ValueRe =3D re.compile(r'\s*L?\".*\"\s*$') > if not (((Value.startswith('L"') or Value.startswith('"')) and >Value.endswith('"')) >- or (Value.startswith('{') and Value.endswith('}')) >+ or (Value.startswith('{') and Value.endswith('}')) or >(Value.startswith("L'") or Value.startswith("'") and Value.endswith("'")) > ): > return False, "Invalid value [%s] of type [%s]; must be in th= e form of {...} >for array"\ >- ", or \"...\" for string, or L\"...\" for unico= de string" % (Value, >Type) >+ ", \"...\" or \'...\' for string, L\"...\" or L= \'...\' for unicode string" % >(Value, Type) > elif ValueRe.match(Value): > # Check the chars in UnicodeString or CString is printable > if Value.startswith("L"): > Value =3D Value[2:-1] > else: >-- >2.6.1.windows.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel