|
From: <gi...@us...> - 2010-08-05 03:03:18
|
Revision: 2007
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2007&view=rev
Author: gikidy
Date: 2010-08-05 03:03:10 +0000 (Thu, 05 Aug 2010)
Log Message:
-----------
BPDG implementation, included:
1) BPDG standalone tool
2) Autogen modification to launch BPDG tool if DSC contains VPD PCD.
Modified Paths:
--------------
trunk/BaseTools/Conf/tools_def.template
trunk/BaseTools/Source/Python/AutoGen/AutoGen.py
trunk/BaseTools/Source/Python/Common/DataType.py
trunk/BaseTools/Source/Python/Makefile
trunk/BaseTools/Source/Python/Workspace/BuildClassObject.py
trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
Added Paths:
-----------
trunk/BaseTools/Source/Python/BPDG/
trunk/BaseTools/Source/Python/BPDG/BPDG.py
trunk/BaseTools/Source/Python/BPDG/GenVpd.py
trunk/BaseTools/Source/Python/BPDG/StringTable.py
trunk/BaseTools/Source/Python/BPDG/__init__.py
trunk/BaseTools/Source/Python/Common/VpdInfoFile.py
Modified: trunk/BaseTools/Conf/tools_def.template
===================================================================
--- trunk/BaseTools/Conf/tools_def.template 2010-07-31 19:31:14 UTC (rev 2006)
+++ trunk/BaseTools/Conf/tools_def.template 2010-08-05 03:03:10 UTC (rev 2007)
@@ -3501,3 +3501,8 @@
*_*_*_TIANO_PATH = TianoCompress
*_*_*_TIANO_GUID = A31280AD-481E-41B6-95E8-127F4C984779
+##################
+# BPDG tool definitions
+##################
+*_*_*_VPDTOOL_PATH = BPDG
+*_*_*_VPDTOOL_GUID = 8C3D856A-9BE6-468E-850A-24F7A8D38E08
Modified: trunk/BaseTools/Source/Python/AutoGen/AutoGen.py
===================================================================
--- trunk/BaseTools/Source/Python/AutoGen/AutoGen.py 2010-07-31 19:31:14 UTC (rev 2006)
+++ trunk/BaseTools/Source/Python/AutoGen/AutoGen.py 2010-08-05 03:03:10 UTC (rev 2007)
@@ -34,6 +34,7 @@
from GenFds.FdfParser import *
from CommonDataClass.CommonClass import SkuInfoClass
from Workspace.BuildClassObject import *
+import Common.VpdInfoFile as VpdInfoFile
## Regular expression for splitting Dependency Expression stirng into tokens
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
@@ -476,9 +477,14 @@
UnicodePcdArray = []
HiiPcdArray = []
OtherPcdArray = []
+ VpdFile = VpdInfoFile.VpdInfoFile()
+ NeedProcessVpdMapFile = False
+
for Pcd in self._DynamicPcdList:
# just pick the a value to determine whether is unicode string type
Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
+ Sku.VpdOffset = Sku.VpdOffset.strip()
+
PcdValue = Sku.DefaultValue
if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"):
# if found PCD which datum value is unicode string the insert to left size of UnicodeIndex
@@ -488,6 +494,61 @@
HiiPcdArray.append(Pcd)
else:
OtherPcdArray.append(Pcd)
+
+ if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
+ VpdFile.Add(Pcd, Sku.VpdOffset)
+ # if the offset of a VPD is *, then it need to be fixed up by third party tool.
+ if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
+ NeedProcessVpdMapFile = True
+
+ if (self.Platform.FlashDefinition == None or self.Platform.FlashDefinition == '') and \
+ VpdFile.GetCount() != 0:
+ EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE,
+ "Fail to get FLASH_DEFINITION definition in DSC file %s which is required when DSC contains VPD PCD." % str(self.Platform.MetaFile))
+
+ if VpdFile.GetCount() != 0:
+ WorkspaceDb = self.BuildDatabase.WorkspaceDb
+ DscTimeStamp = WorkspaceDb.GetTimeStamp(WorkspaceDb.GetFileId(str(self.Platform.MetaFile)))
+ FvPath = os.path.join(self.BuildDir, "FV")
+ if not os.path.exists(FvPath):
+ try:
+ os.makedirs(FvPath)
+ except:
+ EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to create FV folder under %s" % self.BuildDir)
+
+ VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)
+ if not os.path.exists(VpdFilePath) or os.path.getmtime(VpdFilePath) < DscTimeStamp:
+ VpdFile.Write(VpdFilePath)
+
+ # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.
+ BPDGToolName = None
+ for ToolDef in self.ToolDefinition.values():
+ if ToolDef.has_key("GUID") and ToolDef["GUID"] == self.Platform.VpdToolGuid:
+ if not ToolDef.has_key("PATH"):
+ EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self.Platform.VpdToolGuid)
+ BPDGToolName = ToolDef["PATH"]
+ break
+
+ # Call third party GUID BPDG tool.
+ if BPDGToolName != None:
+ VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath)
+ else:
+ EdkLogger.error("Build", FILE_NOT_FOUND, "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
+
+ # Process VPD map file generated by third party BPDG tool
+ if NeedProcessVpdMapFile:
+ VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
+ if os.path.exists(VpdMapFilePath):
+ VpdFile.Read(VpdMapFilePath)
+
+ # Fixup "*" offset
+ for Pcd in self._DynamicPcdList:
+ # just pick the a value to determine whether is unicode string type
+ Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
+ if Sku.VpdOffset == "*":
+ Sku.VpdOffset = VpdFile.GetOffset(Pcd)[0]
+ else:
+ EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
del self._DynamicPcdList[:]
self._DynamicPcdList.extend(UnicodePcdArray)
self._DynamicPcdList.extend(HiiPcdArray)
Added: trunk/BaseTools/Source/Python/BPDG/BPDG.py
===================================================================
--- trunk/BaseTools/Source/Python/BPDG/BPDG.py (rev 0)
+++ trunk/BaseTools/Source/Python/BPDG/BPDG.py 2010-08-05 03:03:10 UTC (rev 2007)
@@ -0,0 +1,137 @@
+## @file
+# Intel Binary Product Data Generation Tool (Intel BPDG).
+# This tool provide a simple process for the creation of a binary file containing read-only
+# configuration data for EDK II platforms that contain Dynamic and DynamicEx PCDs described
+# in VPD sections. It also provide an option for specifying an alternate name for a mapping
+# file of PCD layout for use during the build when the platform integrator selects to use
+# automatic offset calculation.
+#
+# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+##
+# Import Modules
+#
+import os
+import sys
+from optparse import OptionParser
+from encodings import gbk
+from Common import EdkLogger
+from Common.BuildToolError import *
+
+import StringTable as st
+import GenVpd
+
+PROJECT_NAME = st.LBL_BPDG_LONG_UNI
+VERSION = st.LBL_BPDG_VERSION
+
+## Tool entrance method
+#
+# This method mainly dispatch specific methods per the command line options.
+# If no error found, return zero value so the caller of this tool can know
+# if it's executed successfully or not.
+#
+# @retval 0 Tool was successful
+# @retval 1 Tool failed
+#
+def main():
+ global Options, Args
+ Options, Args = myOptionParser()
+
+ ReturnCode = 0
+ # Initialize log system
+ EdkLogger.Initialize()
+
+ if Options.opt_slient:
+ EdkLogger.SetLevel(EdkLogger.ERROR)
+ elif Options.opt_verbose:
+ EdkLogger.SetLevel(EdkLogger.VERBOSE)
+ elif Options.opt_quiet:
+ EdkLogger.SetLevel(EdkLogger.QUIET)
+ elif Options.opt_debug != None:
+ EdkLogger.SetLevel(Options.opt_debug + 1)
+ else:
+ EdkLogger.SetLevel(EdkLogger.INFO)
+
+ if Options.opt_vpd_filename == None:
+ EdkLogger.error("bpdg", ATTRIBUTE_NOT_AVAILABLE, "Please use the -o option to specify the file name for the VPD binary file")
+ if Options.opt_map_file == None:
+ EdkLogger.error("bpdg", ATTRIBUTE_NOT_AVAILABLE, "Please use the -m option to specify the file name for the mapping file")
+
+ Force = False
+ if Options.opt_force != None:
+ Force = True
+
+ if (Args[0] != None) :
+ startBPDG(Args[0], Options.opt_map_file, Options.opt_vpd_filename, Force)
+ else :
+ EdkLogger.error("bpdg", ATTRIBUTE_NOT_AVAILABLE, "Please specify the file which contain the VPD pcd info.",
+ None)
+
+ return ReturnCode
+
+def myOptionParser():
+ #
+ # Process command line firstly.
+ #
+ parser = OptionParser(version="%s - Version %s\n" % (PROJECT_NAME, VERSION),
+ description=PROJECT_NAME,
+ prog='bpdg',
+ usage=st.LBL_BPDG_USAGE
+ )
+ parser.add_option('-d', '--debug', action='store', type="int", dest='opt_debug',
+ help=st.MSG_OPTION_DEBUG_LEVEL)
+ parser.add_option('-v', '--verbose', action='store_true', dest='opt_verbose',
+ help=st.MSG_OPTION_VERBOSE)
+ parser.add_option('-s', '--silent', action='store_true', dest='opt_slient', default=False,
+ help=st.MSG_OPTION_SILENT)
+ parser.add_option('-q', '--quiet', action='store_true', dest='opt_quiet', default=False,
+ help=st.MSG_OPTION_QUIET)
+ parser.add_option('-o', '--vpd-filename', action='store', dest='opt_vpd_filename',
+ help=st.MSG_OPTION_VPD_FILENAME)
+ parser.add_option('-m', '--map-filename', action='store', dest='opt_map_file',
+ help=st.MSG_OPTION_MAP_FILENAME)
+ parser.add_option('-f', '--force', action='store_true', dest='opt_force',
+ help=st.MSG_OPTION_FORCE)
+
+ (options, args) = parser.parse_args()
+ if len(args) == 0:
+ print parser.usage
+ sys.exit(1)
+ return options, args
+
+def startBPDG(InputFileName, MapFileName, VpdFileName, Force):
+ if os.path.exists(VpdFileName) and not Force:
+ print "\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName
+ choice = sys.stdin.readline()
+ if choice.strip().lower() not in ['y', 'yes', '']:
+ return
+
+ GenVPD = GenVpd.GenVPD (InputFileName, MapFileName, VpdFileName)
+
+ EdkLogger.info('%-24s = %s' % ("VPD input data file: ", InputFileName))
+ EdkLogger.info('%-24s = %s' % ("VPD output map file: ", MapFileName))
+ EdkLogger.info('%-24s = %s' % ("VPD output binary file: ", VpdFileName))
+
+ GenVPD.ParserInputFile()
+ GenVPD.FormatFileLine()
+ GenVPD.FixVpdOffset()
+ GenVPD.GenerateVpdFile(MapFileName, VpdFileName)
+
+ EdkLogger.info("- Done! -")
+
+if __name__ == '__main__':
+ r = main()
+ ## 0-127 is a safe return range, and 1 is a standard default error
+ if r < 0 or r > 127: r = 1
+ sys.exit(r)
+
+
Added: trunk/BaseTools/Source/Python/BPDG/GenVpd.py
===================================================================
--- trunk/BaseTools/Source/Python/BPDG/GenVpd.py (rev 0)
+++ trunk/BaseTools/Source/Python/BPDG/GenVpd.py 2010-08-05 03:03:10 UTC (rev 2007)
@@ -0,0 +1,494 @@
+## @file
+#
+# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+import os
+import StringIO
+import StringTable as st
+import array
+
+from struct import *
+import Common.EdkLogger as EdkLogger
+import Common.BuildToolError as BuildToolError
+
+_FORMAT_CHAR = {1: 'B',
+ 2: 'H',
+ 4: 'I',
+ 8: 'Q'
+ }
+
+class PcdEntry:
+ def __init__(self, PcdCName, PcdOffset, PcdSize, PcdValue, PcdUnpackValue=None,
+ PcdBinOffset=None, PcdBinSize=None):
+ self.PcdCName = PcdCName.strip()
+ self.PcdOffset = PcdOffset.strip()
+ self.PcdSize = PcdSize.strip()
+ self.PcdValue = PcdValue.strip()
+ self.PcdUnpackValue = PcdUnpackValue
+ self.PcdBinOffset = PcdBinOffset
+ self.PcdBinSize = PcdBinSize
+
+ self._GenOffsetValue ()
+
+ def _IsBoolean(self, ValueString):
+ if ValueString.upper() in ["TRUE", "FALSE"]:
+ return True
+ return False
+
+ def _GenOffsetValue(self):
+ if self.PcdOffset != "*" :
+ try:
+ self.PcdBinOffset = int (self.PcdOffset)
+ except:
+ try:
+ self.PcdBinOffset = int(self.PcdOffset, 16)
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FORMAT_INVALID,
+ "Invalid offset value %s for PCD %s" % (self.PcdOffset, self.PcdCName))
+
+ def _PackBooleanValue(self, ValueString):
+ if ValueString.upper() == "TRUE":
+ self.PcdValue = pack(_FORMAT_CHAR[1], 1)
+ else:
+ self.PcdValue = pack(_FORMAT_CHAR[1], 0)
+
+ def _PackIntValue(self, IntValue, Size):
+ if Size not in _FORMAT_CHAR.keys():
+ EdkLogger.error("bpdg", BuildToolError.FORMAT_INVALID,
+ "Invalid size %d for PCD in integer datum size." % Size)
+ self.PcdValue = pack(_FORMAT_CHAR[Size], IntValue)
+
+ def _PackPtrValue(self, ValueString, Size):
+ if ValueString.startswith('L"'):
+ self._PackUnicode(ValueString, Size)
+ elif ValueString.startswith('{') and ValueString.endswith('}'):
+ self._PackByteArray(ValueString, Size)
+ elif ValueString.startswith('"') and ValueString.endswith('"'):
+ self._PackString(ValueString, Size)
+ else:
+ EdkLogger.error("bpdg", BuildToolError.FORMAT_INVALID,
+ "Invalid VOID* type PCD value %s" % ValueString)
+
+ def _PackString(self, ValueString, Size):
+ assert Size > 0, "Invalid parameter Size!"
+ assert ValueString != "", "Invalid parameter ValueString"
+ assert len(ValueString) >= 2, 'An ASCII string at least contains two "'
+
+ ValueString = ValueString[1:-1]
+ if len(ValueString) + 1 > Size:
+ EdkLogger.error("bpdg", BuildToolError.RESOURCE_OVERFLOW,
+ "PCD value string %s is exceed to size %d" % (ValueString, Size))
+ self.PcdValue= pack('%ds' % Size, ValueString)
+
+ def _PackByteArray(self, ValueString, Size):
+ assert Size > 0, "Invalid parameter Size!"
+ assert ValueString != "", "Invalid parameter ValueString"
+
+ ValueString = ValueString.strip()
+ ValueString = ValueString.lstrip('{').strip('}')
+ ValueList = ValueString.split(',')
+ ValueList = [item.strip() for item in ValueList]
+
+ if len(ValueList) > Size:
+ EdkLogger.error("bpdg", BuildToolError.RESOURCE_OVERFLOW,
+ "The byte array %s is too large for size %d" % (ValueString, Size))
+
+ ReturnArray = array.array('B')
+
+ for Index in xrange(len(ValueList)):
+ Value = None
+ if ValueList[Index].startswith('0x'):
+ # translate hex value
+ try:
+ Value = int(ValueList[Index], 16)
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FORMAT_INVALID,
+ "The value item %s in byte array %s is an invalid HEX value." % \
+ (ValueList[Index], ValueString))
+ else:
+ # translate decimal value
+ try:
+ Value = int(ValueList[Index], 10)
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FORMAT_INVALID,
+ "The value item %s in byte array %s is an invalid DECIMAL value." % \
+ (ValueList[Index], ValueString))
+
+ if Value > 255:
+ EdkLogger.error("bpdg", BuildToolError.FORMAT_INVALID,
+ "The value item %s in byte array %s do not in range 0 ~ 0xFF" %\
+ (ValueList[Index], ValueString))
+
+ ReturnArray.append(Value)
+
+ for Index in xrange(len(ValueList), Size):
+ ReturnArray.append(0)
+
+ self.PcdValue = ReturnArray.tolist()
+
+ ## Pack a unicode PCD value into byte array.
+ #
+ # A unicode string for a PCD should be in format as L"".
+ #
+ def _PackUnicode(self, UnicodeString, Size):
+ assert Size > 0, "Invalid parameter Size"
+ assert len(UnicodeString) >= 3, "Invalid parameter UnicodeString"
+
+ UnicodeString = UnicodeString[2:-1]
+
+ if (len(UnicodeString) + 1) * 2 > Size:
+ EdkLogger.error("bpdg", BuildToolError.RESOURCE_OVERFLOW,
+ "The size of unicode string %s is too larger for size %s" % \
+ (UnicodeString, Size))
+
+ ReturnArray = array.array('B')
+ for Value in UnicodeString:
+ try:
+ ReturnArray.append(ord(Value))
+ ReturnArray.append(0)
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FORMAT_INVALID,
+ "Invalid unicode character %s in unicode string %s" % \
+ (Value, UnicodeString))
+
+ for Index in range(len(UnicodeString) * 2, Size):
+ ReturnArray.append(0)
+
+ self.PcdValue = ReturnArray.tolist()
+
+class GenVPD :
+
+ ## Constructor of DscBuildData
+ #
+ # Initialize object of GenVPD
+ # @Param InputFileName The filename include the vpd type pcd information
+ # @param MapFileName The filename of map file that stores vpd type pcd information.
+ # This file will be generated by the BPDG tool after fix the offset
+ # and adjust the offset to make the pcd data aligned.
+ # @param VpdFileName The filename of Vpd file that hold vpd pcd information.
+ #
+ def __init__(self, InputFileName, MapFileName, VpdFileName):
+ self.InputFileName = InputFileName
+ self.MapFileName = MapFileName
+ self.VpdFileName = VpdFileName
+ self.FileLinesList = []
+ self.PcdFixedOffsetSizeList = []
+ self.PcdUnknownOffsetList = []
+ try:
+ print InputFileName
+ fInputfile = open(InputFileName, "r", 0)
+ try:
+ self.FileLinesList = fInputfile.readlines()
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FILE_READ_FAILURE, "File read failed for %s" %InputFileName,None)
+ finally:
+ fInputfile.close()
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" %InputFileName,None)
+
+ ##
+ # Parser the input file which is generated by the build tool. Convert the value of each pcd's
+ # from string to it's real format. Also remove the useless line in the input file.
+ #
+ def ParserInputFile (self):
+ count = 0
+ for line in self.FileLinesList:
+ # Strip "\r\n" generated by readlines ().
+ line = line.strip()
+ line = line.rstrip(os.linesep)
+
+ # Skip the comment line
+ if (not line.startswith("#")) and len(line) > 1 :
+ self.FileLinesList[count] = line.split('|')
+ elif len(line) <= 1 :
+ # Set the blank line to "None"
+ self.FileLinesList[count] = None
+ else :
+ # Set the comment line to "None"
+ self.FileLinesList[count] = None
+ count += 1
+
+ # The line count contain usage information
+ count = 0
+ # Delete useless lines
+ while (True) :
+ try :
+ if (self.FileLinesList[count] == None) :
+ del(self.FileLinesList[count])
+ else :
+ count += 1
+ except :
+ break
+ #
+ # After remove the useless line, if there are no data remain in the file line list,
+ # Report warning messages to user's.
+ #
+ if len(self.FileLinesList) == 0 :
+ EdkLogger.warn('bpdg', BuildToolError.RESOURCE_NOT_AVAILABLE,
+ "There are no VPD type pcds defined in DSC file, Please check it.")
+
+ # Process the pcds one by one base on the pcd's value and size
+ count = 0
+ for line in self.FileLinesList:
+ if line != None :
+ PCD = PcdEntry(line[0], line[1], line[2], line[3])
+ # Strip the space char
+ PCD.PcdCName = PCD.PcdCName.strip(' ')
+ PCD.PcdOffset = PCD.PcdOffset.strip(' ')
+ PCD.PcdSize = PCD.PcdSize.strip(' ')
+ PCD.PcdValue = PCD.PcdValue.strip(' ')
+
+ #
+ # Store the original pcd value.
+ # This information will be useful while generate the output map file.
+ #
+ PCD.PcdUnpackValue = str(PCD.PcdValue)
+
+ #
+ # Translate PCD size string to an integer value.
+ PackSize = None
+ try:
+ PackSize = int(PCD.PcdSize, 10)
+ PCD.PcdBinSize = PackSize
+ except:
+ try:
+ PackSize = int(PCD.PcdSize, 16)
+ PCD.PcdBinSize = PackSize
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FORMAT_INVALID, "Invalid PCD size value %s" % PCD.PcdSize)
+
+ if PCD._IsBoolean(PCD.PcdValue):
+ PCD._PackBooleanValue(PCD.PcdValue)
+ self.FileLinesList[count] = PCD
+ count += 1
+ continue
+ #
+ # Try to translate value to an integer firstly.
+ #
+ IsInteger = True
+ PackValue = None
+ try:
+ PackValue = int(PCD.PcdValue)
+ except:
+ try:
+ PackValue = int(PCD.PcdValue, 16)
+ except:
+ IsInteger = False
+
+ if IsInteger:
+ PCD._PackIntValue(PackValue, PackSize)
+ else:
+ PCD._PackPtrValue(PCD.PcdValue, PackSize)
+
+ self.FileLinesList[count] = PCD
+ count += 1
+ else :
+ continue
+
+ ##
+ # This function used to create a clean list only contain useful information and reorganized to make it
+ # easy to be sorted
+ #
+ def FormatFileLine (self) :
+
+ for eachPcd in self.FileLinesList :
+ if eachPcd.PcdOffset != '*' :
+ # Use pcd's Offset value as key, and pcd's Value as value
+ self.PcdFixedOffsetSizeList.append(eachPcd)
+ else :
+ # Use pcd's CName as key, and pcd's Size as value
+ self.PcdUnknownOffsetList.append(eachPcd)
+
+
+ ##
+ # This function is use to fix the offset value which the not specified in the map file.
+ # Usually it use the star (meaning any offset) character in the offset field
+ #
+ def FixVpdOffset (self):
+ # At first, the offset should start at 0
+ # Sort fixed offset list in order to find out where has free spaces for the pcd's offset
+ # value is "*" to insert into.
+
+ self.PcdFixedOffsetSizeList.sort(lambda x,y: cmp(x.PcdBinOffset, y.PcdBinOffset))
+
+ #
+ # Sort the un-fixed pcd's offset by it's size.
+ #
+ self.PcdUnknownOffsetList.sort(lambda x,y: cmp(x.PcdBinSize, y.PcdBinSize))
+
+ # Check the offset of VPD type pcd's offset start from 0.
+ if self.PcdFixedOffsetSizeList[0].PcdBinOffset != 0 :
+ EdkLogger.warn("bpdg", "The offset of VPD type pcd should start with 0, please check it.",
+ None)
+
+ # Judge whether the offset in fixed pcd offset list is overlapped or not.
+ lenOfList = len(self.PcdFixedOffsetSizeList)
+ count = 0
+ while (count < lenOfList - 1) :
+ PcdNow = self.PcdFixedOffsetSizeList[count]
+ PcdNext = self.PcdFixedOffsetSizeList[count+1]
+ # Two pcd's offset is same
+ if PcdNow.PcdBinOffset == PcdNext.PcdBinOffset :
+ EdkLogger.error("bpdg", BuildToolError.ATTRIBUTE_GET_FAILURE,
+ "The offset of %s is same with %s" % (PcdNow.PcdCName, PcdNext.PcdCName),
+ None)
+
+ # Overlapped
+ if PcdNow.PcdBinOffset + PcdNow.PcdBinSize > PcdNext.PcdBinOffset :
+ EdkLogger.error("bpdg", BuildToolError.ATTRIBUTE_GET_FAILURE,
+ "The offset of %s is overlapped with %s" % (PcdNow.PcdCName, PcdNext.PcdCName),
+ None)
+
+ # Has free space, raise a warning message
+ if PcdNow.PcdBinOffset + PcdNow.PcdBinSize < PcdNext.PcdBinOffset :
+ EdkLogger.warn("bpdg", BuildToolError.ATTRIBUTE_GET_FAILURE,
+ "The offsets have free space of between %s and %s" % (PcdNow.PcdCName, PcdNext.PcdCName),
+ None)
+ count += 1
+
+ LastOffset = self.PcdFixedOffsetSizeList[0].PcdBinOffset
+ FixOffsetSizeListCount = 0
+ lenOfList = len(self.PcdFixedOffsetSizeList)
+ lenOfUnfixedList = len(self.PcdUnknownOffsetList)
+
+ ##
+ # Insert the un-fixed offset pcd's list into fixed offset pcd's list if has free space between those pcds.
+ #
+ while (FixOffsetSizeListCount < lenOfList) :
+
+ eachFixedPcd = self.PcdFixedOffsetSizeList[FixOffsetSizeListCount]
+ NowOffset = eachFixedPcd.PcdBinOffset
+
+ # Has free space
+ if LastOffset < NowOffset :
+ if lenOfUnfixedList != 0 :
+ countOfUnfixedList = 0
+ while(countOfUnfixedList < lenOfUnfixedList) :
+ #needFixPcdCName, needFixPcdOffset, needFixPcdSize, needFixPcdValue, needFixUnpackValue = self.PcdUnknownOffsetList[countOfUnfixedList][0:6]
+ eachUnfixedPcd = self.PcdUnknownOffsetList[countOfUnfixedList]
+ needFixPcdSize = eachUnfixedPcd.PcdBinSize
+ needFixPcdOffset = eachUnfixedPcd.PcdOffset
+ # Not been fixed
+ if eachUnfixedPcd.PcdOffset == '*' :
+ # The offset un-fixed pcd can write into this free space
+ if needFixPcdSize <= (NowOffset - LastOffset) :
+ # Change the offset value of un-fixed pcd
+ eachUnfixedPcd.PcdOffset = str(hex(LastOffset))
+ eachUnfixedPcd.PcdBinOffset = LastOffset
+ # Insert this pcd into fixed offset pcd list.
+ self.PcdFixedOffsetSizeList.insert(FixOffsetSizeListCount,eachUnfixedPcd)
+
+ # Delete the item's offset that has been fixed and added into fixed offset list
+ self.PcdUnknownOffsetList.pop(countOfUnfixedList)
+
+ # After item added, should enlarge the length of fixed pcd offset list
+ lenOfList += 1
+ FixOffsetSizeListCount += 1
+
+ # Decrease the un-fixed pcd offset list's length
+ countOfUnfixedList += 1
+ lenOfUnfixedList -= 1
+
+ # Modify the last offset value
+ LastOffset += needFixPcdSize
+ continue
+ else :
+ # It can not insert into those two pcds, need to check stiil has other space can store it.
+ FixOffsetSizeListCount += 1
+ break
+ else :
+ continue
+ # Set the FixOffsetSizeListCount = lenOfList for quit the loop
+ else :
+ FixOffsetSizeListCount = lenOfList
+
+ # No free space, smoothly connect with previous pcd.
+ elif LastOffset == NowOffset :
+ LastOffset = NowOffset + eachFixedPcd.PcdBinSize
+ FixOffsetSizeListCount += 1
+ # Usually it will not enter into this thunk, if so, means it overlapped.
+ else :
+ EdkLogger.error("bpdg", BuildToolError.ATTRIBUTE_NOT_AVAILABLE,
+ "The offset value definition has overlapped at pcd: %s, it's offset is: %s" %(eachFixedPcd.PcdCName, eachFixedPcd.PcdOffset),
+ None)
+ FixOffsetSizeListCount += 1
+
+ # Continue to process the un-fixed offset pcd's list, add this time, just append them behind the fixed pcd's offset list.
+ lenOfUnfixedList = len(self.PcdUnknownOffsetList)
+ lenOfList = len(self.PcdFixedOffsetSizeList)
+ while (lenOfUnfixedList > 0) :
+ # Still has items need to process
+ # The last pcd instance
+ LastPcd = self.PcdFixedOffsetSizeList[lenOfList-1]
+ NeedFixPcd = self.PcdUnknownOffsetList[0]
+
+ NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdBinSize
+ NeedFixPcd.PcdOffset = str(hex(NeedFixPcd.PcdBinOffset))
+
+ # Insert this pcd into fixed offset pcd list's tail.
+ self.PcdFixedOffsetSizeList.insert(lenOfList, NeedFixPcd)
+ # Delete the item's offset that has been fixed and added into fixed offset list
+ self.PcdUnknownOffsetList.pop(0)
+
+ lenOfList += 1
+ lenOfUnfixedList -= 1
+ ##
+ # Write the final data into output files.
+ #
+ def GenerateVpdFile (self, MapFileName, BinFileName):
+ #Open an VPD file to process
+
+ try:
+ fVpdFile = open (BinFileName, "wb", 0)
+ except:
+ # Open failed
+ EdkLogger.error("bpdg", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" %self.VpdFileName,None)
+
+ try :
+ fMapFile = open (MapFileName, "w", 0)
+ except:
+ # Open failed
+ EdkLogger.error("bpdg", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" %self.MapFileName,None)
+
+ # Use a instance of StringIO to cache data
+ fStringIO = StringIO.StringIO('')
+
+ # Write the header of map file.
+ try :
+ fMapFile.write (st.MAP_FILE_COMMENT_TEMPLATE + "\n")
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %self.MapFileName,None)
+
+ for eachPcd in self.PcdFixedOffsetSizeList :
+ # write map file
+ try :
+ fMapFile.write("%s | %s | %s | %s \n" % (eachPcd.PcdCName, eachPcd.PcdOffset, eachPcd.PcdSize,eachPcd.PcdUnpackValue))
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %self.MapFileName,None)
+
+ # Write Vpd binary file
+ fStringIO.seek (eachPcd.PcdBinOffset)
+ if isinstance(eachPcd.PcdValue, list):
+ ValueList = [chr(Item) for Item in eachPcd.PcdValue]
+ fStringIO.write(''.join(ValueList))
+ else:
+ fStringIO.write (eachPcd.PcdValue)
+
+ try :
+ fVpdFile.write (fStringIO.getvalue())
+ except:
+ EdkLogger.error("bpdg", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %self.VpdFileName,None)
+
+ fStringIO.close ()
+ fVpdFile.close ()
+ fMapFile.close ()
+
Added: trunk/BaseTools/Source/Python/BPDG/StringTable.py
===================================================================
--- trunk/BaseTools/Source/Python/BPDG/StringTable.py (rev 0)
+++ trunk/BaseTools/Source/Python/BPDG/StringTable.py 2010-08-05 03:03:10 UTC (rev 2007)
@@ -0,0 +1,91 @@
+## @file
+# This file is the loader of "Boot Loader Development Kit".
+#
+# INTEL CONFIDENTIAL
+#
+# Copyright (c) 2010 Intel Corporation All Rights Reserved.
+#
+# The source code contained or described herein and all documents related to
+# the source code ("Material") are owned by Intel Corporation or its suppliers
+# or licensors. Title to the Material remains with Intel Corporation or its
+# suppliers and licensors. The Material contains trade secrets and proprietary
+# and confidential information of Intel or its suppliers and licensors. The
+# Material is protected by worldwide copyright and trade secret laws and
+# treaty provisions. No part of the Material may be used, copied, reproduced,
+# modified, published, uploaded, posted, transmitted, distributed, or disclosed
+# in any way without Intels prior express written permission.
+#
+# No license under any patent, copyright, trade secret or other intellectual
+# property right is granted to or conferred upon you by disclosure or delivery
+# of the Materials, either expressly, by implication, inducement, estoppel or
+# otherwise. Any license under such intellectual property rights must be
+# express and approved by Intel in writing.
+#
+##
+
+
+#string table starts here...
+
+#strings are classified as following types
+# MSG_...: it is a message string
+# ERR_...: it is a error string
+# WRN_...: it is a warning string
+# LBL_...: it is a UI label (window title, control label, etc.)
+# MNU_...: it is a menu item label
+# HLP_...: it is a help string
+# CFG_...: it is a config string used in module. Do not need to translate it.
+# XRC_...: it is a user visible string from xrc file
+
+MAP_FILE_COMMENT_TEMPLATE = \
+"""
+## @file
+#
+# THIS IS AUTO-GENERATED FILE BY BPDG TOOLS AND PLEASE DO NOT MAKE MODIFICATION.
+#
+# This file lists all VPD informations for a platform fixed/adjusted by BPDG tool.
+#
+# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+"""
+
+
+
+LBL_BPDG_LONG_UNI = (u"Intel Binary Product Data Generation (BPDG) Application")
+LBL_BPDG_VERSION = (u"0.1")
+LBL_BPDG_USAGE = \
+(
+"""
+Usage: bpdg options -o Filename.bin -m Filename.map Filename.txt
+Intel(r) Binary Product Data Generation Tool (Intel(r) BPDG)
+Copyright (c) 2010 Intel Corporation All Rights Reserved.
+
+Required Flags:
+ -o VPD_FILENAME, --vpd-filename=VPD_FILENAME
+ Specify the file name for the VPD binary file
+ -m FILENAME, --map-filename=FILENAME
+ Generate file name for consumption during the build that contains
+ the mapping of Pcd name, offset, datum size and value derived
+ from the input file and any automatic calculations.
+"""
+)
+
+MSG_OPTION_HELP = ("Show this help message and exit.")
+MSG_OPTION_DEBUG_LEVEL = ("Print DEBUG statements, where DEBUG_LEVEL is 0-9.")
+MSG_OPTION_VERBOSE = ("Print informational statements.")
+MSG_OPTION_SILENT = ("Only the exit code will be returned, all informational and error messages will not be displayed.")
+MSG_OPTION_QUIET = ("Returns the exit code and will display only error messages.")
+MSG_OPTION_VPD_FILENAME = ("Specify the file name for the VPD binary file.")
+MSG_OPTION_MAP_FILENAME = ("Generate file name for consumption during the build that contains the mapping of Pcd name, offset, datum size and value derived from the input file and any automatic calculations.")
+MSG_OPTION_FORCE = ("Disable prompting the user for overwriting files as well as for missing input content.")
+
+ERR_INVALID_DEBUG_LEVEL = ("Invalid level for debug message. Only "
+ "'DEBUG', 'INFO', 'WARNING', 'ERROR', "
+ "'CRITICAL' are supported for debugging "
+ "messages.")
Added: trunk/BaseTools/Source/Python/BPDG/__init__.py
===================================================================
--- trunk/BaseTools/Source/Python/BPDG/__init__.py (rev 0)
+++ trunk/BaseTools/Source/Python/BPDG/__init__.py 2010-08-05 03:03:10 UTC (rev 2007)
@@ -0,0 +1,15 @@
+## @file
+# Python 'BPDG' package initialization file.
+#
+# This file is required to make Python interpreter treat the directory
+# as containing package.
+#
+# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
Modified: trunk/BaseTools/Source/Python/Common/DataType.py
===================================================================
--- trunk/BaseTools/Source/Python/Common/DataType.py 2010-07-31 19:31:14 UTC (rev 2006)
+++ trunk/BaseTools/Source/Python/Common/DataType.py 2010-08-05 03:03:10 UTC (rev 2007)
@@ -353,6 +353,7 @@
TAB_DSC_DEFINES_BS_BASE_ADDRESS = 'BsBaseAddress'
TAB_DSC_DEFINES_RT_BASE_ADDRESS = 'RtBaseAddress'
TAB_DSC_DEFINES_DEFINE = 'DEFINE'
+TAB_DSC_DEFINES_VPD_TOOL_GUID = 'VPD_TOOL_GUID'
TAB_FIX_LOAD_TOP_MEMORY_ADDRESS = 'FIX_LOAD_TOP_MEMORY_ADDRESS'
#
Added: trunk/BaseTools/Source/Python/Common/VpdInfoFile.py
===================================================================
--- trunk/BaseTools/Source/Python/Common/VpdInfoFile.py (rev 0)
+++ trunk/BaseTools/Source/Python/Common/VpdInfoFile.py 2010-08-05 03:03:10 UTC (rev 2007)
@@ -0,0 +1,245 @@
+## @file
+#
+# This package manage the VPD PCD information file which will be generated
+# by build tool's autogen.
+# The VPD PCD information file will be input for third-party BPDG tool which
+# is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt
+#
+#
+# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+import os
+import re
+import Common.EdkLogger as EdkLogger
+import Common.BuildToolError as BuildToolError
+import subprocess
+
+FILE_COMMENT_TEMPLATE = \
+"""
+## @file
+#
+# THIS IS AUTO-GENERATED FILE BY BUILD TOOLS AND PLEASE DO NOT MAKE MODIFICATION.
+#
+# This file lists all VPD informations for a platform collected by build.exe.
+#
+# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+"""
+
+## The class manage VpdInfoFile.
+#
+# This file contains an ordered (based on position in the DSC file) list of the PCDs specified in the platform description file (DSC). The Value field that will be assigned to the PCD comes from the DSC file, INF file (if not defined in the DSC file) or the DEC file (if not defined in the INF file). This file is used as an input to the BPDG tool.
+# Format for this file (using EBNF notation) is:
+# <File> :: = [<CommentBlock>]
+# [<PcdEntry>]*
+# <CommentBlock> ::= ["#" <String> <EOL>]*
+# <PcdEntry> ::= <PcdName> "|" <Offset> "|" <Size> "|" <Value> <EOL>
+# <PcdName> ::= <TokenSpaceCName> "." <PcdCName>
+# <TokenSpaceCName> ::= C Variable Name of the Token Space GUID
+# <PcdCName> ::= C Variable Name of the PCD
+# <Offset> ::= {"*"} {<HexNumber>}
+# <HexNumber> ::= "0x" (a-fA-F0-9){1,8}
+# <Size> ::= <HexNumber>
+# <Value> ::= {<HexNumber>} {<NonNegativeInt>} {<QString>} {<Array>}
+# <NonNegativeInt> ::= (0-9)+
+# <QString> ::= ["L"] <DblQuote> <String> <DblQuote>
+# <DblQuote> ::= 0x22
+# <Array> ::= {<CArray>} {<NList>}
+# <CArray> ::= "{" <HexNumber> ["," <HexNumber>]* "}"
+# <NList> ::= <HexNumber> ["," <HexNumber>]*
+#
+class VpdInfoFile:
+
+ ## The mapping dictionary from datum type to size string.
+ _MAX_SIZE_TYPE = {"BOOLEAN":"1", "UINT8":"1", "UINT16":"2", "UINT32":"4", "UINT64":"8"}
+ _rVpdPcdLine = None
+ ## Constructor
+ def __init__(self):
+ ## Dictionary for VPD in following format
+ #
+ # Key : PcdClassObject instance.
+ # @see BuildClassObject.PcdClassObject
+ # Value : offset in different SKU such as [sku1_offset, sku2_offset]
+ self._VpdArray = {}
+
+ ## Add a VPD PCD collected from platform's autogen when building.
+ #
+ # @param vpds The list of VPD PCD collected for a platform.
+ # @see BuildClassObject.PcdClassObject
+ #
+ # @param offset integer value for VPD's offset in specific SKU.
+ #
+ def Add(self, Vpd, Offset):
+ assert Vpd != None, "Invalid VPD PCD entry."
+ assert Offset >= 0 or Offset == "*", "Invalid offset parameter: %s." % Offset
+
+ if Vpd.DatumType == "VOID*":
+ if Vpd.MaxDatumSize <= 0:
+ assert False, "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)
+ elif Vpd.DatumType in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UINT64"]:
+ if Vpd.MaxDatumSize == None or Vpd.MaxDatumSize == "":
+ Vpd.MaxDatumSize = VpdInfoFile._MAX_SIZE_TYPE[Vpd.DatumType]
+ else:
+ assert False, "Invalid DatumType %s for VPD PCD %s.%s" % (Vpd.DatumType, Vpd.TokenSpaceGuidCName, Vpd.TokenCName)
+
+ if Vpd not in self._VpdArray.keys():
+ #
+ # If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one
+ #
+ self._VpdArray[Vpd] = [Offset]
+ else:
+ #
+ # If there is an offset for a specific SKU in dict, then append this offset for other sku to array.
+ #
+ self._VpdArray[Vpd].append(Offset)
+
+
+ ## Generate VPD PCD information into a text file
+ #
+ # If parameter FilePath is invalid, then assert.
+ # If
+ # @param FilePath The given file path which would hold VPD information
+ def Write(self, FilePath):
+ assert FilePath != None or len(FilePath) != 0, "Invalid parameter FilePath: %s." % FilePath
+
+ try:
+ fd = open(FilePath, "w")
+ except:
+ EdkLogger.error("VpdInfoFile",
+ BuildToolError.FILE_OPEN_FAILURE,
+ "Fail to open file %s for written." % FilePath)
+
+ try:
+ # write file header
+ fd.write(FILE_COMMENT_TEMPLATE)
+
+ # write each of PCD in VPD type
+ for Pcd in self._VpdArray.keys():
+ for Offset in self._VpdArray[Pcd]:
+ fd.write("%s.%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, str(Offset).strip(),
+ str(Pcd.MaxDatumSize).strip(), str(Pcd.DefaultValue).strip()))
+ except:
+ EdkLogger.error("VpdInfoFile",
+ BuildToolError.FILE_WRITE_FAILURE,
+ "Fail to write file %s" % FilePath)
+ fd.close()
+
+ ## Read an existing VPD PCD info file.
+ #
+ # This routine will read VPD PCD information from existing file and construct
+ # internal PcdClassObject array.
+ # This routine could be used by third-party tool to parse VPD info file content.
+ #
+ # @param FilePath The full path string for existing VPD PCD info file.
+ def Read(self, FilePath):
+ try:
+ fd = open(FilePath, "r")
+ except:
+ EdkLogger.error("VpdInfoFile",
+ BuildToolError.FILE_OPEN_FAILURE,
+ "Fail to open file %s for written." % FilePath)
+ Lines = fd.readlines()
+ for Line in Lines:
+ Line = Line.strip()
+ if len(Line) == 0 or Line.startswith("#"):
+ continue
+
+ #
+ # the line must follow output format defined in BPDG spec.
+ #
+ try:
+ PcdName, Offset, Size, Value = Line.split("#")[0].split("|")
+ TokenSpaceName, PcdTokenName = PcdName.split(".")
+ except:
+ EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail to parse VPD information file %s" % FilePath)
+
+ Found = False
+ for VpdObject in self._VpdArray.keys():
+ if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObject.TokenCName == PcdTokenName.strip():
+ if self._VpdArray[VpdObject][0] == "*":
+ if Offset == "*":
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)
+
+ self._VpdArray[VpdObject][0] = Offset
+ Found = True
+ break
+ if not Found:
+ EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Can not find PCD defined in VPD guid file.")
+
+ ## Get count of VPD PCD collected from platform's autogen when building.
+ #
+ # @return The integer count value
+ def GetCount(self):
+ Count = 0
+ for OffsetList in self._VpdArray.values():
+ Count += len(OffsetList)
+
+ return Count
+
+ ## Get an offset value for a given VPD PCD
+ #
+ # Because BPDG only support one Sku, so only return offset for SKU default.
+ #
+ # @param vpd A given VPD PCD
+ def GetOffset(self, vpd):
+ if not self._VpdArray.has_key(vpd):
+ return None
+
+ if len(self._VpdArray[vpd]) == 0:
+ return None
+
+ return self._VpdArray[vpd]
+
+## Call external BPDG tool to process VPD file
+#
+# @param ToolPath The string path name for BPDG tool
+# @param VpdFileName The string path name for VPD information guid.txt
+#
+def CallExtenalBPDGTool(ToolPath, VpdFileName):
+ assert ToolPath != None, "Invalid parameter ToolPath"
+ assert VpdFileName != None and os.path.exists(VpdFileName), "Invalid parameter VpdFileName"
+
+ OutputDir = os.path.dirname(VpdFileName)
+ FileName = os.path.basename(VpdFileName)
+ BaseName, ext = os.path.splitext(FileName)
+ OutputMapFileName = os.path.join(OutputDir, "%s.map" % BaseName)
+ OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)
+ cmd = [ToolPath]
+ cmd += ["-o %s" % OutputBinFileName,]
+ cmd += ["-m %s" % OutputMapFileName, ]
+ cmd += ["-s",]
+ cmd += ["-f",]
+ cmd += ["-v",]
+ cmd += [VpdFileName, ]
+
+ try:
+ PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr= subprocess.PIPE)
+ except Exception, X:
+ EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
+ (out, error) = PopenObject.communicate()
+ print out
+ while PopenObject.returncode == None :
+ PopenObject.wait()
+
+ if PopenObject.returncode != 0:
+ if PopenObject.returncode != 0:
+ EdkLogger.debug(EdkLogger.DEBUG_1, "Fail to call BPDG tool", str(error))
+ EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, "Fail to execute BPDG tool with exit code: %d, the error message is: \n %s" % \
+ (PopenObject.returncode, str(error)))
+
+ return PopenObject.returncode
Modified: trunk/BaseTools/Source/Python/Makefile
===================================================================
--- trunk/BaseTools/Source/Python/Makefile 2010-07-31 19:31:14 UTC (rev 2006)
+++ trunk/BaseTools/Source/Python/Makefile 2010-08-05 03:03:10 UTC (rev 2007)
@@ -22,7 +22,7 @@
BIN_DIR=$(EDK_TOOLS_PATH)\Bin\Win32
-APPLICATIONS=$(BIN_DIR)\build.exe $(BIN_DIR)\GenFds.exe $(BIN_DIR)\Trim.exe $(BIN_DIR)\MigrationMsa2Inf.exe $(BIN_DIR)\Fpd2Dsc.exe $(BIN_DIR)\TargetTool.exe $(BIN_DIR)\spd2dec.exe $(BIN_DIR)\GenDepex.exe $(BIN_DIR)\GenPatchPcdTable.exe $(BIN_DIR)\PatchPcdValue.exe
+APPLICATIONS=$(BIN_DIR)\build.exe $(BIN_DIR)\GenFds.exe $(BIN_DIR)\Trim.exe $(BIN_DIR)\MigrationMsa2Inf.exe $(BIN_DIR)\Fpd2Dsc.exe $(BIN_DIR)\TargetTool.exe $(BIN_DIR)\spd2dec.exe $(BIN_DIR)\GenDepex.exe $(BIN_DIR)\GenPatchPcdTable.exe $(BIN_DIR)\PatchPcdValue.exe $(BIN_DIR)\BPDG.exe
COMMON_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\Common\BuildToolError.py \
$(BASE_TOOLS_PATH)\Source\Python\Common\Database.py \
@@ -46,6 +46,7 @@
$(BASE_TOOLS_PATH)\Source\Python\Common\String.py \
$(BASE_TOOLS_PATH)\Source\Python\Common\TargetTxtClassObject.py \
$(BASE_TOOLS_PATH)\Source\Python\Common\ToolDefClassObject.py \
+ $(BASE_TOOLS_PATH)\Source\Python\Common\VpdInfoFile.py \
$(BASE_TOOLS_PATH)\Source\Python\Common\XmlParser.py \
$(BASE_TOOLS_PATH)\Source\Python\Common\XmlRoutines.py \
$(BASE_TOOLS_PATH)\Source\Python\Common\__init__.py \
@@ -62,7 +63,7 @@
$(BASE_TOOLS_PATH)\Source\Python\Autogen\GenMake.py \
$(BASE_TOOLS_PATH)\Source\Python\Autogen\StrGather.py \
$(BASE_TOOLS_PATH)\Source\Python\Autogen\UniClassObject.py \
- $(BASE_TOOLS_PATH)\Source\Python\Autogen\__init__.py
+ $(BASE_TOOLS_PATH)\Source\Python\Autogen\__init__.py
all: SetPythonPath $(APPLICATIONS)
@@ -100,6 +101,9 @@
$(BIN_DIR)\PatchPcdValue.exe: $(BASE_TOOLS_PATH)\Source\Python\PatchPcdValue\PatchPcdValue.py $(COMMON_PYTHON)
@pushd . & @cd PatchPcdValue & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) PatchPcdValue.py & @popd
+$(BIN_DIR)\BPDG.exe: $(BASE_TOOLS_PATH)\Source\Python\BPDG\BPDG.py $(COMMON_PYTHON)
+ @pushd . & @cd BPDG & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) BPDG.py & @popd
+
clean:
cleanall:
@del /f /q $(BIN_DIR)\*.pyd $(BIN_DIR)\*.dll
Modified: trunk/BaseTools/Source/Python/Workspace/BuildClassObject.py
===================================================================
--- trunk/BaseTools/Source/Python/Workspace/BuildClassObject.py 2010-07-31 19:31:14 UTC (rev 2006)
+++ trunk/BaseTools/Source/Python/Workspace/BuildClassObject.py 2010-08-05 03:03:10 UTC (rev 2007)
@@ -1,7 +1,7 @@
## @file
# This file is used to define each component of the build database
#
-# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -31,6 +31,7 @@
# @param MaxDatumSize: Input value for MaxDatumSize of Pcd, default is None
# @param SkuInfoList: Input value for SkuInfoList of Pcd, default is {}
# @param IsOverrided: Input value for IsOverrided of Pcd, default is False
+# @param GuidValue: Input value for TokenSpaceGuidValue of Pcd, default is None
#
# @var TokenCName: To store value for TokenCName
# @var TokenSpaceGuidCName: To store value for TokenSpaceGuidCName
@@ -43,7 +44,7 @@
# @var Phase: To store value for Phase, default is "DXE"
#
class PcdClassObject(object):
- def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, GuidValue = None):
+ def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, IsOverrided = False, GuidValue = None):
self.TokenCName = Name
self.TokenSpaceGuidCName = Guid
self.TokenSpaceGuidValue = GuidValue
@@ -55,7 +56,8 @@
self.SkuInfoList = SkuInfoList
self.Phase = "DXE"
self.Pending = False
-
+ self.IsOverrided = IsOverrided
+
## Convert the class to a string
#
# Convert each member of the class to string
@@ -73,7 +75,7 @@
'MaxDatumSize=' + str(self.MaxDatumSize) + ', '
for Item in self.SkuInfoList.values():
Rtn = Rtn + 'SkuId=' + Item.SkuId + ', ' + 'SkuIdName=' + Item.SkuIdName
- Rtn = Rtn + str(self.IsOverrided)
+ Rtn = Rtn + ', IsOverrided=' + str(self.IsOverrided)
return Rtn
Modified: trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
===================================================================
--- trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py 2010-07-31 19:31:14 UTC (rev 2006)
+++ trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py 2010-08-05 03:03:10 UTC (rev 2007)
@@ -18,6 +18,7 @@
import os
import os.path
import pickle
+import uuid
import Common.EdkLogger as EdkLogger
import Common.GlobalData as GlobalData
@@ -135,6 +136,7 @@
self._Pcds = None
self._BuildOptions = None
self._LoadFixAddress = None
+ self._VpdToolGuid = None
## Get architecture
def _GetArch(self):
@@ -188,6 +190,17 @@
self._SkuName = Record[1]
elif Name == TAB_FIX_LOAD_TOP_MEMORY_ADDRESS:
self._LoadFixAddress = Record[1]
+ elif Name == TAB_DSC_DEFINES_VPD_TOOL_GUID:
+ #
+ # try to convert GUID to a real UUID value to see whether the GUID is format
+ # for VPD_TOOL_GUID is correct.
+ #
+ try:
+ uuid.UUID(Record[1])
+ except:
+ EdkLogger.error("build", FORMAT_INVALID, "Invalid GUID format for VPD_TOOL_GUID", File=self.MetaFile)
+ self._VpdToolGuid = Record[1]
+
# set _Header to non-None in order to avoid database re-querying
self._Header = 'DUMMY'
@@ -321,6 +334,15 @@
self._LoadFixAddress = ''
return self._LoadFixAddress
+ ## Retrieve the GUID string for VPD tool
+ def _GetVpdToolGuid(self):
+ if self._VpdToolGuid == None:
+ if self._Header == None:
+ self._GetHeaderInfo()
+ if self._VpdToolGuid == None:
+ self._VpdToolGuid = ''
+ return self._VpdToolGuid
+
## Retrieve [SkuIds] section information
def _GetSkuIds(self):
if self._SkuIds == None:
@@ -418,6 +440,7 @@
'',
MaxDatumSize,
...
[truncated message content] |