public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v3] IntelFsp2Pkg: YAML script bug fix
@ 2021-05-17  4:04 Tung Lun
  2021-05-17  6:09 ` Chiu, Chasel
  2021-05-18  3:17 ` Chiu, Chasel
  0 siblings, 2 replies; 3+ messages in thread
From: Tung Lun @ 2021-05-17  4:04 UTC (permalink / raw)
  To: devel; +Cc: Loo Tung Lun, Maurice Ma, Nate DeSimone, Star Zeng, Chasel Chiu

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>
---
 IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py | 11 +++++++++--
 IntelFsp2Pkg/Tools/GenCfgOpt.py      |  3 ++-
 2 files changed, 11 insertions(+), 3 deletions(-)

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] IntelFsp2Pkg: YAML script bug fix
  2021-05-17  4:04 [PATCH v3] IntelFsp2Pkg: YAML script bug fix Tung Lun
@ 2021-05-17  6:09 ` Chiu, Chasel
  2021-05-18  3:17 ` Chiu, Chasel
  1 sibling, 0 replies; 3+ messages in thread
From: Chiu, Chasel @ 2021-05-17  6:09 UTC (permalink / raw)
  To: Loo, Tung Lun, devel@edk2.groups.io
  Cc: Ma, Maurice, Desimone, Nathaniel L, Zeng, Star


Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

> -----Original Message-----
> From: Loo, Tung Lun <tung.lun.loo@intel.com>
> Sent: Monday, May 17, 2021 12:04 PM
> To: devel@edk2.groups.io
> Cc: Loo, Tung Lun <tung.lun.loo@intel.com>; Ma, Maurice
> <maurice.ma@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; Chiu,
> Chasel <chasel.chiu@intel.com>
> Subject: [PATCH v3] IntelFsp2Pkg: YAML script bug fix
> 
> 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>
> ---
>  IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py | 11 +++++++++--
>  IntelFsp2Pkg/Tools/GenCfgOpt.py      |  3 ++-
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py
> b/IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py
> index cad9b60e73..d2ca7145ae 100644
> --- a/IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py
> +++ b/IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py
> @@ -46,6 +46,13 @@ def Bytes2Val(Bytes):
>      return reduce(lambda x, y: (x << 8) | y, Bytes[::-1])  +def Str2Bytes(Value,
> Blen):+    Result = bytearray(Value[1:-1], 'utf-8')  # Excluding quotes+    if
> len(Result) < Blen:+        Result.extend(b'\x00' * (Blen - len(Result)))+    return
> Result++ class CFspBsf2Dsc:      def __init__(self, bsf_file):@@ -108,7 +115,8
> @@ class CFspBsf2Dsc:
>                  cfg_item['find'] = prefix                 cfg_item['cname'] = 'Signature'
> cfg_item['length'] = len(finds[0][1])-                cfg_item['value'] = '0x%X' %
> Bytes2Val(finds[0][1].encode('UTF-8'))+                str2byte = Str2Bytes("'" +
> finds[0][1] + "'", len(finds[0][1]))+                cfg_item['value'] = '0x%X' %
> Bytes2Val(str2byte)                 cfg_list.append(dict(cfg_item))                 cfg_item =
> dict(cfg_temp)                 find_list.pop(0)@@ -291,7 +299,6 @@ class
> CFspDsc2Yaml():
>                  raise Exception('DSC variable creation error !')         else:             raise
> Exception('Unsupported file "%s" !' % file_name)-
> gen_cfg_data.UpdateDefaultValue()         self.gen_cfg_data = gen_cfg_data
> def print_dsc_line(self):diff --git a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> b/IntelFsp2Pkg/Tools/GenCfgOpt.py
> index 660824b740..714b2d8b1a 100644
> --- a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> +++ b/IntelFsp2Pkg/Tools/GenCfgOpt.py
> @@ -708,7 +708,8 @@ EndList
>                              for Page in PageList:                                 Page  = Page.strip()
> Match = re.match("(\w+):\"(.+)\"", Page)-
> self._CfgPageDict[Match.group(1)] = Match.group(2)+                                if
> Match != None:+                                    self._CfgPageDict[Match.group(1)] =
> Match.group(2)                          Match =
> re.match("(?:^|.+\s+)BLOCK:{NAME:\"(.+)\"\s*,\s*VER:\"(.+)\"\s*}", Remaining)
> if Match:--
> 2.28.0.windows.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] IntelFsp2Pkg: YAML script bug fix
  2021-05-17  4:04 [PATCH v3] IntelFsp2Pkg: YAML script bug fix Tung Lun
  2021-05-17  6:09 ` Chiu, Chasel
@ 2021-05-18  3:17 ` Chiu, Chasel
  1 sibling, 0 replies; 3+ messages in thread
