public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Fix VPD PCD Sub-section display bug
@ 2018-10-23 11:09 Yonghong Zhu
  2018-10-25  7:29 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-10-23 11:09 UTC (permalink / raw)
  To: edk2-devel

original we get the VPD PCD items from the VPDGuid.map file in the FV
output folder. but this logic doesn't work when 1) there only have
single non Default SKU, 2) there have multiple SKU with same value.
Now we change it to get the really VPD Pcd items that already display
in the PCD section of the report.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/build/BuildReport.py | 46 ++++++++++------------------
 1 file changed, 17 insertions(+), 29 deletions(-)

diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index de8f0fb..ea98ef7 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -124,10 +124,13 @@ gDriverTypeMap = {
   }
 
 ## The look up table of the supported opcode in the dependency expression binaries
 gOpCodeList = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "TRUE", "FALSE", "END", "SOR"]
 
+## Save VPD Pcd
+VPDPcdList = []
+
 ##
 # Writes a string to the file object.
 #
 # This function writes a string to the file object and a new line is appended
 # afterwards. It may optionally wraps the string for better readability.
@@ -1399,10 +1402,13 @@ class PcdReport(object):
                                 FileWrite(File, ' %-*s   : %6s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', Value))
                             else:
                                 FileWrite(File, ' %-*s   : %6s %10s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', Value))
                     if TypeName in ('DYNVPD', 'DEXVPD'):
                         FileWrite(File, '%*s' % (self.MaxLen + 4, SkuInfo.VpdOffset))
+                        VPDPcdItem = (Pcd.TokenSpaceGuidCName + '.' + PcdTokenCName, SkuIdName, SkuInfo.VpdOffset, Pcd.MaxDatumSize, SkuInfo.DefaultValue)
+                        if VPDPcdItem not in VPDPcdList:
+                            VPDPcdList.append(VPDPcdItem)
                     if IsStructure:
                         FiledOverrideFlag = False
                         OverrideValues = Pcd.SkuOverrideValues[Sku]
                         if OverrideValues:
                             Keys = OverrideValues.keys()
@@ -2015,39 +2021,18 @@ class FdReport(object):
         self.FdName = Fd.FdUiName
         self.BaseAddress = Fd.BaseAddress
         self.Size = Fd.Size
         self.FdRegionList = [FdRegionReport(FdRegion, Wa) for FdRegion in Fd.RegionList]
         self.FvPath = os.path.join(Wa.BuildDir, TAB_FV_DIRECTORY)
-        self.VpdFilePath = os.path.join(self.FvPath, "%s.map" % Wa.Platform.VpdToolGuid)
         self.VPDBaseAddress = 0
         self.VPDSize = 0
-        self.VPDInfoList = []
         for index, FdRegion in enumerate(Fd.RegionList):
             if str(FdRegion.RegionType) is 'FILE' and Wa.Platform.VpdToolGuid in str(FdRegion.RegionDataList):
                 self.VPDBaseAddress = self.FdRegionList[index].BaseAddress
                 self.VPDSize = self.FdRegionList[index].Size
                 break
 
-        if os.path.isfile(self.VpdFilePath):
-            fd = open(self.VpdFilePath, "r")
-            Lines = fd.readlines()
-            for Line in Lines:
-                Line = Line.strip()
-                if len(Line) == 0 or Line.startswith("#"):
-                    continue
-                try:
-                    PcdName, SkuId, Offset, Size, Value = Line.split("#")[0].split("|")
-                    PcdName, SkuId, Offset, Size, Value = PcdName.strip(), SkuId.strip(), Offset.strip(), Size.strip(), Value.strip()
-                    if Offset.lower().startswith('0x'):
-                        Offset = '0x%08X' % (int(Offset, 16) + self.VPDBaseAddress)
-                    else:
-                        Offset = '0x%08X' % (int(Offset, 10) + self.VPDBaseAddress)
-                    self.VPDInfoList.append("%s | %s | %s | %s | %s" % (PcdName, SkuId, Offset, Size, Value))
-                except:
-                    EdkLogger.error("BuildReport", CODE_ERROR, "Fail to parse VPD information file %s" % self.VpdFilePath)
-            fd.close()
-
     ##
     # Generate report for the firmware device.
     #
     # This function generates report for the firmware device.
     #
@@ -2063,27 +2048,30 @@ class FdReport(object):
         if len(self.FdRegionList) > 0:
             FileWrite(File, gSectionSep)
             for FdRegionItem in self.FdRegionList:
                 FdRegionItem.GenerateReport(File)
 
-        if len(self.VPDInfoList) > 0:
+        if VPDPcdList:
+            VPDPcdList.sort(key=lambda x: int(x[2], 0))
             FileWrite(File, gSubSectionStart)
             FileWrite(File, "FD VPD Region")
             FileWrite(File, "Base Address:       0x%X" % self.VPDBaseAddress)
             FileWrite(File, "Size:               0x%X (%.0fK)" % (self.VPDSize, self.VPDSize / 1024.0))
             FileWrite(File, gSubSectionSep)
-            for item in self.VPDInfoList:
-                ValueList = item.split('|')
-                Value = ValueList[-1].strip()
-                IsByteArray, ArrayList = ByteArrayForamt(Value)
+            for item in VPDPcdList:
+                # Add BaseAddress for offset
+                Offset = '0x%08X' % (int(item[2], 16) + self.VPDBaseAddress)
+                IsByteArray, ArrayList = ByteArrayForamt(item[-1])
+                Skuinfo = item[1]
+                if len(GlobalData.gSkuids) == 1 :
+                    Skuinfo = GlobalData.gSkuids[0]
                 if IsByteArray:
-                    ValueList[-1] = ' {'
-                    FileWrite(File, '|'.join(ValueList))
+                    FileWrite(File, "%s | %s | %s | %s | %s" % (item[0], Skuinfo, Offset, item[3], '{'))
                     for Array in ArrayList:
                         FileWrite(File, Array)
                 else:
-                    FileWrite(File, item)
+                    FileWrite(File, "%s | %s | %s | %s | %s" % (item[0], Skuinfo, Offset, item[3], item[-1]))
             FileWrite(File, gSubSectionEnd)
         FileWrite(File, gSectionEnd)
 
 
 
-- 
2.6.1.windows.1



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

* Re: [Patch] BaseTools: Fix VPD PCD Sub-section display bug
  2018-10-23 11:09 [Patch] BaseTools: Fix VPD PCD Sub-section display bug Yonghong Zhu
