public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Feng, Bob C" <bob.c.feng@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [Patch] BaseTool: Combine the HiiPcd value if they link to same Variable
Date: Thu, 25 Jan 2018 09:54:44 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1AC6F0@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20180123021853.12684-1-bob.c.feng@intel.com>

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

>-----Original Message-----
>From: Feng, Bob C
>Sent: Tuesday, January 23, 2018 10:19 AM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTool: Combine the HiiPcd value if they link to same
>Variable
>
>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/AutoGen.py |  2 +-
> BaseTools/Source/Python/AutoGen/GenVar.py  | 36
>++++++++++++++++++++++++++++--
> 2 files changed, 35 insertions(+), 3 deletions(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>index 0f7454f55a..604d38a4d6 100644
>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>@@ -1404,11 +1404,11 @@ class PlatformAutoGen(AutoGen):
>                     continue
>                 if len(Sku.VariableName) > 0:
>                     VariableGuidStructure = Sku.VariableGuidValue
>                     VariableGuid =
>GuidStructureStringToGuidString(VariableGuidStructure)
>                     for StorageName in Sku.DefaultStoreDict:
>-
>VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuNa
>me, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableAttribute ,
>Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType))
>+
>VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuNa
>me, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableOffset,
>Sku.VariableAttribute ,
>Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType))
>             Index += 1
>         return VariableInfo
>
>     def UpdateNVStoreMaxSize(self,OrgVpdFile):
>         if self.VariableInfo:
>diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py
>b/BaseTools/Source/Python/AutoGen/GenVar.py
>index 65d0bea36c..1389d7ff62 100644
>--- a/BaseTools/Source/Python/AutoGen/GenVar.py
>+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
>@@ -19,11 +19,11 @@ import collections
> import copy
> from Common.VariableAttributes import VariableAttributes
> from Common.Misc import *
> import collections
>
>-var_info = collections.namedtuple("uefi_var",
>"pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid,
>var_attribute,pcd_default_value, default_value, data_type")
>+var_info = collections.namedtuple("uefi_var",
>"pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid,
>var_offset,var_attribute,pcd_default_value, default_value, data_type")
> NvStorageHeaderSize = 28
> VariableHeaderSize = 32
>
> def StringArrayToList(StringArray):
>     StringArray = StringArray[1:-1]
>@@ -74,11 +74,42 @@ class VariableMgr(object):
>         value_str = "{"
>         default_var_bin_strip = [ data.strip("""'""") for data in default_var_bin]
>         value_str += ",".join(default_var_bin_strip)
>         value_str += "}"
>         return value_str
>-
>+    def combine_variable(self):
>+        indexedvarinfo = collections.OrderedDict()
>+        for item in self.VarInfo:
>+            if (item.skuname,item.defaultstoragename,
>item.var_name,item.var_guid) not in indexedvarinfo:
>+                indexedvarinfo[(item.skuname,item.defaultstoragename,
>item.var_name,item.var_guid) ] = []
>+            indexedvarinfo[(item.skuname,item.defaultstoragename,
>item.var_name,item.var_guid)].append(item)
>+        for key in indexedvarinfo:
>+            sku_var_info_offset_list = indexedvarinfo[key]
>+            if len(sku_var_info_offset_list) == 1:
>+                continue
>+            newvalue = {}
>+            for item in sku_var_info_offset_list:
>+                data_type = item.data_type
>+                value_list = item.default_value.strip("{").strip("}").split(",")
>+                if data_type in ["BOOLEAN","UINT8","UINT16","UINT32","UINT64"]:
>+                    if data_type == ["BOOLEAN","UINT8"]:
>+                        data_flag = "=B"
>+                    elif data_type == "UINT16":
>+                        data_flag = "=H"
>+                    elif data_type == "UINT32":
>+                        data_flag = "=L"
>+                    elif data_type == "UINT64":
>+                        data_flag = "=Q"
>+                    data = value_list[0]
>+                    value_list = []
>+                    for data_byte in pack(data_flag,int(data,16) if
>data.upper().startswith('0X') else int(data)):
>+                        value_list += [hex(unpack("B",data_byte)[0])]
>+                newvalue[int(item.var_offset,16) if
>item.var_offset.upper().startswith("0X") else int(item.var_offset)] =
>value_list
>+            newvaluestr = "{" + ",".join(reduce(lambda x,y: x+y, [newvalue[k] for k
>in sorted(newvalue.keys())] )) +"}"
>+            n = sku_var_info_offset_list[0]
>+            indexedvarinfo[key] =
>[var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_na
>me, n.var_guid, "0x00",n.var_attribute,newvaluestr  , newvaluestr , "VOID*")]
>+        self.VarInfo = [item[0] for item in indexedvarinfo.values()]
>     def process_variable_data(self):
>
>         var_data = dict()
>
>         indexedvarinfo = collections.OrderedDict()
>@@ -132,10 +163,11 @@ class VariableMgr(object):
>                     var_data[(skuid,defaultstoragename)] = collections.OrderedDict()
>                 var_data[(skuid,defaultstoragename)][index] =
>(data_delta,sku_var_info[(skuid,defaultstoragename)])
>         return var_data
>
>     def new_process_varinfo(self):
>+        self.combine_variable()
>
>         var_data = self.process_variable_data()
>
>         if not var_data:
>             return []
>--
>2.14.3.windows.1



      reply	other threads:[~2018-01-25  9:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23  2:18 [Patch] BaseTool: Combine the HiiPcd value if they link to same Variable BobCF
2018-01-25  9:54 ` Gao, Liming [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E1AC6F0@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox