public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Fixed the PcdValue trailing zero issue.
@ 2018-08-28 10:22 BobCF
  2018-08-30  7:36 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: BobCF @ 2018-08-28 10:22 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

1. Not append trailing zero for PcdValue
2. make sure the point to Variable Name in PCD
DataBase 2 bytes aligned.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/AutoGen/GenPcdDb.py   | 6 ++++++
 BaseTools/Source/Python/Common/StringUtils.py | 7 +------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 2176bbefeb..5b260cd515 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -1182,10 +1182,16 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
                 Pcd.InitString = 'INIT'
                 # Store all variable names of one HII PCD under different SKU to stringTable
                 # and calculate the VariableHeadStringIndex
 
                 VariableNameStructure = StringToArray(Sku.VariableName)
+
+                #  Make pointer of VaraibleName(HII PCD) 2 bytes aligned
+                VariableNameStructureBytes = VariableNameStructure.lstrip("{").rstrip("}").split(",")
+                if len(VariableNameStructureBytes) % 2:
+                    VariableNameStructure = "{%s,0x00}" % ",".join(VariableNameStructureBytes)
+
                 if VariableNameStructure not in Dict['STRING_TABLE_VALUE']:
                     Dict['STRING_TABLE_CNAME'].append(CName)
                     Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid)
                     if StringTableIndex == 0:
                         Dict['STRING_TABLE_INDEX'].append('')
diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py
index da2949dbad..d5afde7a95 100644
--- a/BaseTools/Source/Python/Common/StringUtils.py
+++ b/BaseTools/Source/Python/Common/StringUtils.py
@@ -833,16 +833,11 @@ def StringToArray(String):
             if StringLen % 2:
                 return "{%s,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1])
             else:
                 return "{%s,0x00,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1])
     elif String.startswith('{'):
-        StringLen = len(String.split(","))
-        if StringLen % 2:
-            return "{%s,0x00}" % ",".join(C.strip() for C in String[1:-1].split(','))
-        else:
-            return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(','))
-
+        return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(','))
     else:
         if len(String.split()) % 2:
             return '{%s,0}' % ','.join(String.split())
         else:
             return '{%s,0,0}' % ','.join(String.split())
-- 
2.16.2.windows.1



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

* Re: [Patch] BaseTools: Fixed the PcdValue trailing zero issue.
  2018-08-28 10:22 [Patch] BaseTools: Fixed the PcdValue trailing zero issue BobCF
@ 2018-08-30  7:36 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-08-30  7:36 UTC (permalink / raw)
  To: Feng, Bob C, edk2-devel@lists.01.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Feng, Bob C
>Sent: Tuesday, August 28, 2018 6:23 PM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTools: Fixed the PcdValue trailing zero issue.
>
>1. Not append trailing zero for PcdValue
>2. make sure the point to Variable Name in PCD
>DataBase 2 bytes aligned.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng <bob.c.feng@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>---
> BaseTools/Source/Python/AutoGen/GenPcdDb.py   | 6 ++++++
> BaseTools/Source/Python/Common/StringUtils.py | 7 +------
> 2 files changed, 7 insertions(+), 6 deletions(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
>b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
>index 2176bbefeb..5b260cd515 100644
>--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
>+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
>@@ -1182,10 +1182,16 @@ def CreatePcdDatabasePhaseSpecificAutoGen
>(Platform, DynamicPcdList, Phase):
>                 Pcd.InitString = 'INIT'
>                 # Store all variable names of one HII PCD under different SKU to
>stringTable
>                 # and calculate the VariableHeadStringIndex
>
>                 VariableNameStructure = StringToArray(Sku.VariableName)
>+
>+                #  Make pointer of VaraibleName(HII PCD) 2 bytes aligned
>+                VariableNameStructureBytes =
>VariableNameStructure.lstrip("{").rstrip("}").split(",")
>+                if len(VariableNameStructureBytes) % 2:
>+                    VariableNameStructure = "{%s,0x00}" %
>",".join(VariableNameStructureBytes)
>+
>                 if VariableNameStructure not in Dict['STRING_TABLE_VALUE']:
>                     Dict['STRING_TABLE_CNAME'].append(CName)
>                     Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid)
>                     if StringTableIndex == 0:
>                         Dict['STRING_TABLE_INDEX'].append('')
>diff --git a/BaseTools/Source/Python/Common/StringUtils.py
>b/BaseTools/Source/Python/Common/StringUtils.py
>index da2949dbad..d5afde7a95 100644
>--- a/BaseTools/Source/Python/Common/StringUtils.py
>+++ b/BaseTools/Source/Python/Common/StringUtils.py
>@@ -833,16 +833,11 @@ def StringToArray(String):
>             if StringLen % 2:
>                 return "{%s,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1])
>             else:
>                 return "{%s,0x00,0x00}" % ",".join("0x%02x" % ord(C) for C in
>String[1:-1])
>     elif String.startswith('{'):
>-        StringLen = len(String.split(","))
>-        if StringLen % 2:
>-            return "{%s,0x00}" % ",".join(C.strip() for C in String[1:-1].split(','))
>-        else:
>-            return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(','))
>-
>+        return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(','))
>     else:
>         if len(String.split()) % 2:
>             return '{%s,0}' % ','.join(String.split())
>         else:
>             return '{%s,0,0}' % ','.join(String.split())
>--
>2.16.2.windows.1



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

end of thread, other threads:[~2018-08-30  7:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-28 10:22 [Patch] BaseTools: Fixed the PcdValue trailing zero issue BobCF
2018-08-30  7:36 ` Gao, Liming

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