From: Chiu, Chasel @ 2021-05-18  3:17 UTC (permalink / raw)
  To: Loo, Tung Lun, devel@edk2.groups.io
  Cc: Ma, Maurice, Desimone, Nathaniel L, Zeng, Star


Pushed: 1fbf5e30ae8eb725f4e10984f7b0a208f78abbd0

Thanks,
Chasel


> -----Original Message-----
> From: Loo, Tung Lun <tung.lun.loo@intel.com>
> Sent: Monday, May 17, 2021 12:04 PM
> To: devel@edk2.groups.io
> Cc: Loo, Tung Lun <tung.lun.loo@intel.com>; Ma, Maurice
> <maurice.ma@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; Chiu,
> Chasel <chasel.chiu@intel.com>
> Subject: [PATCH v3] IntelFsp2Pkg: YAML script bug fix
> 
> 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>
> ---
>  IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py | 11 +++++++++--
>  IntelFsp2Pkg/Tools/GenCfgOpt.py      |  3 ++-
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py
> b/IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py
> index cad9b60e73..d2ca7145ae 100644
> --- a/IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py
> +++ b/IntelFsp2Pkg/Tools/FspDscBsf2Yaml.py
> @@ -46,6 +46,13 @@ def Bytes2Val(Bytes):
>      return reduce(lambda x, y: (x << 8) | y, Bytes[::-1])  +def Str2Bytes(Value,
> Blen):+    Result = bytearray(Value[1:-1], 'utf-8')  # Excluding quotes+    if
> len(Result) < Blen:+        Result.extend(b'\x00' * (Blen - len(Result)))+    return
> Result++ class CFspBsf2Dsc:      def __init__(self, bsf_file):@@ -108,7 +115,8
> @@ class CFspBsf2Dsc:
>                  cfg_item['find'] = prefix                 cfg_item['cname'] = 'Signature'
> cfg_item['length'] = len(finds[0][1])-                cfg_item['value'] = '0x%X' %
> Bytes2Val(finds[0][1].encode('UTF-8'))+                str2byte = Str2Bytes("'" +
> finds[0][1] + "'", len(finds[0][1]))+                cfg_item['value'] = '0x%X' %
> Bytes2Val(str2byte)                 cfg_list.append(dict(cfg_item))                 cfg_item =
> dict(cfg_temp)                 find_list.pop(0)@@ -291,7 +299,6 @@ class
> CFspDsc2Yaml():
>                  raise Exception('DSC variable creation error !')         else:             raise
> Exception('Unsupported file "%s" !' % file_name)-
> gen_cfg_data.UpdateDefaultValue()         self.gen_cfg_data = gen_cfg_data
> def print_dsc_line(self):diff --git a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> b/IntelFsp2Pkg/Tools/GenCfgOpt.py
> index 660824b740..714b2d8b1a 100644
> --- a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> +++ b/IntelFsp2Pkg/Tools/GenCfgOpt.py
> @@ -708,7 +708,8 @@ EndList
>                              for Page in PageList:                                 Page  = Page.strip()
> Match = re.match("(\w+):\"(.+)\"", Page)-
> self._CfgPageDict[Match.group(1)] = Match.group(2)+                                if
> Match != None:+                                    self._CfgPageDict[Match.group(1)] =
> Match.group(2)                          Match =
> re.match("(?:^|.+\s+)BLOCK:{NAME:\"(.+)\"\s*,\s*VER:\"(.+)\"\s*}", Remaining)
> if Match:--
> 2.28.0.windows.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-18  3:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-17  4:04 [PATCH v3] IntelFsp2Pkg: YAML script bug fix Tung Lun
2021-05-17  6:09 ` Chiu, Chasel
2021-05-18  3:17 ` Chiu, Chasel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox