]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg: YAML script bug fix
authorLoo, Tung Lun <tung.lun.loo@intel.com>
Mon, 17 May 2021 04:04:13 +0000 (12:04 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 18 May 2021 00:46:45 +0000 (00:46 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3395

This patch fixes the issue observed during
BSF file to YAML file conversion. It also
addresses the issue during multibyte array
data conversion check, for example the data
representation of 0xFFFF instead of 0xFF, 0xFF
would be thrown exception "Array size is not
proper" without this patch.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Signed-off-by: Loo Tung Lun <tung.lun.loo@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py
IntelFsp2Pkg/Tools/GenCfgOpt.py

index cad9b60e73158cebc91a274e3c64990a3acd1064..d2ca7145ae1505bed55050ee208cdcad75b750cd 100644 (file)
@@ -46,6 +46,13 @@ def Bytes2Val(Bytes):
     return reduce(lambda x, y: (x << 8) | y, Bytes[::-1])\r
 \r
 \r
+def Str2Bytes(Value, Blen):\r
+    Result = bytearray(Value[1:-1], 'utf-8')  # Excluding quotes\r
+    if len(Result) < Blen:\r
+        Result.extend(b'\x00' * (Blen - len(Result)))\r
+    return Result\r
+\r
+\r
 class CFspBsf2Dsc:\r
 \r
     def __init__(self, bsf_file):\r
@@ -108,7 +115,8 @@ class CFspBsf2Dsc:
                 cfg_item['find'] = prefix\r
                 cfg_item['cname'] = 'Signature'\r
                 cfg_item['length'] = len(finds[0][1])\r
-                cfg_item['value'] = '0x%X' % Bytes2Val(finds[0][1].encode('UTF-8'))\r
+                str2byte = Str2Bytes("'" + finds[0][1] + "'", len(finds[0][1]))\r
+                cfg_item['value'] = '0x%X' % Bytes2Val(str2byte)\r
                 cfg_list.append(dict(cfg_item))\r
                 cfg_item = dict(cfg_temp)\r
                 find_list.pop(0)\r
@@ -291,7 +299,6 @@ class CFspDsc2Yaml():
                 raise Exception('DSC variable creation error !')\r
         else:\r
             raise Exception('Unsupported file "%s" !' % file_name)\r
-        gen_cfg_data.UpdateDefaultValue()\r
         self.gen_cfg_data = gen_cfg_data\r
 \r
     def print_dsc_line(self):\r
index 660824b7401f475e3fe5441cb8d5f747b5c0ddcb..714b2d8b1a955ba133ede4525b8940f2f0073bfd 100644 (file)
@@ -708,7 +708,8 @@ EndList
                             for Page in PageList:\r
                                 Page  = Page.strip()\r
                                 Match = re.match("(\w+):\"(.+)\"", Page)\r
-                                self._CfgPageDict[Match.group(1)] = Match.group(2)\r
+                                if Match != None:\r
+                                    self._CfgPageDict[Match.group(1)] = Match.group(2)\r
 \r
                         Match = re.match("(?:^|.+\s+)BLOCK:{NAME:\"(.+)\"\s*,\s*VER:\"(.+)\"\s*}", Remaining)\r
                         if Match:\r