From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: liming.gao@intel.com) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by groups.io with SMTP; Thu, 09 May 2019 07:08:32 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2019 07:08:32 -0700 X-ExtLoop1: 1 Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 09 May 2019 07:08:32 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 9 May 2019 07:08:29 -0700 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 9 May 2019 07:08:28 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.33]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.150]) with mapi id 14.03.0415.000; Thu, 9 May 2019 22:08:26 +0800 From: "Liming Gao" To: "Fan, ZhijuX" , "devel@edk2.groups.io" Subject: Re: [Patch V3] BaseTools: Correct the value assignment for StructurePcd Thread-Topic: [Patch V3] BaseTools: Correct the value assignment for StructurePcd Thread-Index: AdUGSFxHVyZaXHS2RjiKZIpy5sIGSwAKCliw Date: Thu, 9 May 2019 14:08:26 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E445E64@SHSMSX104.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDVjNmY1MjAtNjM2Zi00YWE5LWI3YmEtYzgyN2JkN2YyOWFkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMXdmSEhQbXFJRXdsd293a2EyZGM3XC94VTNodFFBbDNpZmY1VkJpbTVBYW1UbFBZNDV1WUdka1k0enlFXC8wRWVVIn0= dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I think the test case is enough. I have no comments on the code logic. Revi= ewed-by: Liming Gao > -----Original Message----- > From: Fan, ZhijuX > Sent: Thursday, May 9, 2019 5:20 PM > To: devel@edk2.groups.io > Cc: Gao, Liming > Subject: [Patch V3] BaseTools: Correct the value assignment for Structure= Pcd >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1752 >=20 > This patch is to fix the code bug in StructurePcd overall > value assignment logic. If a Pcd Array size is fixed but the > size of actual value in Dsc or Dec is bigger than the Pcd > array size, the tool will report error about such setting and > stop build. >=20 > The patch is tested minplatform, Ovmf, structure pcd regression test > These tests are build pass. The patch also tested the following cases. > Our cases focused on PcdArraySize. 1.flexiable PcdArraySize. > 2.Fixed PcdArraySize, Pcd overall value exceeds the size of PcdArray. > 3.Fixed PcdArraySize, Pcd overall value Not exceeds the size of PcdArray= . >=20 > Signed-off-by: Bob Feng > Cc: Liming Gao > --- > BaseTools/Source/Python/Common/Misc.py | 1 + > .../Python/Workspace/BuildClassObject.py | 78 ++++--- > .../Source/Python/Workspace/DecBuildData.py | 2 +- > .../Source/Python/Workspace/DscBuildData.py | 211 ++++++++++++++---- > 4 files changed, 218 insertions(+), 74 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Py= thon/Common/Misc.py > index c7daf5417c..526aa2dd54 100644 > --- a/BaseTools/Source/Python/Common/Misc.py > +++ b/BaseTools/Source/Python/Common/Misc.py > @@ -40,10 +40,11 @@ from Common.Parsing import GetSplitValueList > from Common.LongFilePathSupport import OpenLongFilePath as open > from Common.MultipleWorkspace import MultipleWorkspace as mws > from CommonDataClass.Exceptions import BadExpression > from Common.caching import cached_property >=20 > +ArrayIndex =3D re.compile("\[\s*[0-9a-fA-FxX]*\s*\]") > ## Regular expression used to find out place holders in string template > gPlaceholderPattern =3D re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | r= e.UNICODE) >=20 > ## regular expressions for map file processing > startPatternGeneral =3D re.compile("^Start[' ']+Length[' ']+Name[' ']+Cl= ass") > diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/Base= Tools/Source/Python/Workspace/BuildClassObject.py > index b82af49236..b50e250cfb 100644 > --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py > +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py > @@ -14,14 +14,16 @@ > from collections import OrderedDict, namedtuple > from Common.DataType import * > import collections > import re > from collections import OrderedDict > -from Common.Misc import CopyDict > +from Common.Misc import CopyDict,ArrayIndex > import copy > +import Common.EdkLogger as EdkLogger > +from Common.BuildToolError import OPTION_VALUE_INVALID > StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') > -ArrayIndex =3D re.compile("\[\s*[0-9a-fA-FxX]*\s*\]") > + > ## PcdClassObject > # > # This Class is used for PcdObject > # > # @param object: Inherited from object class > @@ -66,44 +68,62 @@ class PcdClassObject(object): > self.validateranges =3D validateranges if validateranges is not = None else [] > self.validlists =3D validlists if validlists is not None else [] > self.expressions =3D expressions if expressions is not None else= [] > self.DscDefaultValue =3D None > self.DscRawValue =3D {} > + self.DscRawValueInfo =3D {} > if IsDsc: > self.DscDefaultValue =3D Value > self.PcdValueFromComm =3D "" > self.PcdValueFromFdf =3D "" > self.CustomAttribute =3D {} > self.UserDefinedDefaultStoresFlag =3D UserDefinedDefaultStoresFl= ag > self._Capacity =3D None >=20 > @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" > - maxsize =3D str(int(maxsize,16)) if maxsize.startswith(("0x"= ,"0X")) else maxsize > - 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") > + if self._Capacity is None: > + 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" > + maxsize =3D str(int(maxsize,16)) if maxsize.startswith((= "0x","0X")) else maxsize > + self._Capacity.append(maxsize) > + if hasattr(self, "SkuOverrideValues"): > + for sku in self.SkuOverrideValues: > + for defaultstore in self.SkuOverrideValues[sku]: > + fields =3D self.SkuOverrideValues[sku][defaultst= ore] > + for demesionattr in fields: > + fieldinfo =3D fields[demesionattr] > + deme =3D ArrayIndex.findall(demesionattr) > + for i in range(len(deme)): > + if int(deme[i].lstrip("[").rstrip("]").s= trip()) >=3D int(self._Capacity[i]): > + if self._Capacity[i] !=3D "-1": > + firstfieldinfo =3D list(fieldinf= o.values())[0] > + EdkLogger.error('Build', OPTION_= VALUE_INVALID, "For Pcd %s, Array Index exceed the > Array size. From %s Line %s \n " % > + (".".join((self.TokenSpaceGuidCName,= self.TokenCName)), firstfieldinfo[1],firstfieldinfo[2] )) > + if hasattr(self,"DefaultValues"): > + for demesionattr in self.DefaultValues: > + fieldinfo =3D self.DefaultValues[demesionattr] > + deme =3D ArrayIndex.findall(demesionattr) > + for i in range(len(deme)): > + if int(deme[i].lstrip("[").rstrip("]").strip()) = >=3D int(self._Capacity[i]): > + if self._Capacity[i] !=3D "-1": > + firstfieldinfo =3D list(fieldinfo.values= ())[0] > + EdkLogger.error('Build', OPTION_VALUE_IN= VALID, "For Pcd %s, Array Index exceed the Array size. > From %s Line %s \n " % > + (".".join((self.TokenSpaceGuidCName,= self.TokenCName)), firstfieldinfo[1],firstfieldinfo[2] )) > return self._Capacity > + > + def PcdArraySize(self): > + if self.Capacity[-1] =3D=3D "-1": > + return -1 > + size =3D 1 > + for de in self.Capacity: > + size =3D size * int(de) > + return size > @property > def DatumType(self): > return self._DatumType >=20 > @DatumType.setter > @@ -231,10 +251,11 @@ class PcdClassObject(object): > new_pcd.IsFromDsc =3D self.IsFromDsc > new_pcd.PcdValueFromComm =3D self.PcdValueFromComm > new_pcd.PcdValueFromFdf =3D self.PcdValueFromFdf > new_pcd.UserDefinedDefaultStoresFlag =3D self.UserDefinedDefault= StoresFlag > new_pcd.DscRawValue =3D self.DscRawValue > + new_pcd.DscRawValueInfo =3D self.DscRawValueInfo > new_pcd.CustomAttribute =3D self.CustomAttribute > new_pcd.validateranges =3D [item for item in self.validateranges= ] > new_pcd.validlists =3D [item for item in self.validlists] > new_pcd.expressions =3D [item for item in self.expressions] > new_pcd.SkuInfoList =3D {key: copy.deepcopy(skuobj) for key,skuo= bj in self.SkuInfoList.items()} > @@ -266,10 +287,11 @@ class StructurePcd(PcdClassObject): > self.SkuOverrideValues =3D OrderedDict() > self.StructName =3D None > self.PcdDefineLineNo =3D 0 > self.PkgPath =3D "" > self.DefaultValueFromDec =3D "" > + self.DefaultValueFromDecInfo =3D None > self.ValueChain =3D set() > self.PcdFieldValueFromComm =3D OrderedDict() > self.PcdFieldValueFromFdf =3D OrderedDict() > self.DefaultFromDSC=3DNone > def __repr__(self): > @@ -281,12 +303,13 @@ class StructurePcd(PcdClassObject): > 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): > + def SetDecDefaultValue(self, DefaultValue,decpath=3DNone,lineno=3DNo= ne): > self.DefaultValueFromDec =3D DefaultValue > + self.DefaultValueFromDecInfo =3D (decpath,lineno) > def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreN= ame, 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 Ordere= dDict() > @@ -317,20 +340,22 @@ class StructurePcd(PcdClassObject): > self.IsFromDsc =3D PcdObject.IsFromDsc if PcdObject.IsFromDsc el= se self.IsFromDsc > self.validateranges =3D PcdObject.validateranges if PcdObject.va= lidateranges else self.validateranges > self.validlists =3D PcdObject.validlists if PcdObject.validlists= else self.validlists > self.expressions =3D PcdObject.expressions if PcdObject.expressi= ons else self.expressions > self.DscRawValue =3D PcdObject.DscRawValue if PcdObject.DscRawVa= lue else self.DscRawValue > + self.DscRawValueInfo =3D PcdObject.DscRawValueInfo if PcdObject.= DscRawValueInfo else self.DscRawValueInfo > self.PcdValueFromComm =3D PcdObject.PcdValueFromComm if PcdObjec= t.PcdValueFromComm else self.PcdValueFromComm > self.PcdValueFromFdf =3D PcdObject.PcdValueFromFdf if PcdObject.= PcdValueFromFdf else self.PcdValueFromFdf > self.CustomAttribute =3D PcdObject.CustomAttribute if PcdObject.= CustomAttribute else self.CustomAttribute > self.UserDefinedDefaultStoresFlag =3D PcdObject.UserDefinedDefau= ltStoresFlag if PcdObject.UserDefinedDefaultStoresFlag else > self.UserDefinedDefaultStoresFlag > if isinstance(PcdObject, StructurePcd): > self.StructuredPcdIncludeFile =3D PcdObject.StructuredPcdInc= ludeFile if PcdObject.StructuredPcdIncludeFile else > self.StructuredPcdIncludeFile > self.PackageDecs =3D PcdObject.PackageDecs if PcdObject.Pack= ageDecs else self.PackageDecs > self.DefaultValues =3D PcdObject.DefaultValues if PcdObject.= DefaultValues else self.DefaultValues > self.PcdMode =3D PcdObject.PcdMode if PcdObject.PcdMode else= self.PcdMode > self.DefaultValueFromDec =3D PcdObject.DefaultValueFromDec i= f PcdObject.DefaultValueFromDec else > self.DefaultValueFromDec > + self.DefaultValueFromDecInfo =3D PcdObject.DefaultValueFromD= ecInfo if PcdObject.DefaultValueFromDecInfo else > self.DefaultValueFromDecInfo > self.SkuOverrideValues =3D PcdObject.SkuOverrideValues if Pc= dObject.SkuOverrideValues else self.SkuOverrideValues > self.StructName =3D PcdObject.DatumType if PcdObject.DatumTy= pe else self.StructName > self.PcdDefineLineNo =3D PcdObject.PcdDefineLineNo if PcdObj= ect.PcdDefineLineNo else self.PcdDefineLineNo > self.PkgPath =3D PcdObject.PkgPath if PcdObject.PkgPath else= self.PkgPath > self.ValueChain =3D PcdObject.ValueChain if PcdObject.ValueC= hain else self.ValueChain > @@ -340,10 +365,11 @@ class StructurePcd(PcdClassObject): > def __deepcopy__(self,memo): > new_pcd =3D StructurePcd() > self.sharedcopy(new_pcd) >=20 > new_pcd.DefaultValueFromDec =3D self.DefaultValueFromDec > + new_pcd.DefaultValueFromDecInfo =3D self.DefaultValueFromDecInfo > new_pcd.PcdMode =3D self.PcdMode > new_pcd.StructName =3D self.DatumType > new_pcd.PcdDefineLineNo =3D self.PcdDefineLineNo > new_pcd.PkgPath =3D self.PkgPath > new_pcd.StructuredPcdIncludeFile =3D [item for item in self.Stru= cturedPcdIncludeFile] > diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTool= s/Source/Python/Workspace/DecBuildData.py > index 149c057b70..ea0f816e27 100644 > --- a/BaseTools/Source/Python/Workspace/DecBuildData.py > +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py > @@ -399,11 +399,11 @@ class DecBuildData(PackageBuildClassObject): > struct_pcd.copy(item) > struct_pcd.TokenValue =3D struct_pcd.TokenValue.stri= p("{").strip() > struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCNam= e =3D pcdname.split(".") > struct_pcd.PcdDefineLineNo =3D LineNo > struct_pcd.PkgPath =3D self.MetaFile.File > - struct_pcd.SetDecDefaultValue(item.DefaultValue) > + struct_pcd.SetDecDefaultValue(item.DefaultValue,self= .MetaFile.File,LineNo) > else: > 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 > diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTool= s/Source/Python/Workspace/DscBuildData.py > index 1ffefe6e7e..7b8c9eedf6 100644 > --- a/BaseTools/Source/Python/Workspace/DscBuildData.py > +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py > @@ -31,21 +31,20 @@ from .MetaDataTable import * > from .MetaFileTable import * > from .MetaFileParser import * >=20 > from .WorkspaceCommon import GetDeclaredPcd > from Common.Misc import AnalyzeDscPcd > -from Common.Misc import ProcessDuplicatedInf,RemoveCComments > +from Common.Misc import ProcessDuplicatedInf,RemoveCComments,ArrayIndex > import re > from Common.Parsing import IsValidWord > from Common.VariableAttributes import VariableAttributes > import Common.GlobalData as GlobalData > import subprocess > from functools import reduce > from Common.Misc import SaveFileOnChange > from Workspace.BuildClassObject import PlatformBuildClassObject, Structu= rePcd, PcdClassObject, ModuleBuildClassObject > from collections import OrderedDict, defaultdict > -from .BuildClassObject import ArrayIndex >=20 > def _IsFieldValueAnArray (Value): > Value =3D Value.strip() > if Value.startswith(TAB_GUID) and Value.endswith(')'): > return True > @@ -1681,21 +1680,21 @@ class DscBuildData(PlatformBuildClassObject): > File=3Dself.MetaFile, Line=3DDummy4) > if int(MaxDatumSize, 0) < 0: > EdkLogger.error('build', FORMAT_INVALID, "The size v= alue can't be set to negative value for %s." % > ".".join((TokenSpaceGuid, PcdCName)), > File=3Dself.MetaFile, Line=3DDummy4) > if (PcdCName, TokenSpaceGuid) in PcdValueDict: > - PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] =3D (Pcd= Value, DatumType, MaxDatumSize) > + PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] =3D (Pcd= Value, DatumType, MaxDatumSize,Dummy4) > else: > - PcdValueDict[PcdCName, TokenSpaceGuid] =3D {SkuName:(Pcd= Value, DatumType, MaxDatumSize)} > + PcdValueDict[PcdCName, TokenSpaceGuid] =3D {SkuName:(Pcd= Value, DatumType, MaxDatumSize,Dummy4)} >=20 > for ((PcdCName, TokenSpaceGuid), PcdSetting) in PcdValueDict.ite= ms(): > if self.SkuIdMgr.SystemSkuId in PcdSetting: > - PcdValue, DatumType, MaxDatumSize =3D PcdSetting[self.Sk= uIdMgr.SystemSkuId] > + PcdValue, DatumType, MaxDatumSize,_ =3D PcdSetting[self.= SkuIdMgr.SystemSkuId] > elif TAB_DEFAULT in PcdSetting: > - PcdValue, DatumType, MaxDatumSize =3D PcdSetting[TAB_DEF= AULT] > + PcdValue, DatumType, MaxDatumSize,_ =3D PcdSetting[TAB_= DEFAULT] > elif TAB_COMMON in PcdSetting: > - PcdValue, DatumType, MaxDatumSize =3D PcdSetting[TAB_COM= MON] > + PcdValue, DatumType, MaxDatumSize,_ =3D PcdSetting[TAB_= COMMON] > else: > PcdValue =3D None > DatumType =3D None > MaxDatumSize =3D None >=20 > @@ -1713,11 +1712,13 @@ class DscBuildData(PlatformBuildClassObject): > IsDsc=3DTrue) > for SkuName in PcdValueDict[PcdCName, TokenSpaceGuid]: > Settings =3D PcdValueDict[PcdCName, TokenSpaceGuid][SkuN= ame] > if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawV= alue: > Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] = =3D {} > + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuNa= me] =3D {} > Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][TAB_= DEFAULT_STORES_DEFAULT] =3D Settings[0] > + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][= TAB_DEFAULT_STORES_DEFAULT] =3D > (self.MetaFile.File,Settings[3]) > return Pcds >=20 > @staticmethod > def GetStructurePcdMaxSize(str_pcd): > pcd_default_value =3D str_pcd.DefaultValue > @@ -1766,28 +1767,45 @@ class DscBuildData(PlatformBuildClassObject): > return Result >=20 > def GenerateSizeFunction(self, Pcd): > CApp =3D "// Default Value in Dec \n" > CApp =3D CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.To= kenSpaceGuidCName, Pcd.TokenCName) > - if Pcd.IsArray(): > + > + if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": > + CApp +=3D " *Size =3D (sizeof (%s) > *Size ? sizeof (%s) : = *Size);\n" % (Pcd.DatumType,Pcd.DatumType) > + else: > + 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.Token= CName) > if Pcd.Type in PCD_DYNAMIC_TYPE_SET | PCD_DYNAMIC_EX_TYPE_SE= T: > for skuname in Pcd.SkuInfoList: > skuobj =3D Pcd.SkuInfoList[skuname] > if skuobj.VariableName: > for defaultstore in skuobj.DefaultStoreDict: > pcddef =3D self.GetPcdDscRawDefaultValue(Pcd= ,skuname,defaultstore) > - if pcddef and "{CODE(" in pcddef: > - CApp +=3D " *Size =3D (sizeof (%s_%s_%s= _%s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % > (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,defaultstore,Pcd.TokenSpa= ceGuidCName,Pcd.TokenCName,skuname,defaultstore) > + if pcddef: > + if "{CODE(" in pcddef: > + CApp +=3D " *Size =3D (sizeof (%s_%= s_%s_%s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : > *Size);\n" % > (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,defaultstore,Pcd.TokenSpa= ceGuidCName,Pcd.TokenCName,skuname,defaultstore) > + else: > + CApp +=3D " *Size =3D %s > *Size ? = %s : *Size;\n" % > (self.GetStructurePcdMaxSize(Pcd),self.GetStructurePcdMaxSize(Pcd)) > else: > pcddef =3D self.GetPcdDscRawDefaultValue(Pcd,sku= name,TAB_DEFAULT_STORES_DEFAULT) > - if pcddef and "{CODE(" in pcddef: > - 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_STORES_DEFAUL= T,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,sku > name,TAB_DEFAULT_STORES_DEFAULT) > + if pcddef: > + if "{CODE(" in pcddef: > + 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_STORES_DEFAUL= T,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,sku > name,TAB_DEFAULT_STORES_DEFAULT) > + else: > + CApp +=3D " *Size =3D %s > *Size ? %s := *Size;\n" % > (self.GetStructurePcdMaxSize(Pcd),self.GetStructurePcdMaxSize(Pcd)) > else: > pcddef =3D self.GetPcdDscRawDefaultValue(Pcd,TAB_DEFAULT= ,TAB_DEFAULT_STORES_DEFAULT) > - if pcddef and "{CODE(" in pcddef: > - CApp +=3D " *Size =3D (sizeof (%s_%s_%s_%s_Value) >= *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % > (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,TAB_DEFAULT,TAB_DEFAULT_STORES_DE= FAULT,Pcd.TokenSpaceGuidCName,Pcd.TokenCName, > TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT) > + if pcddef: > + if "{CODE(" in pcddef: > + CApp +=3D " *Size =3D (sizeof (%s_%s_%s_%s_Valu= e) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % > (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,TAB_DEFAULT,TAB_DEFAULT_STORES_DE= FAULT,Pcd.TokenSpaceGuidCName,Pcd.TokenCName, > TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT) > + else: > + CApp +=3D " *Size =3D %s > *Size ? %s : *Size;\= n" % > (self.GetStructurePcdMaxSize(Pcd),self.GetStructurePcdMaxSize(Pcd)) > + ActualCap =3D [] > for index in Pcd.DefaultValues: > + if index: > + ActualCap.append(index) > FieldList =3D Pcd.DefaultValues[index] > if not FieldList: > continue > for FieldName in FieldList: > FieldName =3D "." + FieldName > @@ -1804,22 +1822,24 @@ class DscBuildData(PlatformBuildClassObject): > else: > NewFieldName =3D '' > FieldName_ori =3D FieldName.strip('.') > while '[' in FieldName: > NewFieldName =3D NewFieldName + FieldName.split(= '[', 1)[0] + '[0]' > - ArrayIndex =3D int(FieldName.split('[', 1)[1].sp= lit(']', 1)[0]) > + Array_Index =3D int(FieldName.split('[', 1)[1].s= plit(']', 1)[0]) > FieldName =3D FieldName.split(']', 1)[1] > FieldName =3D NewFieldName + FieldName > while '[' in FieldName and not Pcd.IsArray: > 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], FieldL= ist[FieldName_ori][2], FieldList[FieldName_ori][0]) > + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s= , %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, > FieldName.strip("."), Array_Index + 1, FieldList[FieldName_ori][1], Field= List[FieldName_ori][2], FieldList[FieldName_ori][0]) > for skuname in Pcd.SkuOverrideValues: > if skuname =3D=3D TAB_COMMON: > continue > for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]: > CApp =3D CApp + "// SkuName: %s, DefaultStoreName: %s \= n" % (skuname, defaultstorenameitem) > for index in Pcd.SkuOverrideValues[skuname][defaultstore= nameitem]: > + if index: > + ActualCap.append(index) > for FieldList in [Pcd.SkuOverrideValues[skuname][def= aultstorenameitem][index]]: > if not FieldList: > continue > for FieldName in FieldList: > FieldName =3D "." + FieldName > @@ -1836,16 +1856,16 @@ class DscBuildData(PlatformBuildClassObject): > 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]) > + Array_Index =3D int(FieldName.split(= '[', 1)[1].split(']', 1)[0]) > FieldName =3D FieldName.split(']', 1= )[1] > FieldName =3D NewFieldName + FieldName > while '[' in FieldName and not Pcd.IsArr= ay: > 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]) > + CApp =3D CApp + ' __FLEXIBLE_SIZE(*= Size, %s, %s, %d); // From %s Line %d Value %s \n' % > (Pcd.DatumType, FieldName.strip("."), Array_Index + 1, FieldList[FieldNam= e_ori][1], FieldList[FieldName_ori][2], > FieldList[FieldName_ori][0]) > if Pcd.PcdFieldValueFromFdf: > CApp =3D CApp + "// From fdf \n" > for FieldName in Pcd.PcdFieldValueFromFdf: > FieldName =3D "." + FieldName > IsArray =3D _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[Fi= eldName.strip(".")][0]) > @@ -1861,16 +1881,16 @@ class DscBuildData(PlatformBuildClassObject): > else: > NewFieldName =3D '' > FieldName_ori =3D FieldName.strip('.') > while '[' in FieldName: > NewFieldName =3D NewFieldName + FieldName.split('[',= 1)[0] + '[0]' > - ArrayIndex =3D int(FieldName.split('[', 1)[1].split(= ']', 1)[0]) > + Array_Index =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 %s Value %s \n' % (Pcd.DatumType, > FieldName.strip("."), ArrayIndex + 1, Pcd.PcdFieldValueFromFdf[FieldName_= ori][1], Pcd.PcdFieldValueFromFdf[FieldName_ori][2], > Pcd.PcdFieldValueFromFdf[FieldName_ori][0]) > + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d= ); // From %s Line %s Value %s \n' % (Pcd.DatumType, > FieldName.strip("."), Array_Index + 1, Pcd.PcdFieldValueFromFdf[FieldName= _ori][1], Pcd.PcdFieldValueFromFdf[FieldName_ori][2], > Pcd.PcdFieldValueFromFdf[FieldName_ori][0]) > if Pcd.PcdFieldValueFromComm: > CApp =3D CApp + "// From Command Line \n" > for FieldName in Pcd.PcdFieldValueFromComm: > FieldName =3D "." + FieldName > IsArray =3D _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[F= ieldName.strip(".")][0]) > @@ -1886,20 +1906,41 @@ class DscBuildData(PlatformBuildClassObject): > else: > NewFieldName =3D '' > FieldName_ori =3D FieldName.strip('.') > while '[' in FieldName: > NewFieldName =3D NewFieldName + FieldName.split('[',= 1)[0] + '[0]' > - ArrayIndex =3D int(FieldName.split('[', 1)[1].split(= ']', 1)[0]) > + Array_Index =3D int(FieldName.split('[', 1)[1].split= (']', 1)[0]) > FieldName =3D FieldName.split(']', 1)[1] > FieldName =3D NewFieldName + FieldName > while '[' in FieldName and not Pcd.IsArray: > 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 + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d= ); // From %s Line %d Value %s \n' % (Pcd.DatumType, > FieldName.strip("."), Array_Index + 1, Pcd.PcdFieldValueFromComm[FieldNam= e_ori][1], Pcd.PcdFieldValueFromComm[FieldName_ori][2], > Pcd.PcdFieldValueFromComm[FieldName_ori][0]) > 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()) > + ArraySizeByAssign =3D self.CalculateActualCap(ActualCap) > + if ArraySizeByAssign > 1: > + CApp =3D CApp + " *Size =3D (%d > *Size ? %d : *Size); \n" = % (ArraySizeByAssign, ArraySizeByAssign) > CApp =3D CApp + "}\n" > return CApp > + def CalculateActualCap(self,ActualCap): > + if not ActualCap: > + return 1 > + maxsize =3D 1 > + for item in ActualCap: > + index_elements =3D ArrayIndex.findall(item) > + rt =3D 1 > + for index_e in index_elements: > + index_num =3D index_e.lstrip("[").rstrip("]").strip() > + if not index_num: > + # Not support flexiable pcd array assignment > + return 1 > + index_num =3D int(index_num,16) if index_num.startswith(= ("0x","0X")) else int(index_num) > + rt =3D rt * (index_num+1) > + if rt >maxsize: > + maxsize =3D rt > + > + return maxsize >=20 > @staticmethod > def GenerateSizeStatments(Pcd,skuname,defaultstorename): > if Pcd.IsArray(): > r_datatype =3D [Pcd.BaseDatumType] > @@ -1974,10 +2015,11 @@ class DscBuildData(PlatformBuildClassObject): > 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.BaseDatumType) > CApp =3D CApp + ' UINT32 FieldSize;\n' > CApp =3D CApp + ' CHAR8 *Value;\n' > + CApp =3D CApp + ' UINT32 PcdArraySize;\n' > DefaultValueFromDec =3D Pcd.DefaultValueFromDec > IsArray =3D _IsFieldValueAnArray(Pcd.DefaultValueFromDec) > if IsArray: > try: > DefaultValueFromDec =3D ValueExpressionEx(Pcd.DefaultVal= ueFromDec, TAB_VOID)(True) > @@ -1985,18 +2027,33 @@ class DscBuildData(PlatformBuildClassObject): > EdkLogger.error("Build", FORMAT_INVALID, "Invalid value = format for %s.%s, from DEC: %s" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName= , DefaultValueFromDec)) > DefaultValueFromDec =3D StringToArray(DefaultValueFromDec) > Value, ValueSize =3D ParseFieldValue (DefaultValueFromDec) > if IsArray: > - # > - # Use memcpy() to copy value into field > - # > - 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) > + # > + # Use memcpy() to copy value into field > + # > + if Pcd.IsArray(): > + pcdarraysize =3D Pcd.PcdArraySize() > + if "{CODE(" in Pcd.DefaultValueFromDec: > + if Pcd.Capacity[-1] !=3D "-1": > + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_IN= IT_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dec > exceed the array capability %s"); // From %s Line %s \n ' % (Pcd.TokenSp= aceGuidCName, > Pcd.TokenCName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.DefaultVa= lueFromDecInfo[1]) > + CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_INIT= _Value);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) > + CApp =3D CApp + ' memcpy (Pcd, %s_%s_INIT_Value,Pcd= ArraySize);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName) > + else: > + if Pcd.Capacity[-1] !=3D "-1": > + CApp =3D CApp + '__STATIC_ASSERT(%d < %d * sizeo= f(%s), "Pcd %s.%s Value in Dec exceed the array > capability %s"); // From %s Line %s \n' % (ValueSize,pcdarraysize,Pcd.Bas= eDatumType,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.DefaultVa= lueFromDecInfo[1]) > + CApp =3D CApp + ' PcdArraySize =3D %d;\n' % ValueSiz= e > + CApp =3D CApp + ' Value =3D %s; // From DEC Def= ault Value %s\n' % (DscBuildData.IntToCString(Value, > ValueSize), Pcd.DefaultValueFromDec) > + CApp =3D CApp + ' memcpy (Pcd, Value, PcdArraySize)= ;\n' > 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) > + if "{CODE(" in Pcd.DefaultValueFromDec: > + CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_INI= T_Value);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) > + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_INIT_Value,Pc= dArraySize);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName) > + else: > + CApp =3D CApp + ' Value =3D %s; // From DEC Def= ault Value %s\n' % (DscBuildData.IntToCString(Value, > ValueSize), Pcd.DefaultValueFromDec) > + CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Va= lueSize) > elif isinstance(Value, str): > CApp =3D CApp + ' Pcd =3D %s; // From DEC Default Value %s\= n' % (Value, Pcd.DefaultValueFromDec) > for index in Pcd.DefaultValues: > FieldList =3D Pcd.DefaultValues[index] > if not FieldList: > @@ -2050,18 +2107,33 @@ class DscBuildData(PlatformBuildClassObject): > pcddefaultvalue =3D Pcd.DscRawValue.get(SkuName, {}).get= (DefaultStoreName) > else: > pcddefaultvalue =3D Pcd.DscRawValue.get(SkuName, {}).get(TAB= _DEFAULT_STORES_DEFAULT) >=20 > return pcddefaultvalue > + def GetPcdDscRawValueInfo(self,Pcd, SkuName,DefaultStoreName): > + DscValueInfo =3D Pcd.DscRawValueInfo.get(SkuName, {}).get(Defaul= tStoreName) > + if DscValueInfo: > + dscfilepath,lineno =3D DscValueInfo > + else: > + dscfilepath =3D self.MetaFile.File > + lineno =3D "" > + return dscfilepath,lineno > + > 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" % (P= cd.TokenSpaceGuidCName, Pcd.TokenCName, SkuName, > DefaultStoreName, Pcd.BaseDatumType) > CApp =3D CApp + ' UINT32 FieldSize;\n' > CApp =3D CApp + ' CHAR8 *Value;\n' > + CApp =3D CApp + ' UINT32 PcdArraySize;\n' >=20 > CApp =3D CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (TA= B_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) > inherit_OverrideValues =3D Pcd.SkuOverrideValues[SkuName] > + dscfilepath,lineno =3D self.GetPcdDscRawValueInfo(Pcd, SkuName, = DefaultStoreName) > + if lineno: > + valuefrom =3D "%s Line %s" % (dscfilepath,str(lineno)) > + else: > + valuefrom =3D dscfilepath >=20 > pcddefaultvalue =3D self.GetPcdDscRawDefaultValue(Pcd, SkuName, = DefaultStoreName) > if pcddefaultvalue: > FieldList =3D pcddefaultvalue > IsArray =3D _IsFieldValueAnArray(FieldList) > @@ -2075,37 +2147,75 @@ class DscBuildData(PlatformBuildClassObject): > Value, ValueSize =3D ParseFieldValue (FieldList) >=20 > if (SkuName, DefaultStoreName) =3D=3D (TAB_DEFAULT, TAB_DEFA= ULT_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.To= kenSpaceGuidCName, Pcd.TokenCName,SkuName, > DefaultStoreName) > + if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": > + pcdarraysize =3D Pcd.PcdArraySize() > + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%= s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc > exceed the array capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCNa= me, Pcd.TokenCName,SkuName, > DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, = Pcd.TokenCName,Pcd.DatumType, valuefrom) > + CApp =3D CApp+ ' PcdArraySize =3D sizeof(%s_%s_%= s_%s_Value);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_Val= ue,PcdArraySize);\n ' % (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, P= cd.DefaultValue) if Pcd.DefaultFromDSC else > Pcd.DefaultValue) > elif IsArray: > - # > - # Use memcpy() to copy value into field > - # > - if Pcd.IsArray() and "{CODE(" in pcddefaultvalue: > - 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.To= kenSpaceGuidCName, Pcd.TokenCName,SkuName, > DefaultStoreName) > + # > + # Use memcpy() to copy value into field > + # > + if Pcd.IsArray(): > + pcdarraysize =3D Pcd.PcdArraySize() > + if "{CODE(" in pcddefaultvalue: > + if Pcd.Capacity[-1] !=3D "-1": > + CApp =3D CApp + '__STATIC_ASSERT(sizeof(= %s_%s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value > in Dsc exceed the array capability %s"); // From %s \n' % (Pcd.TokenSpac= eGuidCName, Pcd.TokenCName,SkuName, > DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, = Pcd.TokenCName,Pcd.DatumType,valuefrom) > + CApp =3D CApp + ' PcdArraySize =3D sizeof(%s= _%s_%s_%s_Value);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_= Value, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + else: > + if Pcd.Capacity[-1] !=3D "-1": > + CApp =3D CApp + '__STATIC_ASSERT(%d < %d= * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array > capability %s"); // From %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumT= ype,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,valuefrom) > + CApp =3D CApp + ' PcdArraySize =3D %d;\n' % = ValueSize > + CApp =3D CApp + ' Value =3D %s; // From= DSC Default Value %s\n' % (DscBuildData.IntToCString(Value, > ValueSize), Pcd.DefaultFromDSC.get(TAB_DEFAULT, {}).get(TAB_DEFAULT_STORE= S_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else > Pcd.DefaultValue) > + CApp =3D CApp + ' memcpy (Pcd, Value, PcdAr= raySize);\n' > 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_STORE= S_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else > Pcd.DefaultValue) > - CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' %= (ValueSize) > + if "{CODE(" in pcddefaultvalue: > + CApp =3D CApp + ' PcdArraySize =3D %d < siz= eof(%s) * %d ? %d: sizeof(%s) * %d;\n ' % > (ValueSize,Pcd.BaseDatumType,pcdarraysize,ValueSize,Pcd.BaseDatumType,pcd= arraysize) > + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s= _Value, PcdArraySize);\n' % > (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_STORE= S_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else > Pcd.DefaultValue) > + CApp =3D CApp + ' memcpy (Pcd, Value, %d);\= n' % (ValueSize) > 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.To= kenSpaceGuidCName, Pcd.TokenCName,SkuName, > DefaultStoreName) > + if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": > + pcdarraysize =3D Pcd.PcdArraySize() > + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%= s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc > exceed the array capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCNa= me, Pcd.TokenCName,SkuName, > DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, = Pcd.TokenCName,Pcd.DatumType,valuefrom) > + CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_= %s_%s_Value);\n '% (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_Val= ue, PcdArraySize);\n' % (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 > - # > - if Pcd.IsArray() and "{CODE(" in pcddefaultvalue: > - 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.To= kenSpaceGuidCName, Pcd.TokenCName,SkuName, > DefaultStoreName) > + # > + # Use memcpy() to copy value into field > + # > + if Pcd.IsArray(): > + pcdarraysize =3D Pcd.PcdArraySize() > + if "{CODE(" in pcddefaultvalue: > + if Pcd.Capacity[-1] !=3D "-1": > + CApp =3D CApp + '__STATIC_ASSERT(sizeof(= %s_%s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value > in Dsc exceed the array capability %s"); // From %s \n' % (Pcd.TokenSpac= eGuidCName, Pcd.TokenCName,SkuName, > DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, = Pcd.TokenCName,Pcd.DatumType,valuefrom) > + CApp + ' PcdArraySize =3D sizeof(%s_%s_%s_%s= _Value);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_= Value, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) > + else: > + if Pcd.Capacity[-1] !=3D "-1": > + CApp =3D CApp + '__STATIC_ASSERT(%d < %d= * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array > capability %s"); // From %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumT= ype,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,valuefrom) > + CApp =3D CApp + ' PcdArraySize =3D %d;\n' % = ValueSize > + CApp =3D CApp + ' Value =3D %s; // From= DSC Default Value %s\n' % (DscBuildData.IntToCString(Value, > ValueSize), Pcd.DscRawValue.get(TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_D= EFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else > Pcd.DefaultValue) > + CApp =3D CApp + ' memcpy (Pcd, Value, PcdAr= raySize);\n' > 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) > + if "{CODE(" in pcddefaultvalue: > + CApp =3D CApp + ' PcdArraySize =3D %d < siz= eof(%s) * %d ? %d: sizeof(%s) * %d;\n ' % > (ValueSize,Pcd.BaseDatumType,pcdarraysize,ValueSize,Pcd.BaseDatumType,pcd= arraysize) > + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s= _Value, PcdArraySize);\n' % > (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) >=20 > inheritvalue =3D inherit_OverrideValues.get(DefaultStoreName) > if not inheritvalue: > inheritvalue =3D [] > for index in inheritvalue: > @@ -2327,10 +2437,13 @@ class DscBuildData(PlatformBuildClassObject): > # the flexible array member. The flexible array member must= be the last field > # in a structure. The size formula for this case is: > # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * = (HighestIndex + 1) > # > CApp =3D CApp + DscBuildData.GenerateSizeStatments(Pcd,SkuNa= me,DefaultStoreName) > + if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": > + CApp =3D CApp + ' OriginalSize =3D OriginalSize < sizeo= f(%s) * %d? OriginalSize:sizeof(%s) * %d; \n' % > (Pcd.BaseDatumType,Pcd.PcdArraySize(),Pcd.BaseDatumType,Pcd.PcdArraySize(= )) > + CApp =3D CApp + ' Size =3D sizeof(%s) * %d; \n' % (Pcd.= BaseDatumType,Pcd.PcdArraySize()) >=20 > # > # Allocate and zero buffer for the PCD > # Must handle cases where current value is smaller, larger, = or same size > # Always keep that larger one as the current size > @@ -2377,12 +2490,10 @@ class DscBuildData(PlatformBuildClassObject): >=20 > def GenerateArrayAssignment(self, Pcd): > CApp =3D "" > if not Pcd: > return CApp > - if not Pcd.IsArray(): > - return CApp > Demesion =3D "" > for d in Pcd.Capacity: > Demesion +=3D "[]" >=20 > Value =3D Pcd.DefaultValueFromDec > @@ -2770,11 +2881,13 @@ class DscBuildData(PlatformBuildClassObject): > None, > IsDsc=3DTrue) >=20 > if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue= : > Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] =3D = {} > + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName] = =3D {} > Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][TAB_DEFA= ULT_STORES_DEFAULT] =3D PcdValue > + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][TAB_= DEFAULT_STORES_DEFAULT] =3D > (self.MetaFile.File,Dummy4) >=20 > for pcd in Pcds.values(): > pcdDecObject =3D self._DecPcds[pcd.TokenCName, pcd.TokenSpac= eGuidCName] > # Only fix the value while no value provided in DSC file. > for sku in pcd.SkuInfoList.values(): > @@ -2972,11 +3085,13 @@ class DscBuildData(PlatformBuildClassObject): > Pcds[PcdCName, TokenSpaceGuid] =3D PcdClassObj >=20 > Pcds[PcdCName, TokenSpaceGuid].CustomAttribute['DscPosit= ion'] =3D int(Dummy4) > if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue= : > Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] =3D = {} > + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName] = =3D {} > Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][DefaultS= tore] =3D DefaultValue > + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][Defa= ultStore] =3D (self.MetaFile.File,Dummy4) > for pcd in Pcds.values(): > pcdDecObject =3D self._DecPcds[pcd.TokenCName, pcd.TokenSpac= eGuidCName] > pcd.DatumType =3D pcdDecObject.DatumType > # Only fix the value while no value provided in DSC file. > for sku in pcd.SkuInfoList.values(): > @@ -3110,11 +3225,13 @@ class DscBuildData(PlatformBuildClassObject): > None, > IsDsc=3DTrue) >=20 > if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue= : > Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] =3D = {} > + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName] = =3D {} > Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][TAB_DEFA= ULT_STORES_DEFAULT] =3D InitialValue > + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][TAB_= DEFAULT_STORES_DEFAULT] =3D > (self.MetaFile.File,Dummy4) > for pcd in Pcds.values(): > pcdDecObject =3D self._DecPcds[pcd.TokenCName, pcd.TokenSpac= eGuidCName] > pcd.DatumType =3D pcdDecObject.DatumType > # Only fix the value while no value provided in DSC file. > for sku in pcd.SkuInfoList.values(): > -- > 2.18.0.windows.1