]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/BPDG/GenVpd.py
Sync BaseTools Trunk (version r2524) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / Python / BPDG / GenVpd.py
index f0196e061a64bfad17c3f5d5038688ba302eea80..cc4985062e4d977288092c6704297fe88e6baf58 100644 (file)
@@ -17,6 +17,7 @@ import os
 import StringIO\r
 import StringTable as st\r
 import array\r
+import re\r
 \r
 from struct import *\r
 import Common.EdkLogger as EdkLogger\r
@@ -225,7 +226,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
@@ -338,8 +339,27 @@ class GenVPD :
             line = line.rstrip(os.linesep)\r
                        \r
             # Skip the comment line\r
-            if (not line.startswith("#")) and len(line) > 1 :              \r
-                self.FileLinesList[count] = line.split('|')\r
+            if (not line.startswith("#")) and len(line) > 1 :\r
+                #\r
+                # Enhanced for support "|" character in the string.\r
+                #\r
+                ValueList = ['', '', '', '']    \r
+                \r
+                ValueRe  = re.compile(r'\s*L?\".*\|.*\"\s*$')\r
+                PtrValue = ValueRe.findall(line)\r
+                \r
+                ValueUpdateFlag = False\r
+                \r
+                if len(PtrValue) >= 1:\r
+                    line = re.sub(ValueRe, '', line)\r
+                    ValueUpdateFlag = True   \r
+            \r
+                TokenList = line.split('|')\r
+                ValueList[0:len(TokenList)] = TokenList\r
+                \r
+                if ValueUpdateFlag:\r
+                    ValueList[3] = PtrValue[0]                              \r
+                self.FileLinesList[count] = ValueList\r
                 # Store the line number\r
                 self.FileLinesList[count].append(str(count+1))\r
             elif len(line) <= 1 :\r
@@ -524,10 +544,8 @@ class GenVPD :
                 if lenOfUnfixedList != 0 :\r
                     countOfUnfixedList = 0\r
                     while(countOfUnfixedList < lenOfUnfixedList) :                   \r
-                        #needFixPcdCName, needFixPcdOffset, needFixPcdSize, needFixPcdValue, needFixUnpackValue = self.PcdUnknownOffsetList[countOfUnfixedList][0:6]\r
                         eachUnfixedPcd      = self.PcdUnknownOffsetList[countOfUnfixedList]\r
                         needFixPcdSize      = eachUnfixedPcd.PcdBinSize\r
-                        needFixPcdOffset    = eachUnfixedPcd.PcdOffset\r
                         # Not been fixed\r
                         if eachUnfixedPcd.PcdOffset == '*' :\r
                             # The offset un-fixed pcd can write into this free space\r
@@ -546,18 +564,16 @@ class GenVPD :
                                 FixOffsetSizeListCount  += 1\r
                                 \r
                                 # Decrease the un-fixed pcd offset list's length\r
-                                countOfUnfixedList      += 1\r
                                 lenOfUnfixedList        -= 1\r
                                 \r
                                 # Modify the last offset value \r
-                                LastOffset              += needFixPcdSize\r
-                                continue                            \r
+                                LastOffset              += needFixPcdSize                            \r
                             else :\r
-                                # It can not insert into those two pcds, need to check stiil has other space can store it.\r
+                                # It can not insert into those two pcds, need to check still has other space can store it.\r
+                                LastOffset             = NowOffset + self.PcdFixedOffsetSizeList[FixOffsetSizeListCount].PcdBinSize\r
                                 FixOffsetSizeListCount += 1\r
-                                break                   \r
-                        else :\r
-                            continue\r
+                                break\r
+                                                                                 \r
                 # Set the FixOffsetSizeListCount = lenOfList for quit the loop\r
                 else :\r
                     FixOffsetSizeListCount = lenOfList                    \r