]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/BPDG/GenVpd.py
There is a limitation on WINDOWS OS for the length of entire file path can’t be large...
[mirror_edk2.git] / BaseTools / Source / Python / BPDG / GenVpd.py
index bbe44eefa4df6d7989f26af0195d9b7ea7e234d0..76d30fa6ff497c165187c3aad98450465489dc21 100644 (file)
@@ -2,7 +2,7 @@
 #  This file include GenVpd class for fix the Vpd type PCD offset, and PcdEntry for describe\r
 #  and process each entry of vpd type PCD.\r
 #\r
-#  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
 \r
-import os\r
+import Common.LongFilePathOs as os\r
 import StringIO\r
 import StringTable as st\r
 import array\r
 import re\r
-\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
 from struct import *\r
 import Common.EdkLogger as EdkLogger\r
 import Common.BuildToolError as BuildToolError\r
@@ -34,9 +34,10 @@ _FORMAT_CHAR = {1: 'B',
 #  This class contain method to format and pack pcd's value.          \r
 #\r
 class PcdEntry:\r
-    def __init__(self, PcdCName, PcdOffset, PcdSize, PcdValue, Lineno=None, FileName=None, PcdUnpackValue=None, \r
+    def __init__(self, PcdCName, SkuId,PcdOffset, PcdSize, PcdValue, Lineno=None, FileName=None, PcdUnpackValue=None, \r
                  PcdBinOffset=None, PcdBinSize=None):\r
         self.PcdCName       = PcdCName.strip()\r
+        self.SkuId          = SkuId.strip()\r
         self.PcdOffset      = PcdOffset.strip()\r
         self.PcdSize        = PcdSize.strip()\r
         self.PcdValue       = PcdValue.strip()\r
@@ -226,7 +227,7 @@ class PcdEntry:
         \r
         for Index in xrange(len(ValueList)):\r
             Value = None\r
-            if ValueList[Index].startswith('0x'):\r
+            if ValueList[Index].lower().startswith('0x'):\r
                 # translate hex value\r
                 try:\r
                     Value = int(ValueList[Index], 16)\r
@@ -284,7 +285,7 @@ class PcdEntry:
                                 "Invalid unicode character %s in unicode string %s(File: %s Line: %s)" % \\r
                                 (Value, UnicodeString, self.FileName, self.Lineno))\r
                 \r
-        for Index in range(len(UnicodeString) * 2, Size):\r
+        for Index in xrange(len(UnicodeString) * 2, Size):\r
             ReturnArray.append(0)\r
             \r
         self.PcdValue =  ReturnArray.tolist()    \r
@@ -343,7 +344,7 @@ class GenVPD :
                 #\r
                 # Enhanced for support "|" character in the string.\r
                 #\r
-                ValueList = ['', '', '', '']    \r
+                ValueList = ['', '', '', '','']    \r
                 \r
                 ValueRe  = re.compile(r'\s*L?\".*\|.*\"\s*$')\r
                 PtrValue = ValueRe.findall(line)\r
@@ -358,7 +359,7 @@ class GenVPD :
                 ValueList[0:len(TokenList)] = TokenList\r
                 \r
                 if ValueUpdateFlag:\r
-                    ValueList[3] = PtrValue[0]                              \r
+                    ValueList[4] = PtrValue[0]                              \r
                 self.FileLinesList[count] = ValueList\r
                 # Store the line number\r
                 self.FileLinesList[count].append(str(count+1))\r
@@ -393,9 +394,10 @@ class GenVPD :
         count = 0\r
         for line in self.FileLinesList:        \r
             if line != None :\r
-                PCD = PcdEntry(line[0], line[1], line[2], line[3], line[4], self.InputFileName)   \r
+                PCD = PcdEntry(line[0], line[1], line[2], line[3], line[4],line[5], self.InputFileName)   \r
                 # Strip the space char\r
                 PCD.PcdCName     = PCD.PcdCName.strip(' ')\r
+                PCD.SkuId        = PCD.SkuId.strip(' ')\r
                 PCD.PcdOffset    = PCD.PcdOffset.strip(' ')\r
                 PCD.PcdSize      = PCD.PcdSize.strip(' ')\r
                 PCD.PcdValue     = PCD.PcdValue.strip(' ')               \r
@@ -639,7 +641,7 @@ class GenVPD :
         for eachPcd in self.PcdFixedOffsetSizeList  :\r
             # write map file\r
             try :\r
-                fMapFile.write("%s | %s | %s | %s  \n" % (eachPcd.PcdCName, eachPcd.PcdOffset, eachPcd.PcdSize,eachPcd.PcdUnpackValue))\r
+                fMapFile.write("%s | %s | %s | %s | %s  \n" % (eachPcd.PcdCName, eachPcd.SkuId,eachPcd.PcdOffset, eachPcd.PcdSize,eachPcd.PcdUnpackValue))\r
             except:\r
                 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)                                                                      \r
                          \r