Enhance PcdValueInit for storage saving
Cc: Rebecca Cran [email protected]
Cc: Liming Gao [email protected]
Cc: Bob Feng [email protected]
Signed-off-by: Yuting Yang <[email protected]>
---
.../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):
CApp = "// Default Value in Dec \n"
CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" %
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
+ CAppList = []
if Pcd.IsArray() and Pcd.Capacity[-1] != "-1":
CApp += " *Size = (sizeof (%s) > *Size ? sizeof (%s) : *Size);\n"
% (Pcd.DatumType,Pcd.DatumType)
@@ -1869,7 +1870,8 @@ class DscBuildData(PlatformBuildClassObject):
(".".join((Pcd.TokenSpaceGuidCName,
Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1],
FieldList[FieldName.strip(".")][2]))
Value, ValueSize = ParseFieldValue(Value)
if not Pcd.IsArray():
- CApp = 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]);
+ CAppInfo = ' __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]);
+ CAppList.append(CAppInfo.split(' //')[0])
else:
NewFieldName = ''
FieldName_ori = FieldName.strip('.')
@@ -1880,7 +1882,8 @@ class DscBuildData(PlatformBuildClassObject):
FieldName = NewFieldName + FieldName
while '[' in FieldName and not Pcd.IsArray():
FieldName = FieldName.rsplit('[', 1)[0]
- CApp = 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])
+ CAppInfo = ' __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])
+ CAppList.append(CAppInfo.split(' //')[0])
flexisbale_size_statement_cache = set()
for skuname in Pcd.SkuOverrideValues:
if skuname == TAB_COMMON:
@@ -1908,7 +1911,10 @@ class DscBuildData(PlatformBuildClassObject):
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))),
FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
Value, ValueSize = ParseFieldValue(Value)
if not Pcd.IsArray():
- CApp = 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]);
+ CAppInfo = ' __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]);
+ CAppInfoWithoutComment = CAppInfo.split('
//')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
else:
NewFieldName = ''
FieldName_ori = FieldName.strip('.')
@@ -1919,9 +1925,12 @@ class DscBuildData(PlatformBuildClassObject):
FieldName = NewFieldName + FieldName
while '[' in FieldName and not Pcd.IsArray():
FieldName = FieldName.rsplit('[', 1)[0]
- CApp = 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])
+ CAppInfo = ' __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])
+ CAppInfoWithoutComment = CAppInfo.split('
//')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
if Pcd.PcdFieldValueFromFdf:
- CApp = CApp + "// From fdf \n"
+ CAppList.append("// From fdf \n")
for FieldName in Pcd.PcdFieldValueFromFdf:
FieldName = "." + FieldName
IsArray =
_IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0])
@@ -1933,7 +1942,10 @@ class DscBuildData(PlatformBuildClassObject):
(".".join((Pcd.TokenSpaceGuidCName,
Pcd.TokenCName, FieldName.strip('.'))),
Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1],
Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2]))
Value, ValueSize = ParseFieldValue(Value)
if not Pcd.IsArray():
- CApp = 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],
Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2],
Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]);
+ CAppInfo = ' __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],
Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2],
Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]);
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
else:
NewFieldName = ''
FieldName_ori = FieldName.strip('.')
@@ -1944,9 +1956,12 @@ class DscBuildData(PlatformBuildClassObject):
FieldName = NewFieldName + FieldName
while '[' in FieldName:
FieldName = FieldName.rsplit('[', 1)[0]
- CApp = 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])
+ CAppInfo = ' __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])
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
if Pcd.PcdFieldValueFromComm:
- CApp = CApp + "// From Command Line \n"
+ CAppList.append("// From Command Line \n")
for FieldName in Pcd.PcdFieldValueFromComm:
FieldName = "." + FieldName
IsArray =
_IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0])
@@ -1958,7 +1973,10 @@ class DscBuildData(PlatformBuildClassObject):
(".".join((Pcd.TokenSpaceGuidCName,
Pcd.TokenCName, FieldName.strip('.'))),
Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1],
Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2]))
Value, ValueSize = ParseFieldValue(Value)
if not Pcd.IsArray():
- CApp = 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.PcdFieldValueFromComm[FieldName.strip(".")][0]);
+ CAppInfo = ' __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.PcdFieldValueFromComm[FieldName.strip(".")][0]);
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
else:
NewFieldName = ''
FieldName_ori = FieldName.strip('.')
@@ -1969,7 +1987,12 @@ class DscBuildData(PlatformBuildClassObject):
FieldName = NewFieldName + FieldName
while '[' in FieldName and not Pcd.IsArray():
FieldName = FieldName.rsplit('[', 1)[0]
- CApp = CApp + ' __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.PcdFieldValueFromComm[FieldName_ori][2],
Pcd.PcdFieldValueFromComm[FieldName_ori][0])
+ CAppInfo = ' __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.PcdFieldValueFromComm[FieldName_ori][2],
Pcd.PcdFieldValueFromComm[FieldName_ori][0])
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
+ for item in CAppList:
+ CApp += item
if Pcd.GetPcdMaxSize():
CApp = CApp + " *Size = (%d > *Size ? %d : *Size); // The Pcd
maxsize is %d \n" % (Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize(),
Pcd.GetPcdMaxSize())
ArraySizeByAssign = self.CalculateActualCap(ActualCap)
--
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/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-