public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Zhu, Yonghong" <yonghong.zhu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Feng, YunhuaX" <yunhuax.feng@intel.com>
Subject: Re: [Patch V2] BaseTools: DSC Components section support flexible PCD
Date: Sat, 3 Mar 2018 04:34:11 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1D6AFF@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1520039538-11204-1-git-send-email-yonghong.zhu@intel.com>

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

> -----Original Message-----
> From: Zhu, Yonghong
> Sent: Saturday, March 3, 2018 9:12 AM
> To: edk2-devel@lists.01.org
> Cc: Feng, YunhuaX <yunhuax.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [Patch V2] BaseTools: DSC Components section support flexible PCD
> 
> From: Yunhua Feng <yunhuax.feng@intel.com>
> 
> DSC Components section support flexible PCD, and for binary driver, we
> need patch this value. Update the split char ',' not ', ' because some
> value may have space, while others may not have this space.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
>  BaseTools/Source/Python/GenFds/FfsInfStatement.py      | 15 +++++++++++++++
>  BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py |  3 ++-
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
> index b0b242b..dfff892 100644
> --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
> +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
> @@ -44,10 +44,11 @@ from PatchPcdValue.PatchPcdValue import PatchBinaryFile
>  from Common.LongFilePathSupport import CopyLongFilePath
>  from Common.LongFilePathSupport import OpenLongFilePath as open
>  import Common.GlobalData as GlobalData
>  from DepexSection import DepexSection
>  from Common.Misc import SaveFileOnChange
> +from Common.Expression import *
> 
>  ## generate FFS from INF
>  #
>  #
>  class FfsInfStatement(FfsInfStatementClassObject):
> @@ -277,10 +278,24 @@ class FfsInfStatement(FfsInfStatementClassObject):
>                          BuildOptionOverride = True
>                          break
> 
>              if not DscOverride and not FdfOverride and not BuildOptionOverride:
>                  continue
> +
> +            # Support Flexible PCD format
> +            if DefaultValue:
> +                try:
> +                    DefaultValue = ValueExpressionEx(DefaultValue, Pcd.DatumType, Platform._GuidDict)(True)
> +                except BadExpression:
> +                    EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName,
> Pcd.TokenCName, DefaultValue), File=self.InfFileName)
> +
> +            if Pcd.DefaultValue:
> +                try:
> +                    Pcd.DefaultValue = ValueExpressionEx(Pcd.DefaultValue, Pcd.DatumType, Platform._GuidDict)(True)
> +                except BadExpression:
> +                    EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName,
> Pcd.TokenCName, Pcd.DefaultValue),File=self.InfFileName)
> +
>              # Check value, if value are equal, no need to patch
>              if Pcd.DatumType == "VOID*":
>                  if Pcd.DefaultValue == DefaultValue or DefaultValue in [None, '']:
>                      continue
>                  # Get the string size from FDF or DSC
> diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
> index 882da81..942ba88 100644
> --- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
> +++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
> @@ -159,14 +159,15 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
>                  Index = Index + 2
>          elif ValueString.startswith("{") and ValueString.endswith("}"):
>              #
>              # Patch {0x1, 0x2, ...} byte by byte
>              #
> -            ValueList = ValueString[1 : len(ValueString) - 1].split(', ')
> +            ValueList = ValueString[1 : len(ValueString) - 1].split(',')
>              Index = 0
>              try:
>                  for ByteString in ValueList:
> +                    ByteString = ByteString.strip()
>                      if ByteString.upper().startswith('0X'):
>                          ByteValue = int(ByteString, 16)
>                      else:
>                          ByteValue = int(ByteString)
>                      ByteList[ValueOffset + Index] = ByteValue % 0x100
> --
> 2.6.1.windows.1



      reply	other threads:[~2018-03-03  4:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-03  1:12 [Patch V2] BaseTools: DSC Components section support flexible PCD Yonghong Zhu
2018-03-03  4:34 ` 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=4A89E2EF3DFEDB4C8BFDE51014F606A14E1D6AFF@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