Update GenFds to support HexValue in DATA region.
authorlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Fri, 5 Mar 2010 09:36:39 +0000 (09:36 +0000)
committerlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Fri, 5 Mar 2010 09:36:39 +0000 (09:36 +0000)
git-svn-id: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/trunk/BaseTools@1916 c2973edb-eda0-4c78-bc6a-9341b269661f

Source/Python/Common/FdfParserLite.py
Source/Python/GenFds/FdfParser.py

index eb7b0d7..b181e65 100644 (file)
@@ -1760,8 +1760,8 @@ class FdfParser(object):
         if not self.__GetNextHexNumber():\r
             raise Warning("expected Hex byte At Line ", self.FileName, self.CurrentLineNumber)\r
         \r
-        if len(self.__Token) > 4:\r
-            raise Warning("Hex byte(must be 2 digits) too long At Line ", self.FileName, self.CurrentLineNumber)\r
+        if len(self.__Token) > 18:\r
+            raise Warning("Hex string can't be converted to a valid UINT64 value", self.FileName, self.CurrentLineNumber)\r
         \r
         DataString = self.__Token\r
         DataString += ","\r
@@ -1792,8 +1792,8 @@ class FdfParser(object):
             if not self.__GetNextHexNumber():\r
                 raise Warning("expected Hex byte At Line ", self.FileName, self.CurrentLineNumber)\r
         \r
-            if len(self.__Token) > 4:\r
-                raise Warning("Hex byte(must be 2 digits) too long At Line ", self.FileName, self.CurrentLineNumber)\r
+            if len(self.__Token) > 18:\r
+                raise Warning("Hex string can't be converted to a valid UINT64 value", self.FileName, self.CurrentLineNumber)\r
         \r
             DataString = self.__Token\r
             DataString += ","\r
index 92d6ab6..1e87eb4 100644 (file)
@@ -1787,19 +1787,27 @@ class FdfParser:
         if not self.__GetNextHexNumber():\r
             raise Warning("expected Hex byte", self.FileName, self.CurrentLineNumber)\r
 \r
-        if len(self.__Token) > 4:\r
-            raise Warning("Hex byte(must be 2 digits) too long", self.FileName, self.CurrentLineNumber)\r
-\r
-        DataString = self.__Token\r
-        DataString += ","\r
-\r
-        while self.__IsToken(","):\r
-            if not self.__GetNextHexNumber():\r
-                raise Warning("Invalid Hex number", self.FileName, self.CurrentLineNumber)\r
-            if len(self.__Token) > 4:\r
-                raise Warning("Hex byte(must be 2 digits) too long", self.FileName, self.CurrentLineNumber)\r
-            DataString += self.__Token\r
-            DataString += ","\r
+        if len(self.__Token) > 18:\r
+            raise Warning("Hex string can't be converted to a valid UINT64 value", self.FileName, self.CurrentLineNumber)\r
+\r
+        # convert hex string value to byte hex string array\r
+        AllString = self.__Token\r
+        AllStrLen = len (AllString)\r
+        DataString = ""\r
+        while AllStrLen > 4:\r
+            DataString = DataString + "0x" + AllString[AllStrLen - 2: AllStrLen] + ","\r
+            AllStrLen  = AllStrLen - 2\r
+        DataString = DataString + AllString[:AllStrLen] + ","\r
+\r
+        # byte value array\r
+        if len (self.__Token) <= 4:\r
+            while self.__IsToken(","):\r
+                if not self.__GetNextHexNumber():\r
+                    raise Warning("Invalid Hex number", self.FileName, self.CurrentLineNumber)\r
+                if len(self.__Token) > 4:\r
+                    raise Warning("Hex byte(must be 2 digits) too long", self.FileName, self.CurrentLineNumber)\r
+                DataString += self.__Token\r
+                DataString += ","\r
 \r
         if not self.__IsToken( "}"):\r
             raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)\r
@@ -1819,18 +1827,27 @@ class FdfParser:
             if not self.__GetNextHexNumber():\r
                 raise Warning("expected Hex byte", self.FileName, self.CurrentLineNumber)\r
 \r
-            if len(self.__Token) > 4:\r
-                raise Warning("Hex byte(must be 2 digits) too long", self.FileName, self.CurrentLineNumber)\r
+            if len(self.__Token) > 18:\r
+                raise Warning("Hex string can't be converted to a valid UINT64 value", self.FileName, self.CurrentLineNumber)\r
 \r
-            DataString = self.__Token\r
-            DataString += ","\r
+            # convert hex string value to byte hex string array\r
+            AllString = self.__Token\r
+            AllStrLen = len (AllString)\r
+            DataString = ""\r
+            while AllStrLen > 4:\r
+                DataString = DataString + "0x" + AllString[AllStrLen - 2: AllStrLen] + ","\r
+                AllStrLen  = AllStrLen - 2\r
+            DataString = DataString + AllString[:AllStrLen] + ","\r
 \r
-            while self.__IsToken(","):\r
-                self.__GetNextHexNumber()\r
-                if len(self.__Token) > 4:\r
-                    raise Warning("Hex byte(must be 2 digits) too long", self.FileName, self.CurrentLineNumber)\r
-                DataString += self.__Token\r
-                DataString += ","\r
+            # byte value array\r
+            if len (self.__Token) <= 4:\r
+                while self.__IsToken(","):\r
+                    if not self.__GetNextHexNumber():\r
+                        raise Warning("Invalid Hex number", self.FileName, self.CurrentLineNumber)\r
+                    if len(self.__Token) > 4:\r
+                        raise Warning("Hex byte(must be 2 digits) too long", self.FileName, self.CurrentLineNumber)\r
+                    DataString += self.__Token\r
+                    DataString += ","\r
 \r
             if not self.__IsToken( "}"):\r
                 raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)\r