summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/GenFds/FfsInfStatement.py
diff options
context:
space:
mode:
authorGao, Liming <liming.gao@intel.com>2014-01-10 05:25:50 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-10 05:25:50 +0000
commit2bc3256ca6d439ebf5d85d5e74e5f3e68df14130 (patch)
treecc9a35c905bea5dae72b9758b19f642fc3013e17 /BaseTools/Source/Python/GenFds/FfsInfStatement.py
parent8d9e16963ee86478776e2f504a776ec712fb0c77 (diff)
downloadedk2-platforms-2bc3256ca6d439ebf5d85d5e74e5f3e68df14130.tar.xz
Sync BaseTool trunk (version r2640) into EDKII BaseTools.
Signed-off-by: Gao, Liming <liming.gao@intel.com> Reviewed-by: Liu, Jiang A <jiang.a.liu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15089 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/GenFds/FfsInfStatement.py')
-rw-r--r--BaseTools/Source/Python/GenFds/FfsInfStatement.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 3d16398c32..feab8c84a0 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -43,6 +43,8 @@ from PatchPcdValue.PatchPcdValue import PatchBinaryFile
#
#
class FfsInfStatement(FfsInfStatementClassObject):
+ ## The mapping dictionary from datum type to its maximum number.
+ _MAX_SIZE_TYPE = {"BOOLEAN":0x01, "UINT8":0xFF, "UINT16":0xFFFF, "UINT32":0xFFFFFFFF, "UINT64":0xFFFFFFFFFFFFFFFF}
## The constructor
#
# @param self The object pointer
@@ -204,10 +206,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
if Inf._Defs != None and len(Inf._Defs) > 0:
self.OptRomDefs.update(Inf._Defs)
+
self.PatchPcds = []
InfPcds = Inf.Pcds
Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
FdfPcdDict = GenFdsGlobalVariable.FdfParser.Profile.PcdDict
+
+ # Workaround here: both build and GenFds tool convert the workspace path to lower case
+ # But INF file path in FDF and DSC file may have real case characters.
+ # Try to convert the path to lower case to see if PCDs value are override by DSC.
DscModules = {}
for DscModule in Platform.Modules:
DscModules[str(DscModule).lower()] = Platform.Modules[DscModule]
@@ -217,6 +224,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
continue
if Pcd.Type != 'PatchableInModule':
continue
+ # Override Patchable PCD value by the value from DSC
PatchPcd = None
InfLowerPath = str(PathClassObj).lower()
if InfLowerPath in DscModules and PcdKey in DscModules[InfLowerPath].Pcds:
@@ -227,16 +235,22 @@ class FfsInfStatement(FfsInfStatementClassObject):
if PatchPcd and Pcd.Type == PatchPcd.Type:
DefaultValue = PatchPcd.DefaultValue
DscOverride = True
+
+ # Override Patchable PCD value by the value from FDF
FdfOverride = False
if PcdKey in FdfPcdDict:
DefaultValue = FdfPcdDict[PcdKey]
FdfOverride = True
+
if not DscOverride and not FdfOverride:
continue
+ # Check value, if value are equal, no need to patch
if Pcd.DatumType == "VOID*":
if Pcd.DefaultValue == DefaultValue or DefaultValue in [None, '']:
continue
+ # Get the string size from FDF or DSC
if DefaultValue[0] == 'L':
+ # Remove L"", but the '\0' must be appended
MaxDatumSize = str((len(DefaultValue) - 2) * 2)
elif DefaultValue[0] == '{':
MaxDatumSize = str(len(DefaultValue.split(',')))
@@ -244,6 +258,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
MaxDatumSize = str(len(DefaultValue) - 1)
if DscOverride:
Pcd.MaxDatumSize = PatchPcd.MaxDatumSize
+ # If no defined the maximum size in DSC, try to get current size from INF
if Pcd.MaxDatumSize in ['', None]:
Pcd.MaxDatumSize = str(len(Pcd.DefaultValue.split(',')))
else:
@@ -259,6 +274,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
continue
except:
continue
+ # Check the Pcd size and data type
if Pcd.DatumType == "VOID*":
if int(MaxDatumSize) > int(Pcd.MaxDatumSize):
EdkLogger.error("GenFds", GENFDS_ERROR, "The size of VOID* type PCD '%s.%s' exceeds its maximum size %d bytes." \
@@ -306,7 +322,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
return EfiFile
Basename = os.path.basename(EfiFile)
Output = os.path.join(self.OutputPath, Basename)
- CopyLongFilePath(EfiFile, Output)
+ shutil.copy(EfiFile, Output)
for Pcd in self.PatchPcds:
RetVal, RetStr = PatchBinaryFile(Output, int(Pcd.Offset, 0), Pcd.DatumType, Pcd.DefaultValue, Pcd.MaxDatumSize)
if RetVal: