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.88; helo=mga01.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 EA5112118EF59 for ; Fri, 9 Nov 2018 07:24:42 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2018 07:24:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,483,1534834800"; d="scan'208";a="272740915" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 09 Nov 2018 07:24:41 -0800 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 9 Nov 2018 07:24:41 -0800 Received: from fmsmsx101.amr.corp.intel.com ([169.254.1.202]) by FMSMSX153.amr.corp.intel.com ([169.254.9.212]) with mapi id 14.03.0415.000; Fri, 9 Nov 2018 07:24:40 -0800 From: "Carsey, Jaben" To: "Feng, Bob C" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [edk2] [PATCH] BaseTools: Enable Pcd Array support. Thread-Index: AQHUdnrzY7rbDnRDTk6f5cfILIq9I6VHkxBw Date: Fri, 9 Nov 2018 15:24:39 +0000 Message-ID: References: <20181107091834.21004-1-bob.c.feng@intel.com> In-Reply-To: <20181107091834.21004-1-bob.c.feng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjAxM2JmMjctOWM0NS00NDk3LTgxODQtMGU3MzU5ODY0MWQxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZWFyd0tjTncwbGc3N0VDclwvbUN4UWZROU9yaUdDMHJPeEJnZ3htMkR1aVdHUGhzdXFBNEN4OXVBT1hDN3RtUUkifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.1.200.108] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools: Enable Pcd Array support. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Nov 2018 15:24:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable How concerned with spaces in the DSC lines are we? The following looks ver= y sensitive to spaces and could be replaced with a regular expression that = would be more flexible. if "{CODE(" not in PcdValue: aprox: if re.match('[{]\w*CODE\w*[(]', PcdValue) > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > BobCF > Sent: Wednesday, November 07, 2018 1:19 AM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [edk2] [PATCH] BaseTools: Enable Pcd Array support. >=20 > From: "bob.c.feng@intel.com" >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D1292 >=20 > This patch is going to enable Array data type for PCD. >=20 > 1. Support Pcd ARRAY as Structure PCD type > including basic datatype array and structure array. > For example: > gStructuredPcdPkgTokenSpaceGuid.PcdTest|{0x0}|TEST[10]|0x00010080 >=20 > gStructuredPcdPkgTokenSpaceGuid.PcdTest2|{0x0}|UINT8[10]|0x00010081 > 2. Support C CODE style value initialization in DEC/DSC. > For example: > gStructuredPcdPkgTokenSpaceGuid.PcdTest|{CODE({ > {0, {0, 0, 0, 0, 0, 0, 0}}, > {0, {0, 0, 0, 0, 0, 0, 0}}, > {0, {0, 0, 0, 0, 0, 0, 0}}, > {0, {0, 0, 0, 0, 0, 0, 0}}, > {0, {0, 0, 0, 0, 0, 0, 0}}, > {0, {0, 0, 0, 0, 0, 0, 0}}, > {0, {0, 0, 0, 0, 0, 0, 0}}, > {0, {0, 0, 0, 0, 0, 0, 0}}, > {0, {0, 0, 0, 0, 0, 0, 0}}, > {0, {0, 0, 0, 0, 0, 0, 0}}, > })} >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Bob Feng > Cc: Liming Gao > --- > BaseTools/Source/Python/Common/Expression.py | 396 +++++++++-------- > - > BaseTools/Source/Python/Common/Misc.py | 2 + > .../Python/Workspace/BuildClassObject.py | 85 +++- > .../Source/Python/Workspace/DecBuildData.py | 29 +- > .../Source/Python/Workspace/DscBuildData.py | 384 +++++++++++------ > .../Source/Python/Workspace/MetaFileParser.py | 86 +++- > 6 files changed, 644 insertions(+), 338 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/Common/Expression.py > b/BaseTools/Source/Python/Common/Expression.py > index a21ab5daa7..f6e245be70 100644 > --- a/BaseTools/Source/Python/Common/Expression.py > +++ b/BaseTools/Source/Python/Common/Expression.py > @@ -820,221 +820,219 @@ class ValueExpressionEx(ValueExpression): >=20 > def __call__(self, RealValue=3DFalse, Depth=3D0): > PcdValue =3D self.PcdValue > - try: > - PcdValue =3D ValueExpression.__call__(self, RealValue, Depth= ) > - if self.PcdType =3D=3D TAB_VOID and (PcdValue.startswith("'"= ) or > PcdValue.startswith("L'")): > - PcdValue, Size =3D ParseFieldValue(PcdValue) > - PcdValueList =3D [] > - for I in range(Size): > - PcdValueList.append('0x%02X'%(PcdValue & 0xff)) > - PcdValue =3D PcdValue >> 8 > - PcdValue =3D '{' + ','.join(PcdValueList) + '}' > - elif self.PcdType in TAB_PCD_NUMERIC_TYPES and > (PcdValue.startswith("'") or \ > - PcdValue.startswith('"') or PcdValue.startswith("L= '") or > PcdValue.startswith('L"') or PcdValue.startswith('{')): > - raise BadExpression > - except WrnExpression as Value: > - PcdValue =3D Value.result > - except BadExpression as Value: > - if self.PcdType in TAB_PCD_NUMERIC_TYPES: > - PcdValue =3D PcdValue.strip() > - if PcdValue.startswith('{') and PcdValue.endswith('}'): > - PcdValue =3D SplitPcdValueString(PcdValue[1:-1]) > - if ERR_STRING_CMP.split(':')[0] in Value.message: > - raise BadExpression("Type: %s, Value: %s, %s" % (sel= f.PcdType, > PcdValue, Value)) > - if isinstance(PcdValue, type([])): > - TmpValue =3D 0 > - Size =3D 0 > - ValueType =3D '' > - for Item in PcdValue: > - Item =3D Item.strip() > - if Item.startswith(TAB_UINT8): > - ItemSize =3D 1 > - ValueType =3D TAB_UINT8 > - elif Item.startswith(TAB_UINT16): > - ItemSize =3D 2 > - ValueType =3D TAB_UINT16 > - elif Item.startswith(TAB_UINT32): > - ItemSize =3D 4 > - ValueType =3D TAB_UINT32 > - elif Item.startswith(TAB_UINT64): > - ItemSize =3D 8 > - ValueType =3D TAB_UINT64 > - elif Item[0] in {'"', "'", 'L'}: > - ItemSize =3D 0 > - ValueType =3D TAB_VOID > - else: > - ItemSize =3D 0 > - ValueType =3D TAB_UINT8 > - Item =3D ValueExpressionEx(Item, ValueType, self= ._Symb)(True) > - > - if ItemSize =3D=3D 0: > - try: > - tmpValue =3D int(Item, 0) > - if tmpValue > 255: > - raise BadExpression("Byte array num= ber %s should less > than 0xFF." % Item) > - except BadExpression as Value: > - raise BadExpression(Value) > - except ValueError: > - pass > - ItemValue, ItemSize =3D ParseFieldValue(Item= ) > - else: > - ItemValue =3D ParseFieldValue(Item)[0] > - > - if isinstance(ItemValue, type('')): > - ItemValue =3D int(ItemValue, 0) > - > - TmpValue =3D (ItemValue << (Size * 8)) | TmpValu= e > - Size =3D Size + ItemSize > - else: > - try: > - TmpValue, Size =3D ParseFieldValue(PcdValue) > - except BadExpression as Value: > - raise BadExpression("Type: %s, Value: %s, %s" % = (self.PcdType, > PcdValue, Value)) > - if isinstance(TmpValue, type('')): > - try: > - TmpValue =3D int(TmpValue) > - except: > - raise BadExpression(Value) > - else: > - PcdValue =3D '0x%0{}X'.format(Size) % (TmpValue) > - if TmpValue < 0: > - raise BadExpression('Type %s PCD Value is negative'= % > self.PcdType) > - if self.PcdType =3D=3D TAB_UINT8 and Size > 1: > - raise BadExpression('Type %s PCD Value Size is Large= r than 1 byte' > % self.PcdType) > - if self.PcdType =3D=3D TAB_UINT16 and Size > 2: > - raise BadExpression('Type %s PCD Value Size is Large= r than 2 byte' > % self.PcdType) > - if self.PcdType =3D=3D TAB_UINT32 and Size > 4: > - raise BadExpression('Type %s PCD Value Size is Large= r than 4 byte' > % self.PcdType) > - if self.PcdType =3D=3D TAB_UINT64 and Size > 8: > - raise BadExpression('Type %s PCD Value Size is Large= r than 8 byte' > % self.PcdType) > - else: > - try: > - TmpValue =3D int(PcdValue) > - TmpList =3D [] > - if TmpValue.bit_length() =3D=3D 0: > - PcdValue =3D '{0x00}' > - else: > - for I in range((TmpValue.bit_length() + 7) / 8): > - TmpList.append('0x%02x' % ((TmpValue >> I * = 8) & 0xff)) > - PcdValue =3D '{' + ', '.join(TmpList) + '}' > - except: > - if PcdValue.strip().startswith('{'): > - PcdValueList =3D SplitPcdValueString(PcdValue.st= rip()[1:-1]) > - LabelDict =3D {} > - NewPcdValueList =3D [] > - LabelOffset =3D 0 > - for Item in PcdValueList: > - # compute byte offset of every LABEL > - LabelList =3D _ReLabel.findall(Item) > - Item =3D _ReLabel.sub('', Item) > + if "{CODE(" not in PcdValue: > + try: > + PcdValue =3D ValueExpression.__call__(self, RealValue, D= epth) > + if self.PcdType =3D=3D TAB_VOID and (PcdValue.startswith= ("'") or > PcdValue.startswith("L'")): > + PcdValue, Size =3D ParseFieldValue(PcdValue) > + PcdValueList =3D [] > + for I in range(Size): > + PcdValueList.append('0x%02X'%(PcdValue & 0xff)) > + PcdValue =3D PcdValue >> 8 > + PcdValue =3D '{' + ','.join(PcdValueList) + '}' > + elif self.PcdType in TAB_PCD_NUMERIC_TYPES and > (PcdValue.startswith("'") or \ > + PcdValue.startswith('"') or PcdValue.startswit= h("L'") or > PcdValue.startswith('L"') or PcdValue.startswith('{')): > + raise BadExpression > + except WrnExpression as Value: > + PcdValue =3D Value.result > + except BadExpression as Value: > + if self.PcdType in TAB_PCD_NUMERIC_TYPES: > + PcdValue =3D PcdValue.strip() > + if PcdValue.startswith('{') and PcdValue.endswith('}= '): > + PcdValue =3D SplitPcdValueString(PcdValue[1:-1]) > + if isinstance(PcdValue, type([])): > + TmpValue =3D 0 > + Size =3D 0 > + ValueType =3D '' > + for Item in PcdValue: > Item =3D Item.strip() > - if LabelList: > - for Label in LabelList: > - if not IsValidCName(Label): > - raise BadExpression('%s is not a= valid c variable name' % > Label) > - if Label not in LabelDict: > - LabelDict[Label] =3D str(LabelOf= fset) > if Item.startswith(TAB_UINT8): > - LabelOffset =3D LabelOffset + 1 > + ItemSize =3D 1 > + ValueType =3D TAB_UINT8 > elif Item.startswith(TAB_UINT16): > - LabelOffset =3D LabelOffset + 2 > + ItemSize =3D 2 > + ValueType =3D TAB_UINT16 > elif Item.startswith(TAB_UINT32): > - LabelOffset =3D LabelOffset + 4 > + ItemSize =3D 4 > + ValueType =3D TAB_UINT32 > elif Item.startswith(TAB_UINT64): > - LabelOffset =3D LabelOffset + 8 > + ItemSize =3D 8 > + ValueType =3D TAB_UINT64 > + elif Item[0] in {'"', "'", 'L'}: > + ItemSize =3D 0 > + ValueType =3D TAB_VOID > else: > + ItemSize =3D 0 > + ValueType =3D TAB_UINT8 > + Item =3D ValueExpressionEx(Item, ValueType, > self._Symb)(True) > + if ItemSize =3D=3D 0: > try: > - ItemValue, ItemSize =3D ParseFieldVa= lue(Item) > - LabelOffset =3D LabelOffset + ItemSi= ze > - except: > - LabelOffset =3D LabelOffset + 1 > - > - for Item in PcdValueList: > - # for LABEL parse > - Item =3D Item.strip() > - try: > - Item =3D _ReLabel.sub('', Item) > - except: > - pass > - try: > - OffsetList =3D _ReOffset.findall(Item) > - except: > - pass > - # replace each offset, except errors > - for Offset in OffsetList: > - try: > - Item =3D Item.replace('OFFSET_OF({})= '.format(Offset), > LabelDict[Offset]) > - except: > - raise BadExpression('%s not defined'= % Offset) > - > - NewPcdValueList.append(Item) > - > - AllPcdValueList =3D [] > - for Item in NewPcdValueList: > - Size =3D 0 > - ValueStr =3D '' > - TokenSpaceGuidName =3D '' > - if Item.startswith(TAB_GUID) and Item.endswi= th(')'): > - try: > - TokenSpaceGuidName =3D re.search('GU= ID\((\w+)\)', > Item).group(1) > - except: > + tmpValue =3D int(Item, 0) > + if tmpValue > 255: > + raise BadExpression("Byte array= number %s should less > than 0xFF." % Item) > + except BadExpression as Value: > + raise BadExpression(Value) > + except ValueError: > pass > - if TokenSpaceGuidName and TokenSpaceGuid= Name in > self._Symb: > - Item =3D 'GUID(' + self._Symb[TokenS= paceGuidName] + ')' > - elif TokenSpaceGuidName: > - raise BadExpression('%s not found in= DEC file' % > TokenSpaceGuidName) > - Item, Size =3D ParseFieldValue(Item) > - for Index in range(0, Size): > - ValueStr =3D '0x%02X' % (int(Item) &= 255) > - Item >>=3D 8 > - AllPcdValueList.append(ValueStr) > - continue > - elif Item.startswith('DEVICE_PATH') and Item= .endswith(')'): > - Item, Size =3D ParseFieldValue(Item) > - AllPcdValueList.append(Item[1:-1]) > - continue > + ItemValue, ItemSize =3D ParseFieldValue(= Item) > else: > - ValueType =3D "" > + ItemValue =3D ParseFieldValue(Item)[0] > + > + if isinstance(ItemValue, type('')): > + ItemValue =3D int(ItemValue, 0) > + > + TmpValue =3D (ItemValue << (Size * 8)) | Tmp= Value > + Size =3D Size + ItemSize > + else: > + try: > + TmpValue, Size =3D ParseFieldValue(PcdValue) > + except BadExpression as Value: > + raise BadExpression("Type: %s, Value: %s, %s= " % > (self.PcdType, PcdValue, Value)) > + if isinstance(TmpValue, type('')): > + try: > + TmpValue =3D int(TmpValue) > + except: > + raise BadExpression(Value) > + else: > + PcdValue =3D '0x%0{}X'.format(Size) % (TmpValue) > + if TmpValue < 0: > + raise BadExpression('Type %s PCD Value is negat= ive' % > self.PcdType) > + if self.PcdType =3D=3D TAB_UINT8 and Size > 1: > + raise BadExpression('Type %s PCD Value Size is L= arger than 1 > byte' % self.PcdType) > + if self.PcdType =3D=3D TAB_UINT16 and Size > 2: > + raise BadExpression('Type %s PCD Value Size is L= arger than 2 > byte' % self.PcdType) > + if self.PcdType =3D=3D TAB_UINT32 and Size > 4: > + raise BadExpression('Type %s PCD Value Size is L= arger than 4 > byte' % self.PcdType) > + if self.PcdType =3D=3D TAB_UINT64 and Size > 8: > + raise BadExpression('Type %s PCD Value Size is L= arger than 8 > byte' % self.PcdType) > + else: > + try: > + TmpValue =3D int(PcdValue) > + TmpList =3D [] > + if TmpValue.bit_length() =3D=3D 0: > + PcdValue =3D '{0x00}' > + else: > + for I in range((TmpValue.bit_length() + 7) /= 8): > + TmpList.append('0x%02x' % ((TmpValue >> = I * 8) & 0xff)) > + PcdValue =3D '{' + ', '.join(TmpList) + '}' > + except: > + if PcdValue.strip().startswith('{'): > + PcdValueList =3D SplitPcdValueString(PcdValu= e.strip()[1:-1]) > + LabelDict =3D {} > + NewPcdValueList =3D [] > + LabelOffset =3D 0 > + for Item in PcdValueList: > + # compute byte offset of every LABEL > + LabelList =3D _ReLabel.findall(Item) > + Item =3D _ReLabel.sub('', Item) > + Item =3D Item.strip() > + if LabelList: > + for Label in LabelList: > + if not IsValidCName(Label): > + raise BadExpression('%s is n= ot a valid c variable name' > % Label) > + if Label not in LabelDict: > + LabelDict[Label] =3D str(Lab= elOffset) > if Item.startswith(TAB_UINT8): > - ItemSize =3D 1 > - ValueType =3D TAB_UINT8 > + LabelOffset =3D LabelOffset + 1 > elif Item.startswith(TAB_UINT16): > - ItemSize =3D 2 > - ValueType =3D TAB_UINT16 > + LabelOffset =3D LabelOffset + 2 > elif Item.startswith(TAB_UINT32): > - ItemSize =3D 4 > - ValueType =3D TAB_UINT32 > + LabelOffset =3D LabelOffset + 4 > elif Item.startswith(TAB_UINT64): > - ItemSize =3D 8 > - ValueType =3D TAB_UINT64 > - else: > - ItemSize =3D 0 > - if ValueType: > - TmpValue =3D ValueExpressionEx(Item,= ValueType, > self._Symb)(True) > + LabelOffset =3D LabelOffset + 8 > else: > - TmpValue =3D ValueExpressionEx(Item,= self.PcdType, > self._Symb)(True) > - Item =3D '0x%x' % TmpValue if not isinst= ance(TmpValue, > type('')) else TmpValue > - if ItemSize =3D=3D 0: > - ItemValue, ItemSize =3D ParseFieldVa= lue(Item) > - if Item[0] not in {'"', 'L', '{'} an= d ItemSize > 1: > - raise BadExpression("Byte array= number %s should less > than 0xFF." % Item) > + try: > + ItemValue, ItemSize =3D ParseFie= ldValue(Item) > + LabelOffset =3D LabelOffset + It= emSize > + except: > + LabelOffset =3D LabelOffset + 1 > + > + for Item in PcdValueList: > + # for LABEL parse > + Item =3D Item.strip() > + try: > + Item =3D _ReLabel.sub('', Item) > + except: > + pass > + try: > + OffsetList =3D _ReOffset.findall(Ite= m) > + except: > + pass > + # replace each offset, except errors > + for Offset in OffsetList: > + try: > + Item =3D Item.replace('OFFSET_OF= ({})'.format(Offset), > LabelDict[Offset]) > + except: > + raise BadExpression('%s not defi= ned' % Offset) > + > + NewPcdValueList.append(Item) > + > + AllPcdValueList =3D [] > + for Item in NewPcdValueList: > + Size =3D 0 > + ValueStr =3D '' > + TokenSpaceGuidName =3D '' > + if Item.startswith(TAB_GUID) and Item.en= dswith(')'): > + try: > + TokenSpaceGuidName =3D re.search= ('GUID\((\w+)\)', > Item).group(1) > + except: > + pass > + if TokenSpaceGuidName and TokenSpace= GuidName in > self._Symb: > + Item =3D 'GUID(' + self._Symb[To= kenSpaceGuidName] + > ')' > + elif TokenSpaceGuidName: > + raise BadExpression('%s not foun= d in DEC file' % > TokenSpaceGuidName) > + Item, Size =3D ParseFieldValue(Item) > + for Index in range(0, Size): > + ValueStr =3D '0x%02X' % (int(Ite= m) & 255) > + Item >>=3D 8 > + AllPcdValueList.append(ValueStr) > + continue > + elif Item.startswith('DEVICE_PATH') and = Item.endswith(')'): > + Item, Size =3D ParseFieldValue(Item) > + AllPcdValueList.append(Item[1:-1]) > + continue > else: > - ItemValue =3D ParseFieldValue(Item)[= 0] > - for I in range(0, ItemSize): > - ValueStr =3D '0x%02X' % (int(ItemVal= ue) & 255) > - ItemValue >>=3D 8 > - AllPcdValueList.append(ValueStr) > - Size +=3D ItemSize > - > - if Size > 0: > - PcdValue =3D '{' + ','.join(AllPcdValueList)= + '}' > - else: > - raise BadExpression("Type: %s, Value: %s, %s"%(= self.PcdType, > PcdValue, Value)) > + ValueType =3D "" > + if Item.startswith(TAB_UINT8): > + ItemSize =3D 1 > + ValueType =3D TAB_UINT8 > + elif Item.startswith(TAB_UINT16): > + ItemSize =3D 2 > + ValueType =3D TAB_UINT16 > + elif Item.startswith(TAB_UINT32): > + ItemSize =3D 4 > + ValueType =3D TAB_UINT32 > + elif Item.startswith(TAB_UINT64): > + ItemSize =3D 8 > + ValueType =3D TAB_UINT64 > + else: > + ItemSize =3D 0 > + if ValueType: > + TmpValue =3D ValueExpressionEx(I= tem, ValueType, > self._Symb)(True) > + else: > + TmpValue =3D ValueExpressionEx(I= tem, self.PcdType, > self._Symb)(True) > + Item =3D '0x%x' % TmpValue if not is= instance(TmpValue, > type('')) else TmpValue > + if ItemSize =3D=3D 0: > + ItemValue, ItemSize =3D ParseFie= ldValue(Item) > + if Item[0] not in {'"', 'L', '{'= } and ItemSize > 1: > + raise BadExpression("Byte a= rray number %s should > less than 0xFF." % Item) > + else: > + ItemValue =3D ParseFieldValue(It= em)[0] > + for I in range(0, ItemSize): > + ValueStr =3D '0x%02X' % (int(Ite= mValue) & 255) > + ItemValue >>=3D 8 > + AllPcdValueList.append(ValueStr) > + Size +=3D ItemSize > + > + if Size > 0: > + PcdValue =3D '{' + ','.join(AllPcdValueL= ist) + '}' > + else: > + raise BadExpression("Type: %s, Value: %s, > %s"%(self.PcdType, PcdValue, Value)) >=20 > - if PcdValue =3D=3D 'True': > - PcdValue =3D '1' > - if PcdValue =3D=3D 'False': > - PcdValue =3D '0' > + if PcdValue =3D=3D 'True': > + PcdValue =3D '1' > + if PcdValue =3D=3D 'False': > + PcdValue =3D '0' >=20 > if RealValue: > return PcdValue > diff --git a/BaseTools/Source/Python/Common/Misc.py > b/BaseTools/Source/Python/Common/Misc.py > index 3b8efb2e71..e23772c297 100644 > --- a/BaseTools/Source/Python/Common/Misc.py > +++ b/BaseTools/Source/Python/Common/Misc.py > @@ -1297,6 +1297,8 @@ def ParseDevPathValue (Value): > return '{' + out + '}', Size >=20 > def ParseFieldValue (Value): > + if "{CODE(" in Value: > + return Value, len(Value.split(",")) > if isinstance(Value, type(0)): > return Value, (Value.bit_length() + 7) / 8 > if not isinstance(Value, type('')): > diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py > b/BaseTools/Source/Python/Workspace/BuildClassObject.py > index 95edc376fe..15bb822910 100644 > --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py > +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py > @@ -50,7 +50,7 @@ class PcdClassObject(object): > self.TokenSpaceGuidCName =3D Guid > self.TokenSpaceGuidValue =3D GuidValue > self.Type =3D Type > - self.DatumType =3D DatumType > + self._DatumType =3D DatumType > self.DefaultValue =3D Value > self.TokenValue =3D Token > self.MaxDatumSize =3D MaxDatumSize > @@ -72,6 +72,63 @@ class PcdClassObject(object): > self.PcdValueFromFdf =3D "" > self.CustomAttribute =3D {} > self.UserDefinedDefaultStoresFlag =3D UserDefinedDefaultStoresFl= ag > + self._Capacity =3D None > + > + @property > + def Capacity(self): > + self._Capacity =3D [] > + dimension =3D ArrayIndex.findall(self._DatumType) > + for item in dimension: > + maxsize =3D item.lstrip("[").rstrip("]").strip() > + if not maxsize: > + maxsize =3D "-1" > + self._Capacity.append(maxsize) > + if hasattr(self, "SkuOverrideValues"): > + for sku in self.SkuOverrideValues: > + for defaultstore in self.SkuOverrideValues[sku]: > + fields =3D self.SkuOverrideValues[sku][defaultstore] > + for demesionattr in fields: > + deme =3D ArrayIndex.findall(demesionattr) > + for i in range(len(deme)-1): > + if int(deme[i].lstrip("[").rstrip("]").strip= ()) > > int(self._Capacity[i]): > + print "error" > + if hasattr(self,"DefaultValues"): > + for demesionattr in self.DefaultValues: > + deme =3D ArrayIndex.findall(demesionattr) > + for i in range(len(deme)-1): > + if int(deme[i].lstrip("[").rstrip("]").strip()) > in= t(self._Capacity[i]): > + print "error" > + self._Capacity =3D [str(int(d) + 1) for d in self._Capacity] > + return self._Capacity > + @property > + def DatumType(self): > + return self._DatumType > + > + @DatumType.setter > + def DatumType(self,DataType): > + self._DatumType =3D DataType > + self._Capacity =3D None > + > + @property > + def BaseDatumType(self): > + if self.IsArray(): > + return self._DatumType[:self._DatumType.index("[")] > + else: > + return self._DatumType > + def IsArray(self): > + return True if len(self.Capacity) else False > + > + def IsAggregateDatumType(self): > + if self.DatumType in [TAB_UINT8, TAB_UINT16, TAB_UINT32, > TAB_UINT64, TAB_VOID, "BOOLEAN"]: > + return False > + if self.IsArray() or StructPattern.match(self.DatumType): > + return True > + return False > + > + def IsSimpleTypeArray(self): > + if self.IsArray() and self.BaseDatumType in [TAB_UINT8, TAB_UINT= 16, > TAB_UINT32, TAB_UINT64, "BOOLEAN"]: > + return True > + return False >=20 > @staticmethod > def GetPcdMaxSizeWorker(PcdString, MaxSize): > @@ -183,23 +240,27 @@ class StructurePcd(PcdClassObject): > def __repr__(self): > return self.TypeName >=20 > - def AddDefaultValue (self, FieldName, Value, FileName=3D"", LineNo= =3D0): > - if FieldName in self.DefaultValues: > - del self.DefaultValues[FieldName] > - self.DefaultValues[FieldName] =3D [Value.strip(), FileName, Line= No] > - return self.DefaultValues[FieldName] > + def AddDefaultValue (self, FieldName, Value, FileName=3D"", > LineNo=3D0,DimensionAttr =3D"-1"): > + if DimensionAttr not in self.DefaultValues: > + self.DefaultValues[DimensionAttr] =3D collections.OrderedDic= t() > + if FieldName in self.DefaultValues[DimensionAttr]: > + del self.DefaultValues[DimensionAttr][FieldName] > + self.DefaultValues[DimensionAttr][FieldName] =3D [Value.strip(), > FileName, LineNo] > + return self.DefaultValues[DimensionAttr][FieldName] >=20 > def SetDecDefaultValue(self, DefaultValue): > self.DefaultValueFromDec =3D DefaultValue > - def AddOverrideValue (self, FieldName, Value, SkuName, > DefaultStoreName, FileName=3D"", LineNo=3D0): > + def AddOverrideValue (self, FieldName, Value, SkuName, > DefaultStoreName, FileName=3D"", LineNo=3D0, DimensionAttr =3D '-1'): > if SkuName not in self.SkuOverrideValues: > self.SkuOverrideValues[SkuName] =3D OrderedDict() > if DefaultStoreName not in self.SkuOverrideValues[SkuName]: > self.SkuOverrideValues[SkuName][DefaultStoreName] =3D > OrderedDict() > - if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName= ]: > - del > self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName] > - self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName] =3D > [Value.strip(), FileName, LineNo] > - return > self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName] > + if DimensionAttr not in > self.SkuOverrideValues[SkuName][DefaultStoreName]: > + > self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr] =3D > collections.OrderedDict() > + if FieldName in > self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr]: > + del > self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName][Dimensi > onAttr] > + > self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][Field > Name] =3D [Value.strip(), FileName, LineNo] > + return > self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][Field > Name] >=20 > def SetPcdMode (self, PcdMode): > self.PcdMode =3D PcdMode > @@ -209,7 +270,7 @@ class StructurePcd(PcdClassObject): > self.TokenSpaceGuidCName =3D PcdObject.TokenSpaceGuidCName if > PcdObject.TokenSpaceGuidCName else PcdObject.TokenSpaceGuidCName > self.TokenSpaceGuidValue =3D PcdObject.TokenSpaceGuidValue if > PcdObject.TokenSpaceGuidValue else self.TokenSpaceGuidValue > self.Type =3D PcdObject.Type if PcdObject.Type else self.Type > - self.DatumType =3D PcdObject.DatumType if PcdObject.DatumType el= se > self.DatumType > + self._DatumType =3D PcdObject.DatumType if PcdObject.DatumType e= lse > self.DatumType > self.DefaultValue =3D PcdObject.DefaultValue if PcdObject.Defau= ltValue > else self.DefaultValue > self.TokenValue =3D PcdObject.TokenValue if PcdObject.TokenValue= else > self.TokenValue > self.MaxDatumSize =3D PcdObject.MaxDatumSize if > PcdObject.MaxDatumSize else self.MaxDatumSize > diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py > b/BaseTools/Source/Python/Workspace/DecBuildData.py > index 31ee13eca9..cc00409fee 100644 > --- a/BaseTools/Source/Python/Workspace/DecBuildData.py > +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py > @@ -361,6 +361,21 @@ class DecBuildData(PackageBuildClassObject): > self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX)) > return self._Pcds >=20 > + def ParsePcdName(self,TokenCName): > + TokenCName =3D TokenCName.strip() > + if TokenCName.startswith("["): > + if "." in TokenCName: > + Demesionattr =3D TokenCName[:TokenCName.index(".")] > + Fields =3D TokenCName[TokenCName.index(".")+1:] > + else: > + Demesionattr =3D TokenCName > + Fields =3D "" > + else: > + Demesionattr =3D "" > + Fields =3D TokenCName > + > + return Demesionattr,Fields > + > def ProcessStructurePcd(self, StructurePcdRawDataSet): > s_pcd_set =3D OrderedDict() > for s_pcd, LineNo in StructurePcdRawDataSet: > @@ -373,6 +388,8 @@ class DecBuildData(PackageBuildClassObject): > dep_pkgs =3D [] > struct_pcd =3D StructurePcd() > for item, LineNo in s_pcd_set[pcdname]: > + if not item.TokenCName: > + continue > if "" in item.TokenCName: > struct_pcd.StructuredPcdIncludeFile.append(item.Defa= ultValue) > elif "" in item.TokenCName: > @@ -385,7 +402,8 @@ class DecBuildData(PackageBuildClassObject): > struct_pcd.PkgPath =3D self.MetaFile.File > struct_pcd.SetDecDefaultValue(item.DefaultValue) > else: > - struct_pcd.AddDefaultValue(item.TokenCName, > item.DefaultValue, self.MetaFile.File, LineNo) > + DemesionAttr, Fields =3D self.ParsePcdName(item.Toke= nCName) > + struct_pcd.AddDefaultValue(Fields, item.DefaultValue= , > self.MetaFile.File, LineNo,DemesionAttr) >=20 > struct_pcd.PackageDecs =3D dep_pkgs > str_pcd_set.append(struct_pcd) > @@ -446,15 +464,12 @@ class DecBuildData(PackageBuildClassObject): > StructurePcds =3D self.ProcessStructurePcd(StrPcdSet) > for pcd in StructurePcds: > Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, > self._PCD_TYPE_STRING_[Type]] =3D pcd > - StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') > for pcd in Pcds.values(): > if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, > TAB_UINT64, TAB_VOID, "BOOLEAN"]: > - if StructPattern.match(pcd.DatumType) is None: > + if not pcd.IsAggregateDatumType(): > EdkLogger.error('build', FORMAT_INVALID, "DatumType = only > support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct > name.", DefinitionPosition[pcd][0], DefinitionPosition[pcd][1]) > - for struct_pcd in Pcds.values(): > - if isinstance(struct_pcd, StructurePcd) and not > struct_pcd.StructuredPcdIncludeFile: > - EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The > structure Pcd %s.%s header file is not found in %s line %s \n" % > (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName, > DefinitionPosition[struct_pcd][0], DefinitionPosition[struct_pcd][1] )) > - > + elif not pcd.IsArray() and not pcd.StructuredPcdIncludeF= ile: > + EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "T= he > structure Pcd %s.%s header file is not found in %s line %s \n" % > (pcd.TokenSpaceGuidCName, pcd.TokenCName, pcd.DefinitionPosition[0], > pcd.DefinitionPosition[1] )) > return Pcds >=20 > @property > diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py > b/BaseTools/Source/Python/Workspace/DscBuildData.py > index 11aa63fb26..66d1881aac 100644 > --- a/BaseTools/Source/Python/Workspace/DscBuildData.py > +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py > @@ -42,6 +42,7 @@ import subprocess > from Common.Misc import SaveFileOnChange > from Workspace.BuildClassObject import PlatformBuildClassObject, > StructurePcd, PcdClassObject, ModuleBuildClassObject > from collections import OrderedDict, defaultdict > +from .BuildClassObject import ArrayIndex >=20 > PcdValueInitName =3D 'PcdValueInit' >=20 > @@ -912,25 +913,26 @@ class DscBuildData(PlatformBuildClassObject): > ExtraData=3D"%s.%s|%s" % (TokenSpaceGuid= , PcdCName, > Setting)) > if ValueList[Index]: > DatumType =3D self._DecPcds[PcdCName, > TokenSpaceGuid].DatumType > - try: > - ValueList[Index] =3D ValueExpressionEx(ValueList[Index],= DatumType, > self._GuidDict)(True) > - except BadExpression as Value: > - EdkLogger.error('Parser', FORMAT_INVALID, Value, > File=3Dself.MetaFile, Line=3DLineNo, > - ExtraData=3D"PCD [%s.%s] Value \"%s\" " = % ( > - TokenSpaceGuid, PcdCName, ValueList[Inde= x])) > - except EvaluationException as Excpt: > - if hasattr(Excpt, 'Pcd'): > - if Excpt.Pcd in GlobalData.gPlatformOtherPcds: > - EdkLogger.error('Parser', FORMAT_INVALID, "Canno= t use this > PCD (%s) in an expression as" > - " it must be defined in a [PcdsF= ixedAtBuild] or > [PcdsFeatureFlag] section" > - " of the DSC file" % Excpt.Pcd, > - File=3Dself.MetaFile, Line=3DLin= eNo) > + if "{CODE(" not in ValueList[Index]: > + try: > + ValueList[Index] =3D ValueExpressionEx(ValueList[Ind= ex], > DatumType, self._GuidDict)(True) > + except BadExpression as Value: > + EdkLogger.error('Parser', FORMAT_INVALID, Value, > File=3Dself.MetaFile, Line=3DLineNo, > + ExtraData=3D"PCD [%s.%s] Value \"%s\= " " % ( > + TokenSpaceGuid, PcdCName, ValueList[= Index])) > + except EvaluationException as Excpt: > + if hasattr(Excpt, 'Pcd'): > + if Excpt.Pcd in GlobalData.gPlatformOtherPcds: > + EdkLogger.error('Parser', FORMAT_INVALID, "C= annot use this > PCD (%s) in an expression as" > + " it must be defined in a [P= cdsFixedAtBuild] or > [PcdsFeatureFlag] section" > + " of the DSC file" % Excpt.P= cd, > + File=3Dself.MetaFile, Line= =3DLineNo) > + else: > + EdkLogger.error('Parser', FORMAT_INVALID, "P= CD (%s) is not > defined in DSC file" % Excpt.Pcd, > + File=3Dself.MetaFile, Line= =3DLineNo) > else: > - EdkLogger.error('Parser', FORMAT_INVALID, "PCD (= %s) is not > defined in DSC file" % Excpt.Pcd, > + EdkLogger.error('Parser', FORMAT_INVALID, "Inval= id > expression: %s" % str(Excpt), > File=3Dself.MetaFile, Line=3DLin= eNo) > - else: > - EdkLogger.error('Parser', FORMAT_INVALID, "Invalid e= xpression: > %s" % str(Excpt), > - File=3Dself.MetaFile, Line=3DLineNo) >=20 > if ValueList[Index]: > Valid, ErrStr =3D CheckPcdDatum(self._DecPcds[PcdCName, > TokenSpaceGuid].DatumType, ValueList[Index]) > @@ -1395,6 +1397,26 @@ class DscBuildData(PlatformBuildClassObject): > self.Pcds[Name, Guid].DefaultValue =3D Value > return AllPcds >=20 > + def ParsePcdNameStruct(self,NamePart1,NamePart2): > + TokenSpaceCName =3D PcdCName =3D DimensionAttr =3D Field =3D "" > + if "." in NamePart1: > + TokenSpaceCName, TempPcdCName =3D NamePart1.split(".") > + if "[" in TempPcdCName: > + PcdCName =3D TempPcdCName[:TempPcdCName.index("[")] > + DimensionAttr =3D TempPcdCName[TempPcdCName.index("["):] > + else: > + PcdCName =3D TempPcdCName > + Field =3D NamePart2 > + else: > + TokenSpaceCName =3D NamePart1 > + if "[" in NamePart2: > + PcdCName =3D NamePart2[:NamePart2.index("[")] > + DimensionAttr =3D NamePart2[NamePart2.index("["):] > + else: > + PcdCName =3D NamePart2 > + > + return TokenSpaceCName,PcdCName,DimensionAttr,Field > + > def UpdateStructuredPcds(self, TypeList, AllPcds): >=20 > DynamicPcdType =3D > [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAULT], > @@ -1424,9 +1446,19 @@ class DscBuildData(PlatformBuildClassObject): > SkuName =3D TAB_DEFAULT if SkuName =3D=3D TAB_COMMON else > SkuName > if SkuName not in SkuIds: > continue > + TCName,PCName,DimensionAttr,Field =3D > self.ParsePcdNameStruct(TokenSpaceGuid, PcdCName) > + pcd_in_dec =3D self._DecPcds.get((PCName,TCName), None) > + if pcd_in_dec is None: > + EdkLogger.error('build', PARSER_ERROR, > + "Pcd (%s.%s) defined in DSC is not declared = in DEC files. Arch: > ['%s']" % (TCName, PCName, self._Arch), > + File=3Dself.MetaFile, Line =3D Dummy5) > + if SkuName in SkuIds and ("." in TokenSpaceGuid or "[" in Pc= dCName): > + if not isinstance (pcd_in_dec, StructurePcd): > + EdkLogger.error('build', PARSER_ERROR, > + "Pcd (%s.%s) is not declared as Structur= e PCD in DEC files. > Arch: ['%s']" % (TCName, PCName, self._Arch), > + File=3Dself.MetaFile, Line =3D Dummy5) >=20 > - if SkuName in SkuIds and "." in TokenSpaceGuid: > - S_PcdSet.append([ TokenSpaceGuid.split(".")[0], > TokenSpaceGuid.split(".")[1], PcdCName, SkuName, default_store, > Dummy5, AnalyzePcdExpression(Setting)[0]]) > + S_PcdSet.append([ TCName,PCName,DimensionAttr,Field, > SkuName, default_store, Dummy5, AnalyzePcdExpression(Setting)[0]]) >=20 > # handle pcd value override > StrPcdSet =3D DscBuildData.GetStructurePcdInfo(S_PcdSet) > @@ -1434,27 +1466,19 @@ class DscBuildData(PlatformBuildClassObject): > for str_pcd in StrPcdSet: > str_pcd_obj =3D Pcds.get((str_pcd[1], str_pcd[0]), None) > str_pcd_dec =3D self._DecPcds.get((str_pcd[1], str_pcd[0]), = None) > - if not isinstance (str_pcd_dec, StructurePcd): > - EdkLogger.error('build', PARSER_ERROR, > - "Pcd (%s.%s) is not declared as Structure PC= D in DEC files. > Arch: ['%s']" % (str_pcd[0], str_pcd[1], self._Arch), > - File=3Dself.MetaFile, Line =3D StrPcdSet[str= _pcd][0][5]) > - if str_pcd_dec: > - str_pcd_obj_str =3D StructurePcd() > - str_pcd_obj_str.copy(str_pcd_dec) > - if str_pcd_obj: > - str_pcd_obj_str.copy(str_pcd_obj) > - if str_pcd_obj.Type in > [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], > self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: > - str_pcd_obj_str.DefaultFromDSC =3D {skuname:{def= aultstore: > str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, > str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in > DefaultStores} for skuname in str_pcd_obj.SkuInfoList} > - else: > - str_pcd_obj_str.DefaultFromDSC =3D {skuname:{def= aultstore: > str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, > str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in > DefaultStores} for skuname in str_pcd_obj.SkuInfoList} > - for str_pcd_data in StrPcdSet[str_pcd]: > - if str_pcd_data[3] in SkuIds: > - str_pcd_obj_str.AddOverrideValue(str_pcd_data[2]= , > str(str_pcd_data[6]), TAB_DEFAULT if str_pcd_data[3] =3D=3D TAB_COMMON > else str_pcd_data[3], TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[4] =3D= =3D > TAB_COMMON else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir > not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) = if > self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:], > LineNo=3Dstr_pcd_data[5]) > - S_pcd_set[str_pcd[1], str_pcd[0]] =3D str_pcd_obj_str > - else: > - EdkLogger.error('build', PARSER_ERROR, > - "Pcd (%s.%s) defined in DSC is not declared = in DEC files. Arch: > ['%s']" % (str_pcd[0], str_pcd[1], self._Arch), > - File=3Dself.MetaFile, Line =3D StrPcdSet[str= _pcd][0][5]) > + str_pcd_obj_str =3D StructurePcd() > + str_pcd_obj_str.copy(str_pcd_dec) > + if str_pcd_obj: > + str_pcd_obj_str.copy(str_pcd_obj) > + if str_pcd_obj.Type in > [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], > self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: > + str_pcd_obj_str.DefaultFromDSC =3D {skuname:{default= store: > str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, > str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in > DefaultStores} for skuname in str_pcd_obj.SkuInfoList} > + else: > + str_pcd_obj_str.DefaultFromDSC =3D {skuname:{default= store: > str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, > str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in > DefaultStores} for skuname in str_pcd_obj.SkuInfoList} > + for str_pcd_data in StrPcdSet[str_pcd]: > + if str_pcd_data[4] in SkuIds: > + str_pcd_obj_str.AddOverrideValue(str_pcd_data[3], > str(str_pcd_data[7]), TAB_DEFAULT if str_pcd_data[4] =3D=3D TAB_COMMON > else str_pcd_data[4], TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[5] =3D= =3D > TAB_COMMON else str_pcd_data[5], self.MetaFile.File if self.WorkspaceDir > not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) = if > self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:], > LineNo=3Dstr_pcd_data[6],DimensionAttr =3D str_pcd_data[2]) > + S_pcd_set[str_pcd[1], str_pcd[0]] =3D str_pcd_obj_str > + > # Add the Structure PCD that only defined in DEC, don't have ove= rride in > DSC file > for Pcd in self.DecPcds: > if isinstance(self._DecPcds[Pcd], StructurePcd): > @@ -1590,9 +1614,10 @@ class DscBuildData(PlatformBuildClassObject): > if SkuName not in AvailableSkuIdSet: > EdkLogger.error('build ', PARAMETER_INVALID, 'Sku %s is = not > defined in [SkuIds] section' % SkuName, > File=3Dself.MetaFile, Line= =3DDummy5) > - if "." not in TokenSpaceGuid: > - PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy5)) > - PcdDict[Arch, PcdCName, TokenSpaceGuid, SkuName] =3D Setting > + if SkuName in (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT, > TAB_COMMON): > + if "." not in TokenSpaceGuid and "[" not in PcdCName: > + PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy= 5)) > + PcdDict[Arch, PcdCName, TokenSpaceGuid, SkuName] =3D Set= ting >=20 > for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdSet: > Setting =3D PcdDict[self._Arch, PcdCName, TokenSpaceGuid, Sk= uName] > @@ -1688,7 +1713,20 @@ class DscBuildData(PlatformBuildClassObject): > def GenerateSizeFunction(self, Pcd): > CApp =3D "// Default Value in Dec \n" > CApp =3D CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) > - for FieldList in [Pcd.DefaultValues]: > + if Pcd.IsArray(): > + if (len(Pcd.Capacity) =3D=3D 1 and Pcd.Capacity[0] !=3D '0')= or > (len(Pcd.Capacity) >1 and reduce(lambda x,y:int(x)*int(y), Pcd.Capacity))= > 0: > + CApp +=3D " *Size =3D (sizeof (%s) * (%s) > *Size) ? si= zeof (%s) * (%s): > *Size; \n" % (Pcd.BaseDatumType, > "*".join(Pcd.Capacity),Pcd.BaseDatumType, "*".join(Pcd.Capacity)) > + if "{CODE(" in Pcd.DefaultValueFromDec: > + CApp +=3D " *Size =3D (sizeof (%s_%s_INIT_Value) > *Siz= e ? sizeof > (%s_%s_INIT_Value) : *Size);\n" % > (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,Pcd.TokenSpaceGuidCName > ,Pcd.TokenCName) > + for skuname in Pcd.SkuInfoList: > + skuobj =3D Pcd.SkuInfoList[skuname] > + if skuobj.VariableName: > + for defaultstore in skuobj.DefaultStoreDict: > + CApp +=3D " *Size =3D (sizeof (%s_%s_%s_%s_Valu= e) > *Size ? > sizeof (%s_%s_%s_%s_Value) : *Size);\n" % > (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,defaultstore,Pcd.T > okenSpaceGuidCName,Pcd.TokenCName,skuname,defaultstore) > + else: > + CApp +=3D " *Size =3D (sizeof (%s_%s_%s_%s_Value) >= *Size ? sizeof > (%s_%s_%s_%s_Value) : *Size);\n" % > (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,TAB_DEFAULT_ST > ORES_DEFAULT,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,TA > B_DEFAULT_STORES_DEFAULT) > + for index in Pcd.DefaultValues: > + FieldList =3D Pcd.DefaultValues[index] > if not FieldList: > continue > for FieldName in FieldList: > @@ -1718,31 +1756,32 @@ class DscBuildData(PlatformBuildClassObject): > continue > for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]: > CApp =3D CApp + "// SkuName: %s, DefaultStoreName: %s \= n" % > (skuname, defaultstorenameitem) > - for FieldList in > [Pcd.SkuOverrideValues[skuname].get(defaultstorenameitem)]: > - if not FieldList: > - continue > - for FieldName in FieldList: > - FieldName =3D "." + FieldName > - IsArray =3D IsFieldValueAnArray(FieldList[FieldN= ame.strip(".")][0]) > - if IsArray and not > (FieldList[FieldName.strip(".")][0].startswith('{GUID') and > FieldList[FieldName.strip(".")][0].endswith('}')): > - try: > - Value =3D > ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, > self._GuidDict)(True) > - except BadExpression: > - EdkLogger.error('Build', FORMAT_INVALID,= "Invalid value > format for %s. From %s Line %d " % > - (".".join((Pcd.TokenSpac= eGuidCName, > Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1= ], > FieldList[FieldName.strip(".")][2])) > - Value, ValueSize =3D ParseFieldValue(Value) > - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s= , %s, %d / > __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, > %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, > FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), > ValueSize, Pcd.DatumType, FieldName.strip("."), > FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], > FieldList[FieldName.strip(".")][0]); > - else: > - NewFieldName =3D '' > - FieldName_ori =3D FieldName.strip('.') > - while '[' in FieldName: > - NewFieldName =3D NewFieldName + FieldNam= e.split('[', 1)[0] > + '[0]' > - ArrayIndex =3D int(FieldName.split('[', = 1)[1].split(']', 1)[0]) > - FieldName =3D FieldName.split(']', 1)[1] > - FieldName =3D NewFieldName + FieldName > - while '[' in FieldName: > - FieldName =3D FieldName.rsplit('[', 1)[0= ] > - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size= , %s, %s, %d); // > From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), > ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], > FieldList[FieldName_ori][0]) > + for index in > Pcd.SkuOverrideValues[skuname][defaultstorenameitem]: > + for FieldList in > [Pcd.SkuOverrideValues[skuname][defaultstorenameitem][index]]: > + if not FieldList: > + continue > + for FieldName in FieldList: > + FieldName =3D "." + FieldName > + IsArray =3D > IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) > + if IsArray and not > (FieldList[FieldName.strip(".")][0].startswith('{GUID') and > FieldList[FieldName.strip(".")][0].endswith('}')): > + try: > + Value =3D > ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, > self._GuidDict)(True) > + except BadExpression: > + EdkLogger.error('Build', FORMAT_INVA= LID, "Invalid value > format for %s. From %s Line %d " % > + (".".join((Pcd.Token= SpaceGuidCName, > Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1= ], > FieldList[FieldName.strip(".")][2])) > + Value, ValueSize =3D ParseFieldValue(Val= ue) > + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size= , %s, %s, %d / > __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, > %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, > FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), > ValueSize, Pcd.DatumType, FieldName.strip("."), > FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], > FieldList[FieldName.strip(".")][0]); > + else: > + NewFieldName =3D '' > + FieldName_ori =3D FieldName.strip('.') > + while '[' in FieldName: > + NewFieldName =3D NewFieldName + Fiel= dName.split('[', > 1)[0] + '[0]' > + ArrayIndex =3D int(FieldName.split('= [', 1)[1].split(']', 1)[0]) > + FieldName =3D FieldName.split(']', 1= )[1] > + FieldName =3D NewFieldName + FieldName > + while '[' in FieldName: > + FieldName =3D FieldName.rsplit('[', = 1)[0] > + CApp =3D CApp + ' __FLEXIBLE_SIZE(*= Size, %s, %s, %d); // > From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), > ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], > FieldList[FieldName_ori][0]) > if Pcd.PcdFieldValueFromFdf: > CApp =3D CApp + "// From fdf \n" > for FieldName in Pcd.PcdFieldValueFromFdf: > @@ -1791,19 +1830,64 @@ class DscBuildData(PlatformBuildClassObject): > while '[' in FieldName: > FieldName =3D FieldName.rsplit('[', 1)[0] > CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d= ); // From %s > Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + > 1, Pcd.PcdFieldValueFromComm[FieldName_ori][1], > Pcd.PcdFieldValueFromComm[FieldName_ori][2], > Pcd.PcdFieldValueFromComm[FieldName_ori][0]) > - CApp =3D CApp + " *Size =3D (%d > *Size ? %d : *Size); // The P= cd maxsize is > %d \n" % (Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize(), > Pcd.GetPcdMaxSize()) > + if Pcd.GetPcdMaxSize(): > + CApp =3D CApp + " *Size =3D (%d > *Size ? %d : *Size); // T= he Pcd maxsize > is %d \n" % (Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize(), > Pcd.GetPcdMaxSize()) > CApp =3D CApp + "}\n" > return CApp >=20 > @staticmethod > def GenerateSizeStatments(Pcd): > - CApp =3D ' Size =3D sizeof(%s);\n' % (Pcd.DatumType) > + if Pcd.IsArray(): > + r_datatype =3D [Pcd.BaseDatumType] > + for dem in Pcd.Capacity: > + if dem =3D=3D '0': > + r_datatype.append("[1]") > + else: > + r_datatype.append("[" + dem + "]") > + CApp =3D ' Size =3D sizeof(%s);\n' % ("".join(r_datatype)) > + else: > + CApp =3D ' Size =3D sizeof(%s);\n' % (Pcd.DatumType) > CApp =3D CApp + ' Cal_%s_%s_Size(&Size);\n' % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) > return CApp >=20 > + def GetIndicator(self,index,FieldName,Pcd): > + def cleanupindex(indexstr): > + return indexstr.strip("[").strip("]").strip() > + index_elements =3D ArrayIndex.findall(index) > + pcd_capacity =3D Pcd.Capacity > + if index: > + indicator =3D "(Pcd" > + if len(pcd_capacity)>2: > + for i in xrange(0,len(index_elements)): > + index_ele =3D index_elements[i] > + index_num =3D index_ele.strip("[").strip("]").strip(= ) > + if i =3D=3D len(index_elements) -2: > + indicator +=3D "+ %d*Size/sizeof(%s)/%d + %s)" > %(int(cleanupindex(index_elements[i+1])),Pcd.BaseDatumType,reduce(lam > bda x,y: int(x)*int(y),pcd_capacity[:-1]), cleanupindex(index_elements[i]= )) > + break > + else: > + indicator +=3D " + %d*%s*Size/sizeof(%s)/%d" > %(int(cleanupindex(index_elements[i])),reduce(lambda x,y: > int(x)*int(y),pcd_capacity[i+1:-1]),Pcd.BaseDatumType,reduce(lambda x,y: > int(x)*int(y),pcd_capacity[:-1])) > + elif len(pcd_capacity) =3D=3D 2: > + indicator +=3D "+ %d*Size/sizeof(%s)/%d + %s)" > %(int(cleanupindex(index_elements[0])),Pcd.BaseDatumType,int(pcd_capac > ity[0]), index_elements[1].strip("[").strip("]").strip()) > + elif len(pcd_capacity) =3D=3D 1: > + index_ele =3D index_elements[0] > + index_num =3D index_ele.strip("[").strip("]").strip() > + indicator +=3D " + %s)" % (index_num) > + else: > + indicator =3D "Pcd" > + if FieldName: > + indicator +=3D "->" + FieldName > + return indicator > + > + def GetStarNum(self,Pcd): > + if not Pcd.IsArray(): > + return 1 > + elif Pcd.IsSimpleTypeArray(): > + return len(Pcd.Capacity) > + else: > + return len(Pcd.Capacity) + 1 > def GenerateDefaultValueAssignFunction(self, Pcd): > CApp =3D "// Default value in Dec \n" > - CApp =3D CApp + "void Assign_%s_%s_Default_Value(%s *Pcd){\n" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumType) > + CApp =3D CApp + "void Assign_%s_%s_Default_Value(%s *Pcd){\n" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.BaseDatumType) > CApp =3D CApp + ' UINT32 FieldSize;\n' > CApp =3D CApp + ' CHAR8 *Value;\n' > DefaultValueFromDec =3D Pcd.DefaultValueFromDec > @@ -1822,9 +1906,13 @@ class DscBuildData(PlatformBuildClassObject): > # > # Use memcpy() to copy value into field > # > - CApp =3D CApp + ' Value =3D %s; // From DEC Default Val= ue %s\n' % > (DscBuildData.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec) > - CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) > - for FieldList in [Pcd.DefaultValues]: > + if "{CODE(" in Pcd.DefaultValueFromDec: > + CApp =3D CApp + ' memcpy (Pcd, %s_%s_INIT_Value, > sizeof(%s_%s_INIT_Value));\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.TokenSpaceGuidCName, Pcd.TokenCName) > + else: > + CApp =3D CApp + ' Value =3D %s; // From DEC Default= Value %s\n' % > (DscBuildData.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec) > + CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueS= ize) > + for index in Pcd.DefaultValues: > + FieldList =3D Pcd.DefaultValues[index] > if not FieldList: > continue > for FieldName in FieldList: > @@ -1840,8 +1928,10 @@ class DscBuildData(PlatformBuildClassObject): > Value, ValueSize =3D ParseFieldValue (FieldList[Fiel= dName][0]) > except Exception: > EdkLogger.error('Build', FORMAT_INVALID, "Invalid va= lue format > for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, > Pcd.TokenCName, FieldName)), FieldList[FieldName][1], > FieldList[FieldName][2])) > + > + indicator =3D self.GetIndicator(index, FieldName,Pcd) > if isinstance(Value, str): > - CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line %= d Value %s\n' % > (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], > FieldList[FieldName][0]) > + CApp =3D CApp + ' %s =3D %s; // From %s Line %d Val= ue %s\n' % > (indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2], > FieldList[FieldName][0]) > elif IsArray: > # > # Use memcpy() to copy value into field > @@ -1850,14 +1940,16 @@ class DscBuildData(PlatformBuildClassObject): > CApp =3D CApp + ' Value =3D %s; // From %s Line= %d Value %s\n' % > (DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1], > FieldList[FieldName][2], FieldList[FieldName][0]) > CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s,= %s) >=3D %d) > || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the buffer arra= y"); // > From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize, > Pcd.DatumType, FieldName, FieldList[FieldName][1], > FieldList[FieldName][2], FieldList[FieldName][0]) > CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSi= ze > 0 && > FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) > + CApp =3D CApp + ' memcpy (&%s, Value, (FieldSize > = 0 && FieldSize > < %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize) > + > else: > if '[' in FieldName and ']' in FieldName: > Index =3D int(FieldName.split('[')[1].split(']')= [0]) > CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARRAY= _SIZE(Pcd- > >%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds the array > number"); // From %s Line %d Index of %s\n' % (Index, > FieldName.split('[')[0], FieldName.split('[')[0], FieldList[FieldName][1]= , > FieldList[FieldName][2], FieldName) > if ValueSize > 4: > - CApp =3D CApp + ' Pcd->%s =3D %dULL; // From %s= Line %d Value > %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][= 2], > FieldList[FieldName][0]) > + CApp =3D CApp + ' %s =3D %dULL; // From %s Line= %d Value %s\n' % > (indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2], > FieldList[FieldName][0]) > else: > - CApp =3D CApp + ' Pcd->%s =3D %d; // From %s Li= ne %d Value %s\n' > % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], > FieldList[FieldName][0]) > + CApp =3D CApp + ' %s =3D %d; // From %s Line %d= Value %s\n' % > (indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2], > FieldList[FieldName][0]) > CApp =3D CApp + "}\n" > return CApp >=20 > @@ -1868,7 +1960,7 @@ class DscBuildData(PlatformBuildClassObject): >=20 > def GenerateInitValueFunction(self, Pcd, SkuName, DefaultStoreName): > CApp =3D "// Value in Dsc for Sku: %s, DefaultStore %s\n" % (Sku= Name, > DefaultStoreName) > - CApp =3D CApp + "void Assign_%s_%s_%s_%s_Value(%s *Pcd){\n" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, SkuName, > DefaultStoreName, Pcd.DatumType) > + CApp =3D CApp + "void Assign_%s_%s_%s_%s_Value(%s *Pcd){\n" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, SkuName, > DefaultStoreName, Pcd.BaseDatumType) > CApp =3D CApp + ' UINT32 FieldSize;\n' > CApp =3D CApp + ' CHAR8 *Value;\n' >=20 > @@ -1881,40 +1973,60 @@ class DscBuildData(PlatformBuildClassObject): > pcddefaultvalue =3D Pcd.DscRawValue.get(SkuName, > {}).get(DefaultStoreName) > else: > pcddefaultvalue =3D Pcd.DscRawValue.get(SkuName, > {}).get(TAB_DEFAULT_STORES_DEFAULT) > - for FieldList in [pcddefaultvalue, > inherit_OverrideValues.get(DefaultStoreName)]: > - if not FieldList: > - continue > - if pcddefaultvalue and FieldList =3D=3D pcddefaultvalue: > - IsArray =3D IsFieldValueAnArray(FieldList) > - if IsArray: > + > + if pcddefaultvalue: > + FieldList =3D pcddefaultvalue > + IsArray =3D IsFieldValueAnArray(FieldList) > + if IsArray: > + if "{CODE(" not in FieldList: > try: > FieldList =3D ValueExpressionEx(FieldList, TAB_V= OID)(True) > except BadExpression: > EdkLogger.error("Build", FORMAT_INVALID, "Invali= d value > format for %s.%s, from DSC: %s" % > (Pcd.TokenSpaceGuidCName, Pcd.To= kenCName, > FieldList)) > - Value, ValueSize =3D ParseFieldValue (FieldList) > + Value, ValueSize =3D ParseFieldValue (FieldList) >=20 > - if (SkuName, DefaultStoreName) =3D=3D (TAB_DEFAULT, > TAB_DEFAULT_STORES_DEFAULT): > - if isinstance(Value, str): > + if (SkuName, DefaultStoreName) =3D=3D (TAB_DEFAULT, > TAB_DEFAULT_STORES_DEFAULT): > + if isinstance(Value, str): > + if "{CODE(" in Value: > + CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Valu= e, > sizeof(%s_%s_%s_%s_Value));\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, > DefaultStoreName,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + else: > CApp =3D CApp + ' Pcd =3D %s; // From DSC Defau= lt Value %s\n' % > (Value, Pcd.DefaultFromDSC.get(TAB_DEFAULT, > {}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if > Pcd.DefaultFromDSC else Pcd.DefaultValue) > - elif IsArray: > - # > - # Use memcpy() to copy value into field > - # > + elif IsArray: > + # > + # Use memcpy() to copy value into field > + # > + if Pcd.IsArray(): > + CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Valu= e, > sizeof(%s_%s_%s_%s_Value));\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, > DefaultStoreName,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + else: > CApp =3D CApp + ' Value =3D %s; // From DSC= Default Value %s\n' > % (DscBuildData.IntToCString(Value, ValueSize), > Pcd.DefaultFromDSC.get(TAB_DEFAULT, > {}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if > Pcd.DefaultFromDSC else Pcd.DefaultValue) > CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' %= (ValueSize) > - else: > - if isinstance(Value, str): > + else: > + if isinstance(Value, str): > + if "{CODE(" in Value: > + CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Valu= e, > sizeof(%s_%s_%s_%s_Value));\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, > DefaultStoreName,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + else: > CApp =3D CApp + ' Pcd =3D %s; // From DSC Defau= lt Value %s\n' % > (Value, Pcd.DscRawValue.get(SkuName, {}).get(DefaultStoreName)) > - elif IsArray: > - # > - # Use memcpy() to copy value into field > - # > + elif IsArray: > + # > + # Use memcpy() to copy value into field > + # > + if Pcd.IsArray(): > + CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Valu= e, > sizeof(%s_%s_%s_%s_Value));\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, > DefaultStoreName,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + else: > CApp =3D CApp + ' Value =3D %s; // From DSC= Default Value %s\n' > % (DscBuildData.IntToCString(Value, ValueSize), > Pcd.DscRawValue.get(SkuName, {}).get(DefaultStoreName)) > CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' %= (ValueSize) > + > + inheritvalue =3D inherit_OverrideValues.get(DefaultStoreName) > + if not inheritvalue: > + inheritvalue =3D [] > + for index in inheritvalue: > + FieldList =3D inheritvalue[index] > + if not FieldList: > continue > if (SkuName, DefaultStoreName) =3D=3D (TAB_DEFAULT, > TAB_DEFAULT_STORES_DEFAULT) or (( (SkuName, '') not in Pcd.ValueChain) > and ( (SkuName, DefaultStoreName) not in Pcd.ValueChain )): > for FieldName in FieldList: > + indicator =3D self.GetIndicator(index, FieldName,Pcd= ) > IsArray =3D IsFieldValueAnArray(FieldList[FieldName]= [0]) > if IsArray: > try: > @@ -1932,18 +2044,19 @@ class DscBuildData(PlatformBuildClassObject): > # > # Use memcpy() to copy value into field > # > - CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s= , %s);\n' % > (Pcd.DatumType, FieldName) > + CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s= , %s);\n' % > (Pcd.BaseDatumType, FieldName) > CApp =3D CApp + ' Value =3D %s; // From %s = Line %d Value %s\n' % > (DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1], > FieldList[FieldName][2], FieldList[FieldName][0]) > CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE= (%s, %s) >=3D > %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the buffer > array"); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, > ValueSize, Pcd.DatumType, FieldName, FieldList[FieldName][1], > FieldList[FieldName][2], FieldList[FieldName][0]) > CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (Fie= ldSize > 0 && > FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) > + CApp =3D CApp + ' memcpy (&%s, Value, (FieldSiz= e > 0 && > FieldSize < %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize) > else: > if '[' in FieldName and ']' in FieldName: > Index =3D int(FieldName.split('[')[1].split(= ']')[0]) > CApp =3D CApp + ' __STATIC_ASSERT((%d < __A= RRAY_SIZE(Pcd- > >%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds the array > number"); // From %s Line %d Index of %s\n' % (Index, > FieldName.split('[')[0], FieldName.split('[')[0], FieldList[FieldName][1]= , > FieldList[FieldName][2], FieldName) > if ValueSize > 4: > - CApp =3D CApp + ' Pcd->%s =3D %dULL; // Fro= m %s Line %d Value > %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][= 2], > FieldList[FieldName][0]) > + CApp =3D CApp + ' %s =3D %dULL; // From %s = Line %d Value %s\n' > % (indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2], > FieldList[FieldName][0]) > else: > - CApp =3D CApp + ' Pcd->%s =3D %d; // From %= s Line %d Value > %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][= 2], > FieldList[FieldName][0]) > + CApp =3D CApp + ' %s =3D %d; // From %s Lin= e %d Value %s\n' % > (indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2], > FieldList[FieldName][0]) > CApp =3D CApp + "}\n" > return CApp >=20 > @@ -1954,7 +2067,7 @@ class DscBuildData(PlatformBuildClassObject): >=20 > def GenerateCommandLineValue(self, Pcd): > CApp =3D "// Value in CommandLine\n" > - CApp =3D CApp + "void Assign_%s_%s_CommandLine_Value(%s > *Pcd){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, > Pcd.DatumType) > + CApp =3D CApp + "void Assign_%s_%s_CommandLine_Value(%s > *Pcd){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, > Pcd.BaseDatumType) > CApp =3D CApp + ' UINT32 FieldSize;\n' > CApp =3D CApp + ' CHAR8 *Value;\n' >=20 > @@ -2001,7 +2114,7 @@ class DscBuildData(PlatformBuildClassObject): > # > # Use memcpy() to copy value into field > # > - CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s= );\n' % > (Pcd.DatumType, FieldName) > + CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s= );\n' % > (Pcd.BaseDatumType, FieldName) > CApp =3D CApp + ' Value =3D %s; // From %s Line= %d Value %s\n' % > (DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1], > FieldList[FieldName][2], FieldList[FieldName][0]) > CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s,= %s) >=3D %d) > || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the buffer arra= y"); // > From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize, > Pcd.DatumType, FieldName, FieldList[FieldName][1], > FieldList[FieldName][2], FieldList[FieldName][0]) > CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSi= ze > 0 && > FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) > @@ -2022,7 +2135,7 @@ class DscBuildData(PlatformBuildClassObject): > return CApp > def GenerateFdfValue(self,Pcd): > CApp =3D "// Value in Fdf\n" > - CApp =3D CApp + "void Assign_%s_%s_Fdf_Value(%s *Pcd){\n" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Pcd.DatumType) > + CApp =3D CApp + "void Assign_%s_%s_Fdf_Value(%s *Pcd){\n" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Pcd.BaseDatumType) > CApp =3D CApp + ' UINT32 FieldSize;\n' > CApp =3D CApp + ' CHAR8 *Value;\n' >=20 > @@ -2069,7 +2182,7 @@ class DscBuildData(PlatformBuildClassObject): > # > # Use memcpy() to copy value into field > # > - CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s= );\n' % > (Pcd.DatumType, FieldName) > + CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s= );\n' % > (Pcd.BaseDatumType, FieldName) > CApp =3D CApp + ' Value =3D %s; // From %s Line= %d Value %s\n' % > (DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1], > FieldList[FieldName][2], FieldList[FieldName][0]) > CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s,= %s) >=3D %d) > || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the buffer arra= y"); // > From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize, > Pcd.DatumType, FieldName, FieldList[FieldName][1], > FieldList[FieldName][2], FieldList[FieldName][0]) > CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSi= ze > 0 && > FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) > @@ -2090,7 +2203,7 @@ class DscBuildData(PlatformBuildClassObject): > return CApp >=20 > def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, > InitByteValue, CApp): > - OverrideValues =3D {DefaultStore:""} > + OverrideValues =3D {DefaultStore:{}} > if Pcd.SkuOverrideValues: > OverrideValues =3D Pcd.SkuOverrideValues[SkuName] > if not OverrideValues: > @@ -2106,16 +2219,14 @@ class DscBuildData(PlatformBuildClassObject): > CApp =3D CApp + ' CHAR8 *Value;\n' > CApp =3D CApp + ' UINT32 OriginalSize;\n' > CApp =3D CApp + ' VOID *OriginalPcd;\n' > - CApp =3D CApp + ' %s *Pcd; // From %s Line %d \n' % > (Pcd.DatumType, Pcd.PkgPath, Pcd.PcdDefineLineNo) > + > + CApp =3D CApp + ' %s *Pcd; // From %s Line %d \n' % > (Pcd.BaseDatumType,Pcd.PkgPath, Pcd.PcdDefineLineNo) > + > CApp =3D CApp + '\n' >=20 > - if SkuName in Pcd.SkuInfoList: > - DefaultValue =3D > Pcd.SkuInfoList[SkuName].DefaultStoreDict.get(DefaultStoreName, > Pcd.SkuInfoList[SkuName].HiiDefaultValue if > Pcd.SkuInfoList[SkuName].HiiDefaultValue else > Pcd.SkuInfoList[SkuName].DefaultValue) > - else: > - DefaultValue =3D Pcd.DefaultValue > - PcdDefaultValue =3D StringToArray(DefaultValue.strip()) > + PcdDefaultValue =3D StringToArray(Pcd.DefaultValueFromDec.st= rip()) >=20 > - InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % (SkuName, > DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, > Pcd.DatumType, PcdDefaultValue) > + InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % (SkuName, > DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, > Pcd.BaseDatumType, PcdDefaultValue) >=20 > # > # Get current PCD value and size > @@ -2138,7 +2249,7 @@ class DscBuildData(PlatformBuildClassObject): > # Always keep that larger one as the current size > # > CApp =3D CApp + ' Size =3D (OriginalSize > Size ? OriginalS= ize : Size);\n' > - CApp =3D CApp + ' Pcd =3D (%s *)malloc (Size);\n' % (Pc= d.DatumType) > + CApp =3D CApp + ' Pcd =3D (%s *)malloc (Size);\n' % > (Pcd.BaseDatumType,) > CApp =3D CApp + ' memset (Pcd, 0, Size);\n' >=20 > # > @@ -2167,7 +2278,7 @@ class DscBuildData(PlatformBuildClassObject): > # > # Set new PCD value and size > # > - CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *= )Pcd);\n' % > (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, > Pcd.TokenCName) > + CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void *)= Pcd);\n' % > (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, > Pcd.TokenCName) >=20 > # > # Free PCD > @@ -2176,6 +2287,39 @@ class DscBuildData(PlatformBuildClassObject): > CApp =3D CApp + '}\n' > CApp =3D CApp + '\n' > return InitByteValue, CApp > + > + def GenerateArrayAssignment(self, Pcd): > + CApp =3D "" > + if not Pcd: > + return CApp > + if not Pcd.IsArray(): > + return CApp > + Demesion =3D "" > + for d in Pcd.Capacity: > + if d =3D=3D "0": > + Demesion +=3D "[]" > + else: > + Demesion +=3D "["+d+"]" > + > + Value =3D Pcd.DefaultValueFromDec > + if "{CODE(" in Pcd.DefaultValueFromDec: > + realvalue =3D Pcd.DefaultValueFromDec.strip()[6:-2] # > "{CODE(").rstrip(")}" > + CApp +=3D "static %s %s_%s_INIT_Value%s =3D %s;\n" % > (Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,Demes > ion,realvalue) > + > + for skuname in Pcd.SkuInfoList: > + skuinfo =3D Pcd.SkuInfoList[skuname] > + if skuinfo.VariableName: > + for defaultstore in skuinfo.DefaultStoreDict: > + Value =3D skuinfo[defaultstore] > + if "{CODE(" in Value: > + realvalue =3D Value.strip()[6:-2] # "{CODE(").rs= trip(")}" > + CApp +=3D "static %s %s_%s_%s_%s_Value%s =3D %s;= \n" % > (Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuna > me,defaultstore,Demesion,realvalue) > + else: > + Value =3D skuinfo.DefaultValue > + if "{CODE(" in Value: > + realvalue =3D Value.strip()[6:-2] # "{CODE(").rstrip= (")}" > + CApp +=3D "static %s %s_%s_%s_%s_Value%s =3D %s;\n" = % > (Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuna > me,TAB_DEFAULT_STORES_DEFAULT,Demesion,realvalue) > + return CApp > def SkuOverrideValuesEmpty(self,OverrideValues): > if not OverrideValues: > return True > @@ -2215,6 +2359,8 @@ class DscBuildData(PlatformBuildClassObject): > IncludeFiles.add(IncludeFile) > CApp =3D CApp + '#include <%s>\n' % (IncludeFile) > CApp =3D CApp + '\n' > + for Pcd in StructuredPcds.values(): > + CApp =3D CApp + self.GenerateArrayAssignment(Pcd) > for PcdName in StructuredPcds: > Pcd =3D StructuredPcds[PcdName] > CApp =3D CApp + self.GenerateSizeFunction(Pcd) > @@ -2395,6 +2541,8 @@ class DscBuildData(PlatformBuildClassObject): > FileLine =3D FileInfo [1].split (')')[0] > else: > FileInfo =3D Message.strip().split(':') > + if len(FileInfo) < 2: > + continue > FileName =3D FileInfo [0] > FileLine =3D FileInfo [1] > if FileLine.isdigit(): > @@ -2478,7 +2626,7 @@ class DscBuildData(PlatformBuildClassObject): > if SkuName not in AvailableSkuIdSet: > EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is n= ot > defined in [SkuIds] section' % SkuName, > File=3Dself.MetaFile, Line= =3DDummy5) > - if "." not in TokenSpaceGuid: > + if "." not in TokenSpaceGuid and "[" not in PcdCName: > PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy= 5)) > PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] =3D Setting >=20 > @@ -2651,7 +2799,7 @@ class DscBuildData(PlatformBuildClassObject): > if DefaultStore not in DefaultStoresDefine: > EdkLogger.error('build', PARAMETER_INVALID, 'DefaultStor= es %s is > not defined in [DefaultStores] section' % DefaultStore, > File=3Dself.MetaFile, Line= =3DDummy5) > - if "." not in TokenSpaceGuid: > + if "." not in TokenSpaceGuid and "[" not in PcdCName: > PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, DefaultSt= ore, > Dummy5)) > PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid, DefaultStor= e] =3D > Setting >=20 > @@ -2814,7 +2962,7 @@ class DscBuildData(PlatformBuildClassObject): > if SkuName not in AvailableSkuIdSet: > EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is n= ot > defined in [SkuIds] section' % SkuName, > File=3Dself.MetaFile, Line= =3DDummy5) > - if "." not in TokenSpaceGuid: > + if "." not in TokenSpaceGuid and "[" not in PcdCName: > PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy= 5)) > PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] =3D Setting >=20 > diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py > b/BaseTools/Source/Python/Workspace/MetaFileParser.py > index 804a4aa5cb..6fde9e54f5 100644 > --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py > +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py > @@ -40,6 +40,7 @@ from .MetaFileCommentParser import > CheckInfComment > ## RegEx for finding file versions > hexVersionPattern =3D re.compile(r'0[xX][\da-f-A-F]{5,8}') > decVersionPattern =3D re.compile(r'\d+\.\d+') > +CODEPattern =3D re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}") >=20 > ## A decorator used to parse macro definition > def ParseMacro(Parser): > @@ -913,6 +914,10 @@ class DscParser(MetaFileParser): > # > self._IdMapping =3D {-1:-1} >=20 > + self._PcdCodeValue =3D "" > + self._PcdDataTypeCODE =3D False > + self._CurrentPcdName =3D "" > + > ## Parser starter > def Start(self): > Content =3D '' > @@ -922,6 +927,9 @@ class DscParser(MetaFileParser): > EdkLogger.error("Parser", FILE_READ_FAILURE, > ExtraData=3Dself.MetaFile) >=20 > OwnerId =3D {} > + > + Content =3D self.ProcessMultipleLineCODEValue(Content) > + > for Index in range(0, len(Content)): > Line =3D CleanString(Content[Index]) > # skip empty line > @@ -1133,6 +1141,41 @@ class DscParser(MetaFileParser): > def _LibraryInstanceParser(self): > self._ValueList[0] =3D self._CurrentLine >=20 > + def ProcessMultipleLineCODEValue(self,Content): > + CODEBegin =3D False > + CODELine =3D "" > + continuelinecount =3D 0 > + newContent =3D [] > + for Index in range(0, len(Content)): > + Line =3D Content[Index] > + if CODEBegin: > + CODELine =3D CODELine + Line > + continuelinecount +=3D1 > + if ")}" in Line: > + newContent.append(CODELine) > + for _ in range(continuelinecount): > + newContent.append("") > + CODEBegin =3D False > + CODELine =3D "" > + continuelinecount =3D 0 > + else: > + if not Line: > + newContent.append(Line) > + continue > + if "{CODE(" not in Line: > + newContent.append(Line) > + continue > + elif CODEPattern.findall(Line): > + newContent.append(Line) > + continue > + else: > + CODEBegin =3D True > + CODELine =3D Line > + > + return newContent > + > + def _DecodeCODEData(self): > + pass > ## PCD sections parser > # > # [PcdsFixedAtBuild] > @@ -1149,7 +1192,28 @@ class DscParser(MetaFileParser): > # > @ParseMacro > def _PcdParser(self): > + if self._PcdDataTypeCODE: > + self._PcdCodeValue =3D self._PcdCodeValue + "\n " + self._Cu= rrentLine > + if self._CurrentLine.endswith(")}"): > + self._CurrentLine =3D "|".join((self._CurrentPcdName, > self._PcdCodeValue)) > + self._PcdDataTypeCODE =3D False > + self._PcdCodeValue =3D "" > + else: > + self._ValueList =3D None > + return > TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPL= IT, 1) > + self._CurrentPcdName =3D TokenList[0] > + if TokenList[1].strip().startswith("{CODE"): > + self._PcdDataTypeCODE =3D True > + self._PcdCodeValue =3D TokenList[1].strip() > + > + if self._PcdDataTypeCODE: > + if self._CurrentLine.endswith(")}"): > + self._PcdDataTypeCODE =3D False > + self._PcdCodeValue =3D "" > + else: > + self._ValueList =3D None > + return > self._ValueList[0:1] =3D GetSplitValueList(TokenList[0], TAB_SPL= IT) > PcdNameTockens =3D GetSplitValueList(TokenList[0], TAB_SPLIT) > if len(PcdNameTockens) =3D=3D 2: > @@ -1907,6 +1971,17 @@ class DecParser(MetaFileParser): > if self._ValueList[0] not in self._GuidDict: > self._GuidDict[self._ValueList[0]] =3D self._ValueList[1] >=20 > + def ParsePcdName(self,namelist): > + if "[" in namelist[1]: > + pcdname =3D namelist[1][:namelist[1].index("[")] > + arrayindex =3D namelist[1][namelist[1].index("["):] > + namelist[1] =3D pcdname > + if len(namelist) =3D=3D 2: > + namelist.append(arrayindex) > + else: > + namelist[2] =3D ".".join((arrayindex,namelist[2])) > + return namelist > + > ## PCD sections parser > # > # [PcdsFixedAtBuild] > @@ -1945,9 +2020,16 @@ class DecParser(MetaFileParser): > return > else: > PcdTockens =3D self._CurrentLine.split(TAB_VALUE_SPLIT) > - PcdNames =3D PcdTockens[0].split(TAB_SPLIT) > + PcdNames =3D self.ParsePcdName(PcdTockens[0].split(TAB_S= PLIT)) > if len(PcdNames) =3D=3D 2: > - self._CurrentStructurePcdName =3D "" > + if PcdNames[1].strip().endswith("]"): > + PcdName =3D PcdNames[1][:PcdNames[1].index('[')] > + Index =3D PcdNames[1][PcdNames[1].index('['):] > + self._ValueList[0] =3D TAB_SPLIT.join((PcdNames[= 0],PcdName)) > + self._ValueList[1] =3D Index > + self._ValueList[2] =3D PcdTockens[1] > + else: > + self._CurrentStructurePcdName =3D "" > else: > if self._CurrentStructurePcdName !=3D > TAB_SPLIT.join(PcdNames[:2]): > EdkLogger.error('Parser', FORMAT_INVALID, "Pcd N= ame does > not match: %s and %s " % (self._CurrentStructurePcdName, > TAB_SPLIT.join(PcdNames[:2])), > -- > 2.19.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel