From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1869478003C for ; Fri, 1 Mar 2024 02:10:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=mEH55+3a7GcTAOkTVYMmdQ5jjsQDXtbI5VUJQLmhRJU=; c=relaxed/simple; d=groups.io; h=From:To:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1709259014; v=1; b=up5cs0zznziyly9b/0rRVk8eHXv5YKf+hJ6mu86rGzSZOMO0uHKDIl7hojnYTyjvB8Mb6yJb 3KT9+UdDcaiG2Ny6bTY8+k1ngUp8D1kO1lYkK+ZBEORr7LW5qDjHufwfCxlqGrHaejDU7vPGmVU hyP/I195xAaXLONQEb2R5E5w= X-Received: by 127.0.0.2 with SMTP id rqRMYY7687511xY1d1za5VPz; Thu, 29 Feb 2024 18:10:14 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mx.groups.io with SMTP id smtpd.web10.13229.1709259014078731537 for ; Thu, 29 Feb 2024 18:10:14 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="14347455" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14347455" X-Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 18:10:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="8592527" X-Received: from sh0701bl-hv01.ccr.corp.intel.com ([10.239.220.156]) by orviesa008.jf.intel.com with ESMTP; 29 Feb 2024 18:10:12 -0800 From: "Yuting Yang" To: devel@edk2.groups.io Subject: [edk2-devel] [PATCH] BaseTools: PcdValueInit enhancement Date: Thu, 29 Feb 2024 18:10:11 -0800 Message-Id: <20240301021011.1371-1-yuting2.yang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yuting2.yang@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 2nQ7aJSsYpGajZDvynktQvX6x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=up5cs0zz; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Enhance PcdValueInit for storage saving Cc: Rebecca Cran rebecca@bsdio.com Cc: Liming Gao gaoliming@byosoft.com.cn Cc: Bob Feng bob.c.feng@intel.com Signed-off-by: Yuting Yang --- .../Source/Python/Workspace/DscBuildData.py | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 5df184f9c8..e83188f4b3 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1820,6 +1820,7 @@ class DscBuildData(PlatformBuildClassObject): def GenerateSizeFunction(self, Pcd):=0D CApp =3D "// Default Value in Dec \n"=0D CApp =3D CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.Toke= nSpaceGuidCName, Pcd.TokenCName)=0D + CAppList =3D []=0D =0D if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1":=0D CApp +=3D " *Size =3D (sizeof (%s) > *Size ? sizeof (%s) : *S= ize);\n" % (Pcd.DatumType,Pcd.DatumType)=0D @@ -1869,7 +1870,8 @@ class DscBuildData(PlatformBuildClassObject): (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1= ], FieldList[FieldName.strip(".")][2]))=0D Value, ValueSize =3D ParseFieldValue(Value)=0D if not Pcd.IsArray():=0D - 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.stri= p("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.Datu= mType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[= FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);=0D + CAppInfo =3D ' __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.DatumTy= pe, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[Fie= ldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);=0D + CAppList.append(CAppInfo.split(' //')[0])=0D else:=0D NewFieldName =3D ''=0D FieldName_ori =3D FieldName.strip('.')=0D @@ -1880,7 +1882,8 @@ class DscBuildData(PlatformBuildClassObject): FieldName =3D NewFieldName + FieldName=0D while '[' in FieldName and not Pcd.IsArray():=0D FieldName =3D FieldName.rsplit('[', 1)[0]=0D - 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], FieldList[FieldName_ori][2],= FieldList[FieldName_ori][0])=0D + CAppInfo =3D ' __FLEXIBLE_SIZE(*Size, %s, %s, %d)= ; // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), Ar= ray_Index + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], Fi= eldList[FieldName_ori][0])=0D + CAppList.append(CAppInfo.split(' //')[0])=0D flexisbale_size_statement_cache =3D set()=0D for skuname in Pcd.SkuOverrideValues:=0D if skuname =3D=3D TAB_COMMON:=0D @@ -1908,7 +1911,10 @@ class DscBuildData(PlatformBuildClassObject): (".".join((Pcd.TokenSp= aceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.s= trip(".")][1], FieldList[FieldName.strip(".")][2]))=0D Value, ValueSize =3D ParseFieldValue(Value= )=0D if not Pcd.IsArray():=0D - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Si= ze, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZ= E(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, Fiel= dName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize= , Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], = FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);=0D + CAppInfo =3D ' __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, FieldNa= me.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, P= cd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], Fie= ldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);=0D + CAppInfoWithoutComment =3D CAppInfo.sp= lit(' //')[0]=0D + if CAppInfoWithoutComment not in CAppL= ist:=0D + CAppList.append(CAppInfoWithoutCom= ment)=0D else:=0D NewFieldName =3D ''=0D FieldName_ori =3D FieldName.strip('.')=0D @@ -1919,9 +1925,12 @@ class DscBuildData(PlatformBuildClassObject): FieldName =3D NewFieldName + FieldName=0D while '[' in FieldName and not Pcd.IsArray= ():=0D FieldName =3D FieldName.rsplit('[', 1)= [0]=0D - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Si= ze, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldNam= e.strip("."), Array_Index + 1, FieldList[FieldName_ori][1], FieldList[Field= Name_ori][2], FieldList[FieldName_ori][0])=0D + CAppInfo =3D ' __FLEXIBLE_SIZE(*Size,= %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.s= trip("."), Array_Index + 1, FieldList[FieldName_ori][1], FieldList[FieldNam= e_ori][2], FieldList[FieldName_ori][0])=0D + CAppInfoWithoutComment =3D CAppInfo.sp= lit(' //')[0]=0D + if CAppInfoWithoutComment not in CAppL= ist:=0D + CAppList.append(CAppInfoWithoutCom= ment)=0D if Pcd.PcdFieldValueFromFdf:=0D - CApp =3D CApp + "// From fdf \n"=0D + CAppList.append("// From fdf \n")=0D for FieldName in Pcd.PcdFieldValueFromFdf:=0D FieldName =3D "." + FieldName=0D IsArray =3D _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[Fiel= dName.strip(".")][0])=0D @@ -1933,7 +1942,10 @@ class DscBuildData(PlatformBuildClassObject): (".".join((Pcd.TokenSpaceGuidCName, Pc= d.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromFdf[FieldName.st= rip(".")][1], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2]))=0D Value, ValueSize =3D ParseFieldValue(Value)=0D if not Pcd.IsArray():=0D - 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("."), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], P= cd.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[= FieldName.strip(".")][0]);=0D + CAppInfo =3D ' __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("."), V= alueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, Fi= eldName.strip("."), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], Pcd.= PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[Fie= ldName.strip(".")][0]);=0D + CAppInfoWithoutComment =3D CAppInfo.split(' //')[0]=0D + if CAppInfoWithoutComment not in CAppList:=0D + CAppList.append(CAppInfoWithoutComment)=0D else:=0D NewFieldName =3D ''=0D FieldName_ori =3D FieldName.strip('.')=0D @@ -1944,9 +1956,12 @@ class DscBuildData(PlatformBuildClassObject): FieldName =3D NewFieldName + FieldName=0D while '[' in FieldName:=0D FieldName =3D FieldName.rsplit('[', 1)[0]=0D - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d);= // From %s Line %s Value %s \n' % (Pcd.DatumType, FieldName.strip("."), Ar= ray_Index + 1, Pcd.PcdFieldValueFromFdf[FieldName_ori][1], Pcd.PcdFieldValu= eFromFdf[FieldName_ori][2], Pcd.PcdFieldValueFromFdf[FieldName_ori][0])=0D + CAppInfo =3D ' __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.PcdFieldValueFr= omFdf[FieldName_ori][2], Pcd.PcdFieldValueFromFdf[FieldName_ori][0])=0D + CAppInfoWithoutComment =3D CAppInfo.split(' //')[0]=0D + if CAppInfoWithoutComment not in CAppList:=0D + CAppList.append(CAppInfoWithoutComment)=0D if Pcd.PcdFieldValueFromComm:=0D - CApp =3D CApp + "// From Command Line \n"=0D + CAppList.append("// From Command Line \n")=0D for FieldName in Pcd.PcdFieldValueFromComm:=0D FieldName =3D "." + FieldName=0D IsArray =3D _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[Fie= ldName.strip(".")][0])=0D @@ -1958,7 +1973,10 @@ class DscBuildData(PlatformBuildClassObject): (".".join((Pcd.TokenSpaceGuidCName, Pc= d.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName.s= trip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2]))=0D Value, ValueSize =3D ParseFieldValue(Value)=0D if not Pcd.IsArray():=0D - 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("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], = Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromCo= mm[FieldName.strip(".")][0]);=0D + CAppInfo =3D ' __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("."), V= alueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, Fi= eldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd= .PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[= FieldName.strip(".")][0]);=0D + CAppInfoWithoutComment =3D CAppInfo.split(' //')[0]=0D + if CAppInfoWithoutComment not in CAppList:=0D + CAppList.append(CAppInfoWithoutComment)=0D else:=0D NewFieldName =3D ''=0D FieldName_ori =3D FieldName.strip('.')=0D @@ -1969,7 +1987,12 @@ class DscBuildData(PlatformBuildClassObject): FieldName =3D NewFieldName + FieldName=0D while '[' in FieldName and not Pcd.IsArray():=0D FieldName =3D FieldName.rsplit('[', 1)[0]=0D - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d);= // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), Ar= ray_Index + 1, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldVal= ueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0])= =0D + CAppInfo =3D ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); //= From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), Array= _Index + 1, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldValueF= romComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0])=0D + CAppInfoWithoutComment =3D CAppInfo.split(' //')[0]=0D + if CAppInfoWithoutComment not in CAppList:=0D + CAppList.append(CAppInfoWithoutComment)=0D + for item in CAppList:=0D + CApp +=3D item=0D if Pcd.GetPcdMaxSize():=0D CApp =3D CApp + " *Size =3D (%d > *Size ? %d : *Size); // The= Pcd maxsize is %d \n" % (Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize(), Pcd.Get= PcdMaxSize())=0D ArraySizeByAssign =3D self.CalculateActualCap(ActualCap)=0D --=20 2.26.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116201): https://edk2.groups.io/g/devel/message/116201 Mute This Topic: https://groups.io/mt/104657038/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-