@ 2018-10-25  7:29 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-10-25  7:29 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org

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

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yonghong Zhu
> Sent: Tuesday, October 23, 2018 7:10 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [Patch] BaseTools: Fix VPD PCD Sub-section display bug
> 
> original we get the VPD PCD items from the VPDGuid.map file in the FV
> output folder. but this logic doesn't work when 1) there only have
> single non Default SKU, 2) there have multiple SKU with same value.
> Now we change it to get the really VPD Pcd items that already display
> in the PCD section of the report.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
>  BaseTools/Source/Python/build/BuildReport.py | 46 ++++++++++------------------
>  1 file changed, 17 insertions(+), 29 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
> index de8f0fb..ea98ef7 100644
> --- a/BaseTools/Source/Python/build/BuildReport.py
> +++ b/BaseTools/Source/Python/build/BuildReport.py
> @@ -124,10 +124,13 @@ gDriverTypeMap = {
>    }
> 
>  ## The look up table of the supported opcode in the dependency expression binaries
>  gOpCodeList = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "TRUE", "FALSE", "END", "SOR"]
> 
> +## Save VPD Pcd
> +VPDPcdList = []
> +
>  ##
>  # Writes a string to the file object.
>  #
>  # This function writes a string to the file object and a new line is appended
>  # afterwards. It may optionally wraps the string for better readability.
> @@ -1399,10 +1402,13 @@ class PcdReport(object):
>                                  FileWrite(File, ' %-*s   : %6s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType +
> ')', Value))
>                              else:
>                                  FileWrite(File, ' %-*s   : %6s %10s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' +
> Pcd.DatumType + ')', '(' + SkuIdName + ')', Value))
>                      if TypeName in ('DYNVPD', 'DEXVPD'):
>                          FileWrite(File, '%*s' % (self.MaxLen + 4, SkuInfo.VpdOffset))
> +                        VPDPcdItem = (Pcd.TokenSpaceGuidCName + '.' + PcdTokenCName, SkuIdName, SkuInfo.VpdOffset,
> Pcd.MaxDatumSize, SkuInfo.DefaultValue)
> +                        if VPDPcdItem not in VPDPcdList:
> +                            VPDPcdList.append(VPDPcdItem)
>                      if IsStructure:
>                          FiledOverrideFlag = False
>                          OverrideValues = Pcd.SkuOverrideValues[Sku]
>                          if OverrideValues:
>                              Keys = OverrideValues.keys()
> @@ -2015,39 +2021,18 @@ class FdReport(object):
>          self.FdName = Fd.FdUiName
>          self.BaseAddress = Fd.BaseAddress
>          self.Size = Fd.Size
>          self.FdRegionList = [FdRegionReport(FdRegion, Wa) for FdRegion in Fd.RegionList]
>          self.FvPath = os.path.join(Wa.BuildDir, TAB_FV_DIRECTORY)
> -        self.VpdFilePath = os.path.join(self.FvPath, "%s.map" % Wa.Platform.VpdToolGuid)
>          self.VPDBaseAddress = 0
>          self.VPDSize = 0
> -        self.VPDInfoList = []
>          for index, FdRegion in enumerate(Fd.RegionList):
>              if str(FdRegion.RegionType) is 'FILE' and Wa.Platform.VpdToolGuid in str(FdRegion.RegionDataList):
>                  self.VPDBaseAddress = self.FdRegionList[index].BaseAddress
>                  self.VPDSize = self.FdRegionList[index].Size
>                  break
> 
> -        if os.path.isfile(self.VpdFilePath):
> -            fd = open(self.VpdFilePath, "r")
> -            Lines = fd.readlines()
> -            for Line in Lines:
> -                Line = Line.strip()
> -                if len(Line) == 0 or Line.startswith("#"):
> -                    continue
> -                try:
> -                    PcdName, SkuId, Offset, Size, Value = Line.split("#")[0].split("|")
> -                    PcdName, SkuId, Offset, Size, Value = PcdName.strip(), SkuId.strip(), Offset.strip(), Size.strip(), Value.strip()
> -                    if Offset.lower().startswith('0x'):
> -                        Offset = '0x%08X' % (int(Offset, 16) + self.VPDBaseAddress)
> -                    else:
> -                        Offset = '0x%08X' % (int(Offset, 10) + self.VPDBaseAddress)
> -                    self.VPDInfoList.append("%s | %s | %s | %s | %s" % (PcdName, SkuId, Offset, Size, Value))
> -                except:
> -                    EdkLogger.error("BuildReport", CODE_ERROR, "Fail to parse VPD information file %s" % self.VpdFilePath)
> -            fd.close()
> -
>      ##
>      # Generate report for the firmware device.
>      #
>      # This function generates report for the firmware device.
>      #
> @@ -2063,27 +2048,30 @@ class FdReport(object):
>          if len(self.FdRegionList) > 0:
>              FileWrite(File, gSectionSep)
>              for FdRegionItem in self.FdRegionList:
>                  FdRegionItem.GenerateReport(File)
> 
> -        if len(self.VPDInfoList) > 0:
> +        if VPDPcdList:
> +            VPDPcdList.sort(key=lambda x: int(x[2], 0))
>              FileWrite(File, gSubSectionStart)
>              FileWrite(File, "FD VPD Region")
>              FileWrite(File, "Base Address:       0x%X" % self.VPDBaseAddress)
>              FileWrite(File, "Size:               0x%X (%.0fK)" % (self.VPDSize, self.VPDSize / 1024.0))
>              FileWrite(File, gSubSectionSep)
> -            for item in self.VPDInfoList:
> -                ValueList = item.split('|')
> -                Value = ValueList[-1].strip()
> -                IsByteArray, ArrayList = ByteArrayForamt(Value)
> +            for item in VPDPcdList:
> +                # Add BaseAddress for offset
> +                Offset = '0x%08X' % (int(item[2], 16) + self.VPDBaseAddress)
> +                IsByteArray, ArrayList = ByteArrayForamt(item[-1])
> +                Skuinfo = item[1]
> +                if len(GlobalData.gSkuids) == 1 :
> +                    Skuinfo = GlobalData.gSkuids[0]
>                  if IsByteArray:
> -                    ValueList[-1] = ' {'
> -                    FileWrite(File, '|'.join(ValueList))
> +                    FileWrite(File, "%s | %s | %s | %s | %s" % (item[0], Skuinfo, Offset, item[3], '{'))
>                      for Array in ArrayList:
>                          FileWrite(File, Array)
>                  else:
> -                    FileWrite(File, item)
> +                    FileWrite(File, "%s | %s | %s | %s | %s" % (item[0], Skuinfo, Offset, item[3], item[-1]))
>              FileWrite(File, gSubSectionEnd)
>          FileWrite(File, gSectionEnd)
> 
> 
> 
> --
> 2.6.1.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


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

end of thread, other threads:[~2018-10-25  7:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-23 11:09 [Patch] BaseTools: Fix VPD PCD Sub-section display bug Yonghong Zhu
2018-10-25  7:29 ` Gao, Liming

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