[edk2] [patch] BaseTools: Add missing license and copyright info

2019-03-15 Thread Dandan Bi
Cc: Bob Feng 
Cc: Liming Gao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Conf/Empty_Package_Information_Data_File.ini | 12 
 1 file changed, 12 insertions(+)

diff --git a/BaseTools/Conf/Empty_Package_Information_Data_File.ini 
b/BaseTools/Conf/Empty_Package_Information_Data_File.ini
index fe162568c4..230d858ef9 100644
--- a/BaseTools/Conf/Empty_Package_Information_Data_File.ini
+++ b/BaseTools/Conf/Empty_Package_Information_Data_File.ini
@@ -1,5 +1,17 @@
+;@file
+; Example ini file used for UPT.
+;
+; Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.
+; This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD 
License
+; which accompanies this distribution.  The full text of the license may be 
found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
 [DistributionHeader]
 Name = 
 GUID = 
 Version = 
 Vendor = 
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch v2 0/2] Remove duplicated BSD license

2019-03-11 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1612

V2: Keep Microsoft copyright in patch 0001, which is deleted
by mistake in V1.

Cc: Michael D Kinney 
Cc: Liming Gao 
Dandan Bi (2):
  SecurityPkg: Remove duplicated BSD license
  Vlv2TbltDevicePkg: Remove duplicated BSD license

 .../Ppi/FirmwareVolumeInfoPrehashedFV.h   | 28 ++-
 .../Library/I2CLib/I2CLibNull.inf | 10 +--
 2 files changed, 3 insertions(+), 35 deletions(-)

-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch v2 2/2] Vlv2TbltDevicePkg: Remove duplicated BSD license

2019-03-11 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1612

V2 is the same with V1.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
Reviewed-by: Zailiang Sun 
---
 Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf 
b/Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf
index 6e1496bcf5..32959d9bd5 100644
--- a/Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf
+++ b/Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf
@@ -1,23 +1,15 @@
 ## @file
 # Null instance of Debug Agent Library with empty functions.
 #
 #  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
-#  


-# This program and the accompanying materials are licensed and made available 
under

-# the terms and conditions of the BSD License that accompanies this 
distribution.  

-# The full text of the license may be found at 


-# http://opensource.org/licenses/bsd-license.php.  


-#  


-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,


-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.

-#  


 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution. The full text of the license may be 
found at
 #  http://opensource.org/licenses/bsd-license.php
+#
 #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
 #
 #
 
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch v2 1/2] SecurityPkg: Remove duplicated BSD license

2019-03-11 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1612

V2: Keep Microsoft copyright, which is deleted by mistake in V1.

Cc: Chao Zhang 
Cc: Jian Wang 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Ppi/FirmwareVolumeInfoPrehashedFV.h   | 28 ++-
 1 file changed, 2 insertions(+), 26 deletions(-)

diff --git a/SecurityPkg/Include/Ppi/FirmwareVolumeInfoPrehashedFV.h 
b/SecurityPkg/Include/Ppi/FirmwareVolumeInfoPrehashedFV.h
index 23a56715ca..5fe3579eed 100644
--- a/SecurityPkg/Include/Ppi/FirmwareVolumeInfoPrehashedFV.h
+++ b/SecurityPkg/Include/Ppi/FirmwareVolumeInfoPrehashedFV.h
@@ -1,43 +1,19 @@
 /** @file
 PPI to describe all hash digests for a given FV
 
+Copyright (c) 2017, Microsoft Corporation
 Copyright (c) 2017, Intel Corporation. All rights reserved.
+
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
-**/
-/**
-PPI to describe all hash digests for a given FV
-
-Copyright (c) 2017, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 **/
 
 #ifndef __PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_H__
 #define __PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_H__
 
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/2] Vlv2TbltDevicePkg: Remove duplicated BSD license

2019-03-11 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1612

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf 
b/Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf
index 6e1496bcf5..32959d9bd5 100644
--- a/Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf
+++ b/Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf
@@ -1,23 +1,15 @@
 ## @file
 # Null instance of Debug Agent Library with empty functions.
 #
 #  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
-#  


-# This program and the accompanying materials are licensed and made available 
under

-# the terms and conditions of the BSD License that accompanies this 
distribution.  

-# The full text of the license may be found at 


-# http://opensource.org/licenses/bsd-license.php.  


-#  


-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,


-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.

-#  


 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution. The full text of the license may be 
found at
 #  http://opensource.org/licenses/bsd-license.php
+#
 #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
 #
 #
 
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/2] SecurityPkg: Remove duplicated BSD license

2019-03-11 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1612

Cc: Chao Zhang 
Cc: Jian Wang 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Ppi/FirmwareVolumeInfoPrehashedFV.h   | 26 ---
 1 file changed, 26 deletions(-)

diff --git a/SecurityPkg/Include/Ppi/FirmwareVolumeInfoPrehashedFV.h 
b/SecurityPkg/Include/Ppi/FirmwareVolumeInfoPrehashedFV.h
index 23a56715ca..9a02c429ac 100644
--- a/SecurityPkg/Include/Ppi/FirmwareVolumeInfoPrehashedFV.h
+++ b/SecurityPkg/Include/Ppi/FirmwareVolumeInfoPrehashedFV.h
@@ -8,36 +8,10 @@ which accompanies this distribution.  The full text of the 
license may be found
 http://opensource.org/licenses/bsd-license.php
 
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
-**/
-/**
-PPI to describe all hash digests for a given FV
-
-Copyright (c) 2017, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 **/
 
 #ifndef __PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_H__
 #define __PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_H__
 
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 0/2] Remove duplicated BSD license

2019-03-11 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1612

Cc: Michael D Kinney 
Cc: Liming Gao 
Dandan Bi (2):
  SecurityPkg: Remove the duplicated BSD license
  Vlv2TbltDevicePkg: Remove the duplicated BSD license

 .../Ppi/FirmwareVolumeInfoPrehashedFV.h   | 26 ---
 .../Library/I2CLib/I2CLibNull.inf | 10 +--
 2 files changed, 1 insertion(+), 35 deletions(-)

-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch V4] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible

2019-02-18 Thread Dandan Bi
From: Max Knutsen 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1114

V2: simplify the code logic.
update
if (!mHaveExitedBootServices &&
  (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer)) {
  gBS->FreePool (StatusCodeData);
}
to
if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
  gBS->FreePool (StatusCodeData);
}

V3:
And the code below into the else condition (stack buffer is not enough)
in /DxeReportStatusCodeLib/ReportStatusCodeLib.c

  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
return EFI_UNSUPPORTED;
  }

V4:
Refine code logic.

When report status code with ExtendedData data,
and the extended data can fit in the local static buffer,
there is no need to use AllocatePool to hold the ExtendedData data.

This patch is just to do the enhancement to avoid using AllocatePool.

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Michael Turner 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../ReportStatusCodeLib.c | 45 +--
 .../ReportStatusCodeLib.c | 14 +++---
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
index b28dc5c3bb..d3cf8b1de3 100644
--- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -494,41 +494,38 @@ ReportStatusCodeEx (
   UINT64Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1];
 
   ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
   ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
 
-  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
-return EFI_UNSUPPORTED;
-  }
-
-  //
-  // Retrieve the current TPL
-  //
-  Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
-  gBS->RestoreTPL (Tpl);
+  if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
+//
+// Use Buffer instead of allocating if possible.
+//
+StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;
+  } else {
+if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
+  return EFI_UNSUPPORTED;
+}
 
-  StatusCodeData = NULL;
-  if (Tpl <= TPL_NOTIFY) {
 //
-// Allocate space for the Status Code Header and its buffer
+// Retrieve the current TPL
 //
-gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **));
-  }
+Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
+gBS->RestoreTPL (Tpl);
+
+if (Tpl > TPL_NOTIFY) {
+  return EFI_OUT_OF_RESOURCES;
+}
 
-  if (StatusCodeData == NULL) {
 //
-// If a buffer could not be allocated, then see if the local variable 
Buffer can be used
+// Allocate space for the Status Code Header and its buffer
 //
-if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
-  //
-  // The local variable Buffer not large enough to hold the extended data 
associated
-  // with the status code being reported.
-  //
-  DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be 
reported!\n"));
+StatusCodeData = NULL;
+gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **));
+if (StatusCodeData == NULL) {
   return EFI_OUT_OF_RESOURCES;
 }
-StatusCodeData = (EFI_STATUS_CODE_DATA  *)Buffer;
   }
 
   //
   // Fill in the extended data header
   //
@@ -626,6 +623,6 @@ EFIAPI
 ReportDebugCodeEnabled (
   VOID
   )
 {
   return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & 
REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
-}
+}
\ No newline at end of file
diff --git 
a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
index b73103517a..9b79854538 100644
--- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -630,16 +630,20 @@ ReportStatusCodeEx (
   UINT64StatusCodeBuffer[(MAX_EXTENDED_DATA_SIZE / sizeof 
(UINT64)) + 1];
 
   ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
   ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
 
-  if (mHaveExitedBootServices) {
-if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
+  if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
+//
+// Use Buffer instead of allocating if possible.
+//
+StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
+  } else {
+if 

[edk2] [patch edk2-wiki] Update ECC wiki page

2019-02-17 Thread Dandan Bi
Update ECC wiki page to record how to solve the
problem “ModuleNotFoundError: No module named 'antlr4'”
when run ECC tool with python3.x.

Cc: Liming Gao 
Cc: Bob Feng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ECC-tool.md | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/ECC-tool.md b/ECC-tool.md
index eaf4137..03dbb30 100644
--- a/ECC-tool.md
+++ b/ECC-tool.md
@@ -12,18 +12,27 @@ Steps to run ECC tool:
 **1). Enter edk2 directory, run: **edksetup.bat (**on Windows**)
   **Enter edk2 directory, run: **source edksetup.sh (**on Linux**)
 
 **2). Then in edk2 directory, you can type "Ecc" to run ECC tool 
directly**.
 
-**3). If you meet following error:**
+**3). If you meet following errors:**
+**Error 1:**
 **import antlr3**
 **ImportError: No module named antlr3**
 
-Since ECC depends on antlr V3.0.1, you can download it from 
http://www.antlr3.org/download/Python/ 
+This error may be met when you run ECC tool with python 2.x, then ECC depends 
on antlr V3.0.1, you can download it from 
http://www.antlr3.org/download/Python/ 
 After download and extract it, you can enter the antlr tool directory and run: 

 **C:\Python27\python.exe setup.py install** to install it.(**on Windows**) 
-**python setup.py install**" to install it, root access may be required.(**on 
Linux**) 
+**python setup.py install** to install it, root access may be required.(**on 
Linux**) 
+
+**Error 2:**
+**import antlr4 as antlr** 
+**ModuleNotFoundError: No module named 'antlr4'** 
+
+This error may be met when you run ECC tool with python 3.x, then ECC depends 
on antlr4, you can install it through following command.
+**py -3 -m pip install antlr4-python3-runtime** to install it.(**on Windows**) 

+**sudo python3 -m pip install antlr4-python3-runtime** to install it. (**on 
Linux**) 
 
 **4). You can type "Ecc -h/Ecc --help" to get the help info of ECC tool**.
 
 **5). Common usage model:**
 **Ecc -c config file  -e exception file  -t  the target directory which need 
to be scanned by ECC -r the ECC scan result csv file**
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch V3] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible

2019-02-17 Thread Dandan Bi
From: Max Knutsen 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1114

V2: simplify the code logic.
update
if (!mHaveExitedBootServices &&
  (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer)) {
  gBS->FreePool (StatusCodeData);
}
to
if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
  gBS->FreePool (StatusCodeData);
}

V3:
And the code below into the else condition (stack buffer is not enough)
in /DxeReportStatusCodeLib/ReportStatusCodeLib.c

  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
return EFI_UNSUPPORTED;
  }

When report status code with ExtendedData data,
and the extended data can fit in the local static buffer,
there is no need to use AllocatePool to hold the ExtendedData data.

This patch is just to do the enhancement to avoid using AllocatePool.

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Michael Turner 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeReportStatusCodeLib/ReportStatusCodeLib.c  | 15 +--
 .../ReportStatusCodeLib.c |  9 +++--
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
index b28dc5c3bb..3bca0a94ee 100644
--- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -494,24 +494,27 @@ ReportStatusCodeEx (
   UINT64Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1];
 
   ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
   ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
 
-  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
-return EFI_UNSUPPORTED;
-  }
-
   //
   // Retrieve the current TPL
   //
   Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
   gBS->RestoreTPL (Tpl);
 
   StatusCodeData = NULL;
-  if (Tpl <= TPL_NOTIFY) {
+  if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
+//
+// Use Buffer instead of allocating if possible.
+//
+StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;
+  } else if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == 
NULL) {
+return EFI_UNSUPPORTED;
+  } else if (Tpl <= TPL_NOTIFY){
 //
-// Allocate space for the Status Code Header and its buffer
+// If Buffer is not big enough, allocate space for the Status Code Header 
and its buffer
 //
 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **));
   }
 
   if (StatusCodeData == NULL) {
diff --git 
a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
index b73103517a..75e2f88ad2 100644
--- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -635,11 +635,14 @@ ReportStatusCodeEx (
   if (mHaveExitedBootServices) {
 if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
   return EFI_OUT_OF_RESOURCES;
 }
 StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
-  } else  {
+  } else if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
+//
+// Only use AllocatePool for larger ExtendedData.
+//
 if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
   return EFI_UNSUPPORTED;
 }
 
 //
@@ -648,10 +651,12 @@ ReportStatusCodeEx (
 StatusCodeData = NULL;
 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **));
 if (StatusCodeData == NULL) {
   return EFI_OUT_OF_RESOURCES;
 }
+  } else {
+StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
   }
 
   //
   // Fill in the extended data header
   //
@@ -678,11 +683,11 @@ ReportStatusCodeEx (
   Status = InternalReportStatusCode (Type, Value, Instance, CallerId, 
StatusCodeData);
 
   //
   // Free the allocated buffer
   //
-  if (!mHaveExitedBootServices) {
+  if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
 gBS->FreePool (StatusCodeData);
   }
 
   return Status;
 }
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 0/2] Report error status when fail to load/start boot option

2019-02-15 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1398

According to PI1.7, this patch series is to add the support that
report extended data describing an EFI_STATUS return value along
with  EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR and
EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED status code when fail to load
or start boot option image.

These two commit are also available at:
https://github.com/dandanbi/edk2/commits/ExtendedStatusCodeV1

PI1.7 is at
https://uefi.org/sites/default/files/resources/PI_Spec_1_7_final_Jan_2019.pdf

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Laszlo Ersek 
Cc: Sean Brogan 
Dandan Bi (2):
  MdePkg/StatusCodeDataTypeId.h: Add new definition per PI1.7 Spec
  MdeModulePkg/BmBoot: Report status when fail to load/start boot option

 .../Library/UefiBootManagerLib/BmBoot.c   | 22 ++-
 MdePkg/Include/Guid/StatusCodeDataTypeId.h| 22 ++-
 2 files changed, 37 insertions(+), 7 deletions(-)

-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/2] MdePkg/StatusCodeDataTypeId.h: Add new definition per PI1.7 Spec

2019-02-15 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1398

According to PI1.7 Spec, add the new definition
EFI_RETURN_STATUS_EXTENDED_DATA in StatusCodeDataTypeId.h

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Include/Guid/StatusCodeDataTypeId.h | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Guid/StatusCodeDataTypeId.h 
b/MdePkg/Include/Guid/StatusCodeDataTypeId.h
index 22cf8e5aae..b01999581b 100644
--- a/MdePkg/Include/Guid/StatusCodeDataTypeId.h
+++ b/MdePkg/Include/Guid/StatusCodeDataTypeId.h
@@ -1,9 +1,9 @@
 /** @file
   GUID used to identify id for the caller who is initiating the Status Code.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php
 
@@ -116,10 +116,11 @@ extern EFI_GUID gEfiStatusCodeDataTypeStringGuid;
 ///   - EFI_MEMORY_RANGE_EXTENDED_DATA
 ///   - EFI_DEBUG_ASSERT_DATA
 ///   - EFI_STATUS_CODE_EXCEP_EXTENDED_DATA
 ///   - EFI_STATUS_CODE_START_EXTENDED_DATA
 ///   - EFI_LEGACY_OPROM_EXTENDED_DATA
+///   - EFI_RETURN_STATUS_EXTENDED_DATA
 ///
 #define EFI_STATUS_CODE_SPECIFIC_DATA_GUID \
   { 0x335984bd, 0xe805, 0x409a, { 0xb8, 0xf8, 0xd2, 0x7e, 0xce, 0x5f, 0xf7, 
0xa6 } }
 
 ///
@@ -782,8 +783,27 @@ typedef struct {
   /// The base address of the shadowed legacy ROM image.  May or may not point 
to the shadow RAM area.
   ///
   EFI_PHYSICAL_ADDRESS  RomImageBase;
 } EFI_LEGACY_OPROM_EXTENDED_DATA;
 
+///
+/// This structure defines extended data describing an EFI_STATUS return value 
that stands for a
+/// failed function call (such as a UEFI boot service).
+///
+typedef struct {
+  ///
+  /// The data header identifying the data:
+  /// DataHeader.HeaderSize should be sizeof(EFI_STATUS_CODE_DATA),
+  /// DataHeader.Size should be sizeof(EFI_RETURN_STATUS_EXTENDED_DATA) - 
HeaderSize,
+  /// DataHeader.Type should be EFI_STATUS_CODE_SPECIFIC_DATA_GUID.
+  ///
+  EFI_STATUS_CODE_DATA DataHeader;
+  ///
+  /// The EFI_STATUS return value of the service or function whose failure 
triggered the
+  /// reporting of the status code (generally an error code or a debug code).
+  ///
+  EFI_STATUS   ReturnStatus;
+} EFI_RETURN_STATUS_EXTENDED_DATA;
+
 extern EFI_GUID gEfiStatusCodeSpecificDataGuid;
 
 #endif
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/2] MdeModulePkg/BmBoot: Report status when fail to load/start boot option

2019-02-15 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1398

According to PI1.7 Spec, report extended data describing an 
EFI_STATUS return value along with 
EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR and
EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED status code
when fail to load or start boot option image.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Ruiyu Ni 
Cc: Laszlo Ersek 
Cc: Sean Brogan 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Library/UefiBootManagerLib/BmBoot.c   | 22 ++-
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 6444fb43eb..9be1633b74 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1818,15 +1818,20 @@ EfiBootManagerBoot (
   FreePool (FilePath);
 }
 
 if (EFI_ERROR (Status)) {
   //
-  // Report Status Code to indicate that the failure to load boot option
+  // Report Status Code with the failure status to indicate that the 
failure to load boot option
   //
-  REPORT_STATUS_CODE (
+  REPORT_STATUS_CODE_EX (
 EFI_ERROR_CODE | EFI_ERROR_MINOR,
-(EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR)
+(EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR),
+0,
+NULL,
+NULL,
+,
+sizeof (EFI_STATUS)
 );
   BootOption->Status = Status;
   //
   // Destroy the RAM disk
   //
@@ -1902,15 +1907,20 @@ EfiBootManagerBoot (
   Status = gBS->StartImage (ImageHandle, >ExitDataSize, 
>ExitData);
   DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Image Return Status = %r\n", Status));
   BootOption->Status = Status;
   if (EFI_ERROR (Status)) {
 //
-// Report Status Code to indicate that boot failure
+// Report Status Code with the failure status to indicate that boot failure
 //
-REPORT_STATUS_CODE (
+REPORT_STATUS_CODE_EX (
   EFI_ERROR_CODE | EFI_ERROR_MINOR,
-  (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED)
+  (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED),
+  0,
+  NULL,
+  NULL,
+  ,
+  sizeof (EFI_STATUS)
   );
   }
   PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber);
 
   //
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch V2] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible

2019-02-13 Thread Dandan Bi
From: Max Knutsen 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1114

V2:  simplify the code logic.
update
if (!mHaveExitedBootServices &&
  (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer)) {
  gBS->FreePool (StatusCodeData);
}
to
if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
  gBS->FreePool (StatusCodeData);
}

When report status code with ExtendedData data,
and the extended data can fit in the local static buffer,
there is no need to use AllocatePool to hold the ExtendedData data.

This patch is just to do the enhancement to avoid using AllocatePool.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Michael Turner 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c | 9 +++--
 .../RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c  | 9 +++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
index b28dc5c3bb..c88be5a1a3 100644
--- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -505,13 +505,18 @@ ReportStatusCodeEx (
   //
   Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
   gBS->RestoreTPL (Tpl);
 
   StatusCodeData = NULL;
-  if (Tpl <= TPL_NOTIFY) {
+  if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
 //
-// Allocate space for the Status Code Header and its buffer
+// Use Buffer instead of allocating if possible.
+//
+StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;
+  } else if (Tpl <= TPL_NOTIFY){
+//
+// If Buffer is not big enough, allocate space for the Status Code Header 
and its buffer
 //
 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **));
   }
 
   if (StatusCodeData == NULL) {
diff --git 
a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
index b73103517a..75e2f88ad2 100644
--- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -635,11 +635,14 @@ ReportStatusCodeEx (
   if (mHaveExitedBootServices) {
 if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
   return EFI_OUT_OF_RESOURCES;
 }
 StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
-  } else  {
+  } else if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
+//
+// Only use AllocatePool for larger ExtendedData.
+//
 if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
   return EFI_UNSUPPORTED;
 }
 
 //
@@ -648,10 +651,12 @@ ReportStatusCodeEx (
 StatusCodeData = NULL;
 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **));
 if (StatusCodeData == NULL) {
   return EFI_OUT_OF_RESOURCES;
 }
+  } else {
+StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
   }
 
   //
   // Fill in the extended data header
   //
@@ -678,11 +683,11 @@ ReportStatusCodeEx (
   Status = InternalReportStatusCode (Type, Value, Instance, CallerId, 
StatusCodeData);
 
   //
   // Free the allocated buffer
   //
-  if (!mHaveExitedBootServices) {
+  if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
 gBS->FreePool (StatusCodeData);
   }
 
   return Status;
 }
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible

2019-02-02 Thread Dandan Bi
From: Max Knutsen 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1114

When report status code with ExtendedData data,
and the extended data can fit in the local static buffer,
there is no need to use AllocatePool to hold the ExtendedData data.

This patch is just to do the enhancement to avoid using AllocatePool.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Michael Turner 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c | 9 +++--
 .../RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c  | 9 +++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
index b28dc5c3bb..c88be5a1a3 100644
--- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -505,13 +505,18 @@ ReportStatusCodeEx (
   //
   Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
   gBS->RestoreTPL (Tpl);
 
   StatusCodeData = NULL;
-  if (Tpl <= TPL_NOTIFY) {
+  if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
 //
-// Allocate space for the Status Code Header and its buffer
+// Use Buffer instead of allocating if possible.
+//
+StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;
+  } else if (Tpl <= TPL_NOTIFY){
+//
+// If Buffer is not big enough, allocate space for the Status Code Header 
and its buffer
 //
 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **));
   }
 
   if (StatusCodeData == NULL) {
diff --git 
a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
index b73103517a..3380469759 100644
--- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -635,11 +635,14 @@ ReportStatusCodeEx (
   if (mHaveExitedBootServices) {
 if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
   return EFI_OUT_OF_RESOURCES;
 }
 StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
-  } else  {
+  } else if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
+//
+// Only use AllocatePool for larger ExtendedData.
+//
 if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
   return EFI_UNSUPPORTED;
 }
 
 //
@@ -648,10 +651,12 @@ ReportStatusCodeEx (
 StatusCodeData = NULL;
 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **));
 if (StatusCodeData == NULL) {
   return EFI_OUT_OF_RESOURCES;
 }
+  } else {
+StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
   }
 
   //
   // Fill in the extended data header
   //
@@ -678,11 +683,11 @@ ReportStatusCodeEx (
   Status = InternalReportStatusCode (Type, Value, Instance, CallerId, 
StatusCodeData);
 
   //
   // Free the allocated buffer
   //
-  if (!mHaveExitedBootServices) {
+  if (!mHaveExitedBootServices && (StatusCodeData != (EFI_STATUS_CODE_DATA *) 
StatusCodeBuffer)) {
 gBS->FreePool (StatusCodeData);
   }
 
   return Status;
 }
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/2] MdePkg: Fix coding style issues

2019-01-31 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1478

Fix issues that reported by Edk2 coding style check tool(ECC) that:
in Comment, <@param SystemTable> does NOT consistent with parameter
name MmSystemTable.

Cc: Ard Biesheuvel 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Library/StandaloneMmDriverEntryPoint.h   | 16 
 .../StandaloneMmDriverEntryPoint.c   |  4 ++--
 .../StandaloneMmServicesTableLib.c   |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h 
b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
index d618998622..fbc75add73 100644
--- a/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
+++ b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
@@ -34,12 +34,12 @@ extern CONST UINT32   _gMmRevision;
   is an error status, then ProcessLibraryDestructorList() must be called.
   The return value from ProcessModuleEntryPointList() is returned.
   If _gMmRevision is not zero and MmSystemTable->Hdr.Revision is
   less than _gMmRevision, then return EFI_INCOMPATIBLE_VERSION.
 
-  @param  ImageHandle  The image handle of the Standalone MM Driver.
-  @param  SystemTable  A pointer to the EFI System Table.
+  @param  ImageHandleThe image handle of the Standalone MM Driver.
+  @param  MmSystemTable  A pointer to the MM System Table.
 
   @retval  EFI_SUCCESS   The Standalone MM Driver exited normally.
   @retval  EFI_INCOMPATIBLE_VERSION  _gMmRevision is greater than
  MmSystemTable->Hdr.Revision.
   @retval  Other Return value from
@@ -66,12 +66,12 @@ _ModuleEntryPoint (
   tools and those build tools are responsible for collecting the set of library
   instances, determine which ones have constructors, and calling the library
   constructors in the proper order based upon each of the library instances own
   dependencies.
 
-  @param  ImageHandle  The image handle of the Standalone MM Driver.
-  @param  SystemTable  A pointer to the MM System Table.
+  @param  ImageHandleThe image handle of the Standalone MM Driver.
+  @param  MmSystemTable  A pointer to the MM System Table.
 
 **/
 VOID
 EFIAPI
 ProcessLibraryConstructorList (
@@ -92,12 +92,12 @@ ProcessLibraryConstructorList (
   This function is auto generated by build tools and those build tools are
   responsible for collecting the set of library instances, determine which ones
   have destructors, and calling the library destructors in the proper order
   based upon each of the library instances own dependencies.
 
-  @param  ImageHandle  The image handle of the Standalone MM Driver.
-  @param  SystemTable  A pointer to the MM System Table.
+  @param  ImageHandleThe image handle of the Standalone MM Driver.
+  @param  MmSystemTable  A pointer to the MM System Table.
 
 **/
 VOID
 EFIAPI
 ProcessLibraryDestructorList (
@@ -113,12 +113,12 @@ ProcessLibraryDestructorList (
   This function calls the set of module entry points.
   This function is auto generated by build tools and those build tools are
   responsible for collecting the module entry points and calling them in a
   specified order.
 
-  @param  ImageHandle  The image handle of the Standalone MM Driver.
-  @param  SystemTable  A pointer to the EFI System Table.
+  @param  ImageHandleThe image handle of the Standalone MM Driver.
+  @param  MmSystemTable  A pointer to the MM System Table.
 
   @retval  EFI_SUCCESS   The Standalone MM Driver executed normally.
   @retval  !EFI_SUCCESS  The Standalone MM Driver failed to execute normally.
 **/
 EFI_STATUS
diff --git 
a/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c 
b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c
index 4fb494d8cb..b665233142 100644
--- a/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c
+++ b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c
@@ -32,12 +32,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
   is an error status, then ProcessLibraryDestructorList() must be called.
   The return value from ProcessModuleEntryPointList() is returned.
   If _gMmRevision is not zero and SystemTable->Hdr.Revision is
   less than _gMmRevision, then return EFI_INCOMPATIBLE_VERSION.
 
-  @param  ImageHandle  The image handle of the Standalone MM Driver.
-  @param  SystemTable  A pointer to the EFI System Table.
+  @param  ImageHandleThe image handle of the Standalone MM Driver.
+  @param  MmSystemTable  A pointer to the MM System Table.
 
   @retval  EFI_SUCCESS   The Standalone MM Driver exited normally.
   @retval  EFI_INCOMPATIBLE_VERSION  _gMmRevision is greater than
  MmSystemTable->Hdr.Revision.
   @retval  Other   

[edk2] [patch 1/2] MdeModulePkg: Fix coding style issues

2019-01-31 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1479

Fix issues that reported by Edk2 coding style check tool(ECC) that:
Comment description should end with period '.'

Cc: Ard Biesheuvel 
Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h | 4 ++--
 .../FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c  | 2 +-
 .../FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c | 2 +-
 .../Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h| 4 ++--
 .../Universal/Variable/RuntimeDxe/VariableStandaloneMm.c| 6 +++---
 .../Universal/Variable/RuntimeDxe/VariableTraditionalMm.c   | 4 ++--
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
index 61293ca864..cf1aef7ca4 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
@@ -76,11 +76,11 @@ typedef struct {
   BOOLEAN   Complete;
   UINT8 Data[1];
 } SMM_FTW_GET_LAST_WRITE_HEADER;
 
 /**
-  Shared entry point of the module
+  Shared entry point of the module.
 
   @retval EFI_SUCCESS   The initialization finished successfully.
   @retval EFI_OUT_OF_RESOURCES  Allocate memory error
   @retval EFI_INVALID_PARAMETER Workspace or Spare block does not exist
 
@@ -107,11 +107,11 @@ FtwSmmIsBufferOutsideSmmValid (
   IN EFI_PHYSICAL_ADDRESS  Buffer,
   IN UINT64Length
   );
 
 /**
-  Notify the system that the SMM FTW driver is ready
+  Notify the system that the SMM FTW driver is ready.
 **/
 VOID
 FtwNotifySmmReady (
   VOID
   );
diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
index 8a4ea5b476..c2aa501465 100644
--- 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
+++ 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
@@ -63,11 +63,11 @@ FtwCalculateCrc32 (
 {
   return CalculateCrc32 (Buffer, Length);
 }
 
 /**
-  Notify the system that the SMM FTW driver is ready
+  Notify the system that the SMM FTW driver is ready.
 **/
 VOID
 FtwNotifySmmReady (
   VOID
   )
diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
index 0981c3c2a9..7c76e1f756 100644
--- 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
+++ 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
@@ -70,11 +70,11 @@ FtwCalculateCrc32 (
 
   return ReturnValue;
 }
 
 /**
-  Notify the system that the SMM FTW driver is ready
+  Notify the system that the SMM FTW driver is ready.
 **/
 VOID
 FtwNotifySmmReady (
   VOID
   )
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
index 0a886558f4..9b294e6b36 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
@@ -96,19 +96,19 @@ VOID
 VariableSpeculationBarrier (
   VOID
   );
 
 /**
-  Notify the system that the SMM variable driver is ready
+  Notify the system that the SMM variable driver is ready.
 **/
 VOID
 VariableNotifySmmReady (
   VOID
   );
 
 /**
-  Notify the system that the SMM variable write driver is ready
+  Notify the system that the SMM variable write driver is ready.
 **/
 VOID
 VariableNotifySmmWriteReady (
   VOID
   );
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
index 1e87ccfb5d..2eed038054 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
@@ -36,31 +36,31 @@ VariableSmmIsBufferOutsideSmmValid (
 {
   return TRUE;
 }
 
 /**
-  Notify the system that the SMM variable driver is ready
+  Notify the system that the SMM variable driver is ready.
 **/
 VOID
 VariableNotifySmmReady (
   VOID
   )
 {
 }
 
 /**
-  Notify the system that the SMM variable write driver is ready
+  Notify the system that the SMM variable write driver is ready.
 **/
 VOID
 VariableNotifySmmWriteReady (
   VOID
   )
 {
 }
 
 /**
-  Variable service MM driver entry point
+  Variable service MM driver entry point.
 
   @param[in] ImageHandleA handle for the image that is initializing this
 driver
   @param[in] MmSystemTable  A pointer to the MM system table
 
diff --git a/MdeModulePkg

[edk2] [patch 0/2] Fix coding style issues in MdeModulePkg and MdePkg

2019-01-31 Thread Dandan Bi
Cc: Ard Biesheuvel 
Cc: Liming Gao 
Cc: Jian J Wang 
Cc: Hao Wu 
Dandan Bi (2):
  MdeModulePkg: Fix coding style issues
  MdePkg: Fix coding style issues

 .../FaultTolerantWriteSmmCommon.h|  4 ++--
 .../FaultTolerantWriteStandaloneMm.c |  2 +-
 .../FaultTolerantWriteTraditionalMm.c|  2 +-
 .../Variable/RuntimeDxe/PrivilegePolymorphic.h   |  4 ++--
 .../Variable/RuntimeDxe/VariableStandaloneMm.c   |  6 +++---
 .../Variable/RuntimeDxe/VariableTraditionalMm.c  |  4 ++--
 .../Library/StandaloneMmDriverEntryPoint.h   | 16 
 .../StandaloneMmDriverEntryPoint.c   |  4 ++--
 .../StandaloneMmServicesTableLib.c   |  4 ++--
 9 files changed, 23 insertions(+), 23 deletions(-)

-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] ShellPkg/UefiShellAcpiViewCommandLib: Fix VS tool chain build failure

2019-01-27 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1491

This patch is to update the data type of variable "Offset"
from UINT8 to UINT32 to fix following build issue.

...\Parsers\Pptt\PpttParser.c(193): error C2220:
warning treated as error - no 'object' file generated
...\Parsers\Pptt\PpttParser.c(193): warning C4244: '=':
conversion from 'UINT32' to 'UINT8', possible loss of data

Cc: Krzysztof Koch 
Cc: Jaben Carsey 
Cc: Ray Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
index d97ddf8e92..bc56fe9ea1 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
@@ -176,11 +176,11 @@ VOID
 DumpProcessorHierarchyNodeStructure (
   IN UINT8* Ptr,
   IN UINT8  Length
   )
 {
-  UINT8  Offset;
+  UINT32 Offset;
   UINT8* PrivateResourcePtr;
   UINT32 Index;
   CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
 
   Offset = ParseAcpi (
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd

2019-01-18 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1426

When calculating the address of RelocBaseEnd,
the RelocBase address is ImageBase + RelocDir->VirtualAddress,
the size of RelocDir is RelocDir->Size.
So the RelocBaseEnd address is:
ImageBase + RelocDir->VirtualAddress + RelocDir->Size - 1
not
ImageBase + RelocDir->VirtualAddress + RelocDir->Size

This patch is to fix this issue when call PeCoffLoaderImageAddress
function to calculate the address of RelocBaseEnd.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c 
b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index d9c94b89bd..1bd079ad6a 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -1741,11 +1741,11 @@ PeCoffLoaderRelocateImageForRuntime (
   //
   if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
 RelocDir  = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
 RelocBase = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
(, RelocDir->VirtualAddress, 0);
 RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
(,
-
RelocDir->VirtualAddress + RelocDir->Size,
+
RelocDir->VirtualAddress + RelocDir->Size - 1,
 0
 );
   } else {
 //
 // Cannot find relocations, cannot continue to relocate the image, ASSERT 
for this invalid image.
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch v2] MdePkg/BasePeCoffLib: Add more check for relocation data

2019-01-14 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1426

V2:
(1) Add NULL pointer check for the input parameters
(2) Add check for the "Adjust" value before applying fix ups.

In function PeCoffLoaderRelocateImageForRuntime, it doesn't
do much check when do relocation. For API level consideration,
it's not safe enough.
So this patch is to replace the same code logic with function
PeCoffLoaderImageAddress which will cover more validation.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 165 +-
 1 file changed, 95 insertions(+), 70 deletions(-)

diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c 
b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index c57816a808..d9c94b89bd 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -13,11 +13,11 @@
   This library will also do some additional check for PE header fields.
 
   PeCoffLoaderGetPeHeader() routine will do basic check for PE/COFF header.
   PeCoffLoaderGetImageInfo() routine will do basic check for whole PE/COFF 
image.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
   Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -1669,25 +1669,34 @@ PeCoffLoaderRelocateImageForRuntime (
   UINT32  NumberOfRvaAndSizes;
   EFI_IMAGE_DATA_DIRECTORY*DataDirectory;
   EFI_IMAGE_DATA_DIRECTORY*RelocDir;
   EFI_IMAGE_BASE_RELOCATION   *RelocBase;
   EFI_IMAGE_BASE_RELOCATION   *RelocBaseEnd;
+  EFI_IMAGE_BASE_RELOCATION   *RelocBaseOrig;
   UINT16  *Reloc;
   UINT16  *RelocEnd;
   CHAR8   *Fixup;
   CHAR8   *FixupBase;
   UINT16  *Fixup16;
   UINT32  *Fixup32;
   UINT64  *Fixup64;
   CHAR8   *FixupData;
   UINTN   Adjust;
   RETURN_STATUS   Status;
+  PE_COFF_LOADER_IMAGE_CONTEXTImageContext;
+
+  if (RelocationData == NULL || ImageBase == 0x0 || VirtImageBase == 0x0) {
+return;
+  }
 
   OldBase = (CHAR8 *)((UINTN)ImageBase);
   NewBase = (CHAR8 *)((UINTN)VirtImageBase);
   Adjust = (UINTN) NewBase - (UINTN) OldBase;
 
+  ImageContext.ImageAddress = ImageBase;
+  ImageContext.ImageSize = ImageSize;
+
   //
   // Find the image's relocate dir info
   //
   DosHdr = (EFI_IMAGE_DOS_HEADER *)OldBase;
   if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
@@ -1730,12 +1739,15 @@ PeCoffLoaderRelocateImageForRuntime (
   // is present in the image. You have to check the NumberOfRvaAndSizes in
   // the optional header to verify a desired directory entry is there.
   //
   if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
 RelocDir  = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
-RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + 
RelocDir->VirtualAddress);
-RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + 
RelocDir->VirtualAddress + RelocDir->Size);
+RelocBase = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
(, RelocDir->VirtualAddress, 0);
+RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
(,
+
RelocDir->VirtualAddress + RelocDir->Size,
+0
+);
   } else {
 //
 // Cannot find relocations, cannot continue to relocate the image, ASSERT 
for this invalid image.
 //
 ASSERT (FALSE);
@@ -1745,100 +1757,113 @@ PeCoffLoaderRelocateImageForRuntime (
   //
   // ASSERT for the invalid image when RelocBase and RelocBaseEnd are both 
NULL.
   //
   ASSERT (RelocBase != NULL && RelocBaseEnd != NULL);
 
-  //
-  // Run the whole relocation block. And re-fixup data that has not been
-  // modified. The FixupData is used to see if the image has been modified
-  // since it was relocated. This is so data sections that have been updated
-  // by code will not be fixed up, since that would set them back to
-  // defaults.
-  //
-  FixupData = RelocationData;
-  while (RelocBase < RelocBaseEnd) {
+  if (Adjust != 0) {
 //
-// Add check for RelocBase->SizeOfBlock field

[edk2] [patch] MdePkg/BasePeCoffLib: Add more check for relocation data

2019-01-04 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1426

In function PeCoffLoaderRelocateImageForRuntime, it doesn't
do much check when applies relocation fixups. For API level
consideration, it's not safe enough.
This patch is to replace the same code logic with calling
function PeCoffLoaderImageAddress which will cover more
check and validation.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 29 +++
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c 
b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index c57816a808..ae64705d7c 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -13,11 +13,11 @@
   This library will also do some additional check for PE header fields.
 
   PeCoffLoaderGetPeHeader() routine will do basic check for PE/COFF header.
   PeCoffLoaderGetImageInfo() routine will do basic check for whole PE/COFF 
image.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
   Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -1669,25 +1669,30 @@ PeCoffLoaderRelocateImageForRuntime (
   UINT32  NumberOfRvaAndSizes;
   EFI_IMAGE_DATA_DIRECTORY*DataDirectory;
   EFI_IMAGE_DATA_DIRECTORY*RelocDir;
   EFI_IMAGE_BASE_RELOCATION   *RelocBase;
   EFI_IMAGE_BASE_RELOCATION   *RelocBaseEnd;
+  EFI_IMAGE_BASE_RELOCATION   *RelocBaseOrig;
   UINT16  *Reloc;
   UINT16  *RelocEnd;
   CHAR8   *Fixup;
   CHAR8   *FixupBase;
   UINT16  *Fixup16;
   UINT32  *Fixup32;
   UINT64  *Fixup64;
   CHAR8   *FixupData;
   UINTN   Adjust;
   RETURN_STATUS   Status;
+  PE_COFF_LOADER_IMAGE_CONTEXTImageContext;
 
   OldBase = (CHAR8 *)((UINTN)ImageBase);
   NewBase = (CHAR8 *)((UINTN)VirtImageBase);
   Adjust = (UINTN) NewBase - (UINTN) OldBase;
 
+  ImageContext.ImageAddress = ImageBase;
+  ImageContext.ImageSize = ImageSize;
+
   //
   // Find the image's relocate dir info
   //
   DosHdr = (EFI_IMAGE_DOS_HEADER *)OldBase;
   if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
@@ -1730,12 +1735,15 @@ PeCoffLoaderRelocateImageForRuntime (
   // is present in the image. You have to check the NumberOfRvaAndSizes in
   // the optional header to verify a desired directory entry is there.
   //
   if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
 RelocDir  = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
-RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + 
RelocDir->VirtualAddress);
-RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + 
RelocDir->VirtualAddress + RelocDir->Size);
+RelocBase = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
(, RelocDir->VirtualAddress, 0);
+RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
(,
+
RelocDir->VirtualAddress + RelocDir->Size,
+0
+);
   } else {
 //
 // Cannot find relocations, cannot continue to relocate the image, ASSERT 
for this invalid image.
 //
 ASSERT (FALSE);
@@ -1753,10 +1761,11 @@ PeCoffLoaderRelocateImageForRuntime (
   // since it was relocated. This is so data sections that have been updated
   // by code will not be fixed up, since that would set them back to
   // defaults.
   //
   FixupData = RelocationData;
+  RelocBaseOrig = RelocBase;
   while (RelocBase < RelocBaseEnd) {
 //
 // Add check for RelocBase->SizeOfBlock field.
 //
 if ((RelocBase->SizeOfBlock == 0) || (RelocBase->SizeOfBlock > 
RelocDir->Size)) {
@@ -1766,18 +1775,28 @@ PeCoffLoaderRelocateImageForRuntime (
   return;
 }
 
 Reloc = (UINT16 *) ((UINT8 *) RelocBase + sizeof 
(EFI_IMAGE_BASE_RELOCATION));
 RelocEnd  = (UINT16 *) ((UINT8 *) RelocBase + RelocBase->SizeOfBlock);
-FixupBase = (CHAR8 *) ((UINTN)ImageBase) + RelocBase->VirtualAddress;
+if ((UINTN)RelocEnd > (UINTN)RelocBaseOrig + Reloc

[edk2] [patch] MdeModulePkg/NonDiscoverablePciDevice: Remove the redundant check

2019-01-01 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1422

if (Attributes) {
  if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) {
return EFI_UNSUPPORTED;
  }
}
In above code block,
"If ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0)" is TRUE,
the Attributes must be not 0. So we can remove the redundant
check "if (Attributes)".

Cc: Vladimir Olovyannikov 
Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
Reviewed-by: Star Zeng 
---
 .../NonDiscoverablePciDeviceIo.c  | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
index f0d3472ea5..2be8b36acc 100644
--- 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
+++ 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
@@ -1274,15 +1274,13 @@ PciIoAttributes (
   #define DEV_SUPPORTED_ATTRIBUTES \
 (EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE)
 
   Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
 
-  if (Attributes) {
-  if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) {
-return EFI_UNSUPPORTED;
-  }
-}
+  if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) {
+return EFI_UNSUPPORTED;
+  }
 
   Enable = FALSE;
   switch (Operation) {
   case EfiPciIoAttributeOperationGet:
 if (Result == NULL) {
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/NonDiscoverable: Use compare operator for comparison

2018-12-28 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1422

According to EDK II C Coding Standards Specification,
Non-Boolean comparisons must use a compare operator.
This patch is to update the code to follow EDKII coding style.

Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
index f0d3472ea5..a0fe3b9ffa 100644
--- 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
+++ 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
@@ -1274,11 +1274,11 @@ PciIoAttributes (
   #define DEV_SUPPORTED_ATTRIBUTES \
 (EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE)
 
   Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
 
-  if (Attributes) {
+  if (Attributes != 0) {
   if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) {
 return EFI_UNSUPPORTED;
   }
 }
 
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] BaseTools/VfrCompile: report error for Integer overflow

2018-12-28 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1415

When an integer constant specified in the .vfr file is
too large for the varstore field it is being used with,
the VFR compiler reports an overflow warning like this:
Test.vfr(693): WARNING: Overflow: Value 1024 is too large to
 store in a UINT8
: String to UINT* Overflow
Since Warning does not break the build process,
and it is easy to miss it.
This patch is to update the code to report error and break
the build if meet this kind of issue.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 BaseTools/Source/C/VfrCompile/VfrError.cpp |  2 +-
 BaseTools/Source/C/VfrCompile/VfrError.h   |  2 +-
 BaseTools/Source/C/VfrCompile/VfrSyntax.g  | 10 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp 
b/BaseTools/Source/C/VfrCompile/VfrError.cpp
index bbf738c217..c105d73bea 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp
@@ -45,16 +45,16 @@ static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
   { VFR_RETURN_DATA_STRING_ERROR, ": data field string error or not support"},
   { VFR_RETURN_DEFAULT_VALUE_REDEFINED, ": default value re-defined with 
different value"},
   { VFR_RETURN_CONSTANT_ONLY, ": only constant is allowed in the expression"},
   { VFR_RETURN_VARSTORE_NAME_REDEFINED_ERROR, ": Varstore name is defined by 
more than one varstores, it can't be referred as varstore, only varstore 
strucure name could be used."},
   { VFR_RETURN_BIT_WIDTH_ERROR, ": bit width must be <= sizeof (type) * 8 and 
the max width can not > 32" },
+  { VFR_RETURN_STRING_TO_UINT_OVERFLOW, ": String to UINT* Overflow"},
   { VFR_RETURN_CODEUNDEFINED, ": undefined Error Code" }
 };
 
 static SVFR_WARNING_HANDLE VFR_WARNING_HANDLE_TABLE [] = {
   { VFR_WARNING_DEFAULT_VALUE_REDEFINED, ": default value re-defined with 
different value"},
-  { VFR_WARNING_STRING_TO_UINT_OVERFLOW, ": String to UINT* Overflow"},
   { VFR_WARNING_ACTION_WITH_TEXT_TWO, ": Action opcode should not have TextTwo 
part"},
   { VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE, ": Not recommend to use obsoleted 
framework opcode"},
   { VFR_WARNING_CODEUNDEFINED, ": undefined Warning Code" }
 };
 
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.h 
b/BaseTools/Source/C/VfrCompile/VfrError.h
index e83ae900fa..e795f1631d 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.h
+++ b/BaseTools/Source/C/VfrCompile/VfrError.h
@@ -43,16 +43,16 @@ typedef enum {
   VFR_RETURN_DATA_STRING_ERROR,
   VFR_RETURN_DEFAULT_VALUE_REDEFINED,
   VFR_RETURN_CONSTANT_ONLY,
   VFR_RETURN_VARSTORE_NAME_REDEFINED_ERROR,
   VFR_RETURN_BIT_WIDTH_ERROR,
+  VFR_RETURN_STRING_TO_UINT_OVERFLOW,
   VFR_RETURN_CODEUNDEFINED
 } EFI_VFR_RETURN_CODE;
 
 typedef enum {
   VFR_WARNING_DEFAULT_VALUE_REDEFINED = 0,
-  VFR_WARNING_STRING_TO_UINT_OVERFLOW,
   VFR_WARNING_ACTION_WITH_TEXT_TWO,
   VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE,
   VFR_WARNING_CODEUNDEFINED
 } EFI_VFR_WARNING_CODE;
 
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g 
b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index 84dd2c3ed3..7d8088a889 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -1,9 +1,9 @@
 /*++ @file
 Vfr Syntax
 
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -5320,11 +5320,11 @@ EfiVfrParser::_STOU8 (
 if (c >= '0' && c <= '9') {
   Value += (c - '0');
 }
 if((IsHex && ((Value/16) != PreviousValue)) || (!IsHex && ((Value/10) != 
PreviousValue))) {
   sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a UINT8", 
OrigString);
-  gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, 
LineNum, ErrorMsg);
+  mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError 
(VFR_RETURN_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);
 }
   }
 
   return Value;
 }
@@ -5357,11 +5357,11 @@ EfiVfrParser::_STOU16 (
 if (c >= '0' && c <= '9') {
   Value += (c - '0');
 }
 if((IsHex && ((Value/16) != PreviousValue)) || (!IsHex && ((Value/10) != 
PreviousValue))) {
   sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a 
UINT16", OrigString);
-  gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, 
LineNum, ErrorMsg);
+  mParserStatus = mParserStatus + gCVfrErrorHand

[edk2] [patch] MdePkg: check Length para before use in DevPathToTextUsbWWID

2018-11-18 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1336

In function DevPathToTextUsbWWID, the Length parameter is used
without check. This patch is to add check before using it.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 97d279eeb2..678f3d0a92 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -970,11 +970,11 @@ DevPathToTextUsbWWID (
 
   UsbWWId = DevPath;
 
   SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof 
(USB_WWID_DEVICE_PATH));
   Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) 
UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));
-  if (SerialNumberStr [Length - 1] != 0) {
+  if (Length >= 1 && SerialNumberStr [Length - 1] != 0) {
 //
 // In case no NULL terminator in SerialNumber, create a new one with NULL 
terminator
 //
 NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), 
SerialNumberStr);
 ASSERT (NewStr != NULL);
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdePkg: Check input Ptrs in GetSectionFromAnyFvByFileType

2018-11-18 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1337

In function GetSectionFromAnyFvByFileType, the input parameter "Buffer"
and "size" should not be NULL, so add ASSERT here to avoid any checker
report that the NULL pointer may be used.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/DxeServicesLib/DxeServicesLib.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdePkg/Library/DxeServicesLib/DxeServicesLib.c 
b/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
index d4f366425f..e78d51cb92 100644
--- a/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
+++ b/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
@@ -251,10 +251,13 @@ GetSectionFromAnyFvByFileType  (
   UINTN Key;
   EFI_GUID  NameGuid;
   EFI_FV_FILE_ATTRIBUTESAttributes;
   EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
 
+  ASSERT (Buffer != NULL);
+  ASSERT (Size != NULL);
+
   //
   // Locate all available FVs.
   //
   HandleBuffer = NULL;
   Status = gBS->LocateHandleBuffer (
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdePkg: Fix incorrect check for DisplayOnly text format in AcpiEx

2018-11-08 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1312

Text format for AcpiEx device path in UEFI Spec:
AcpiEx(HID,CID,UID,HIDSTR,CIDSTR,UIDSTR)
AcpiEx(HID|HIDSTR,(CID|CIDSTR,UID|UIDSTR))(Display Only)

When convert device path to text for ACPI device path,
current code check AllowShortcuts parameter to convert
the device path to DisplayOnly text format(shorter text
representation) by mistake.
It should check DisplayOnly parameter.

This commit is to fix this issue.

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index cdcdb3623a..97d279eeb2 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -495,11 +495,11 @@ DevPathToTextAcpiEx (
 CIDText,
 UIDStr
);
 }
   } else {
-if (AllowShortcuts) {
+if (DisplayOnly) {
   //
   // display only
   //
   if (AcpiEx->HID == 0) {
 UefiDevicePathLibCatPrint (Str, L"AcpiEx(%a,", HIDStr);
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/DisplayEngine: Remove useless NULL ptr check for NewPos

2018-11-07 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1306

In function UiDisplayMenu, the NewPos ptr which used to point to the
highlight menu entry. It will always point to the menu entry which
need to be highlighted or the gMenuOption menu if the highlight menu
is not found.
So we can remove the NULL ptr check for NewPos in this function.
And add the ASSERT code to avoid if any false positive reports
of NULL pointer dereference issue raised from static analysis.

Cc: Liming Gao 
Cc: Eric Dong 
Cc: Star Zeng 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c 
b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
index 7390f954b6..44f087fe01 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
@@ -2880,10 +2880,11 @@ UiDisplayMenu (
   // MenuOption is set to NULL in Repaint
   // NewPos: Current menu option that need to hilight
   //
   ControlFlag = CfUpdateHelpString;
 
+  ASSERT (NewPos != NULL);
   UpdateHighlightMenuInfo(NewPos, TopOfScreen, SkipValue);
 
   if (SkipHighLight) {
 SkipHighLight = FALSE;
 MenuOption= SavedMenuOption;
@@ -2908,11 +2909,11 @@ UiDisplayMenu (
 Temp2 = SkipValue;
   } else {
 Temp2 = 0;
   }
 
-  if (NewPos != NULL && (MenuOption == NULL || NewPos != 
>Link)) {
+  if (MenuOption == NULL || NewPos != >Link) {
 if (MenuOption != NULL) {
   //
   // Remove the old highlight menu.
   //
   Status = DisplayOneMenu (MenuOption,
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 0/2] MdeModulePkg/HiiDatabaseDxe: Make sure database update behaviors are atomic

2018-10-12 Thread Dandan Bi
The main purpose of this task is to make sure the operations
that update the HiiDatabase atomic the avoid the potential
risk that the one update operation with higher TPL may interrupt
another.

Patch 1 is to reorgnize the existing code logic and make it's
easy to add EfiAcquireLock/EfiReleaseLock function in patch 2.

Patch 2 is to add EfiAcquireLock/EfiReleaseLock function to
make sure the HiiDatabse update operations atomic.

Cc: Liming Gao 
Cc: Eric Dong 
Dandan Bi (2):
  MdeModulePkg/HiiDB: Reorganize codes of exporting HII settings
  MdeModulePkg/HiiDB: Make sure database update behaviors are atomic

 .../Universal/HiiDatabaseDxe/Database.c   | 128 --
 .../Universal/HiiDatabaseDxe/HiiDatabase.h|   8 +-
 .../HiiDatabaseDxe/HiiDatabaseEntry.c |   3 +-
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c |  12 ++
 .../Universal/HiiDatabaseDxe/String.c |   9 ++
 5 files changed, 112 insertions(+), 48 deletions(-)

-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/2] MdeModulePkg/HiiDB: Make sure database update behaviors are atomic

2018-10-12 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1235

When update contents in HiiDatabase, like:
1. Add/update/remove package list
2. Add/update string
3. Add/update image
We should make these operations atomic to prevent the
potential issue that the one update operation with
higher TPL may interrupt another.
This commit is to make the HiiDatabase update behaviors
atomic by adding EfiAcquireLock/EfiReleaseLock function.

Cc: Liming Gao 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Universal/HiiDatabaseDxe/Database.c   | 53 ++-
 .../Universal/HiiDatabaseDxe/HiiDatabase.h|  2 +
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 12 +
 .../Universal/HiiDatabaseDxe/String.c |  9 
 4 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c 
b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index 1e2724f126..85fd10b63b 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -24,10 +24,15 @@ UINTN  gConfigRespSize = 0;
 BOOLEANgExportConfigResp = FALSE;
 UINTN  gNvDefaultStoreSize = 0;
 SKU_ID gSkuId  = 0x;
 LIST_ENTRY gVarStorageList = 
INITIALIZE_LIST_HEAD_VARIABLE (gVarStorageList);
 
+//
+// HII database lock.
+//
+EFI_LOCK mHiiDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE(TPL_NOTIFY);
+
 /**
   This function generates a HII_DATABASE_RECORD node and adds into hii 
database.
   This is a internal function.
 
   @param  Privatehii database private structure
@@ -3491,24 +3496,28 @@ HiiNewPackageList (
 DatabaseRecord->DriverHandle == DriverHandle) {
   return EFI_INVALID_PARAMETER;
 }
   }
 
+  EfiAcquireLock ();
+
   //
   // Build a PackageList node
   //
   Status = GenerateHiiDatabaseRecord (Private, );
   if (EFI_ERROR (Status)) {
+EfiReleaseLock ();
 return Status;
   }
 
   //
   // Fill in information of the created Package List node
   // according to incoming package list.
   //
   Status = AddPackages (Private, EFI_HII_DATABASE_NOTIFY_NEW_PACK, 
PackageList, DatabaseRecord);
   if (EFI_ERROR (Status)) {
+EfiReleaseLock ();
 return Status;
   }
 
   DatabaseRecord->DriverHandle = DriverHandle;
 
@@ -3532,12 +3541,21 @@ HiiNewPackageList (
   // Only after ReadyToBoot, need to do the export.
   //
   if (gExportAfterReadyToBoot) {
 HiiGetDatabaseInfo (This);
   }
+  EfiReleaseLock ();
 
   //
+  // Notes:
+  // HiiGetDatabaseInfo () will get the contents of HII data base,
+  // belong to the atomic behavior of Hii Database update.
+  // And since HiiGetConfigRespInfo () will get the configuration setting info 
from HII drivers
+  // we can not think it belong to the atomic behavior of Hii Database update.
+  // That's why EfiReleaseLock () is callled before 
HiiGetConfigRespInfo ().
+  //
+
   // Check whether need to get the configuration setting info from HII drivers.
   // When after ReadyToBoot and need to do the export for form package add.
   //
   if (gExportAfterReadyToBoot && gExportConfigResp) {
 HiiGetConfigRespInfo (This);
@@ -3583,10 +3601,12 @@ HiiRemovePackageList (
 
   if (!IsHiiHandleValid (Handle)) {
 return EFI_NOT_FOUND;
   }
 
+  EfiAcquireLock ();
+
   Private = HII_DATABASE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
 
   //
   // Get the packagelist to be removed.
   //
@@ -3600,38 +3620,46 @@ HiiRemovePackageList (
   // Call registered functions with REMOVE_PACK before removing packages
   // then remove them.
   //
   Status = RemoveGuidPackages (Private, Handle, PackageList);
   if (EFI_ERROR (Status)) {
+EfiReleaseLock ();
 return Status;
   }
   Status = RemoveFormPackages (Private, Handle, PackageList);
   if (EFI_ERROR (Status)) {
+EfiReleaseLock ();
 return Status;
   }
   Status = RemoveKeyboardLayoutPackages (Private, Handle, PackageList);
   if (EFI_ERROR (Status)) {
+EfiReleaseLock ();
 return Status;
   }
   Status = RemoveStringPackages (Private, Handle, PackageList);
   if (EFI_ERROR (Status)) {
+EfiReleaseLock ();
 return Status;
   }
   Status = RemoveFontPackages (Private, Handle, PackageList);
   if (EFI_ERROR (Status)) {
+EfiReleaseLock ();
 return Status;
   }
   Status = RemoveImagePackages (Private, Handle, PackageList);
   if (EFI_ERROR (Status)) {
+EfiReleaseLock ();
 return Status;
   }
   Status = RemoveSimpleFontPackages (Private, Handle, PackageList);
   if (EFI_ERROR (Status)) {
+EfiReleaseLock ();
 return Status;
   }
   Status = RemoveDevicePathPackage (Private, Handle, PackageList);
   if (EFI

[edk2] [patch 3/3] MdePkg: Handle AcpiExp device path when optional para is not specified

2018-10-11 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

AcpiExp text device path: AcpiExp(HID,CID,UIDSTR)
And according to UEFI spec, the CID parameter is optional
and has a default value of 0. But current implementation
miss to check following cases for the AcpiExp.
FromText:when text device is AcpiExp(HID,,UIDSTR)/AcpiExp(HID,0,UIDSTR)
ToText: when the CID is 0 in the node structure

This commit is to do the enhancement.

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../UefiDevicePathLib/DevicePathFromText.c| 11 -
 .../UefiDevicePathLib/DevicePathToText.c  | 23 +--
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index 4b49e341c7..b759146b72 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -917,11 +917,20 @@ DevPathFromTextAcpiExp (
   ACPI_EXTENDED_DP,
   Length
   );
 
   AcpiEx->HID = EisaIdFromText (HIDStr);
-  AcpiEx->CID = EisaIdFromText (CIDStr);
+  //
+  // According to UEFI spec, the CID parametr is optional and has a default 
value of 0.
+  // So when the CID parametr is not specified or specified as 0 in the text 
device node.
+  // Set the CID to 0 in the ACPI extension device path structure.
+  //
+  if (*CIDStr == L'\0' || *CIDStr == L'0') {
+AcpiEx->CID = 0;
+  } else {
+AcpiEx->CID = EisaIdFromText (CIDStr);
+  }
   AcpiEx->UID = 0;
 
   AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof 
(ACPI_EXTENDED_HID_DEVICE_PATH));
   //
   // HID string is NULL
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 7ad9eadf6c..cdcdb3623a 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -478,17 +478,26 @@ DevPathToTextAcpiEx (
 
   if ((*HIDStr == '\0') && (*CIDStr == '\0') && (*UIDStr != '\0')) {
 //
 // use AcpiExp()
 //
-UefiDevicePathLibCatPrint (
-  Str,
-  L"AcpiExp(%s,%s,%a)",
-  HIDText,
-  CIDText,
-  UIDStr
-  );
+if (AcpiEx->CID == 0) {
+  UefiDevicePathLibCatPrint (
+Str,
+L"AcpiExp(%s,0,%a)",
+HIDText,
+UIDStr
+   );
+} else {
+  UefiDevicePathLibCatPrint (
+Str,
+L"AcpiExp(%s,%s,%a)",
+HIDText,
+CIDText,
+UIDStr
+   );
+}
   } else {
 if (AllowShortcuts) {
   //
   // display only
   //
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/3] MdePkg: Handle USBxxx device path when optional para is not specified

2018-10-11 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

According to UEFI spec,
for the Messaging Device Path with USB Class SubType, some paras
are optional in the text device path.
Take UsbClass(VID,PID,Class,SubClass,Protocol) for example,
The VID is an integer between 0 and 65535 and is optional. The
default value is 0x.
The PID is an integer between 0 and 65535 and is optional. The
default value is 0x.
The Class is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The SubClass is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The Protocol is an integer between 0 and 255 and is optional. The
default value is 0xFF.
So if any the optional para is not specified in the text device,
we should set related para in the node structure to default value.

This commit is to do the enhancement for USB Class device path
when optional para is not specified

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../UefiDevicePathLib/DevicePathFromText.c| 30 +++
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index 7e33160ee9..4b49e341c7 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -2059,26 +2059,46 @@ ConvertFromTextUsbClass (
 
   VIDStr  = GetNextParamStr ();
   PIDStr  = GetNextParamStr ();
   if (UsbClassText->ClassExist) {
 ClassStr = GetNextParamStr ();
-UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);
+if (*ClassStr == L'\0') {
+  UsbClass->DeviceClass = 0xFF;
+} else {
+  UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);
+}
   } else {
 UsbClass->DeviceClass = UsbClassText->Class;
   }
   if (UsbClassText->SubClassExist) {
 SubClassStr = GetNextParamStr ();
-UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);
+if (*SubClassStr == L'\0') {
+  UsbClass->DeviceSubClass = 0xFF;
+} else {
+  UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);
+}
   } else {
 UsbClass->DeviceSubClass = UsbClassText->SubClass;
   }
 
   ProtocolStr = GetNextParamStr ();
 
-  UsbClass->VendorId= (UINT16) Strtoi (VIDStr);
-  UsbClass->ProductId   = (UINT16) Strtoi (PIDStr);
-  UsbClass->DeviceProtocol  = (UINT8) Strtoi (ProtocolStr);
+  if (*VIDStr == L'\0') {
+UsbClass->VendorId= 0x;
+  } else {
+UsbClass->VendorId= (UINT16) Strtoi (VIDStr);
+  }
+  if (*PIDStr == L'\0') {
+UsbClass->ProductId   = 0x;
+  } else {
+UsbClass->ProductId   = (UINT16) Strtoi (PIDStr);
+  }
+  if (*ProtocolStr == L'\0') {
+UsbClass->DeviceProtocol  = 0xFF;
+  } else {
+UsbClass->DeviceProtocol  = (UINT8) Strtoi (ProtocolStr);
+  }
 
   return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;
 }
 
 
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/3] MdePkg: Handle Sata device path when optional para is not specified

2018-10-11 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

Sata device path format:Sata(HPN, PMPN, LUN)
According to UEFI Spec, the PMPN is an integer between
0 and 65535 and is optional. If not provided, the default is 0x.

This commit is to do the enhancement for Sata device path
when optional para is not specified.

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index c5f3764fc0..7e33160ee9 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -3414,11 +3414,19 @@ DevPathFromTextSata (
 MESSAGING_DEVICE_PATH,
 MSG_SATA_DP,
 (UINT16) sizeof (SATA_DEVICE_PATH)
 );
   Sata->HBAPortNumber= (UINT16) Strtoi (Param1);
-  Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);
+
+  //
+  // According to UEFI spec, if PMPN is not provided, the default is 0x
+  //
+  if (*Param2 == L'\0' ) {
+Sata->PortMultiplierPortNumber = 0x;
+  } else {
+Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);
+  }
   Sata->Lun  = (UINT16) Strtoi (Param3);
 
   return (EFI_DEVICE_PATH_PROTOCOL *) Sata;
 }
 
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 0/3] MdePkg/UefiDevicePathLib: Enahncement for Sata/Usbxx/AcpiExp device path

2018-10-11 Thread Dandan Bi
https://bugzilla.tianocore.org/show_bug.cgi?id=1243

This pacth series is mainly to do the enahncement for
Sata/Usbxx/AcpiExp device path to handle the cases when some
optional paremeter is not specified in the text device path.

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Dandan Bi (3):
  MdePkg: Handle Sata device path when optional para is not specified
  MdePkg: Handle USBxxx device path when optional para is not specified
  MdePkg: Handle AcpiExp device path when optional para is not specified

 .../UefiDevicePathLib/DevicePathFromText.c| 51 ---
 .../UefiDevicePathLib/DevicePathToText.c  | 23 ++---
 2 files changed, 60 insertions(+), 14 deletions(-)

-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 3/5] MdePkg: Correct condition check for AcpiExp text format

2018-10-07 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1226

According to UEFI Spec, for ACPI Expanded Device Path,
when HIDSTR=empty, CIDSTR=empty, UID STR!=empty,
the ACPI Expanded Device Path node can be displayed as
AcpiExp(HID,CID,UIDSTR) format.
And if UID is 0 and UIDSTR is empty, then use AcpiEx format.

This patch is to correct the condition check to follow UEFI
Spec when convert the device path node to the AcpiExp text
format.

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 1c08a3ec2f..8e5efba1e8 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -453,11 +453,11 @@ DevPathToTextAcpiEx (
 ((AcpiEx->CID >>  5) & 0x1f) + 'A' - 1,
 ((AcpiEx->CID >>  0) & 0x1f) + 'A' - 1,
 (AcpiEx->CID >> 16) & 0x
 );
 
-  if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) {
+  if ((*HIDStr == '\0') && (*CIDStr == '\0') && (*UIDStr != '\0')) {
 //
 // use AcpiExp()
 //
 UefiDevicePathLibCatPrint (
   Str,
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 4/5] MdePkg: Add PciRoot/PcieRoot text for ACPI Expanded Device Path

2018-10-07 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1228

According to UEFI spec,for ACPI Expanded Device Path
when HID=PNP0A03 or CID=PNP0A03 and HID != PNP0A08,
the device path node can be displayed as: PciRoot(UID|UIDSTR)
When HID=PNP0A08 or CID=PNP0A08, the device path node can be
displayed as: PcieRoot(UID|UIDSTR). But current code miss the
code logic.

This commit is to do the enhancement.

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 .../UefiDevicePathLib/DevicePathToText.c  | 21 +++
 1 file changed, 21 insertions(+)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 8e5efba1e8..7ad9eadf6c 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -431,10 +431,31 @@ DevPathToTextAcpiEx (
   AcpiEx = DevPath;
   HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof 
(ACPI_EXTENDED_HID_DEVICE_PATH));
   UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;
   CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;
 
+  if (DisplayOnly) {
+if ((EISA_ID_TO_NUM (AcpiEx->HID) == 0x0A03) ||
+(EISA_ID_TO_NUM (AcpiEx->CID) == 0x0A03 && EISA_ID_TO_NUM 
(AcpiEx->HID) != 0x0A08)) {
+  if (AcpiEx->UID == 0) {
+UefiDevicePathLibCatPrint (Str, L"PciRoot(%a)", UIDStr);
+  } else {
+UefiDevicePathLibCatPrint (Str, L"PciRoot(0x%x)", AcpiEx->UID);
+  }
+  return;
+}
+
+if (EISA_ID_TO_NUM (AcpiEx->HID) == 0x0A08 || EISA_ID_TO_NUM (AcpiEx->CID) 
== 0x0A08) {
+  if (AcpiEx->UID == 0) {
+UefiDevicePathLibCatPrint (Str, L"PcieRoot(%a)", UIDStr);
+  } else {
+UefiDevicePathLibCatPrint (Str, L"PcieRoot(0x%x)", AcpiEx->UID);
+  }
+  return;
+}
+  }
+
   //
   // Converts EISA identification to string.
   //
   UnicodeSPrint (
 HIDText,
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/5] MdePkg: Correct the string order of ACPI Expanded Device Path

2018-10-07 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1227

According to UEFI Spec, ACPI Expanded Device Path can be display
AcpiEx(HID|HIDSTR,(CID|CIDSTR,UID|UIDSTR)), but current code display
UID|UIDSTR before CID|CIDSTR.
This patch is to fix this issue.

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 85f5e97131..1c08a3ec2f 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -475,20 +475,20 @@ DevPathToTextAcpiEx (
 UefiDevicePathLibCatPrint (Str, L"AcpiEx(%a,", HIDStr);
   } else {
 UefiDevicePathLibCatPrint (Str, L"AcpiEx(%s,", HIDText);
   }
 
-  if (AcpiEx->UID == 0) {
-UefiDevicePathLibCatPrint (Str, L"%a,", UIDStr);
+  if (AcpiEx->CID == 0) {
+UefiDevicePathLibCatPrint (Str, L"%a,", CIDStr);
   } else {
-UefiDevicePathLibCatPrint (Str, L"0x%x,", AcpiEx->UID);
+UefiDevicePathLibCatPrint (Str, L"%s,", CIDText);
   }
 
-  if (AcpiEx->CID == 0) {
-UefiDevicePathLibCatPrint (Str, L"%a)", CIDStr);
+  if (AcpiEx->UID == 0) {
+UefiDevicePathLibCatPrint (Str, L"%a)", UIDStr);
   } else {
-UefiDevicePathLibCatPrint (Str, L"%s)", CIDText);
+UefiDevicePathLibCatPrint (Str, L"0x%x)", AcpiEx->UID);
   }
 } else {
   UefiDevicePathLibCatPrint (
 Str,
 L"AcpiEx(%s,%s,0x%x,%a,%a,%a)",
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 5/5] MdePkg: Use VENDOR_DEVICE_PATH structure for Debug Port device path

2018-10-07 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1229

When converting DebugPort device path from text,
current code use VENDOR_DEFINED_MESSAGING_DEVICE_PATH structure
for Debug port device node.
typedef struct {
  EFI_DEVICE_PATH_PROTOCOL  Header;
  EFI_GUID  Guid;
  UINT8 VendorDefinedData[1];
} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;

And Debugport Device Path is a vendor-defined messaging
device path with no data, only a GUID. So it's better to
use VENDOR_DEVICE_PATH to create the Debug port device node.
typedef struct {
  EFI_DEVICE_PATH_PROTOCOLHeader;
  EFI_GUIDGuid;
} VENDOR_DEVICE_PATH;

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index c5f3764fc0..49da8268eb 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -1756,16 +1756,16 @@ DevPathFromTextEmmc (
 EFI_DEVICE_PATH_PROTOCOL *
 DevPathFromTextDebugPort (
   IN CHAR16 *TextDeviceNode
   )
 {
-  VENDOR_DEFINED_MESSAGING_DEVICE_PATH  *Vend;
+  VENDOR_DEVICE_PATH  *Vend;
 
-  Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (
+  Vend = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
 MESSAGING_DEVICE_PATH,
 MSG_VENDOR_DP,
-(UINT16) sizeof 
(VENDOR_DEFINED_MESSAGING_DEVICE_PATH)
+(UINT16) sizeof 
(VENDOR_DEVICE_PATH)
 );
 
   CopyGuid (>Guid, );
 
   return (EFI_DEVICE_PATH_PROTOCOL *) Vend;
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/5] MdePkg: Correct the string expression of UTF8 vendor device path

2018-10-07 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1225

According to UEFI spec, the string expression of UTF8 vendor
device node should be displayed as: VenUtf8(). Current code
display it as: VenUft8() by mistake when convert device
path node to text.

This commit is to fix this bug.

Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 7d8d304f6f..85f5e97131 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -193,11 +193,11 @@ DevPathToTextVendor (
 return ;
   } else if (CompareGuid (>Guid, )) {
 UefiDevicePathLibCatPrint (Str, L"VenVt100Plus()");
 return ;
   } else if (CompareGuid (>Guid, )) {
-UefiDevicePathLibCatPrint (Str, L"VenUft8()");
+UefiDevicePathLibCatPrint (Str, L"VenUtf8()");
 return ;
   } else if (CompareGuid (>Guid, )) {
 FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) 
Vendor)->FlowControlMap);
 switch (FlowControlMap & 0x0003) {
 case 0:
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/HiiDB: Fix incorrect structure convention for checkbox

2018-10-07 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1224

When covert IFR binary to EFI_IFR_CHECKBOX structure,
Current code has following incorrect code logic:
IfrCheckBox = (EFI_IFR_CHECKBOX *) (IfrOpHdr + 1);
The correct one should be:
IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr;

This patch is to fix this bug.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c 
b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index 45448c5198..664687796f 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -896,11 +896,11 @@ UpdateDefaultSettingInFormPackage (
   break;
 case EFI_IFR_CHECKBOX_OP:
   IfrScope = IfrOpHdr->Scope;
   IfrQuestionType  = IfrOpHdr->OpCode;
   IfrQuestionHdr   = (EFI_IFR_QUESTION_HEADER *) (IfrOpHdr + 1);
-  IfrCheckBox  = (EFI_IFR_CHECKBOX *) (IfrOpHdr + 1);
+  IfrCheckBox  = (EFI_IFR_CHECKBOX *) IfrOpHdr;
   EfiVarStoreIndex = IsEfiVarStoreQuestion (IfrQuestionHdr, 
EfiVarStoreList, EfiVarStoreNumber);
   Width= sizeof (BOOLEAN);
   if (EfiVarStoreIndex < EfiVarStoreNumber) {
 for (Index = 0; Index < DefaultIdNumber; Index ++) {
   if (DefaultIdList[Index] == EFI_HII_DEFAULT_CLASS_STANDARD) {
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 3/3] MdeModulePkg: Avoid key notification called more than once

2018-09-10 Thread dandan bi
From: Dandan Bi 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=996

Issue:
In current code logic, when a key is pressed, it will search
the whole NotifyList to find whether a notification has been
registered with the keystroke. if yes, it will en-queue the
key for notification execution later. And now if different
notification functions have been registered with the same key,
then the key will be en-queued more than once. Then it will
cause the notification executed more than once.

This patch is to enhance the code logic to fix this issue.

Cc: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c| 1 +
 MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c   | 1 +
 MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c 
b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
index 2ee293d64d..53cb6f0b48 100644
--- a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
+++ b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
@@ -1449,10 +1449,11 @@ KeyGetchar (
   // while current TPL is TPL_NOTIFY. It will be invoked in
   // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
   //
   PushEfikeyBufTail (>EfiKeyQueueForNotify, );
   gBS->SignalEvent (ConsoleIn->KeyNotifyProcessEvent);
+  break;
 }
   }
 
   PushEfikeyBufTail (>EfiKeyQueue, );
 }
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c 
b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c
index b3b5fb9ff4..9cb4b5db6b 100644
--- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c
+++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c
@@ -1693,10 +1693,11 @@ UsbKeyCodeToEfiInputKey (
   // while current TPL is TPL_NOTIFY. It will be invoked in
   // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
   //
   Enqueue (>EfiKeyQueueForNotify, KeyData, sizeof 
(*KeyData));
   gBS->SignalEvent (UsbKeyboardDevice->KeyNotifyProcessEvent);
+  break;
 }
   }
 
   return EFI_SUCCESS;
 }
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c 
b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 33f9b6e585..d681a3039e 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -985,10 +985,11 @@ EfiKeyFiFoInsertOneKey (
   // while current TPL is TPL_NOTIFY. It will be invoked in
   // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
   //
   EfiKeyFiFoForNotifyInsertOneKey (TerminalDevice->EfiKeyFiFoForNotify, 
Key);
   gBS->SignalEvent (TerminalDevice->KeyNotifyProcessEvent);
+  break;
 }
   }
   if (IsEfiKeyFiFoFull (TerminalDevice)) {
 //
 // Efi Key FIFO is full
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/3] EmbeddedPkg/VirtualKeyboard: Avoid notification called more than once

2018-09-10 Thread dandan bi
From: Dandan Bi 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=996

Issue:
In current code logic, when a key is pressed, it will search
the whole NotifyList to find whether a notification has been
registered with the keystroke. if yes, it will en-queue the
key for notification execution later. And now if different
notification functions have been registered with the same key,
then the key will be en-queued more than once. Then it will
cause the notification executed more than once.

This patch is to enhance the code logic to fix this issue.

Cc: Ruiyu Ni 
Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c 
b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c
index 6609bc8dbe..daea9c47d2 100644
--- a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c
+++ b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c
@@ -1,9 +1,9 @@
 /** @file
   VirtualKeyboard driver
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 Copyright (c) 2018, Linaro Ltd. All rights reserved.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions
 of the BSD License which accompanies this distribution.  The
@@ -1043,10 +1043,11 @@ VirtualKeyboardTimerHandler (
   // while current TPL is TPL_NOTIFY. It will be invoked in
   // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
   //
   Enqueue (>QueueForNotify, );
   gBS->SignalEvent (VirtualKeyboardPrivate->KeyNotifyProcessEvent);
+  break;
 }
   }
 
   Enqueue (>Queue, );
 
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/3] IntelFrameworkModulePkg: Avoid key notification called more than once

2018-09-10 Thread dandan bi
From: Dandan Bi 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=996

Issue:
In current code logic, when a key is pressed, it will search
the whole NotifyList to find whether a notification has been
registered with the keystroke. if yes, it will en-queue the
key for notification execution later. And now if different
notification functions have been registered with the same key,
then the key will be en-queued more than once. Then it will
cause the notification executed more than once.

This patch is to enhance the code logic to fix this issue.

Cc: Ruiyu Ni 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c   | 1 +
 IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c 
b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
index 202588191e..fddb0b21fb 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
@@ -1485,10 +1485,11 @@ KeyGetchar (
   // while current TPL is TPL_NOTIFY. It will be invoked in
   // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
   //
   PushEfikeyBufTail (>EfiKeyQueueForNotify, );
   gBS->SignalEvent (ConsoleIn->KeyNotifyProcessEvent);
+  break;
 }
   }
 
   PushEfikeyBufTail (>EfiKeyQueue, );
 }
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c 
b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c
index 63f6303995..bee5f8f5e5 100644
--- a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c
+++ b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c
@@ -1984,10 +1984,11 @@ BiosKeyboardTimerHandler (
   // while current TPL is TPL_NOTIFY. It will be invoked in
   // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
   //
   Enqueue (>QueueForNotify, );
   gBS->SignalEvent (BiosKeyboardPrivate->KeyNotifyProcessEvent);
+  break;
 }
   }
 
   Enqueue (>Queue, );
 
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] BaseTools/PatchCheck.py: Fix error when run with Python3

2018-09-05 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1145

Currently run PatchCheck.py with Python3 will meet
following error:
.
File "PatchCheck.py", line 554, in run_git
return Result[0].decode('utf-8', 'ignore') if Result[0] and
Result[0].find("fatal")!=0 else None
TypeError: a bytes-like object is required, not 'str'

This issue was introduce by commit:5ac4548cdf654.

This patch is to convert the str object of "fatal" to
byte object to fix this failure.

Cc: Liming Gao 
Cc: Jaben Carsey 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 BaseTools/Scripts/PatchCheck.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py
index 96b3cdf1fd..0b580f3b31 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -549,11 +549,11 @@ class CheckGitCommits:
 cmd += args
 p = subprocess.Popen(cmd,
  stdout=subprocess.PIPE,
  stderr=subprocess.STDOUT)
 Result = p.communicate()
-return Result[0].decode('utf-8', 'ignore') if Result[0] and 
Result[0].find("fatal")!=0 else None
+return Result[0].decode('utf-8', 'ignore') if Result[0] and 
Result[0].find(b"fatal")!=0 else None
 
 class CheckOnePatchFile:
 """Performs a patch check for a single file.
 
 stdin is used when the filename is '-'.
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch V3] ShellPkg/SmbiosView: Update SmbiosView for SMBIOS3.2.0

2018-08-29 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1099

Update SmbiosView to parse the new definitions which
are introduced in SMBIOS3.2.0

V2:
1. Add structure length check before dump the fileds in
Type 9 and Type 17 in case some fileds are not organized
and reported by drivers.
2. Dump the InterfaceTypeSpecificData in Type 42.

V3:
1. Correct the structure length in Type17.
2. Remove the redundant check "if (PeerGroupCount > 0)" in Type 9.
3. Use the Uint16 filed instead of Bits field in union
MEMORY_DEVICE_OPERATING_MODE_CAPABILITY to dump data.

Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../SmbiosView/PrintInfo.c |  86 ++---
 .../SmbiosView/QueryTable.c| 135 -
 .../SmbiosView/QueryTable.h|  26 +++-
 .../SmbiosView/SmbiosViewStrings.uni   |   9 +-
 4 files changed, 237 insertions(+), 19 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index 93c6094df1..af8551fe2e 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -541,26 +541,49 @@ SmbiosPrintStructure (
 
   //
   // System Slots (Type 9)
   //
   case 9:
-PRINT_PENDING_STRING (Struct, Type9, SlotDesignation);
-DisplaySystemSlotType (Struct->Type9->SlotType, Option);
-DisplaySystemSlotDataBusWidth (Struct->Type9->SlotDataBusWidth, Option);
-DisplaySystemSlotCurrentUsage (Struct->Type9->CurrentUsage, Option);
-DisplaySystemSlotLength (Struct->Type9->SlotLength, Option);
-DisplaySystemSlotId (
-  Struct->Type9->SlotID,
-  Struct->Type9->SlotType,
-  Option
- );
-DisplaySlotCharacteristics1 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics1), Option);
-DisplaySlotCharacteristics2 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics2), Option);
-if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0xD)) {
-  PRINT_STRUCT_VALUE_H (Struct, Type9, SegmentGroupNum);
-  PRINT_STRUCT_VALUE_H (Struct, Type9, BusNum);
-  PRINT_STRUCT_VALUE_H (Struct, Type9, DevFuncNum);
+{
+  MISC_SLOT_PEER_GROUP  *PeerGroupPtr;
+  UINT8 PeerGroupCount;
+
+  PRINT_PENDING_STRING (Struct, Type9, SlotDesignation);
+  DisplaySystemSlotType (Struct->Type9->SlotType, Option);
+  DisplaySystemSlotDataBusWidth (Struct->Type9->SlotDataBusWidth, Option);
+  DisplaySystemSlotCurrentUsage (Struct->Type9->CurrentUsage, Option);
+  DisplaySystemSlotLength (Struct->Type9->SlotLength, Option);
+  DisplaySystemSlotId (
+Struct->Type9->SlotID,
+Struct->Type9->SlotType,
+Option
+   );
+  DisplaySlotCharacteristics1 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics1), Option);
+  DisplaySlotCharacteristics2 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics2), Option);
+  if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0xD)) {
+PRINT_STRUCT_VALUE_H (Struct, Type9, SegmentGroupNum);
+PRINT_STRUCT_VALUE_H (Struct, Type9, BusNum);
+PRINT_STRUCT_VALUE_H (Struct, Type9, DevFuncNum);
+  }
+  if (AE_SMBIOS_VERSION (0x3, 0x2)) {
+if (Struct->Hdr->Length > 0x11) {
+  PRINT_STRUCT_VALUE (Struct, Type9, DataBusWidth);
+}
+if (Struct->Hdr->Length > 0x12) {
+  PRINT_STRUCT_VALUE (Struct, Type9, PeerGroupingCount);
+
+  PeerGroupCount = Struct->Type9->PeerGroupingCount;
+  PeerGroupPtr   = Struct->Type9->PeerGroups;
+  for (Index = 0; Index < PeerGroupCount; Index++) {
+ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_SLOT_PEER_GROUPS), gShellDebug1HiiHandle, Index + 1);
+ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_SEGMENT_GROUP_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].SegmentGroupNum);
+ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_BUS_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].BusNum);
+ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_DEV_FUNC_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].DevFuncNum);
+ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_DATA_BUS_WIDTH), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].DataBusWidth);
+  }
+}
+  }
 }
 break;
 
   //
   // On Board Devices Information (Type 10)
@@ -753,10 +776,33 @@ SmbiosPrintStructure (
 if (AE_SMBIOS_VERSION (0x2, 0x8) && (Struct->Hdr->Length > 0x22)) {
   

[edk2] [V2 patch] ShellPkg/SmbiosView: Update SmbiosView for SMBIOS3.2.0

2018-08-28 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1099

Update SmbiosView to parse the new definitions which
are introduced in SMBIOS3.2.0

V2:
1. Add structure length check before dump the fileds in
Type 9 and Type 17 in case some fileds are not organized
and reported by drivers.
2. Dump the InterfaceTypeSpecificData in Type 42.

Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../SmbiosView/PrintInfo.c |  88 +++---
 .../SmbiosView/QueryTable.c| 135 -
 .../SmbiosView/QueryTable.h|  26 +++-
 .../SmbiosView/SmbiosViewStrings.uni   |   9 +-
 4 files changed, 239 insertions(+), 19 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index 93c6094df1..a91677e670 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -541,26 +541,51 @@ SmbiosPrintStructure (
 
   //
   // System Slots (Type 9)
   //
   case 9:
-PRINT_PENDING_STRING (Struct, Type9, SlotDesignation);
-DisplaySystemSlotType (Struct->Type9->SlotType, Option);
-DisplaySystemSlotDataBusWidth (Struct->Type9->SlotDataBusWidth, Option);
-DisplaySystemSlotCurrentUsage (Struct->Type9->CurrentUsage, Option);
-DisplaySystemSlotLength (Struct->Type9->SlotLength, Option);
-DisplaySystemSlotId (
-  Struct->Type9->SlotID,
-  Struct->Type9->SlotType,
-  Option
- );
-DisplaySlotCharacteristics1 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics1), Option);
-DisplaySlotCharacteristics2 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics2), Option);
-if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0xD)) {
-  PRINT_STRUCT_VALUE_H (Struct, Type9, SegmentGroupNum);
-  PRINT_STRUCT_VALUE_H (Struct, Type9, BusNum);
-  PRINT_STRUCT_VALUE_H (Struct, Type9, DevFuncNum);
+{
+  MISC_SLOT_PEER_GROUP  *PeerGroupPtr;
+  UINT8 PeerGroupCount;
+
+  PRINT_PENDING_STRING (Struct, Type9, SlotDesignation);
+  DisplaySystemSlotType (Struct->Type9->SlotType, Option);
+  DisplaySystemSlotDataBusWidth (Struct->Type9->SlotDataBusWidth, Option);
+  DisplaySystemSlotCurrentUsage (Struct->Type9->CurrentUsage, Option);
+  DisplaySystemSlotLength (Struct->Type9->SlotLength, Option);
+  DisplaySystemSlotId (
+Struct->Type9->SlotID,
+Struct->Type9->SlotType,
+Option
+   );
+  DisplaySlotCharacteristics1 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics1), Option);
+  DisplaySlotCharacteristics2 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics2), Option);
+  if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0xD)) {
+PRINT_STRUCT_VALUE_H (Struct, Type9, SegmentGroupNum);
+PRINT_STRUCT_VALUE_H (Struct, Type9, BusNum);
+PRINT_STRUCT_VALUE_H (Struct, Type9, DevFuncNum);
+  }
+  if (AE_SMBIOS_VERSION (0x3, 0x2)) {
+if (Struct->Hdr->Length > 0x11) {
+  PRINT_STRUCT_VALUE (Struct, Type9, DataBusWidth);
+}
+if (Struct->Hdr->Length > 0x12) {
+  PRINT_STRUCT_VALUE (Struct, Type9, PeerGroupingCount);
+
+  PeerGroupCount = Struct->Type9->PeerGroupingCount;
+  if (PeerGroupCount > 0) {
+PeerGroupPtr   = Struct->Type9->PeerGroups;
+for (Index = 0; Index < PeerGroupCount; Index++) {
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_SLOT_PEER_GROUPS), gShellDebug1HiiHandle, Index + 1);
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_SEGMENT_GROUP_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].SegmentGroupNum);
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_BUS_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].BusNum);
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_DEV_FUNC_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].DevFuncNum);
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_DATA_BUS_WIDTH), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].DataBusWidth);
+}
+  }
+}
+  }
 }
 break;
 
   //
   // On Board Devices Information (Type 10)
@@ -753,10 +778,33 @@ SmbiosPrintStructure (
 if (AE_SMBIOS_VERSION (0x2, 0x8) && (Struct->Hdr->Length > 0x22)) {
   PRINT_STRUCT_VALUE (Struct, Type17, MinimumVoltage);
   PRINT_STRUCT_VALUE (Struct, Type17, MaximumVoltage);
   PRINT_STRUCT_VALUE (Struct, Type1

[edk2] [patch] MdeModulePkg/Setup: Fix incorrect size used in AllocateCopyPool

2018-08-27 Thread Dandan Bi
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1115

When the type of HiiValue is EFI_IFR_TYPE_BUFFER,
its question type is EFI_IFR_ORDERED_LIST_OP.
And the buffer size allocated for Statement->BufferValue
of orderedList is "Statement->StorageWidth"
in IfrParse.c.

So here when backup the buffer value and copy the size of
"Statement->StorageWidth + sizeof(CHAR16)" is incorrect.

This patch is to fix this issue.

Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c 
b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
index ded1c7ad11..58daaab404 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
@@ -2002,11 +2002,11 @@ ProcessCallBackFunction (
 //
 // If EFI_BROWSER_ACTION_CHANGING type, back up the new question value.
 //
 if (Action == EFI_BROWSER_ACTION_CHANGING) {
   if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
-BackUpBuffer = AllocateCopyPool(Statement->StorageWidth + 
sizeof(CHAR16), Statement->BufferValue);
+BackUpBuffer = AllocateCopyPool(Statement->StorageWidth, 
Statement->BufferValue);
 ASSERT (BackUpBuffer != NULL);
   } else {
 CopyMem (, >Value, sizeof (EFI_IFR_TYPE_VALUE));
   }
 }
@@ -2128,11 +2128,11 @@ ProcessCallBackFunction (
   // then the browser will use the value passed to Callback() and ignore 
the
   // value returned by Callback().
   //
   if (Action  == EFI_BROWSER_ACTION_CHANGING && Status == EFI_UNSUPPORTED) 
{
 if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
-  CopyMem (Statement->BufferValue, BackUpBuffer, 
Statement->StorageWidth + sizeof(CHAR16));
+  CopyMem (Statement->BufferValue, BackUpBuffer, 
Statement->StorageWidth);
 } else {
   CopyMem (>Value, , sizeof 
(EFI_IFR_TYPE_VALUE));
 }
 
 //
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] ShellPkg/SmbiosView: Update SmbiosView for SMBIOS3.2.0

2018-08-27 Thread Dandan Bi
https://bugzilla.tianocore.org/show_bug.cgi?id=1099
Update SmbiosView to parse the new definitions which
are introduced in SMBIOS3.2.0

Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../SmbiosView/PrintInfo.c |  71 ---
 .../SmbiosView/QueryTable.c| 135 -
 .../SmbiosView/QueryTable.h|  26 +++-
 .../SmbiosView/SmbiosViewStrings.uni   |   9 +-
 4 files changed, 222 insertions(+), 19 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index 93c6094df1..e1b29059b8 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -541,26 +541,45 @@ SmbiosPrintStructure (
 
   //
   // System Slots (Type 9)
   //
   case 9:
-PRINT_PENDING_STRING (Struct, Type9, SlotDesignation);
-DisplaySystemSlotType (Struct->Type9->SlotType, Option);
-DisplaySystemSlotDataBusWidth (Struct->Type9->SlotDataBusWidth, Option);
-DisplaySystemSlotCurrentUsage (Struct->Type9->CurrentUsage, Option);
-DisplaySystemSlotLength (Struct->Type9->SlotLength, Option);
-DisplaySystemSlotId (
-  Struct->Type9->SlotID,
-  Struct->Type9->SlotType,
-  Option
- );
-DisplaySlotCharacteristics1 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics1), Option);
-DisplaySlotCharacteristics2 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics2), Option);
-if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0xD)) {
-  PRINT_STRUCT_VALUE_H (Struct, Type9, SegmentGroupNum);
-  PRINT_STRUCT_VALUE_H (Struct, Type9, BusNum);
-  PRINT_STRUCT_VALUE_H (Struct, Type9, DevFuncNum);
+{
+  MISC_SLOT_PEER_GROUP  *PeerGroupPtr;
+  UINT8 PeerGroupCount;
+
+  PRINT_PENDING_STRING (Struct, Type9, SlotDesignation);
+  DisplaySystemSlotType (Struct->Type9->SlotType, Option);
+  DisplaySystemSlotDataBusWidth (Struct->Type9->SlotDataBusWidth, Option);
+  DisplaySystemSlotCurrentUsage (Struct->Type9->CurrentUsage, Option);
+  DisplaySystemSlotLength (Struct->Type9->SlotLength, Option);
+  DisplaySystemSlotId (
+Struct->Type9->SlotID,
+Struct->Type9->SlotType,
+Option
+   );
+  DisplaySlotCharacteristics1 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics1), Option);
+  DisplaySlotCharacteristics2 (*(UINT8 *) 
&(Struct->Type9->SlotCharacteristics2), Option);
+  if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0xD)) {
+PRINT_STRUCT_VALUE_H (Struct, Type9, SegmentGroupNum);
+PRINT_STRUCT_VALUE_H (Struct, Type9, BusNum);
+PRINT_STRUCT_VALUE_H (Struct, Type9, DevFuncNum);
+  }
+  if (AE_SMBIOS_VERSION (0x3, 0x2) && (Struct->Hdr->Length > 0x11)) {
+PRINT_STRUCT_VALUE (Struct, Type9, DataBusWidth);
+PRINT_STRUCT_VALUE (Struct, Type9, PeerGroupingCount);
+
+PeerGroupCount = Struct->Type9->PeerGroupingCount;
+PeerGroupPtr   = Struct->Type9->PeerGroups;
+for (Index = 0; Index < PeerGroupCount; Index++) {
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_SLOT_PEER_GROUPS), gShellDebug1HiiHandle, Index + 1);
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_SEGMENT_GROUP_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].SegmentGroupNum);
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_BUS_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].BusNum);
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_DEV_FUNC_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].DevFuncNum);
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_DATA_BUS_WIDTH), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].DataBusWidth);
+}
+  }
 }
 break;
 
   //
   // On Board Devices Information (Type 10)
@@ -753,10 +772,23 @@ SmbiosPrintStructure (
 if (AE_SMBIOS_VERSION (0x2, 0x8) && (Struct->Hdr->Length > 0x22)) {
   PRINT_STRUCT_VALUE (Struct, Type17, MinimumVoltage);
   PRINT_STRUCT_VALUE (Struct, Type17, MaximumVoltage);
   PRINT_STRUCT_VALUE (Struct, Type17, ConfiguredVoltage);
 }
+if (AE_SMBIOS_VERSION (0x3, 0x2) && (Struct->Hdr->Length > 0x28)) {
+  DisplayMemoryDeviceMemoryTechnology (Struct->Type17->MemoryTechnology, 
Option);
+  DisplayMemoryDeviceMemoryOperatingModeCapability (ReadUnaligned16 
((UINT16 *) (UINTN) &(Struct->Type17->MemoryOperatingModeCapability.Bits)), 
Option);

[edk2] [patch] MdeModulePkg/SmmCorePerfLib: Add DxeServicesLib library class in INF

2018-08-21 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1100

SmmCorePerformanceLib consume the DxeServicesLib, but miss to
add the library class in INF file.
This patch is to fix this issue.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf 
b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
index 88052f8037..78b783b012 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
@@ -58,10 +58,11 @@
   SmmServicesTableLib
   SmmMemLib
   UefiLib
   ReportStatusCodeLib
   PeCoffGetEntryPointLib
+  DxeServicesLib
 
 [Protocols]
   gEfiSmmBase2ProtocolGuid  ## CONSUMES
   gEdkiiSmmReadyToBootProtocolGuid  ## NOTIFY
 
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/2] MdeModulePkg: Add definition of Boot Performance Table protocol

2018-07-30 Thread Dandan Bi
Add an internal protocol to get the boot performance data,
which is used by driver FirmwarePerformanceDxe to get the
performance data from performance library (DxeCorePerformanceLib).

Cc: Dmitry Antipov 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Include/Guid/FirmwareBootPerformanceTable.h| 47 ++
 MdeModulePkg/MdeModulePkg.dec  |  4 ++
 2 files changed, 51 insertions(+)
 create mode 100644 MdeModulePkg/Include/Guid/FirmwareBootPerformanceTable.h

diff --git a/MdeModulePkg/Include/Guid/FirmwareBootPerformanceTable.h 
b/MdeModulePkg/Include/Guid/FirmwareBootPerformanceTable.h
new file mode 100644
index 00..61a21445c7
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/FirmwareBootPerformanceTable.h
@@ -0,0 +1,47 @@
+/** @file
+
+Firmware Boot Performance Table Protocol.
+
+Copyright (c) 2018, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available 
under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _FIRMWARE_BOOT_PERFORMANCE_TABLE_H_
+#define _FIRMWARE_BOOT_PERFORMANCE_TABLE_H_
+
+//
+// GUID for get firmware boot performance table Protocol
+//
+#define FIRMWARE_BOOT_PERFORMANCE_TABLE_PROTOCOL_GUID \
+  { 0xffc182cf, 0xb0da, 0x4e81, {0xaf, 0xf8, 0x45, 0x0d, 0xab, 0x6d, 0xc9, 
0xa7 } }
+
+typedef struct _EDKII_FIRMWARE_BOOT_PERFORMANCE_TABLE_PROTOCOL 
EDKII_FIRMWARE_BOOT_PERFORMANCE_TABLE_PROTOCOL;
+
+/**
+  Get the address of the Firmware Boot Performance Table.
+
+  @param BootPerformanceTable   - Pointer to the address of firmware boot 
performance table.
+
+  @retval EFI_SUCCESS   - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *GET_FIRMWARE_BOOT_PERFORMANCE_TABLE)(
+  OUT VOID   **BootPerformanceTable
+  );
+
+struct _EDKII_FIRMWARE_BOOT_PERFORMANCE_TABLE_PROTOCOL {
+  GET_FIRMWARE_BOOT_PERFORMANCE_TABLE GetFirmwareBootPerformanceTable;
+};
+
+extern EFI_GUID gEdkiiFirmwareBootPerformanceTableProtocolGuid;
+
+#endif // _FIRMWARE_BOOT_PERFORMANCE_TABLE_H_
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 3db97f536e..5faebe5457 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -263,10 +263,14 @@
   #  Include/Guid/PerformanceMeasurement.h
   gEdkiiPerformanceMeasurementProtocolGuid  = { 0xc85d06be, 0x5f75, 
0x48ce, { 0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87, 0xb1 } }
   gEdkiiSmmPerformanceMeasurementProtocolGuid   = { 0xd56b6d73, 0x1a7b, 
0x4015, { 0x9b, 0xb4, 0x7b, 0x07, 0x17, 0x29, 0xed, 0x24 } }
   gEdkiiPerformanceMeasurementPpiGuid   = { 0x0eca9ae3, 0xa792, 
0x418c, { 0xbd, 0x36, 0X6c, 0x2e, 0xca, 0x5c, 0x59, 0xfc } }
 
+  ## Protocol to get firmware boot performance table.
+  #  Include/Guid/FirmwareBootPerformanceTable.h
+  gEdkiiFirmwareBootPerformanceTableProtocolGuid = { 0xffc182cf, 0xb0da, 
0x4e81, { 0xaf, 0xf8, 0x45, 0x0d, 0xab, 0x6d, 0xc9, 0xa7 } }
+
   ## Guid is defined for CRC32 encapsulation scheme.
   #  Include/Guid/Crc32GuidedSectionExtraction.h
   gEfiCrc32GuidedSectionExtractionGuid = { 0xFC1BCDB0, 0x7D31, 0x49aa, {0x93, 
0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } }
 
   ## Include/Guid/StatusCodeCallbackGuid.h
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 0/2] Enahnce Perf data transfer between Dxe Perf Lib and driver

2018-07-30 Thread Dandan Bi
Add an internal protocol Firmware Boot Performance Table protocol to
get the performance data from DxeCorePerformanceLib.
Thus the FirmwarePerformanceDxe driver can call the API in the
new protocl to get the performance data instead of through
hook status code.

Cc: Dmitry Antipov 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Star Zeng 
Dandan Bi (2):
  MdeModulePkg: Add definition of Boot Performance Table protocol
  MdeModulePkg: Implement/use Boot Performance Table protocol

 .../Include/Guid/FirmwareBootPerformanceTable.h| 47 ++
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 74 ++
 .../DxeCorePerformanceLib.inf  |  6 +-
 .../DxeCorePerformanceLibInternal.h| 15 +
 MdeModulePkg/MdeModulePkg.dec  |  4 ++
 .../FirmwarePerformanceDxe.c   | 71 -
 .../FirmwarePerformanceDxe.inf |  5 +-
 7 files changed, 144 insertions(+), 78 deletions(-)
 create mode 100644 MdeModulePkg/Include/Guid/FirmwareBootPerformanceTable.h

-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/2] MdeModulePkg: Implement/use Boot Performance Table protocol

2018-07-30 Thread Dandan Bi
1.Update DxeCorePerformanceLib to implement the Firmware
Boot performance Table protocol.

2. Update FirmwarePerformanceDxe to use Boot performance
Table protocol get Performance data from DxeCorePerformanceLib

Cc: Dmitry Antipov 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 74 ++
 .../DxeCorePerformanceLib.inf  |  6 +-
 .../DxeCorePerformanceLibInternal.h| 15 +
 .../FirmwarePerformanceDxe.c   | 71 -
 .../FirmwarePerformanceDxe.inf |  5 +-
 5 files changed, 93 insertions(+), 78 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 5798c89fff..7a46be5304 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -88,10 +88,17 @@ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL  *mDevicePathToText = NULL;
 //
 EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
   CreatePerformanceMeasurement,
   };
 
+//
+// Interfaces for Firmware Boot Performance Table Protocol.
+//
+EDKII_FIRMWARE_BOOT_PERFORMANCE_TABLE_PROTOCOL 
mBootPerformanceProtocolInterface = {
+  GetFirmwareBootPerformanceTable,
+  };
+
 PERFORMANCE_PROPERTY  mPerformanceProperty;
 
 /**
   Return the pointer to the FPDT record in the allocated memory.
 
@@ -209,17 +216,21 @@ IsKnownID (
 return FALSE;
   }
 }
 
 /**
-  Allocate buffer for Boot Performance table.
+  Get the address of the Firmware Boot Performance Table.
 
-  @return Status code.
+  @param BootPerformanceTable   - Pointer to the address of firmware boot 
performance table.
 
+  @retval EFI_SUCCESS   - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
 **/
 EFI_STATUS
-AllocateBootPerformanceTable (
+EFIAPI
+GetFirmwareBootPerformanceTable (
+  OUT VOID   **BootPerformanceTable
   )
 {
   EFI_STATUS  Status;
   UINTN   Size;
   UINT8   *SmmBootRecordCommBuffer;
@@ -403,10 +414,12 @@ AllocateBootPerformanceTable (
 
   mBootRecordBuffer  = (UINT8 *) mAcpiBootPerformanceTable;
   mBootRecordSize= mAcpiBootPerformanceTable->Header.Length;
   mBootRecordMaxSize = mBootRecordSize + PcdGet32 
(PcdExtFpdtBootRecordPadSize);
 
+  mFpdtBufferIsReported = TRUE;
+  *BootPerformanceTable = mAcpiBootPerformanceTable;
   return EFI_SUCCESS;
 }
 
 /**
   Get a human readable module name and module guid for the given image handle.
@@ -1302,48 +1315,10 @@ InternalGetPeiPerformance (
 //
 GuidHob = GetNextGuidHob (, 
GET_NEXT_HOB (GuidHob));
   }
 }
 
-/**
-  Report Boot Perforamnce table address as report status code.
-
-  @param  EventThe event of notify protocol.
-  @param  Context  Notify event context.
-
-**/
-VOID
-EFIAPI
-ReportFpdtRecordBuffer (
-  IN EFI_EVENT Event,
-  IN VOID  *Context
-  )
-{
-  EFI_STATUS  Status;
-  UINT64  BPDTAddr;
-
-  if (!mFpdtBufferIsReported) {
-Status = AllocateBootPerformanceTable ();
-if (!EFI_ERROR(Status)) {
-  BPDTAddr = (UINT64)(UINTN)mAcpiBootPerformanceTable;
-  REPORT_STATUS_CODE_EX (
-  EFI_PROGRESS_CODE,
-  EFI_SOFTWARE_DXE_BS_DRIVER,
-  0,
-  NULL,
-  ,
-  ,
-  sizeof (UINT64)
-  );
-}
-//
-// Set FPDT report state to TRUE.
-//
-mFpdtBufferIsReported = TRUE;
-  }
-}
-
 /**
   The constructor function initializes Performance infrastructure for DXE 
phase.
 
   The constructor function publishes Performance and PerformanceEx protocol, 
allocates memory to log DXE performance
   and merges PEI performance data to DXE performance log.
@@ -1362,11 +1337,10 @@ DxeCorePerformanceLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
   EFI_STATUSStatus;
   EFI_HANDLEHandle;
-  EFI_EVENT ReadyToBootEvent;
   PERFORMANCE_PROPERTY  *PerformanceProperty;
 
   if (!PerformanceMeasurementEnabled ()) {
 //
 // Do not initialize performance infrastructure if not required.
@@ -1385,28 +1359,16 @@ DxeCorePerformanceLibConstructor (
   Handle = NULL;
   Status = gBS->InstallMultipleProtocolInterfaces (
   ,
   ,
   ,
+  ,
+  ,
   NULL
   );
   ASSERT_EFI_ERROR (Status);
 
-  //
-  // Register ReadyToBoot event to report StatusCode data
-  //
-  Status = gBS->CreateEventEx (
-  EVT_NOTIFY_SIGNAL,
-  TPL_CALLBACK,
-  ReportFpdtRec

[edk2] [patch 2/3] MdeModulePkg/PeiPerformanceLib: Produce the new PerformancePpi

2018-07-30 Thread Dandan Bi
Enhance the PeiPerformanceLib to produce the Performance
Measurement PPI.

Cc: Dmitry Antipov 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c  | 81 ++
 .../PeiPerformanceLib/PeiPerformanceLib.inf|  1 +
 2 files changed, 82 insertions(+)

diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c 
b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
index 808a63501e..528bf12303 100644
--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
@@ -30,14 +30,52 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #define  STRING_SIZE(FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof 
(CHAR8))
 #define  PEI_MAX_RECORD_SIZE(sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD) + 
STRING_SIZE)
 
+/**
+  Create performance record with event description and a timestamp.
+
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID.
+  @param Guid  - Pointer to a GUID.
+  @param String- Pointer to a string describing the measurement.
+  @param TimeStamp - 64-bit time stamp.
+  @param Address   - Pointer to a location in memory relevant to the 
measurement.
+  @param Identifier- Performance identifier describing the type of 
measurement.
+  @param Attribute - The attribute of the measurement. According to 
attribute can create a start
+ record for PERF_START/PERF_START_EX, or a end 
record for PERF_END/PERF_END_EX,
+ or a general record for other Perf macros.
+
+  @retval EFI_SUCCESS   - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
+  @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+  pointer or invalid PerfId.
+**/
+EFI_STATUS
+EFIAPI
+CreatePerformanceMeasurementPpi (
+  IN CONST VOID*CallerIdentifier,
+  IN CONST VOID*Guid,   OPTIONAL
+  IN CONST CHAR8   *String, OPTIONAL
+  IN   UINT64  TimeStamp,
+  IN   UINT64  Address,  OPTIONAL
+  IN   UINT32  Identifier,
+  IN   PERF_MEASUREMENT_ATTRIBUTE  Attribute
+  );
+
+EDKII_PERFORMANCE_MEASUREMENT_PPI mPerformancePpi = 
{CreatePerformanceMeasurementPpi};
+
+EFI_PEI_PPI_DESCRIPTOR  mPerformancePpiDesc = {
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+  ,
+  
+};
 
 /**
   Return the pointer to the FPDT record in the allocated memory.
 
   @param  RecordSizeThe size of FPDT record.
@@ -56,10 +94,12 @@ GetFpdtRecordPtr (
 {
   UINT16PeiPerformanceLogEntries;
   UINTN PeiPerformanceSize;
   UINT8 *PeiFirmwarePerformance;
   EFI_HOB_GUID_TYPE *GuidHob;
+  EFI_HOB_GUID_TYPE *FirstGuidHob;
+  EFI_STATUSStatus;
 
   //
   // Get the number of PeiPerformanceLogEntries form PCD.
   //
   PeiPerformanceLogEntries = (UINT16) (PcdGet16 
(PcdMaxPeiPerformanceLogEntries16) != 0 ?
@@ -68,10 +108,11 @@ GetFpdtRecordPtr (
 
   //
   // Create GUID HOB Data.
   //
   GuidHob = GetFirstGuidHob ();
+  FirstGuidHob = GuidHob;
   PeiFirmwarePerformance = NULL;
   while (GuidHob != NULL) {
 //
 // PEI Performance HOB was found, then return the existing one.
 //
@@ -89,10 +130,16 @@ GetFpdtRecordPtr (
 //
 GuidHob = GetNextGuidHob (, 
GET_NEXT_HOB (GuidHob));
   }
 
   if (GuidHob == NULL) {
+if (FirstGuidHob == NULL) {
+  Status = PeiServicesInstallPpi();
+  if (EFI_ERROR(Status)) {
+DEBUG((DEBUG_ERROR, "PeiCorePerformanceLib - %a - InstallPpi returned 
%r!\n", __FUNCTION__, Status));
+  }
+}
 //
 // PEI Performance HOB was not found, then build one.
 //
 PeiPerformanceSize  = sizeof (FPDT_PEI_EXT_PERF_HEADER) +
   PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntries;
@@ -513,10 +560,44 @@ InsertFpdtRecord (
   PeiPerformanceLogHeader->SizeOfAllEntries += 
FpdtRecordPtr.RecordHeader->Length;
 
   return EFI_SUCCESS;
 }
 
+/**
+  Create performance record with event description and a timestamp.
+
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID.
+  @param Guid  - Pointer to a GUID.
+  @param String- Pointer to a string describing the measurement.
+  @param TimeStamp - 64-bit time stamp.
+  @param Address   - Pointer to a location in memory relevant to the 
measur

[edk2] [patch 3/3] MdeModulePkg/PeiPerformancePpiLib: Add PeiPerformancePpiLib

2018-07-30 Thread Dandan Bi
Add a new "thin" PerformanceLib instance
PeiPerformancePpiLib which will locate a
Performance measurement Ppi to log performance data.

Platform can link the "thin" PeiPerformancePpiLib
to log the performance data for PEIMs.
It also can link the PeiPerformanceLib in PEI phase
to keep the compatibility.

Cc: Dmitry Antipov 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.c| 420 +
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.inf  |  49 +++
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.uni  |  23 ++
 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 4 files changed, 493 insertions(+)
 create mode 100644 
MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c
 create mode 100644 
MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf
 create mode 100644 
MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.uni

diff --git a/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c 
b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c
new file mode 100644
index 00..e1ac6b6b61
--- /dev/null
+++ b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c
@@ -0,0 +1,420 @@
+/** @file
+Performance library instance used for PEIMs
+
+This library provides the performance measurement interfaces in PEI phase, It 
locates
+performance measurement PPI to log the performance data.
+
+Copyright (c) 2018, Intel Corporation. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD 
License
+which accompanies this distribution.  The full text of the license may be 
found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+/**
+  Create performance record with event description and a timestamp.
+  This function locates the Performance PPI and calls it with the same 
parameters.
+
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID.
+  @param Guid  - Pointer to a GUID.
+  @param String- Pointer to a string describing the measurement.
+  @param TimeStamp - 64-bit time stamp.
+  @param Address   - Pointer to a location in memory relevant to the 
measurement.
+  @param Identifier- Performance identifier describing the type of 
measurement.
+  @param Attribute - The attribute of the measurement. According to 
attribute can create a start
+ record for PERF_START/PERF_START_EX, or a end 
record for PERF_END/PERF_END_EX,
+ or a general record for other Perf macros.
+
+  @retval EFI_SUCCESS   - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
+  @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+  pointer or invalid PerfId.
+**/
+RETURN_STATUS
+CreatePerformanceMeasurement (
+  IN CONST VOID  *CallerIdentifier,  OPTIONAL
+  IN CONST VOID  *Guid,OPTIONAL
+  IN CONST CHAR8 *String,  OPTIONAL
+  IN UINT64  TimeStamp,OPTIONAL
+  IN UINT64  Address,  OPTIONAL
+  IN UINT32  Identifier,
+  IN PERF_MEASUREMENT_ATTRIBUTE  Attribute
+  )
+{
+  EFI_STATUS  Status;
+  EDKII_PERFORMANCE_MEASUREMENT_PPI   *PerformancePpi;
+
+  Status = PeiServicesLocatePpi (
+,
+0,
+NULL,
+(VOID **) 
+);
+
+  if (!EFI_ERROR(Status)) {
+return (RETURN_STATUS) 
PerformancePpi->CreatePerformanceMeasurementPpi(CallerIdentifier, Guid, String, 
TimeStamp, Address, Identifier, Attribute);
+  } else {
+return RETURN_NOT_READY;
+  }
+}
+
+/**
+  Creates a record for the beginning of a performance measurement.
+
+  If TimeStamp is zero, then this function reads the current time stamp
+  and adds that time stamp value to the record as the start time.
+
+  If TimeStamp is one, then this function reads 0 as the start time.
+
+  If TimeStamp is other value, then TimeStamp is added to the record as the 
start time.
+
+  @param  Handle  Pointer to environment specific context used
+  to identify the component being measured.
+  @param  Token   Pointer to a Null-terminated ASCII string
+  that identifies the component being measured.
+  @param  Module  Pointer to a Null-terminated ASCII string
+

[edk2] [patch 0/3] Add PeiPerformancePpiLib

2018-07-30 Thread Dandan Bi
Enhance the PeiPerformanceLib to install the Performance
Measurement PPI.

Add a new "thin" PerformanceLib instance
PeiPerformancePpiLib which will locate a
Performance measurement Ppi to log performance data.

Platform can link the "thin" PeiPerformancePpiLib
to log the performance data for PEIMs.
It also can link the PeiPerformanceLib in PEI phase
to keep the compatibility.

Cc: Dmitry Antipov 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Star Zeng 

Dandan Bi (3):
  MdeModulePkg: Add the definition of performance measurement PPI
  MdeModulePkg/PeiPerformanceLib: Produce the new PerformancePpi
  MdeModulePkg/PeiPerformancePpiLib: Add PeiPerformancePpiLib

 MdeModulePkg/Include/Guid/PerformanceMeasurement.h |  14 +
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c  |  81 
 .../PeiPerformanceLib/PeiPerformanceLib.inf|   1 +
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.c| 420 +
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.inf  |  49 +++
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.uni  |  23 ++
 MdeModulePkg/MdeModulePkg.dec  |   1 +
 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 8 files changed, 590 insertions(+)
 create mode 100644 
MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c
 create mode 100644 
MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf
 create mode 100644 
MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.uni

-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/3] MdeModulePkg: Add the definition of performance measurement PPI

2018-07-30 Thread Dandan Bi
Cc: Dmitry Antipov 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Include/Guid/PerformanceMeasurement.h | 14 ++
 MdeModulePkg/MdeModulePkg.dec  |  1 +
 2 files changed, 15 insertions(+)

diff --git a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h 
b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
index 0c3eb593a0..099504c6d6 100644
--- a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
+++ b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
@@ -73,6 +73,20 @@ struct _EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL {
 };
 
 extern EFI_GUID gEdkiiPerformanceMeasurementProtocolGuid;
 extern EFI_GUID gEdkiiSmmPerformanceMeasurementProtocolGuid;
 
+//
+// Performance measurement PPI.
+//
+#define PERFORMANCE_MEASUREMENT_PPI_GUID \
+  { 0x0eca9ae3, 0xa792, 0x418c, {0xbd, 0x36, 0X6c, 0x2e, 0xca, 0x5c, 0x59, 
0xfc } }
+
+typedef struct _EDKII_PERFORMANCE_MEASUREMENT_PPI 
EDKII_PERFORMANCE_MEASUREMENT_PPI;
+
+struct _EDKII_PERFORMANCE_MEASUREMENT_PPI {
+  CREATE_PERFORMANCE_MEASUREMENT   CreatePerformanceMeasurementPpi;
+};
+
+extern EFI_GUID gEdkiiPerformanceMeasurementPpiGuid;
+
 #endif // _PERFORMANCE_MEASUREMENT_H_
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 6a6d9660ed..3db97f536e 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -261,10 +261,11 @@
   gPerformanceExProtocolGuid = { 0x1ea81bec, 0xf01a, 0x4d98, { 0xa2, 0x1,  
0x4a, 0x61, 0xce, 0x2f, 0xc0, 0x22 } }
   gSmmPerformanceExProtocolGuid  = { 0x931fc048, 0xc71d, 0x4455, { 0x89, 0x30, 
0x47, 0x6,  0x30, 0xe3, 0xe,  0xe5 } }
   #  Include/Guid/PerformanceMeasurement.h
   gEdkiiPerformanceMeasurementProtocolGuid  = { 0xc85d06be, 0x5f75, 
0x48ce, { 0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87, 0xb1 } }
   gEdkiiSmmPerformanceMeasurementProtocolGuid   = { 0xd56b6d73, 0x1a7b, 
0x4015, { 0x9b, 0xb4, 0x7b, 0x07, 0x17, 0x29, 0xed, 0x24 } }
+  gEdkiiPerformanceMeasurementPpiGuid   = { 0x0eca9ae3, 0xa792, 
0x418c, { 0xbd, 0x36, 0X6c, 0x2e, 0xca, 0x5c, 0x59, 0xfc } }
 
   ## Guid is defined for CRC32 encapsulation scheme.
   #  Include/Guid/Crc32GuidedSectionExtraction.h
   gEfiCrc32GuidedSectionExtractionGuid = { 0xFC1BCDB0, 0x7D31, 0x49aa, {0x93, 
0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } }
 
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 3/4] ShellPkg: Remove DxeSmmPerformanceLib

2018-07-29 Thread Dandan Bi
DxeSmmPerformanceLib previously is used by DP tool.
But in new pweformance infrastructure, we have updated
Dp tool to get the performance data from firmware
performance data table in ACPI.
So remove the usage of DxeSmmPerformanceLib here.

Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/ShellPkg.dsc | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index cb2a2422ed..59dd07e0ae 100644
--- a/ShellPkg/ShellPkg.dsc
+++ b/ShellPkg/ShellPkg.dsc
@@ -127,15 +127,10 @@
   }
   ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
   ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
-
-  
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
-  }
-  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf {
-
-  
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
   }
+  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/4] Vlv2TbltDevicePkg: Remove DxeSmmPerformanceLib

2018-07-29 Thread Dandan Bi
DxeSmmPerformanceLib previously is used by DP tool.
But in new pweformance infrastructure, we have updated
Dp tool to get the performance data from firmware
performance data table in ACPI.
So remove the usage of DxeSmmPerformanceLib here.

Cc: David Wei 
Cc: Mang Guo 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 2 --
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 2 --
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 2 --
 3 files changed, 6 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index af845ed19f..8b8a55ae6f 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -1292,12 +1292,10 @@ 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
   #
 !if $(PERFORMANCE_ENABLE) == TRUE
   ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
-
-  
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
   }
 !endif
 
   Vlv2TbltDevicePkg/VlvPlatformInitDxe/VlvPlatformInitDxe.inf{
 
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 44a6fcab18..cbdfb1b83a 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -1280,12 +1280,10 @@ 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
   #
 !if $(PERFORMANCE_ENABLE) == TRUE
   ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
-
-  
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
   }
 !endif
 
   Vlv2TbltDevicePkg/VlvPlatformInitDxe/VlvPlatformInitDxe.inf{
 
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 0217a2818f..6396f7aad4 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -1292,12 +1292,10 @@ 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
   #
 !if $(PERFORMANCE_ENABLE) == TRUE
   ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
-
-  
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
   }
 !endif
 
   Vlv2TbltDevicePkg/VlvPlatformInitDxe/VlvPlatformInitDxe.inf{
 
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 0/4] Remove DxeSmmPerformanceLib

2018-07-29 Thread Dandan Bi
DxeSmmPerformanceLib previously is used by DP tool.
But in new pweformance infrastructure, we have updated
Dp tool to get the performance data from firmware
performance data table in ACPI.
Now the DxeSmmPerformanceLib is not used by
any module. So remove it from edk2 code base to
avoid being used by mistake.

Dandan Bi (4):
  QuarkPlatformPkg: Remove DxeSmmPerformanceLib
  Vlv2TbltDevicePkg: Remove DxeSmmPerformanceLib
  ShellPkg: Remove DxeSmmPerformanceLib
  MdeModulePkg: Remove DxeSmmPerformanceLib

 .../DxeSmmPerformanceLib/DxeSmmPerformanceLib.c| 866 -
 .../DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf  |  68 --
 .../DxeSmmPerformanceLib/DxeSmmPerformanceLib.uni  |  24 -
 MdeModulePkg/MdeModulePkg.dsc  |   1 -
 QuarkPlatformPkg/Quark.dsc |   2 -
 QuarkPlatformPkg/QuarkMin.dsc  |   4 +-
 ShellPkg/ShellPkg.dsc  |   7 +-
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc|   2 -
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc  |   2 -
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc   |   2 -
 10 files changed, 2 insertions(+), 976 deletions(-)
 delete mode 100644 
MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c
 delete mode 100644 
MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
 delete mode 100644 
MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.uni

-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 4/4] MdeModulePkg: Remove DxeSmmPerformanceLib

2018-07-29 Thread Dandan Bi
DxeSmmPerformanceLib previously is used by DP tool.
But in new pweformance infrastructure, we have updated
Dp tool to get the performance data from firmware
performance data table in ACPI.
Now the DxeSmmPerformanceLib is not used by
any module. So remove it from edk2 code base to
avoid being used by mistake.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeSmmPerformanceLib/DxeSmmPerformanceLib.c| 866 -
 .../DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf  |  68 --
 .../DxeSmmPerformanceLib/DxeSmmPerformanceLib.uni  |  24 -
 MdeModulePkg/MdeModulePkg.dsc  |   1 -
 4 files changed, 959 deletions(-)
 delete mode 100644 
MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c
 delete mode 100644 
MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
 delete mode 100644 
MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.uni

diff --git a/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c 
b/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c
deleted file mode 100644
index 353174724e..00
--- a/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c
+++ /dev/null
@@ -1,866 +0,0 @@
-/** @file
-  Performance library instance used in DXE phase to dump both PEI/DXE and SMM 
performance data.
-
-  This library instance allows a DXE driver or UEFI application to dump both 
PEI/DXE and SMM performance data.
-  StartPerformanceMeasurement(), EndPerformanceMeasurement(), 
StartPerformanceMeasurementEx()
-  and EndPerformanceMeasurementEx() are not implemented.
-
-  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD 
License
-which accompanies this distribution.  The full text of the license may be 
found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-
-#include 
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#include 
-#include 
-
-#define SMM_PERFORMANCE_COMMUNICATION_BUFFER_SIZE (OFFSET_OF 
(EFI_SMM_COMMUNICATE_HEADER, Data)  + sizeof (SMM_PERF_COMMUNICATE))
-
-EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication = NULL;
-UINT8   *mSmmPerformanceBuffer;
-GAUGE_DATA_ENTRY*mGaugeData = NULL;
-UINTN   mGaugeNumberOfEntries = 0;
-GAUGE_DATA_ENTRY_EX *mGaugeDataEx = NULL;
-UINTN   mGaugeNumberOfEntriesEx = 0;
-
-BOOLEAN mNoSmmPerfHandler = FALSE;
-BOOLEAN mNoSmmPerfExHandler = FALSE;
-
-//
-// The cached Performance Protocol and PerformanceEx Protocol interface.
-//
-PERFORMANCE_PROTOCOL*mPerformance = NULL;
-PERFORMANCE_EX_PROTOCOL *mPerformanceEx = NULL;
-
-/**
-  The function caches the pointer to SMM Communication protocol.
-
-  The function locates SMM Communication protocol from protocol database.
-
-  @retval EFI_SUCCESS SMM Communication protocol is successfully located.
-  @retval Other   SMM Communication protocol is not located to log 
performance.
-
-**/
-EFI_STATUS
-GetCommunicationProtocol (
-  VOID
-  )
-{
-  EFI_STATUS  Status;
-  EFI_SMM_COMMUNICATION_PROTOCOL  *Communication;
-
-  if (mSmmCommunication != NULL) {
-return EFI_SUCCESS;
-  }
-
-  Status = gBS->LocateProtocol (, NULL, (VOID 
**) );
-  if (!EFI_ERROR (Status)) {
-ASSERT (Communication != NULL);
-//
-// Cache SMM Communication protocol.
-//
-mSmmCommunication = Communication;
-  }
-
-  return Status;
-}
-
-/**
-  The function caches the pointers to PerformanceEx protocol and Performance 
Protocol.
-
-  The function locates PerformanceEx protocol and Performance Protocol from 
protocol database.
-
-  @retval EFI_SUCCESS PerformanceEx protocol or Performance Protocol is 
successfully located.
-  @retval EFI_NOT_FOUND   Both PerformanceEx protocol and Performance Protocol 
are not located to log performance.
-
-**/
-EFI_STATUS
-GetPerformanceProtocol (
-  VOID
-  )
-{
-  EFI_STATUSStatus;
-  PERFORMANCE_PROTOCOL  *Performance;
-  PERFORMANCE_EX_PROTOCOL   *PerformanceEx;
-
-  if (mPerformanceEx != NULL || mPerformance != NULL) {
-return EFI_SUCCESS;
-  }
-
-  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
-  if (!EFI_ERROR (Status)) {
-ASSERT (PerformanceEx != NULL);
-//
-// Cache PerformanceEx Protocol.
-//
-mPerformanceEx = PerformanceEx;
-return EFI_SUCCESS;
-  }
-
-  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
-  if (!EFI_ERROR (Status)) {
-ASSERT (Performance != NULL);
- 

[edk2] [patch 1/4] QuarkPlatformPkg: Remove DxeSmmPerformanceLib

2018-07-29 Thread Dandan Bi
DxeSmmPerformanceLib previously is used by DP tool.
But in new pweformance infrastructure, we have updated
Dp tool to get the performance data from firmware
performance data table in ACPI.
So remove the usage of DxeSmmPerformanceLib here.

Cc: Michael D Kinney 
Cc: Kelly Steele 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 QuarkPlatformPkg/Quark.dsc| 2 --
 QuarkPlatformPkg/QuarkMin.dsc | 4 +---
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/QuarkPlatformPkg/Quark.dsc b/QuarkPlatformPkg/Quark.dsc
index 14142087bd..96ae404f47 100644
--- a/QuarkPlatformPkg/Quark.dsc
+++ b/QuarkPlatformPkg/Quark.dsc
@@ -891,12 +891,10 @@
   #
 !if $(PERFORMANCE_ENABLE)
   ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
-
-  
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
   }
 !endif
 
   #
   # Force Recovery Application
diff --git a/QuarkPlatformPkg/QuarkMin.dsc b/QuarkPlatformPkg/QuarkMin.dsc
index 404f507966..d7a25686a3 100644
--- a/QuarkPlatformPkg/QuarkMin.dsc
+++ b/QuarkPlatformPkg/QuarkMin.dsc
@@ -1,10 +1,10 @@
 ## @file
 # Clanton Peak CRB platform with 32-bit DXE for 4MB/8MB flash devices.
 #
 # This package provides Clanton Peak CRB platform specific modules.
-# Copyright (c) 2013 - 2017 Intel Corporation.
+# Copyright (c) 2013 - 2018 Intel Corporation.
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
 # which accompanies this distribution.  The full text of the license may be 
found at
 # http://opensource.org/licenses/bsd-license.php
@@ -619,12 +619,10 @@
   #
 !if $(PERFORMANCE_ENABLE)
   ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
-
-  
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
   }
 !endif
 
   ShellPkg/Application/Shell/Shell.inf {
 
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 4/4] ShellPkg/UefiShellAcpiViewCommandLib: Fix GCC build failure

2018-07-29 Thread Dandan Bi
Fix following GCC build issues:
1.
xxx/SratParser.c:127:47: error:
initialization from incompatible pointer type
[-Werror=incompatible-pointer-types]
{L"Proximity Domain [31:8]", 3, 9, L"0x%x", DumpSratApicProximity,
^
xxx/SratParser.c:127:47: note:
(near initialization for 'SratApciSapicAffinityParser[6].PrintFormatter')

2.
xxx\UefiShellAcpiViewCommandLib.c:66:14:
error: 'Status' may be used uninitialized in this fu
nction [-Werror=maybe-uninitialized]
   EFI_STATUS Status;
  ^

cc: Alexei Fedorov 
cc: Ruiyu Ni 
cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c  | 2 ++
 .../Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c   | 1 +
 2 files changed, 3 insertions(+)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
index 043277aabf..e3f5567bec 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
@@ -46,10 +46,11 @@ ValidateSratReserved (
   @param [in] Format  Format string for tracing the data.
   @param [in] Ptr Pointer to the start of the buffer.
 **/
 STATIC
 VOID
+EFIAPI
 DumpSratApicProximity (
   IN  CONST CHAR16*  Format,
   IN  UINT8* Ptr
   );
 
@@ -170,10 +171,11 @@ ValidateSratReserved (
   @param [in] Format  Format string for tracing the data.
   @param [in] Ptr Pointer to the start of the buffer.
 **/
 STATIC
 VOID
+EFIAPI
 DumpSratApicProximity (
  IN CONST CHAR16* Format,
  IN UINT8*Ptr
  )
 {
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index c2f40009ee..245700a253 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -64,10 +64,11 @@ RegisterAllParsers (
   )
 {
   EFI_STATUS Status;
   UINTN Count;
 
+  Status = EFI_SUCCESS;
   Count = sizeof (ParserList) / sizeof (ParserList[0]);
 
   while (Count-- != 0) {
 Status = RegisterParser (
ParserList[Count].Signature,
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/4] ShellPkg/UefiShellAcpiViewCommandLib: Fix VS2012 build failure

2018-07-29 Thread Dandan Bi
Fix following build error:
UefiShellAcpiViewCommandLib\AcpiParser.c(519) :
error C2308: concatenating mismatched strings
Concatenating wide "ERROR: %a: Offset Mismatch for %s"
with narrow "CurrentOffset = %d FieldOffset = %d"

cc: Alexei Fedorov 
cc: Ruiyu Ni 
cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c   | 2 +-
 .../Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c   | 2 +-
 .../Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c   | 6 +++---
 .../Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c   | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
index 630c41b71d..18c4983e95 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
@@ -514,11 +514,11 @@ ParseAcpi (
 
 if (Offset != Parser[Index].Offset) {
   IncrementErrorCount ();
   Print (
 L"\nERROR: %a: Offset Mismatch for %s\n"
-  "CurrentOffset = %d FieldOffset = %d\n",
+  L"CurrentOffset = %d FieldOffset = %d\n",
 AsciiName,
 Parser[Index].NameStr,
 Offset,
 Parser[Index].Offset
 );
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
index bc8b7b00e3..e6185d2755 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
@@ -118,11 +118,11 @@ ValidateNameSpaceStrLen (
 
   if (NameSpaceStrLen < 2) {
 IncrementErrorCount ();
 Print (
   L"\nERROR: NamespaceString Length = %d. If no Namespace device exists,\n"
-   "then NamespaceString[] must contain a period '.'",
+   L"then NamespaceString[] must contain a period '.'",
   NameSpaceStrLen
   );
   }
 }
 
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
index a704b0c631..999ac698ec 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
@@ -229,11 +229,11 @@ ParseAcpiMadt (
 if (((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength) ||
 (*MadtInterruptControllerLength < 4)) {
   IncrementErrorCount ();
   Print (
  L"ERROR: Invalid Interrupt Controller Length,"
-  " Type = %d, Length = %d\n",
+  L" Type = %d, Length = %d\n",
  *MadtInterruptControllerType,
  *MadtInterruptControllerLength
  );
   break;
 }
@@ -254,11 +254,11 @@ ParseAcpiMadt (
   case EFI_ACPI_6_2_GICD: {
 if (++GICDCount > 1) {
   IncrementErrorCount ();
   Print (
 L"ERROR: Only one GICD must be present,"
-  " GICDCount = %d\n",
+  L" GICDCount = %d\n",
 GICDCount
 );
 }
 ParseAcpi (
   TRUE,
@@ -309,11 +309,11 @@ ParseAcpiMadt (
 
   default: {
 IncrementErrorCount ();
 Print (
   L"ERROR: Unknown Interrupt Controller Structure,"
-" Type = %d, Length = %d\n",
+L" Type = %d, Length = %d\n",
   *MadtInterruptControllerType,
   *MadtInterruptControllerLength
   );
   }
 } // switch
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
index c38666d2b7..6496a3d624 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
@@ -117,11 +117,11 @@ ParseAcpiSlit (
   // Element[x][x] must be equal to 10
   if ((Count == Index) && (SLIT_ELEMENT (LocalityPtr, Count,Index) != 10)) 
{
 IncrementErrorCount ();
 Print (
   L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)."
-" Normalized Value is not 10\n",
+L" Normalized Value is not 10\n",
   Count,
   Index,
   SLIT_ELEMENT (LocalityPtr, Count, Index)
   );
   }
@@ -129,11 +129,11 @@ ParseAcpiSlit (
   if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=
   SLIT_ELEMENT (LocalityPtr, Index, Count)) {
 IncrementErrorCount ();
 Print (
   L"ERROR: Relative distances for El

[edk2] [patch 3/4] ShellPkg/UefiShellAcpiViewCommandLib: Fix VS build failure

2018-07-29 Thread Dandan Bi
Fix following warnings:
1.
xxx\GtdtParser.c(179): warning C4244:
'=': conversion from 'UINT32' to 'UINT16', possible loss of data
xxx\GtdtParser.c(180): warning C4244:
'-=': conversion from 'UINT32' to 'UINT16', possible loss of data
xxx\GtdtParser.c(196): warning C4244:
'-=': conversion from 'UINT32' to 'UINT16', possible loss of data

2.
xxx\XsdtParser.c(99): warning C4457:
declaration of 'Ptr' hides function parameter

cc: Alexei Fedorov 
cc: Ruiyu Ni 
cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c|  6 +++---
 .../UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c| 12 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
index 3a3cee948a..d5671081da 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
@@ -174,12 +174,12 @@ DumpGTBlock (
  "GT Block",
  Ptr,
  Length,
  PARSER_PARAMS (GtBlockParser)
  );
-  GTBlockTimerLength = (*GtBlockLength - Offset) / (*GtBlockTimerCount);
-  Length -= Offset;
+  GTBlockTimerLength = (*GtBlockLength - (UINT16)Offset) / 
(UINT16)(*GtBlockTimerCount);
+  Length -= (UINT16)Offset;
 
   if (*GtBlockTimerCount != 0) {
 Ptr += (*GtBlockTimerOffset);
 Index = 0;
 while ((Index < (*GtBlockTimerCount)) && (Length >= GTBlockTimerLength)) {
@@ -191,11 +191,11 @@ DumpGTBlock (
  GTBlockTimerLength,
  PARSER_PARAMS (GtBlockTimerParser)
  );
   // Increment by GT Block Timer structure size
   Ptr += Offset;
-  Length -= Offset;
+  Length -= (UINT16)Offset;
   Index++;
 }
 
 if (Length != 0) {
   IncrementErrorCount ();
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
index 99521cd67a..341a61b8fb 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
@@ -63,10 +63,11 @@ ParseAcpiXsdt (
   UINT32Offset;
   UINT32TableOffset;
   UINT64*   TablePointer;
   UINTN EntryIndex;
   CHAR16Buffer[32];
+  UINT8*Pointer;
 
   // Parse the ACPI header to get the length
   ParseAcpi (
 FALSE,
 0,
@@ -94,30 +95,29 @@ ParseAcpiXsdt (
   CONST UINT32* Signature;
   CONST UINT32* Length;
   CONST UINT8*  Revision;
 
   if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
-UINT8*  Ptr;
 
 ParseAcpiHeader (
   (UINT8*)(UINTN)(*TablePointer),
   ,
   ,
   
   );
 
-Ptr = (UINT8*)Signature;
+Pointer = (UINT8*)Signature;
 
 UnicodeSPrint (
   Buffer,
   sizeof (Buffer),
   L"Entry[%d] - %c%c%c%c",
   EntryIndex++,
-  Ptr[0],
-  Ptr[1],
-  Ptr[2],
-  Ptr[3]
+  Pointer[0],
+  Pointer[1],
+  Pointer[2],
+  Pointer[3]
   );
   } else {
 UnicodeSPrint (
   Buffer,
   sizeof (Buffer),
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/4] ShellPkg/UefiShellAcpiViewCommandLib: Fix VS2012 build failure

2018-07-29 Thread Dandan Bi
Fix following build error:
xxx\AcpiParser.c(487) : error C2275: 'UINTN' :
illegal use of this type as an expression
xxx\ProcessorBind.h(224) : see declaration of 'UINTN'
xxx\AcpiParser.c(487) : error C2146: syntax error :
missing ';' before identifier 'OriginalAttribute'
xxx\AcpiParser.c(487) : error C2065: 'OriginalAttribute' :
undeclared identifier
..

cc: Alexei Fedorov 
cc: Ruiyu Ni 
cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
index 6d3bc451ac..630c41b71d 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
@@ -474,19 +474,19 @@ ParseAcpi (
 )
 {
   UINT32  Index;
   UINT32  Offset;
   BOOLEAN HighLight;
+  UINTN   OriginalAttribute;
 
   Offset = 0;
 
   // Increment the Indent
   gIndent += Indent;
 
   if (Trace && (AsciiName != NULL)){
 HighLight = GetColourHighlighting ();
-UINTN   OriginalAttribute;
 
 if (HighLight) {
   OriginalAttribute = gST->ConOut->Mode->Attribute;
   gST->ConOut->SetAttribute (
  gST->ConOut,
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 0/4] ShellPkg/UefiShellAcpiViewCommandLib: Fix build issues

2018-07-29 Thread Dandan Bi
Fix VS and GCC build failure issues

cc: Alexei Fedorov 
cc: Ruiyu Ni 
cc: Jaben Carsey 
Dandan Bi (4):
  ShellPkg/UefiShellAcpiViewCommandLib: Fix VS2012 build failure
  ShellPkg/UefiShellAcpiViewCommandLib: Fix VS2012 build failure
  ShellPkg/UefiShellAcpiViewCommandLib: Fix VS build failure
  ShellPkg/UefiShellAcpiViewCommandLib: Fix GCC build failure

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c|  4 ++--
 .../UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c|  2 +-
 .../UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c|  6 +++---
 .../UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c|  6 +++---
 .../UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c|  4 ++--
 .../UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c|  2 ++
 .../UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c| 12 ++--
 .../UefiShellAcpiViewCommandLib.c|  1 +
 8 files changed, 20 insertions(+), 17 deletions(-)

-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] ShellPkg/Dp: Cumulate the perf data of "DB:Stop"

2018-07-19 Thread Dandan Bi
Currently DP tool will cumulate the performance data for
Driver Binding Support/Start, will count the number they
appears, and record the maximum/minimum time value...
Now add Driver Binding Stop performance data to the
cumulative data to keep consistency.

Cc: Liming Gao 
Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index 213f6057c9..2c094b63c9 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -71,11 +71,12 @@ UINTN   mMeasurementNum= 0;
 /// Items for which to gather cumulative statistics.
 PERF_CUM_DATA CumData[] = {
   PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK),
   PERF_INIT_CUM_DATA (START_IMAGE_TOK),
   PERF_INIT_CUM_DATA (DRIVERBINDING_START_TOK),
-  PERF_INIT_CUM_DATA (DRIVERBINDING_SUPPORT_TOK)
+  PERF_INIT_CUM_DATA (DRIVERBINDING_SUPPORT_TOK),
+  PERF_INIT_CUM_DATA (DRIVERBINDING_STOP_TOK)
 };
 
 /// Number of items for which we are gathering cumulative statistics.
 UINT32 const  NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);
 
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/2] SecurityPkg/Tcg: Add use case for new Perf macro

2018-07-19 Thread Dandan Bi
Add an example case for the usage of
PERF_CALLBACK_BEGIN/PERF_CALLBACK_END

Cc: Liming Gao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 4 
 SecurityPkg/Tcg/TcgPei/TcgPei.c   | 5 +
 SecurityPkg/Tcg/TcgPei/TcgPei.inf | 1 +
 3 files changed, 10 insertions(+)

diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 74cdd1fa88..09ef0c70a5 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -159,10 +159,12 @@ EndofPeiSignalNotifyCallBack (
 {
   MEASURED_HOB_DATA *MeasuredHobData;
 
   MeasuredHobData = NULL;
 
+  PERF_CALLBACK_BEGIN ();
+
   //
   // Create a Guid hob to save all measured Fv
   //
   MeasuredHobData = BuildGuidHob(
   ,
@@ -184,10 +186,12 @@ EndofPeiSignalNotifyCallBack (
 // Save measured child Fv info
 //
 CopyMem (>MeasuredFvBuf[mMeasuredBaseFvIndex] , 
mMeasuredChildFvInfo, sizeof(EFI_PLATFORM_FIRMWARE_BLOB) * 
(mMeasuredChildFvIndex));
   }
 
+  PERF_CALLBACK_END ();
+
   return EFI_SUCCESS;
 }
 
 /**
   Make sure that the current PCR allocations, the TPM supported PCRs,
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index 1ed11a1b29..d07047580c 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -39,10 +39,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 BOOLEAN mImageInMemory  = FALSE;
 
 EFI_PEI_PPI_DESCRIPTOR  mTpmInitializedPpiList = {
   EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
@@ -168,10 +169,12 @@ EndofPeiSignalNotifyCallBack (
 {
   MEASURED_HOB_DATA *MeasuredHobData;
 
   MeasuredHobData = NULL;
 
+  PERF_CALLBACK_BEGIN ();
+
   //
   // Create a Guid hob to save all measured Fv
   //
   MeasuredHobData = BuildGuidHob(
   ,
@@ -193,10 +196,12 @@ EndofPeiSignalNotifyCallBack (
 // Save measured child Fv info
 //
 CopyMem (>MeasuredFvBuf[mMeasuredBaseFvIndex] , 
mMeasuredChildFvInfo, sizeof(EFI_PLATFORM_FIRMWARE_BLOB) * 
(mMeasuredChildFvIndex));
   }
 
+  PERF_CALLBACK_END ();
+
   return EFI_SUCCESS;
 }
 
 /**
 Single function calculates SHA1 digest value for all raw data. It
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf 
b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
index 0252511391..4c8a055c6c 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
@@ -54,10 +54,11 @@
   BaseLib
   PcdLib
   MemoryAllocationLib
   ReportStatusCodeLib
   Tpm12CommandLib
+  PerformanceLib
 
 [Guids]
   gTcgEventEntryHobGuid   ## 
PRODUCES   ## HOB
   gTpmErrorHobGuid## 
SOMETIMES_PRODUCES ## HOB
   gMeasuredFvHobGuid  ## 
PRODUCES   ## HOB
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/2] MdeModulePkg/DxeLoadFunc: Add use case for new Perf macro

2018-07-19 Thread Dandan Bi
Add an example case for the usage of
PERF_EVENT_SIGNAL_BEGIN/PERF_EVENT_SIGNAL_END

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.h   | 3 ++-
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 1 +
 MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c | 4 
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
index 6f8e13d213..9ea88a399b 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
@@ -1,10 +1,10 @@
 /** @file
   Master header file for DxeIpl PEIM. All source files in this module should
   include this file for common definitions.
 
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -46,10 +46,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #define STACK_SIZE  0x2
 #define BSP_STORE_SIZE  0x4000
 
 
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index 7deeb8f270..302934283a 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -77,10 +77,11 @@
   BaseLib
   PeimEntryPoint
   DebugLib
   DebugAgentLib
   PeiServicesTablePointerLib
+  PerformanceLib
 
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   ArmMmuLib
 
 [Ppis]
diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c 
b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
index d5aa0474b0..8a939b6c24 100644
--- a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
+++ b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
@@ -318,11 +318,13 @@ HandOffToDxeCore (
 PageTables = CreateIdentityMappingPageTables (BaseOfStack, STACK_SIZE);
 
 //
 // End of PEI phase signal
 //
+PERF_EVENT_SIGNAL_BEGIN (gEndOfPeiSignalPpi.Guid);
 Status = PeiServicesInstallPpi ();
+PERF_EVENT_SIGNAL_END (gEndOfPeiSignalPpi.Guid);
 ASSERT_EFI_ERROR (Status);
 
 AsmWriteCr3 (PageTables);
 
 //
@@ -435,11 +437,13 @@ HandOffToDxeCore (
 }
 
 //
 // End of PEI phase signal
 //
+PERF_EVENT_SIGNAL_BEGIN (gEndOfPeiSignalPpi.Guid);
 Status = PeiServicesInstallPpi ();
+PERF_EVENT_SIGNAL_END (gEndOfPeiSignalPpi.Guid);
 ASSERT_EFI_ERROR (Status);
 
 if (BuildPageTablesIa32Pae) {
   AsmWriteCr3 (PageTables);
   //
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] UefiCpuPkg/MpInitLib: Fix VS2012 build failure

2018-07-18 Thread Dandan Bi
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 UefiCpuPkg/Library/MpInitLib/Microcode.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c 
b/UefiCpuPkg/Library/MpInitLib/Microcode.c
index efda143e67..9726172fbd 100644
--- a/UefiCpuPkg/Library/MpInitLib/Microcode.c
+++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c
@@ -61,10 +61,12 @@ MicrocodeDetect (
   VOID*MicrocodeData;
   MSR_IA32_PLATFORM_ID_REGISTER   PlatformIdMsr;
   UINT32  ProcessorFlags;
   UINT32  ThreadId;
 
+  ProcessorFlags = 0;
+
   if (CpuMpData->MicrocodePatchRegionSize == 0) {
 //
 // There is no microcode patches
 //
 return;
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/PerformanceMeasurement.h: Correct the license

2018-07-12 Thread Dandan Bi
Corrected to use the BSD license.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Include/Guid/PerformanceMeasurement.h | 31 +++---
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h 
b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
index f2955c7..0c3eb59 100644
--- a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
+++ b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
@@ -1,31 +1,18 @@
 /** @file
 
-Copyright (c) 2017, Microsoft Corporation
-Copyright (c) 2018, Intel Corporation. All rights reserved.
+Performance measurement protocol, allows logging performance data.
 
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+Copyright (c) 2017, Microsoft Corporation
+Copyright (c) 2018, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available 
under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
 
-Performance measurement protocol, allows logging performance data.
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
 #ifndef _PERFORMANCE_MEASUREMENT_H_
 #define _PERFORMANCE_MEASUREMENT_H_
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/SmmCorePerformanceLib: Update mPerformanceLength

2018-07-01 Thread Dandan Bi
In mSmmBootPerformanceTable there are two parts,
one is the FPDT table header and the other is FPDT records.
Currently:
mPerformanceLength: The length of existing FPDT records.
mMaxPerformanceLength: The maximum length allocated for
mSmmBootPerformanceTable(including FPDT table header length
and existing FPDT records length)
But when compare mPerformanceLength with mMaxPerformanceLength
to check whether need to allocate new buffer for new FPDT
record, we miss to add mPerformanceLength with header length,
which will cause pool allocation behavior is not correct.

Now update the mPerformanceLength to fix this issue:
updated mPerformanceLength = FPDT table header length
+ existing FPDT records length.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c 
b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
index f18c3fb60d..e03d41ed37 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
@@ -43,11 +43,11 @@ typedef struct {
 } HANDLE_GUID_MAP;
 
 HANDLE_GUID_MAP  mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT];
 UINTNmCachePairCount = 0;
 
-UINT32   mPerformanceLength= 0;
+UINT32   mPerformanceLength= sizeof 
(SMM_BOOT_PERFORMANCE_TABLE);
 UINT32   mMaxPerformanceLength = 0;
 UINT32   mLoadImageCount   = 0;
 BOOLEAN  mFpdtDataIsReported   = FALSE;
 BOOLEAN  mLackSpaceIsReport= FALSE;
 CHAR8*mPlatformLanguage= NULL;
@@ -98,19 +98,19 @@ GetFpdtRecordPtr (
 // Check if pre-allocated buffer is full
 //
 if (mPerformanceLength + RecordSize > mMaxPerformanceLength) {
   mSmmBootPerformanceTable = ReallocatePool (
mPerformanceLength,
-   mPerformanceLength + sizeof 
(SMM_BOOT_PERFORMANCE_TABLE) + RecordSize + FIRMWARE_RECORD_BUFFER,
+   mPerformanceLength + RecordSize + 
FIRMWARE_RECORD_BUFFER,
mSmmBootPerformanceTable
   );
 
   if (mSmmBootPerformanceTable == NULL) {
 return EFI_OUT_OF_RESOURCES;
   }
-  mSmmBootPerformanceTable->Header.Length = sizeof 
(SMM_BOOT_PERFORMANCE_TABLE) + mPerformanceLength;
-  mMaxPerformanceLength = mPerformanceLength + sizeof 
(SMM_BOOT_PERFORMANCE_TABLE) + RecordSize + FIRMWARE_RECORD_BUFFER;
+  mSmmBootPerformanceTable->Header.Length = mPerformanceLength;
+  mMaxPerformanceLength = mPerformanceLength + RecordSize + 
FIRMWARE_RECORD_BUFFER;
 }
 //
 // Covert buffer to FPDT Ptr Union type.
 //
 FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER 
*)((UINT8*)mSmmBootPerformanceTable + mSmmBootPerformanceTable->Header.Length);
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry

2018-06-27 Thread Dandan Bi
The perf measurement entry in SmmEntryPoint function
doesn't have significant meaning. So remove it now.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c 
b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
index 45f40e0e60c..2fb401e47e7 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
@@ -642,12 +642,10 @@ SmmEntryPoint (
   BOOLEAN InLegacyBoot;
   BOOLEAN IsOverlapped;
   VOID*CommunicationBuffer;
   UINTN   BufferSize;
 
-  PERF_INMODULE_BEGIN ("SMM");
-
   //
   // Update SMST with contents of the SmmEntryContext structure
   //
   gSmmCoreSmst.SmmStartupThisAp  = SmmEntryContext->SmmStartupThisAp;
   gSmmCoreSmst.CurrentlyExecutingCpu = SmmEntryContext->CurrentlyExecutingCpu;
@@ -736,12 +734,10 @@ SmmEntryPoint (
 //
 // Clear the InSmm flag as we are going to leave SMM
 //
 gSmmCorePrivate->InSmm = FALSE;
   }
-
-  PERF_INMODULE_END ("SMM");
 }
 
 /**
   Install LoadedImage protocol for SMM Core.
 **/
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/PerformanceLib: Add NULL pointer check

2018-06-27 Thread Dandan Bi
1. Add NULL pointer check for the "Guid" parameter
   when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE.
2. Make the code logic in DxeCore/SmmCore/PeiPerformanceLib
   aligned when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE.

Cc: Liming Gao 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 18 --
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c  | 13 -
 .../SmmCorePerformanceLib/SmmCorePerformanceLib.c  | 18 --
 3 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index efff5134c7b..6e0c328c635 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -1109,18 +1109,17 @@ InsertFpdtRecord (
 
   case PERF_EVENTSIGNAL_START_ID:
   case PERF_EVENTSIGNAL_END_ID:
   case PERF_CALLBACK_START_ID:
   case PERF_CALLBACK_END_ID:
-if (String == NULL) {
+if (String == NULL || Guid == NULL) {
   return EFI_INVALID_PARAMETER;
 }
-//
-// Cache the event guid in string event record when 
PcdEdkiiFpdtStringRecordEnableOnly == TRUE
-//
-CopyGuid (, Guid);
 StringPtr = String;
+if (AsciiStrLen (String) == 0) {
+  StringPtr = "unknown name";
+}
 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
   FpdtRecordPtr.DualGuidStringEvent->Header.Type  = 
FPDT_DUAL_GUID_STRING_EVENT_TYPE;
   FpdtRecordPtr.DualGuidStringEvent->Header.Length= sizeof 
(FPDT_DUAL_GUID_STRING_EVENT_RECORD);
   FpdtRecordPtr.DualGuidStringEvent->Header.Revision  = 
FPDT_RECORD_REVISION_1;
   FpdtRecordPtr.DualGuidStringEvent->ProgressID   = PerfId;
@@ -1194,11 +1193,18 @@ InsertFpdtRecord (
 FpdtRecordPtr.DynamicStringEvent->Header.Type   = 
FPDT_DYNAMIC_STRING_EVENT_TYPE;
 FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof 
(FPDT_DYNAMIC_STRING_EVENT_RECORD);
 FpdtRecordPtr.DynamicStringEvent->Header.Revision   = 
FPDT_RECORD_REVISION_1;
 FpdtRecordPtr.DynamicStringEvent->ProgressID= PerfId;
 FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
-CopyMem (>Guid, , sizeof 
(FpdtRecordPtr.DynamicStringEvent->Guid));
+if (Guid != NULL) {
+  //
+  // Cache the event guid in string event record.
+  //
+  CopyMem (>Guid, Guid, sizeof 
(FpdtRecordPtr.DynamicStringEvent->Guid));
+} else {
+  CopyMem (>Guid, , sizeof 
(FpdtRecordPtr.DynamicStringEvent->Guid));
+}
 if (AsciiStrLen (StringPtr) == 0) {
   StringPtr = "unknown name";
 }
 CopyStringIntoPerfRecordAndUpdateLength 
(FpdtRecordPtr.DynamicStringEvent->String, StringPtr, 
>Header.Length);
 
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c 
b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
index cd1b0e34ef7..3a44a0a438e 100644
--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
@@ -75,14 +75,14 @@ GetFpdtRecordPtr (
 //
 // PEI Performance HOB was found, then return the existing one.
 //
 PeiFirmwarePerformance  = (UINT8*)GET_GUID_HOB_DATA (GuidHob);
 *PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER 
*)PeiFirmwarePerformance;
-if (!(*PeiPerformanceLogHeader)->HobIsFull && 
(*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > 
(UINTN)(PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
+if (!(*PeiPerformanceLogHeader)->HobIsFull && 
(*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > 
(PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
   (*PeiPerformanceLogHeader)->HobIsFull = TRUE;
 }
-if (!(*PeiPerformanceLogHeader)->HobIsFull && 
(*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= 
(UINTN)(PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
+if (!(*PeiPerformanceLogHeader)->HobIsFull && 
(*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= 
(PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
   FpdtRecordPtr->RecordHeader = 
(EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(PeiFirmwarePerformance + sizeof 
(FPDT_PEI_EXT_PERF_HEADER) + (*PeiPerformanceLogHeader)->SizeOfAllEntries);
   break;
 }
 //
 // Previous HOB is used, then find next one.
@@ -421,23 +421,26 @@ InsertFpdtRecord (
 
   case PERF_EVENTSIGNAL_START_ID:
   case PERF_EVENTSIGNAL_END_ID:
   case PERF_CALLBACK_START_ID:
   case PERF_CALLBACK_END_ID:
-if (String != NULL && AsciiStrLen (String) != 0) {
-  StringPtr = String;
-} else {
+if (String == NULL || Guid == NULL) {
+  

[edk2] [patch] ShellPkg/DP: Add more check for input parameters

2018-06-25 Thread Dandan Bi
New added checkers includes:
1. Too many invalid parameters
2. Too few parameter
3. Invalid number parameter for -n and -t flag
4. Conflict parameter of -A and -R.

Cc: Liming Gao 
Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c   | 105 
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni |   6 ++
 2 files changed, 77 insertions(+), 34 deletions(-)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index 38766613175..dea9ff85738 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -718,10 +718,11 @@ RunDp (
   CONST CHAR16  *CustomCumulativeToken;
   PERF_CUM_DATA *CustomCumulativeData;
   UINTN NameSize;
   SHELL_STATUS  ShellStatus;
   TIMER_INFOTimerInfo;
+  UINT64Intermediate;
 
   StringPtr   = NULL;
   SummaryMode = FALSE;
   VerboseMode = FALSE;
   AllMode = FALSE;
@@ -742,10 +743,13 @@ RunDp (
   //
   Status = ShellCommandLineParse (ParamList, , NULL, TRUE);
   if (EFI_ERROR(Status)) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), 
mDpHiiHandle);
 return SHELL_INVALID_PARAMETER;
+  } else if (ShellCommandLineGetCount(ParamPackage) > 1){
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_MANY), 
mDpHiiHandle);
+return SHELL_INVALID_PARAMETER;
   }
 
   //
   // Boolean options
   //
@@ -755,28 +759,84 @@ RunDp (
   RawMode = ShellCommandLineGetFlag (ParamPackage, L"-R");
   ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");
   mShowId = ShellCommandLineGetFlag (ParamPackage, L"-i");
   CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");
 
+  if (AllMode && RawMode) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CONFLICT_ARG), 
mDpHiiHandle, L"-A", L"-R");
+return SHELL_INVALID_PARAMETER;
+  }
+
   // Options with Values
-  CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-n");
-  if (CmdLineArg == NULL) {
-Number2Display = DEFAULT_DISPLAYCOUNT;
-  } else {
-Number2Display = StrDecimalToUintn(CmdLineArg);
-if (Number2Display == 0) {
-  Number2Display = MAXIMUM_DISPLAYCOUNT;
+  if (ShellCommandLineGetFlag (ParamPackage, L"-n")) {
+CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-n");
+if (CmdLineArg == NULL) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), 
mDpHiiHandle);
+  return SHELL_INVALID_PARAMETER;
+} else {
+  if (!(RawMode || AllMode)) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_NO_RAW_ALL), 
mDpHiiHandle);
+return SHELL_INVALID_PARAMETER;
+  }
+  Status = ShellConvertStringToUint64(CmdLineArg, , FALSE, 
TRUE);
+  if (EFI_ERROR (Status)) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), 
mDpHiiHandle, L"-n");
+return SHELL_INVALID_PARAMETER;
+  } else {
+Number2Display = (UINTN)Intermediate;
+if (Number2Display == 0 || Number2Display > MAXIMUM_DISPLAYCOUNT) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_RANGE), 
mDpHiiHandle, L"-n", 0, MAXIMUM_DISPLAYCOUNT);
+  return SHELL_INVALID_PARAMETER;
+}
+  }
 }
+  } else {
+Number2Display = DEFAULT_DISPLAYCOUNT;
   }
 
-  CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-t");
-  if (CmdLineArg == NULL) {
-mInterestThreshold = DEFAULT_THRESHOLD;  // 1ms := 1,000 us
+  if (ShellCommandLineGetFlag (ParamPackage, L"-t")) {
+CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-t");
+if (CmdLineArg == NULL) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), 
mDpHiiHandle);
+  return SHELL_INVALID_PARAMETER;
+} else {
+  Status = ShellConvertStringToUint64(CmdLineArg, , FALSE, 
TRUE);
+  if (EFI_ERROR (Status)) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), 
mDpHiiHandle, L"-t");
+return SHELL_INVALID_PARAMETER;
+  } else {
+mInterestThreshold = Intermediate;
+  }
+}
   } else {
-mInterestThreshold = StrDecimalToUint64(CmdLineArg);
+mInterestThreshold = DEFAULT_THRESHOLD;  // 1ms := 1,000 us
   }
 
+  if (ShellCommandLineGetFlag (ParamPackage, L"-c")) {
+CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");
+if (CustomCumulativeToken == NULL) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), 
mDpHiiHandle);
+  return SHELL_INVALID_PARAMETER;
+} else {
+  CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));
+  if (Cu

[edk2] [patch] MdeModulePkg/CapsuleRuntimeDxe: Fix ECC issue

2018-06-24 Thread Dandan Bi
Add guard macro for new added header file.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c | 2 +-
 MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.h   | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c 
b/MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c
index 32579ceefb5..d79d2fc6932 100644
--- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c
+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c
@@ -1,6 +1,6 @@
- /** @file
+/** @file
   ARM implementation of architecture specific routines related to
   PersistAcrossReset capsules
 
   Copyright (c) 2018, Linaro, Ltd. All rights reserved.
 
diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.h 
b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.h
index 7a5df742f1e..787c70c1957 100644
--- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.h
+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.h
@@ -15,10 +15,13 @@
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
+#ifndef _CAPSULE_SERVICE_H_
+#define _CAPSULE_SERVICE_H_
+
 #include 
 
 #include 
 #include 
 #include 
@@ -67,5 +70,7 @@ IsPersistAcrossResetCapsuleSupported (
 **/
 VOID
 CapsuleCacheWriteBack (
   IN  EFI_PHYSICAL_ADDRESSScatterGatherList
   );
+
+#endif
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch V2 8/9] SecurityPkg: Use new added Perf macros

2018-06-22 Thread Dandan Bi
Replace old Perf macros with the new added ones.

Cc: Liming Gao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeRsa2048Sha256GuidedSectionExtractLib.c| 16 
 .../PeiRsa2048Sha256GuidedSectionExtractLib.c| 16 
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git 
a/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c
 
b/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c
index 39768fbac22..d6f4207a506 100644
--- 
a/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c
+++ 
b/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c
@@ -161,13 +161,13 @@ Rsa2048Sha256GuidedSectionHandler (
 // Get the RSA 2048 SHA 256 information.
 //
 CertBlockRsa2048Sha256 = &((RSA_2048_SHA_256_SECTION2_HEADER *) 
InputSection)->CertBlockRsa2048Sha256;
 OutputBufferSize   = SECTION2_SIZE (InputSection) - sizeof 
(RSA_2048_SHA_256_SECTION2_HEADER);
 if EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & 
EFI_GUIDED_SECTION_PROCESSING_REQUIRED) != 0) {
-  PERF_START (NULL, "RsaCopy", "DXE", 0);
+  PERF_INMODULE_BEGIN ("DxeRsaCopy");
   CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof 
(RSA_2048_SHA_256_SECTION2_HEADER), OutputBufferSize);
-  PERF_END (NULL, "RsaCopy", "DXE", 0);
+  PERF_INMODULE_END ("DxeRsaCopy");
 } else {
   *OutputBuffer = (UINT8 *)InputSection + sizeof 
(RSA_2048_SHA_256_SECTION2_HEADER);
 }
 
 //
@@ -189,13 +189,13 @@ Rsa2048Sha256GuidedSectionHandler (
 // Get the RSA 2048 SHA 256 information.
 //
 CertBlockRsa2048Sha256 = &((RSA_2048_SHA_256_SECTION_HEADER 
*)InputSection)->CertBlockRsa2048Sha256;
 OutputBufferSize   = SECTION_SIZE (InputSection) - sizeof 
(RSA_2048_SHA_256_SECTION_HEADER);
 if EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & 
EFI_GUIDED_SECTION_PROCESSING_REQUIRED) != 0) {
-  PERF_START (NULL, "RsaCopy", "DXE", 0);
+  PERF_INMODULE_BEGIN ("DxeRsaCopy");
   CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof 
(RSA_2048_SHA_256_SECTION_HEADER), OutputBufferSize);
-  PERF_END (NULL, "RsaCopy", "DXE", 0);
+  PERF_INMODULE_END ("DxeRsaCopy");
 } else {
   *OutputBuffer = (UINT8 *)InputSection + sizeof 
(RSA_2048_SHA_256_SECTION_HEADER);
 }
 
 //
@@ -325,13 +325,13 @@ Rsa2048Sha256GuidedSectionHandler (
   if (!CryptoStatus) {
 DEBUG ((DEBUG_ERROR, "DxeRsa2048Sha256: Sha256Init() failed\n"));
 *AuthenticationStatus |= EFI_AUTH_STATUS_TEST_FAILED;
 goto Done;
   }
-  PERF_START (NULL, "RsaShaData", "DXE", 0);
+  PERF_INMODULE_BEGIN ("DxeRsaShaData");
   CryptoStatus = Sha256Update (HashContext, *OutputBuffer, OutputBufferSize);
-  PERF_END (NULL, "RsaShaData", "DXE", 0);
+  PERF_INMODULE_END ("DxeRsaShaData");
   if (!CryptoStatus) {
 DEBUG ((DEBUG_ERROR, "DxeRsa2048Sha256: Sha256Update() failed\n"));
 *AuthenticationStatus |= EFI_AUTH_STATUS_TEST_FAILED;
 goto Done;
   }
@@ -343,19 +343,19 @@ Rsa2048Sha256GuidedSectionHandler (
   }
 
   //
   // Verify the RSA 2048 SHA 256 signature.
   //
-  PERF_START (NULL, "RsaVerify", "DXE", 0);
+  PERF_INMODULE_BEGIN ("DxeRsaVerify");
   CryptoStatus = RsaPkcs1Verify (
Rsa, 
Digest, 
SHA256_DIGEST_SIZE, 
CertBlockRsa2048Sha256->Signature, 
sizeof (CertBlockRsa2048Sha256->Signature)
);
-  PERF_END (NULL, "RsaVerify", "DXE", 0);
+  PERF_INMODULE_END ("DxeRsaVerify");
   if (!CryptoStatus) {
 //
 // If RSA 2048 SHA 256 signature verification fails, AUTH tested failed 
bit is set.
 //
 DEBUG ((DEBUG_ERROR, "DxeRsa2048Sha256: RsaPkcs1Verify() failed\n"));
diff --git 
a/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c
 
b/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c
index ba1c700ad03..2272308ddca 100644
--- 
a/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c
+++ 
b/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c
@@ -158,13 +158,13 @@ Rsa2048Sha256GuidedSectionHandler (
 // Get the RSA 2048 SHA 256 information.
 //
 CertBlockRsa2048Sha256 = &((RSA_2048_SHA_256_SECTION2_HEADER *) 
InputSection)->CertBlo

[edk2] [patch V2 9/9] UefiCpuPkg: Use new added Perf macros

2018-06-22 Thread Dandan Bi
Replace old Perf macros with the new added ones.

Cc: Liming Gao 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 4ae168a2c3c..d3cb07cd2d0 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -428,21 +428,21 @@ S3ResumeBootOs (
   // NOTE: Because Debug Timer interrupt and system interrupts will be 
disabled 
   // in BootScriptExecuteDxe, the rest code in S3ResumeBootOs() cannot be 
halted
   // by soft debugger.
   //
 
-  PERF_END (NULL, "ScriptExec", NULL, 0);
+  PERF_INMODULE_END ("ScriptExec");
 
   //
   // Install BootScriptDonePpi
   //
-  PERF_START_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_START_ID);
+  PERF_INMODULE_BEGIN ("BootScriptDonePpi");
 
   Status = PeiServicesInstallPpi ();
   ASSERT_EFI_ERROR (Status);
 
-  PERF_END_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_END_ID);
+  PERF_INMODULE_END ("BootScriptDonePpi");
 
   //
   // Get ACPI Table Address
   //
   Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) 
(AcpiS3Context->AcpiFacsTable));
@@ -462,26 +462,26 @@ S3ResumeBootOs (
   }
 
   //
   // Install EndOfPeiPpi
   //
-  PERF_START_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_START_ID);
+  PERF_INMODULE_BEGIN("EndOfPeiPpi");
 
   Status = PeiServicesInstallPpi ();
   ASSERT_EFI_ERROR (Status);
 
-  PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID);
+  PERF_INMODULE_END("EndOfPeiPpi");
 
-  PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_START_ID);
+  PERF_INMODULE_BEGIN("EndOfS3Resume");
 
   DEBUG ((DEBUG_INFO, "Signal EndOfS3Resume\n"));
   //
   // Signal EndOfS3Resume to SMM.
   //
   SignalToSmmByCommunication ();
 
-  PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_END_ID);
+  PERF_INMODULE_END ("EndOfS3Resume");
 
   //
   // report status code on S3 resume
   //
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | 
EFI_SW_PEI_PC_OS_WAKE);
@@ -878,11 +878,11 @@ S3ResumeExecuteBootScript (
   //
   // Report Status Code to indicate S3 boot script execution
   //
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | 
EFI_SW_PEI_PC_S3_BOOT_SCRIPT);
 
-  PERF_START (NULL, "ScriptExec", NULL, 0);
+  PERF_INMODULE_BEGIN ("ScriptExec");
 
   if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
 //
 // X64 S3 Resume
 //
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch V2 7/9] MdeModulePkg: Use new added Perf macros

2018-06-22 Thread Dandan Bi
Replace old Perf macros with the new added ones.

Cc: Liming Gao 
Cc: Star Zeng 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c  |  7 +
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c|  8 ++
 MdeModulePkg/Core/Dxe/Hand/DriverSupport.c |  8 +++---
 MdeModulePkg/Core/Dxe/Image/Image.c| 30 +-
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c  |  8 +++---
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c| 17 ++--
 MdeModulePkg/Core/PiSmmCore/Dispatcher.c   | 15 ---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c|  4 +--
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   |  2 +-
 .../Library/UefiBootManagerLib/BmConsole.c |  9 +++
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c   | 21 ---
 11 files changed, 53 insertions(+), 76 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
index 088cd810631..4c6ca761a60 100644
--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
@@ -417,10 +417,11 @@ CoreDispatcher (
   LIST_ENTRY  *Link;
   EFI_CORE_DRIVER_ENTRY   *DriverEntry;
   BOOLEAN ReadyToRun;
   EFI_EVENT   DxeDispatchEvent;
   
+  PERF_FUNCTION_BEGIN ();
 
   if (gDispatcherRunning) {
 //
 // If the dispatcher is running don't let it be restarted.
 //
@@ -582,10 +583,12 @@ CoreDispatcher (
   //
   CoreCloseEvent (DxeDispatchEvent);
 
   gDispatcherRunning = FALSE;
 
+  PERF_FUNCTION_END ();
+
   return ReturnStatus;
 }
 
 
 /**
@@ -1435,17 +1438,21 @@ CoreFwVolEventProtocolNotify (
 VOID
 CoreInitializeDispatcher (
   VOID
   )
 {
+  PERF_FUNCTION_BEGIN ();
+
   mFwVolEvent = EfiCreateProtocolNotifyEvent (
   ,
   TPL_CALLBACK,
   CoreFwVolEventProtocolNotify,
   NULL,
   
   );
+
+  PERF_FUNCTION_END ();
 }
 
 //
 // Function only used in debug builds
 //
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c 
b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index 07c74034624..3f753738a27 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -299,12 +299,12 @@ DxeMain (
 
   //
   // Call constructor for all libraries
   //
   ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST);
-  PERF_END   (NULL,"PEI", NULL, 0) ;
-  PERF_START (NULL,"DXE", NULL, 0) ;
+  PERF_CROSSMODULE_END   ("PEI");
+  PERF_CROSSMODULE_BEGIN ("DXE");
 
   //
   // Report DXE Core image information to the PE/COFF Extra Action Library
   //
   ZeroMem (, sizeof (ImageContext));
@@ -497,20 +497,16 @@ DxeMain (
   ASSERT_EFI_ERROR (Status);
 
   //
   // Initialize the DXE Dispatcher
   //
-  PERF_START (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ;
   CoreInitializeDispatcher ();
-  PERF_END (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ;
 
   //
   // Invoke the DXE Dispatcher
   //
-  PERF_START (NULL, "CoreDispatcher", "DxeMain", 0);
   CoreDispatcher ();
-  PERF_END (NULL, "CoreDispatcher", "DxeMain", 0);
 
   //
   // Display Architectural protocols that were not loaded if this is DEBUG 
build
   //
   DEBUG_CODE_BEGIN ();
diff --git a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c 
b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
index 33dd0bd0b7c..ab3cc0c07e5 100644
--- a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
+++ b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
@@ -625,32 +625,32 @@ CoreConnectSingleController (
 DriverBinding = NULL;
 DriverFound = FALSE;
 for (Index = 0; (Index < NumberOfSortedDriverBindingProtocols) && 
!DriverFound; Index++) {
   if (SortedDriverBindingProtocols[Index] != NULL) {
 DriverBinding = SortedDriverBindingProtocols[Index];
-PERF_START (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 
0);
+PERF_DRIVER_BINDING_SUPPORT_BEGIN (DriverBinding->DriverBindingHandle, 
ControllerHandle);
 Status = DriverBinding->Supported(
   DriverBinding,
   ControllerHandle,
   RemainingDevicePath
   );
-PERF_END (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 0);
+PERF_DRIVER_BINDING_SUPPORT_END (DriverBinding->DriverBindingHandle, 
ControllerHandle);
 if (!EFI_ERROR (Status)) {
   SortedDriverBindingProtocols[Index] = NULL;
   DriverFound = TRUE;
 
   //
   // A driver was found that supports ControllerHandle, so attempt to 
start the driver

[edk2] [patch V2 6/9] ShellPkg/dp: Update dp tool to parse new Perf record

2018-06-22 Thread Dandan Bi
Since performance library instances have been updated
to create new FPDT records for new Perf macros.
So enhance dp tool to parse the new FPDT records.
Enhancement mainly includes:
1. parse the single records for PERF_EVENT macro
2. Parse the new added FPDT_DUAL_GUID_STRING_EVENT_RECORD

Cc: Liming Gao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c  | 75 +++---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h  |  1 +
 .../DynamicCommand/DpDynamicCommand/DpInternal.h   | 14 
 ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c |  4 +-
 .../DynamicCommand/DpDynamicCommand/DpUtilities.c  | 31 +
 5 files changed, 113 insertions(+), 12 deletions(-)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index 38766613175..925341303a4 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -428,15 +428,29 @@ GetMeasurementInfo (
   break;
 default:
   ASSERT(FALSE);
 }
 
-if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
-  Measurement->Handle = &(((FPDT_GUID_EVENT_RECORD 
*)RecordHeader)->Guid);
+if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, 
ALit_PEIM) == 0) {
+  Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Guid);
 } else {
   GetHandleFormModuleGuid(ModuleGuid, );
-  Measurement->Handle = StartHandle;
+  Measurement->Handle = StartHandle;
+  //
+  // When no perf entry to record the PEI and DXE phase,
+  // For start image, we need detect the PEIM and non PEIM here.
+  //
+  if (Measurement->Token == NULL) {
+if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
+  Measurement->Token  = ALit_PEIM;
+  Measurement->Module = ALit_PEIM;
+  Measurement->Handle = ModuleGuid;
+} else {
+  Measurement->Token  = ALit_START_IMAGE;
+  Measurement->Module = ALit_START_IMAGE;
+}
+  }
 }
 break;
 
   case FPDT_DYNAMIC_STRING_EVENT_TYPE:
 ModuleGuid= &(((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Guid);
@@ -481,15 +495,27 @@ GetMeasurementInfo (
   break;
 }
 
 Measurement->Module   = ((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->String;
 
-if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
+if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, 
ALit_PEIM) == 0) {
   Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Guid);
 } else {
   GetHandleFormModuleGuid(ModuleGuid, );
   Measurement->Handle = StartHandle;
+  //
+  // When no perf entry to record the PEI and DXE phase,
+  // For start image, we need detect the PEIM and non PEIM here.
+  //
+  if (Measurement->Token == NULL  && (Measurement->Identifier == 
MODULE_START_ID || Measurement->Identifier == MODULE_END_ID)) {
+if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
+  Measurement->Token  = ALit_PEIM;
+  Measurement->Handle = ModuleGuid;
+} else {
+  Measurement->Token  = ALit_START_IMAGE;
+}
+  }
 }
 break;
 
   case FPDT_GUID_QWORD_EVENT_TYPE:
 ModuleGuid= &(((FPDT_GUID_QWORD_EVENT_RECORD 
*)RecordHeader)->Guid);
@@ -551,10 +577,24 @@ GetMeasurementInfo (
 }
 GetHandleFormModuleGuid(ModuleGuid, );
 Measurement->Handle = StartHandle;
 break;
 
+  case FPDT_DUAL_GUID_STRING_EVENT_TYPE:
+ModuleGuid= &(((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->Guid1);
+Measurement->Identifier   = 
((UINT32)((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
+if (IsStart) {
+  Measurement->StartTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+} else {
+  Measurement->EndTimeStamp   = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+}
+Measurement->Token= ((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->String;
+Measurement->Module   = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->String;
+GetHandleFormModuleGuid(ModuleGuid, );
+Measurement->Handle = StartHandle;
+break;
+
   default:
 break;
   }
 }
 
@@ -578,10 +618,18 @@ SearchMeasurement (
   (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) 
== 0) &&
   (AsciiStrCmp (mMeasurementList[Index].Module, 
EndMeasureMent->Module) == 0)) {
 mMeasurem

[edk2] [patch V2 5/9] MdeModulePkg: Update performance library instances

2018-06-22 Thread Dandan Bi
Update the performance library instances in MdeModulePkg
to implement the APIs used for new added Perf macros.

V2:
Share the common logics of creating FPDT record for
new added Perf macros and existing Perf macros.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Include/Guid/ExtendedFirmwarePerformance.h |   6 -
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 864 +++--
 .../DxeCorePerformanceLib.inf  |   1 +
 .../DxeCorePerformanceLibInternal.h|   1 +
 .../Library/DxePerformanceLib/DxePerformanceLib.c  |  68 ++
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c  | 632 +--
 .../SmmCorePerformanceLib/SmmCorePerformanceLib.c  | 645 +--
 .../Library/SmmPerformanceLib/SmmPerformanceLib.c  |  68 ++
 8 files changed, 1565 insertions(+), 720 deletions(-)

diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h 
b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h
index 465b4082750..dedb0b82f0d 100644
--- a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h
+++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h
@@ -218,16 +218,10 @@ typedef struct {
   CHAR8   String[0];
 } FPDT_GUID_QWORD_STRING_EVENT_RECORD;
 
 #pragma pack()
 
-typedef struct {
-  UINT16  ProgressID;
-  UINT16  Type;
-  UINT8   RecordSize;
-} FPDT_BASIC_RECORD_INFO;
-
 //
 // Union of all FPDT records
 //
 typedef union {
   EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER  RecordHeader;
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 79820605184..efff5134c7b 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -69,17 +69,19 @@ UINTN   mCachePairCount = 0;
 UINT32  mLoadImageCount   = 0;
 UINT32  mPerformanceLength= 0;
 UINT32  mMaxPerformanceLength = 0;
 UINT32  mBootRecordSize   = 0;
 UINT32  mBootRecordMaxSize= 0;
+UINT32  mCachedLength = 0;
 
 BOOLEAN mFpdtBufferIsReported = FALSE;
 BOOLEAN mLackSpaceIsReported  = FALSE;
 CHAR8   *mPlatformLanguage= NULL;
 UINT8   *mPerformancePointer  = NULL;
 UINT8   *mBootRecordBuffer= NULL;
 BOOLEAN  mLockInsertRecord= FALSE;
+CHAR8   *mDevicePathString= NULL;
 
 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL  *mDevicePathToText = NULL;
 
 //
 // Interfaces for PerformanceMeasurement Protocol.
@@ -88,10 +90,64 @@ EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL 
mPerformanceMeasurementInterface = {
   CreatePerformanceMeasurement,
   };
 
 PERFORMANCE_PROPERTY  mPerformanceProperty;
 
+/**
+  Return the pointer to the FPDT record in the allocated memory.
+
+  @param  RecordSize The size of FPDT record.
+  @param  FpdtRecordPtr  Pointer the FPDT record in the allocated 
memory.
+
+  @retval EFI_SUCCESSSuccessfully get the pointer to the FPDT 
record.
+  @retval EFI_OUT_OF_RESOURCES   Ran out of space to store the records.
+**/
+EFI_STATUS
+GetFpdtRecordPtr (
+  IN UINT8   RecordSize,
+  IN OUT FPDT_RECORD_PTR *FpdtRecordPtr
+)
+{
+  if (mFpdtBufferIsReported) {
+//
+// Append Boot records to the boot performance table.
+//
+if (mBootRecordSize + RecordSize > mBootRecordMaxSize) {
+  if (!mLackSpaceIsReported) {
+DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save 
boot records\n"));
+mLackSpaceIsReported = TRUE;
+  }
+  return EFI_OUT_OF_RESOURCES;
+} else {
+  //
+  // Save boot record into BootPerformance table
+  //
+  FpdtRecordPtr->RecordHeader = 
(EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + 
mBootRecordSize);
+}
+  } else {
+//
+// Check if pre-allocated buffer is full
+//
+if (mPerformanceLength + RecordSize > mMaxPerformanceLength) {
+  mPerformancePointer = ReallocatePool (
+  mPerformanceLength,
+  mPerformanceLength + RecordSize + 
FIRMWARE_RECORD_BUFFER,
+  mPerformancePointer
+  );
+  if (mPerformancePointer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+   }
+  mMaxPerformanceLength = mPerformanceLength + RecordSize + 
FIRMWARE_RECORD_BUFFER;
+}
+//
+// Covert buffer to FPDT Ptr Union type.
+//
+FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER 
*)(mPerformancePointer + mPerformanceLength);
+  }
+  return EFI_SUCCESS;
+}
+
 /**
 Check whether the Token is a known one which is uesed by core.
 
 @param  Token  Pointer to a Null-terminated ASCII string
 
@@ -58

[edk2] [patch V2 2/9] MdeModulePkg: Update Performance instances to use new protocol

2018-06-22 Thread Dandan Bi
Update Performance instances in MdeModulePkg to use new
PerformanceMeasurement protocol.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 325 +---
 .../DxeCorePerformanceLib.inf  |   6 +-
 .../DxeCorePerformanceLibInternal.h| 216 ++
 .../Library/DxePerformanceLib/DxePerformanceLib.c  | 125 +++-
 .../DxePerformanceLib/DxePerformanceLib.inf|   5 +-
 .../SmmCorePerformanceLib/SmmCorePerformanceLib.c  | 327 +
 .../SmmCorePerformanceLib.inf  |   7 +-
 .../SmmCorePerformanceLibInternal.h| 215 ++
 .../Library/SmmPerformanceLib/SmmPerformanceLib.c  | 130 +++-
 .../SmmPerformanceLib/SmmPerformanceLib.inf|   5 +-
 10 files changed, 283 insertions(+), 1078 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 68b29ac5a9e..79820605184 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -80,25 +80,14 @@ UINT8   *mBootRecordBuffer= NULL;
 BOOLEAN  mLockInsertRecord= FALSE;
 
 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL  *mDevicePathToText = NULL;
 
 //
-// Interfaces for Performance Protocol.
+// Interfaces for PerformanceMeasurement Protocol.
 //
-PERFORMANCE_PROTOCOL mPerformanceInterface = {
-  StartGauge,
-  EndGauge,
-  GetGauge
-  };
-
-//
-// Interfaces for PerformanceEx Protocol.
-//
-PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = {
-  StartGaugeEx,
-  EndGaugeEx,
-  GetGaugeEx
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
+  CreatePerformanceMeasurement,
   };
 
 PERFORMANCE_PROPERTY  mPerformanceProperty;
 
 /**
@@ -797,22 +786,15 @@ InsertFpdtMeasurement (
 
   StringPtr = NULL;
   UseModuleName = FALSE;
   ZeroMem (ModuleName, sizeof (ModuleName));
 
-  if (mLockInsertRecord) {
-return EFI_UNSUPPORTED;
-  }
-
-  mLockInsertRecord = TRUE;
-
   //
   // Get record info (type, size, ProgressID and Module Guid).
   //
   Status = GetFpdtRecordInfo (IsStart, Handle, Token, Module, , 
);
   if (EFI_ERROR (Status)) {
-mLockInsertRecord = FALSE;
 return Status;
   }
 
   //
   // If PERF_START()/PERF_END() have specified the ProgressID,it has high 
priority.
@@ -822,11 +804,10 @@ InsertFpdtMeasurement (
   // If it is start pref: the lower 4 bits of the ID should be 0.
   // If it is end pref: the lower 4 bits of the ID should not be 0.
   // If input ID doesn't follow the rule, we will adjust it.
   //
   if ((Identifier != 0) && (IsKnownID (Identifier)) && (!IsKnownTokens 
(Token))) {
-mLockInsertRecord = FALSE;
 return EFI_UNSUPPORTED;
   } else if ((Identifier != 0) && (!IsKnownID (Identifier)) && (!IsKnownTokens 
(Token))) {
 if (IsStart && ((Identifier & 0x000F) != 0)) {
   Identifier &= 0xFFF0;
 } else if ((!IsStart) && ((Identifier & 0x000F) == 0)) {
@@ -842,11 +823,10 @@ InsertFpdtMeasurement (
 if (mBootRecordSize + RecordInfo.RecordSize > mBootRecordMaxSize) {
   if (!mLackSpaceIsReported) {
 DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save 
boot records\n"));
 mLackSpaceIsReported = TRUE;
   }
-  mLockInsertRecord = FALSE;
   return EFI_OUT_OF_RESOURCES;
 } else {
   //
   // Save boot record into BootPerformance table
   //
@@ -864,11 +844,10 @@ InsertFpdtMeasurement (
   mPerformanceLength + RecordInfo.RecordSize + 
FIRMWARE_RECORD_BUFFER,
   mPerformancePointer
   );
 
   if (mPerformancePointer == NULL) {
-mLockInsertRecord = FALSE;
 return EFI_OUT_OF_RESOURCES;
   }
   mMaxPerformanceLength = mPerformanceLength + RecordInfo.RecordSize + 
FIRMWARE_RECORD_BUFFER;
 }
 //
@@ -961,15 +940,13 @@ InsertFpdtMeasurement (
 
   default:
 //
 // Record is not supported in current DXE phase, return EFI_ABORTED
 //
-mLockInsertRecord = FALSE;
 return EFI_UNSUPPORTED;
   }
 
-  mLockInsertRecord = FALSE;
   return EFI_SUCCESS;
 }
 
 /**
   Dumps all the PEI performance.
@@ -1061,223 +1038,10 @@ ReportFpdtRecordBuffer (
 //
 mFpdtBufferIsReported = TRUE;
   }
 }
 
-/**
-  Adds a record at the end of the performance measurement log
-  that records the start time of a performance measurement.
-
-  Adds a record to the end of the performance measurement log
-  that contains the Handle, Token, Module and Identifier.
-  The end time of the new record must be set to zero.
-  If TimeStamp is not zero, then TimeStamp is used to fill in the start time 
in the record.
-  If Tim

[edk2] [patch V2 3/9] MdePkg/PerformanceLib.h: Add new Perf macros

2018-06-22 Thread Dandan Bi
1. Add new Perf macros for performance measurement
and related APIs and definitions in Performance
library class.

2. Update NULL performance library instance in MdePkg.

Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Include/Library/PerformanceLib.h| 408 -
 .../BasePerformanceLibNull/PerformanceLib.c|  57 ++-
 MdePkg/MdePkg.dec  |   9 +-
 MdePkg/MdePkg.uni  |   6 +
 4 files changed, 477 insertions(+), 3 deletions(-)

diff --git a/MdePkg/Include/Library/PerformanceLib.h 
b/MdePkg/Include/Library/PerformanceLib.h
index 3ecd62bd201..8a8f5e3694a 100644
--- a/MdePkg/Include/Library/PerformanceLib.h
+++ b/MdePkg/Include/Library/PerformanceLib.h
@@ -1,9 +1,9 @@
 /** @file
   Provides services to log the execution times and retrieve them later.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -18,10 +18,49 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 ///
 /// Performance library propery mask bits
 ///
 #define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED  0x0001
 
+//
+// Public Progress Identifiers for Event Records.
+//
+#define PERF_EVENT_ID   0x00
+
+#define MODULE_START_ID 0x01
+#define MODULE_END_ID   0x02
+#define MODULE_LOADIMAGE_START_ID   0x03
+#define MODULE_LOADIMAGE_END_ID 0x04
+#define MODULE_DB_START_ID  0x05
+#define MODULE_DB_END_ID0x06
+#define MODULE_DB_SUPPORT_START_ID  0x07
+#define MODULE_DB_SUPPORT_END_ID0x08
+#define MODULE_DB_STOP_START_ID 0x09
+#define MODULE_DB_STOP_END_ID   0x0A
+
+#define PERF_EVENTSIGNAL_START_ID   0x10
+#define PERF_EVENTSIGNAL_END_ID 0x11
+#define PERF_CALLBACK_START_ID  0x20
+#define PERF_CALLBACK_END_ID0x21
+#define PERF_FUNCTION_START_ID  0x30
+#define PERF_FUNCTION_END_ID0x31
+#define PERF_INMODULE_START_ID  0x40
+#define PERF_INMODULE_END_ID0x41
+#define PERF_CROSSMODULE_START_ID   0x50
+#define PERF_CROSSMODULE_END_ID 0x51
+
+//
+// Declare bits for PcdPerformanceLibraryPropertyMask and
+// also used as the Type parameter of LogPerformanceMeasurementEnabled().
+//
+#define PERF_CORE_START_IMAGE0x0002
+#define PERF_CORE_LOAD_IMAGE 0x0004
+#define PERF_CORE_DB_SUPPORT 0x0008
+#define PERF_CORE_DB_START   0x0010
+#define PERF_CORE_DB_STOP0x0020
+
+#define PERF_GENERAL_TYPE0x0040
+
 /**
   Creates a record for the beginning of a performance measurement. 
   
   Creates a record that contains the Handle, Token, and Module.
   If TimeStamp is not zero, then TimeStamp is added to the record as the start 
time.
@@ -269,10 +308,377 @@ BOOLEAN
 EFIAPI
 PerformanceMeasurementEnabled (
   VOID
   );
 
+
+/**
+  Check whether the specified performance measurement can be logged.
+
+  This function returns TRUE when the 
PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of 
PcdPerformanceLibraryPropertyMask is set
+  and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.
+
+  @param Type- Type of the performance measurement entry.
+
+  @retval TRUE The performance measurement can be logged.
+  @retval FALSEThe performance measurement can NOT be logged.
+
+**/
+BOOLEAN
+EFIAPI
+LogPerformanceMeasurementEnabled (
+  IN  CONST UINTNType
+  );
+
+/**
+  Create performance record with event description.
+
+  @param CallerIdentifier - Image handle or pointer to caller ID GUID
+  @param Guid - Pointer to a GUID.
+Used for event signal perf and callback perf to 
cache the event guid.
+  @param String   - Pointer to a string describing the measurement
+  @param Address  - Pointer to a location in memory relevant to the 
measurement.
+  @param Identifier   - Performance identifier describing the type of 
measurement.
+
+  @retval RETURN_SUCCESS   - Successfully created performance record
+  @retval RETURN_OUT_OF_RESOURCES  - Ran out of space to store the records
+  @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - 
NULL
+ pointer or invalid Identifier.
+
+**/
+RETURN_STATUS
+EFIAPI
+LogPerformanceMeasurement (
+  IN CONST VOID   *CallerIdentifier, OPTIONAL
+  IN CONST VOID   *Guid,OPTIONAL
+  IN CONST CHAR8  *String,  OPTIONAL
+  IN UINT64

[edk2] [patch V2 4/9] MdeModulePkg/ExtendedFirmwarePerf: Remove PerfId definitions

2018-06-22 Thread Dandan Bi
Remove the definitions of performance identifier since they
have been added into PerformanceLib.h.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Include/Guid/ExtendedFirmwarePerformance.h | 25 --
 1 file changed, 25 deletions(-)

diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h 
b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h
index f2db02ddf49..465b4082750 100644
--- a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h
+++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h
@@ -30,35 +30,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #define DRIVERBINDING_STOP_TOK  "DB:Stop:"///< Driver Binding 
Stop() function call
 #define LOAD_IMAGE_TOK  "LoadImage:"  ///< Load a 
dispatched module
 #define START_IMAGE_TOK "StartImage:" ///< Dispatched 
Modules Entry Point execution
 #define PEIM_TOK"PEIM"///< PEIM Modules 
Entry Point execution
 
-//
-// Public Progress Identifiers for Event Records to map the above known token
-//
-#define MODULE_START_ID 0x01
-#define MODULE_END_ID   0x02
-#define MODULE_LOADIMAGE_START_ID   0x03
-#define MODULE_LOADIMAGE_END_ID 0x04
-#define MODULE_DB_START_ID  0x05
-#define MODULE_DB_END_ID0x06
-#define MODULE_DB_SUPPORT_START_ID  0x07
-#define MODULE_DB_SUPPORT_END_ID0x08
-#define MODULE_DB_STOP_START_ID 0x09
-#define MODULE_DB_STOP_END_ID   0x0A
-
-#define PERF_EVENTSIGNAL_START_ID   0x10
-#define PERF_EVENTSIGNAL_END_ID 0x11
-#define PERF_CALLBACK_START_ID  0x20
-#define PERF_CALLBACK_END_ID0x21
-#define PERF_FUNCTION_START_ID  0x30
-#define PERF_FUNCTION_END_ID0x31
-#define PERF_INMODULE_START_ID  0x40
-#define PERF_INMODULE_END_ID0x41
-#define PERF_CROSSMODULE_START_ID   0x50
-#define PERF_CROSSMODULE_END_ID 0x51
-
 //
 // Misc defines
 //
 #define FPDT_RECORD_REVISION_1  (0x01)
 
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch V2 0/9] Add new Perf macros

2018-06-22 Thread Dandan Bi
Add a group of new Perf macros in performance library for performance
logging. Which will simplify the usage model of performance measurement.
And also introduce new control functionality to disable different
perf types.

Patch 1-2:
Add a new internal protocol PERFORMANCE_MEASUREMENT_PROTOCOL,
which can be used to log performance info.

Patch 3-5:
Add new Perf macros and update library instances in MdeModulePkg
to for the implementation of new perf macros.

Patch 6:
Enhance the logic in DP tool since some new record and control
functionality are introduced by new Perf macros.

Patch 7-9:
update the consumer codes in core to use the new Perf macros.

Unit test:
1.DP tool can dump the performance data saved in the ACPI FPDT
  when set PcdEdkiiFpdtStringRecordEnableOnly to TRUE/FALSE.
2.Can disable specific knids of Perf entry through
  setting PcdPerformanceLibraryPropertyMask.

V2:
Patch 5: Share the common logics of creating FPDT record for
new added Perf macros and existing Perf macros.

Cc: Liming Gao 
Cc: Star Zeng 
Cc: Michael Kinney 

Dandan Bi (9):
  MdeModulePkg: Add PERFORMANCE_MEASUREMENT_PROTOCOL
  MdeModulePkg: Update Performance instances to use new protocol
  MdePkg/PerformanceLib.h: Add new Perf macros
  MdeModulePkg/ExtendedFirmwarePerf: Remove PerfId definitions
  MdeModulePkg: Update performance library instances
  ShellPkg/dp: Update dp tool to parse new Perf record
  MdeModulePkg: Use new added Perf macros
  SecurityPkg: Use new added Perf macros
  UefiCpuPkg: Use new added Perf macros

 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c  |7 +
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c|8 +-
 MdeModulePkg/Core/Dxe/Hand/DriverSupport.c |8 +-
 MdeModulePkg/Core/Dxe/Image/Image.c|   30 +-
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c  |8 +-
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c|   17 +-
 MdeModulePkg/Core/PiSmmCore/Dispatcher.c   |   15 +-
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c|4 +-
 .../Include/Guid/ExtendedFirmwarePerformance.h |   31 -
 MdeModulePkg/Include/Guid/PerformanceMeasurement.h |   91 ++
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 1183 +++-
 .../DxeCorePerformanceLib.inf  |7 +-
 .../DxeCorePerformanceLibInternal.h|  217 +---
 .../Library/DxePerformanceLib/DxePerformanceLib.c  |  193 ++--
 .../DxePerformanceLib/DxePerformanceLib.inf|5 +-
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c  |  632 +++
 .../SmmCorePerformanceLib/SmmCorePerformanceLib.c  |  960 
 .../SmmCorePerformanceLib.inf  |7 +-
 .../SmmCorePerformanceLibInternal.h|  215 +---
 .../Library/SmmPerformanceLib/SmmPerformanceLib.c  |  198 ++--
 .../SmmPerformanceLib/SmmPerformanceLib.inf|5 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   |2 +-
 .../Library/UefiBootManagerLib/BmConsole.c |9 +-
 MdeModulePkg/MdeModulePkg.dec  |3 +
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c   |   21 +-
 MdePkg/Include/Library/PerformanceLib.h|  408 ++-
 .../BasePerformanceLibNull/PerformanceLib.c|   57 +-
 MdePkg/MdePkg.dec  |9 +-
 MdePkg/MdePkg.uni  |6 +
 .../DxeRsa2048Sha256GuidedSectionExtractLib.c  |   16 +-
 .../PeiRsa2048Sha256GuidedSectionExtractLib.c  |   16 +-
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c  |   75 +-
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h  |1 +
 .../DynamicCommand/DpDynamicCommand/DpInternal.h   |   14 +
 ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c |4 +-
 .../DynamicCommand/DpDynamicCommand/DpUtilities.c  |   31 +
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c  |   16 +-
 37 files changed, 2600 insertions(+), 1929 deletions(-)
 create mode 100644 MdeModulePkg/Include/Guid/PerformanceMeasurement.h

-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch V2 1/9] MdeModulePkg: Add PERFORMANCE_MEASUREMENT_PROTOCOL

2018-06-22 Thread Dandan Bi
Add PerformanceMeasurement protocol to log performance info.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Include/Guid/PerformanceMeasurement.h | 91 ++
 MdeModulePkg/MdeModulePkg.dec  |  3 +
 2 files changed, 94 insertions(+)
 create mode 100644 MdeModulePkg/Include/Guid/PerformanceMeasurement.h

diff --git a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h 
b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
new file mode 100644
index 000..f2955c73589
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
@@ -0,0 +1,91 @@
+/** @file
+
+Copyright (c) 2017, Microsoft Corporation
+Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Performance measurement protocol, allows logging performance data.
+
+**/
+
+#ifndef _PERFORMANCE_MEASUREMENT_H_
+#define _PERFORMANCE_MEASUREMENT_H_
+
+//
+// GUID for Performance measurement Protocol
+//
+#define PERFORMANCE_MEASUREMENT_PROTOCOL_GUID \
+  { 0xc85d06be, 0x5f75, 0x48ce, {0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87, 
0xb1 } }
+
+#define SMM_PERFORMANCE_MEASUREMENT_PROTOCOL_GUID \
+  { 0xd56b6d73, 0x1a7b, 0x4015, {0x9b, 0xb4, 0x7b, 0x07, 0x17, 0x29, 0xed, 
0x24 } }
+
+typedef struct _EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL 
EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL;
+
+typedef enum {
+  PerfStartEntry,// used in 
StartPerformanceMeasurement()/StartPerformanceMeasurementEx()
+ // (map to PERF_START/PERF_START_EX)
+  PerfEndEntry,  // used in 
EndPerformanceMeasurement()/EndPerformanceMeasurementEx()
+ // (map to PERF_END/PERF_END_EX)
+  PerfEntry  // used in LogPerformanceMeasurement()
+ // (map to other Perf macros except 
above 4 macros)
+} PERF_MEASUREMENT_ATTRIBUTE;
+
+/**
+  Create performance record with event description and a timestamp.
+
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID.
+  @param Guid  - Pointer to a GUID.
+  @param String- Pointer to a string describing the measurement.
+  @param TimeStamp - 64-bit time stamp.
+  @param Address   - Pointer to a location in memory relevant to the 
measurement.
+  @param Identifier- Performance identifier describing the type of 
measurement.
+  @param Attribute - The attribute of the measurement. According to 
attribute can create a start
+ record for PERF_START/PERF_START_EX, or a end 
record for PERF_END/PERF_END_EX,
+ or a general record for other Perf macros.
+
+  @retval EFI_SUCCESS   - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
+  @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+  pointer or invalid PerfId.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *CREATE_PERFORMANCE_MEASUREMENT)(
+  IN CONST VOID*CallerIdentifier, OPTIONAL
+  IN CONST VOID*Guid, OPTIONAL
+  IN CONST CHAR8   *String,   OPTIONAL
+  IN   UINT64  TimeStamp, OPTIONAL
+  IN   UINT64  Address,   OPTIONAL
+  IN   UINT32  Identifier,
+  IN   PERF_MEASUREMENT_ATTRIBUTE  Attribute
+  );
+
+struct _EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL {
+  CREATE_PERFORMANCE_MEASUREMENT CreatePerformanceMeasurement;
+};
+
+exter

[edk2] [patch] SignedCapsulePkg/SystemFirmwareUpdateDxe: Fix ECC issues

2018-06-19 Thread Dandan Bi
Make function comments align with functions.

Cc: Star Zeng 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 5 +
 1 file changed, 5 insertions(+)

diff --git 
a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c 
b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
index 8e66aedf627..a1ce5b486f7 100644
--- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
+++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
@@ -57,10 +57,13 @@ ParseUpdateDataFile (
   @param[in]  SystemFirmwareImage Points to the System Firmware image.
   @param[in]  SystemFirmwareImageSize The length of the System Firmware image 
in bytes.
   @param[in]  ConfigData  Points to the component configuration 
structure.
   @param[out] LastAttemptVersion  The last attempt version, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
   @param[out] LastAttemptStatus   The last attempt status, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+  @param[in]  ProgressA function used by the driver to report 
the progress of the firmware update.
+  @param[in]  StartPercentage The start completion percentage value 
that may be used to report progress during the flash write operation.
+  @param[in]  EndPercentage   The end completion percentage value that 
may be used to report progress during the flash write operation.
 
   @retval EFI_SUCCESS The System Firmware image is updated.
   @retval EFI_WRITE_PROTECTED The flash device is read only.
 **/
 EFI_STATUS
@@ -115,10 +118,11 @@ PerformUpdate (
   @param[in]  SystemFirmwareImageSize The length of the System Firmware image 
in bytes.
   @param[in]  ConfigImage Points to the config file image.
   @param[in]  ConfigImageSize The length of the config file image in 
bytes.
   @param[out] LastAttemptVersion  The last attempt version, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
   @param[out] LastAttemptStatus   The last attempt status, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+  @param[in]  ProgressA function used by the driver to report 
the progress of the firmware update.
 
   @retval EFI_SUCCESS The System Firmware image is updated.
   @retval EFI_WRITE_PROTECTED The flash device is read only.
 **/
 EFI_STATUS
@@ -243,10 +247,11 @@ UpdateImage (
 
   @param[in]  Image  The EDKII system FMP capsule image.
   @param[in]  ImageSize  The size of the EDKII system FMP capsule 
image in bytes.
   @param[out] LastAttemptVersion The last attempt version, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
   @param[out] LastAttemptStatus  The last attempt status, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+  @param[in]  Progress   A function used by the driver to report the 
progress of the firmware update.
 
   @retval EFI_SUCCESS EDKII system FMP capsule passes 
authentication and the System Firmware image is updated.
   @retval EFI_SECURITY_VIOLATION  EDKII system FMP capsule fails 
authentication and the System Firmware image is not updated.
   @retval EFI_WRITE_PROTECTED The flash device is read only.
 **/
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 9/9] UefiCpuPkg: Use new added Perf macros

2018-06-19 Thread Dandan Bi
Replace old Perf macros with the new added ones.

Cc: Liming Gao 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 4ae168a2c3c..d3cb07cd2d0 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -428,21 +428,21 @@ S3ResumeBootOs (
   // NOTE: Because Debug Timer interrupt and system interrupts will be 
disabled 
   // in BootScriptExecuteDxe, the rest code in S3ResumeBootOs() cannot be 
halted
   // by soft debugger.
   //
 
-  PERF_END (NULL, "ScriptExec", NULL, 0);
+  PERF_INMODULE_END ("ScriptExec");
 
   //
   // Install BootScriptDonePpi
   //
-  PERF_START_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_START_ID);
+  PERF_INMODULE_BEGIN ("BootScriptDonePpi");
 
   Status = PeiServicesInstallPpi ();
   ASSERT_EFI_ERROR (Status);
 
-  PERF_END_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_END_ID);
+  PERF_INMODULE_END ("BootScriptDonePpi");
 
   //
   // Get ACPI Table Address
   //
   Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) 
(AcpiS3Context->AcpiFacsTable));
@@ -462,26 +462,26 @@ S3ResumeBootOs (
   }
 
   //
   // Install EndOfPeiPpi
   //
-  PERF_START_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_START_ID);
+  PERF_INMODULE_BEGIN("EndOfPeiPpi");
 
   Status = PeiServicesInstallPpi ();
   ASSERT_EFI_ERROR (Status);
 
-  PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID);
+  PERF_INMODULE_END("EndOfPeiPpi");
 
-  PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_START_ID);
+  PERF_INMODULE_BEGIN("EndOfS3Resume");
 
   DEBUG ((DEBUG_INFO, "Signal EndOfS3Resume\n"));
   //
   // Signal EndOfS3Resume to SMM.
   //
   SignalToSmmByCommunication ();
 
-  PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_END_ID);
+  PERF_INMODULE_END ("EndOfS3Resume");
 
   //
   // report status code on S3 resume
   //
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | 
EFI_SW_PEI_PC_OS_WAKE);
@@ -878,11 +878,11 @@ S3ResumeExecuteBootScript (
   //
   // Report Status Code to indicate S3 boot script execution
   //
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | 
EFI_SW_PEI_PC_S3_BOOT_SCRIPT);
 
-  PERF_START (NULL, "ScriptExec", NULL, 0);
+  PERF_INMODULE_BEGIN ("ScriptExec");
 
   if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
 //
 // X64 S3 Resume
 //
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 8/9] SecurityPkg: Use new added Perf macros

2018-06-19 Thread Dandan Bi
Replace old Perf macros with the new added ones.

Cc: Liming Gao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeRsa2048Sha256GuidedSectionExtractLib.c| 16 
 .../PeiRsa2048Sha256GuidedSectionExtractLib.c| 16 
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git 
a/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c
 
b/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c
index 39768fbac22..d6f4207a506 100644
--- 
a/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c
+++ 
b/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c
@@ -161,13 +161,13 @@ Rsa2048Sha256GuidedSectionHandler (
 // Get the RSA 2048 SHA 256 information.
 //
 CertBlockRsa2048Sha256 = &((RSA_2048_SHA_256_SECTION2_HEADER *) 
InputSection)->CertBlockRsa2048Sha256;
 OutputBufferSize   = SECTION2_SIZE (InputSection) - sizeof 
(RSA_2048_SHA_256_SECTION2_HEADER);
 if EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & 
EFI_GUIDED_SECTION_PROCESSING_REQUIRED) != 0) {
-  PERF_START (NULL, "RsaCopy", "DXE", 0);
+  PERF_INMODULE_BEGIN ("DxeRsaCopy");
   CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof 
(RSA_2048_SHA_256_SECTION2_HEADER), OutputBufferSize);
-  PERF_END (NULL, "RsaCopy", "DXE", 0);
+  PERF_INMODULE_END ("DxeRsaCopy");
 } else {
   *OutputBuffer = (UINT8 *)InputSection + sizeof 
(RSA_2048_SHA_256_SECTION2_HEADER);
 }
 
 //
@@ -189,13 +189,13 @@ Rsa2048Sha256GuidedSectionHandler (
 // Get the RSA 2048 SHA 256 information.
 //
 CertBlockRsa2048Sha256 = &((RSA_2048_SHA_256_SECTION_HEADER 
*)InputSection)->CertBlockRsa2048Sha256;
 OutputBufferSize   = SECTION_SIZE (InputSection) - sizeof 
(RSA_2048_SHA_256_SECTION_HEADER);
 if EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & 
EFI_GUIDED_SECTION_PROCESSING_REQUIRED) != 0) {
-  PERF_START (NULL, "RsaCopy", "DXE", 0);
+  PERF_INMODULE_BEGIN ("DxeRsaCopy");
   CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof 
(RSA_2048_SHA_256_SECTION_HEADER), OutputBufferSize);
-  PERF_END (NULL, "RsaCopy", "DXE", 0);
+  PERF_INMODULE_END ("DxeRsaCopy");
 } else {
   *OutputBuffer = (UINT8 *)InputSection + sizeof 
(RSA_2048_SHA_256_SECTION_HEADER);
 }
 
 //
@@ -325,13 +325,13 @@ Rsa2048Sha256GuidedSectionHandler (
   if (!CryptoStatus) {
 DEBUG ((DEBUG_ERROR, "DxeRsa2048Sha256: Sha256Init() failed\n"));
 *AuthenticationStatus |= EFI_AUTH_STATUS_TEST_FAILED;
 goto Done;
   }
-  PERF_START (NULL, "RsaShaData", "DXE", 0);
+  PERF_INMODULE_BEGIN ("DxeRsaShaData");
   CryptoStatus = Sha256Update (HashContext, *OutputBuffer, OutputBufferSize);
-  PERF_END (NULL, "RsaShaData", "DXE", 0);
+  PERF_INMODULE_END ("DxeRsaShaData");
   if (!CryptoStatus) {
 DEBUG ((DEBUG_ERROR, "DxeRsa2048Sha256: Sha256Update() failed\n"));
 *AuthenticationStatus |= EFI_AUTH_STATUS_TEST_FAILED;
 goto Done;
   }
@@ -343,19 +343,19 @@ Rsa2048Sha256GuidedSectionHandler (
   }
 
   //
   // Verify the RSA 2048 SHA 256 signature.
   //
-  PERF_START (NULL, "RsaVerify", "DXE", 0);
+  PERF_INMODULE_BEGIN ("DxeRsaVerify");
   CryptoStatus = RsaPkcs1Verify (
Rsa, 
Digest, 
SHA256_DIGEST_SIZE, 
CertBlockRsa2048Sha256->Signature, 
sizeof (CertBlockRsa2048Sha256->Signature)
);
-  PERF_END (NULL, "RsaVerify", "DXE", 0);
+  PERF_INMODULE_END ("DxeRsaVerify");
   if (!CryptoStatus) {
 //
 // If RSA 2048 SHA 256 signature verification fails, AUTH tested failed 
bit is set.
 //
 DEBUG ((DEBUG_ERROR, "DxeRsa2048Sha256: RsaPkcs1Verify() failed\n"));
diff --git 
a/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c
 
b/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c
index ba1c700ad03..2272308ddca 100644
--- 
a/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c
+++ 
b/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c
@@ -158,13 +158,13 @@ Rsa2048Sha256GuidedSectionHandler (
 // Get the RSA 2048 SHA 256 information.
 //
 CertBlockRsa2048Sha256 = &((RSA_2048_SHA_256_SECTION2_HEADER *) 
InputSection)->CertBlo

[edk2] [patch 5/9] MdeModulePkg: Update performance library instances

2018-06-19 Thread Dandan Bi
Update the performance library instances in MdeModulePkg
to implement the APIs used for new added Perf macros.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 664 +++--
 .../DxeCorePerformanceLib.inf  |   1 +
 .../DxeCorePerformanceLibInternal.h|   1 +
 .../Library/DxePerformanceLib/DxePerformanceLib.c  |  68 +++
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c  | 442 --
 .../SmmCorePerformanceLib/SmmCorePerformanceLib.c  | 440 --
 .../Library/SmmPerformanceLib/SmmPerformanceLib.c  |  68 +++
 7 files changed, 1550 insertions(+), 134 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 79820605184..68724ce9e1c 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -69,17 +69,19 @@ UINTN   mCachePairCount = 0;
 UINT32  mLoadImageCount   = 0;
 UINT32  mPerformanceLength= 0;
 UINT32  mMaxPerformanceLength = 0;
 UINT32  mBootRecordSize   = 0;
 UINT32  mBootRecordMaxSize= 0;
+UINT32  mCachedLength = 0;
 
 BOOLEAN mFpdtBufferIsReported = FALSE;
 BOOLEAN mLackSpaceIsReported  = FALSE;
 CHAR8   *mPlatformLanguage= NULL;
 UINT8   *mPerformancePointer  = NULL;
 UINT8   *mBootRecordBuffer= NULL;
 BOOLEAN  mLockInsertRecord= FALSE;
+CHAR8   *mDevicePathString= NULL;
 
 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL  *mDevicePathToText = NULL;
 
 //
 // Interfaces for PerformanceMeasurement Protocol.
@@ -88,10 +90,64 @@ EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL 
mPerformanceMeasurementInterface = {
   CreatePerformanceMeasurement,
   };
 
 PERFORMANCE_PROPERTY  mPerformanceProperty;
 
+/**
+  Return the pointer to the FPDT record in the allocated memory.
+
+  @param  RecordSize The size of FPDT record.
+  @param  FpdtRecordPtr  Pointer the FPDT record in the allocated 
memory.
+
+  @retval EFI_SUCCESSSuccessfully get the pointer to the FPDT 
record.
+  @retval EFI_OUT_OF_RESOURCES   Ran out of space to store the records.
+**/
+EFI_STATUS
+GetFpdtRecordPtr (
+  IN UINT8   RecordSize,
+  IN OUT FPDT_RECORD_PTR *FpdtRecordPtr
+)
+{
+  if (mFpdtBufferIsReported) {
+//
+// Append Boot records to the boot performance table.
+//
+if (mBootRecordSize + RecordSize > mBootRecordMaxSize) {
+  if (!mLackSpaceIsReported) {
+DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save 
boot records\n"));
+mLackSpaceIsReported = TRUE;
+  }
+  return EFI_OUT_OF_RESOURCES;
+} else {
+  //
+  // Save boot record into BootPerformance table
+  //
+  FpdtRecordPtr->RecordHeader = 
(EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + 
mBootRecordSize);
+}
+  } else {
+//
+// Check if pre-allocated buffer is full
+//
+if (mPerformanceLength + RecordSize > mMaxPerformanceLength) {
+  mPerformancePointer = ReallocatePool (
+  mPerformanceLength,
+  mPerformanceLength + RecordSize + 
FIRMWARE_RECORD_BUFFER,
+  mPerformancePointer
+  );
+  if (mPerformancePointer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+   }
+  mMaxPerformanceLength = mPerformanceLength + RecordSize + 
FIRMWARE_RECORD_BUFFER;
+}
+//
+// Covert buffer to FPDT Ptr Union type.
+//
+FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER 
*)(mPerformancePointer + mPerformanceLength);
+  }
+  return EFI_SUCCESS;
+}
+
 /**
 Check whether the Token is a known one which is uesed by core.
 
 @param  Token  Pointer to a Null-terminated ASCII string
 
@@ -814,49 +870,13 @@ InsertFpdtMeasurement (
   Identifier += 1;
 }
 RecordInfo.ProgressID = (UINT16)Identifier;
   }
 
-  if (mFpdtBufferIsReported) {
-//
-// Append Boot records to the boot performance table.
-//
-if (mBootRecordSize + RecordInfo.RecordSize > mBootRecordMaxSize) {
-  if (!mLackSpaceIsReported) {
-DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save 
boot records\n"));
-mLackSpaceIsReported = TRUE;
-  }
-  return EFI_OUT_OF_RESOURCES;
-} else {
-  //
-  // Save boot record into BootPerformance table
-  //
-  FpdtRecordPtr.RecordHeader = 
(EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + 
mBootRecordSize);
-  mBootRecordSize += RecordInfo.RecordSize;
-  mAcpiBootPerformanceTable->Header.Length += RecordInfo.RecordSize;
-}
-  } else {
-//
-// Check if pre-allocated buffer is fu

[edk2] [patch 7/9] MdeModulePkg: Use new added Perf macros

2018-06-19 Thread Dandan Bi
Replace old Perf macros with the new added ones.

Cc: Liming Gao 
Cc: Star Zeng 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c  |  7 +
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c|  8 ++
 MdeModulePkg/Core/Dxe/Hand/DriverSupport.c |  8 +++---
 MdeModulePkg/Core/Dxe/Image/Image.c| 30 +-
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c  |  8 +++---
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c| 17 ++--
 MdeModulePkg/Core/PiSmmCore/Dispatcher.c   | 15 ---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c|  4 +--
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   |  2 +-
 .../Library/UefiBootManagerLib/BmConsole.c |  9 +++
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c   | 21 ---
 11 files changed, 53 insertions(+), 76 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
index 088cd810631..4c6ca761a60 100644
--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
@@ -417,10 +417,11 @@ CoreDispatcher (
   LIST_ENTRY  *Link;
   EFI_CORE_DRIVER_ENTRY   *DriverEntry;
   BOOLEAN ReadyToRun;
   EFI_EVENT   DxeDispatchEvent;
   
+  PERF_FUNCTION_BEGIN ();
 
   if (gDispatcherRunning) {
 //
 // If the dispatcher is running don't let it be restarted.
 //
@@ -582,10 +583,12 @@ CoreDispatcher (
   //
   CoreCloseEvent (DxeDispatchEvent);
 
   gDispatcherRunning = FALSE;
 
+  PERF_FUNCTION_END ();
+
   return ReturnStatus;
 }
 
 
 /**
@@ -1435,17 +1438,21 @@ CoreFwVolEventProtocolNotify (
 VOID
 CoreInitializeDispatcher (
   VOID
   )
 {
+  PERF_FUNCTION_BEGIN ();
+
   mFwVolEvent = EfiCreateProtocolNotifyEvent (
   ,
   TPL_CALLBACK,
   CoreFwVolEventProtocolNotify,
   NULL,
   
   );
+
+  PERF_FUNCTION_END ();
 }
 
 //
 // Function only used in debug builds
 //
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c 
b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index 07c74034624..3f753738a27 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -299,12 +299,12 @@ DxeMain (
 
   //
   // Call constructor for all libraries
   //
   ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST);
-  PERF_END   (NULL,"PEI", NULL, 0) ;
-  PERF_START (NULL,"DXE", NULL, 0) ;
+  PERF_CROSSMODULE_END   ("PEI");
+  PERF_CROSSMODULE_BEGIN ("DXE");
 
   //
   // Report DXE Core image information to the PE/COFF Extra Action Library
   //
   ZeroMem (, sizeof (ImageContext));
@@ -497,20 +497,16 @@ DxeMain (
   ASSERT_EFI_ERROR (Status);
 
   //
   // Initialize the DXE Dispatcher
   //
-  PERF_START (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ;
   CoreInitializeDispatcher ();
-  PERF_END (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ;
 
   //
   // Invoke the DXE Dispatcher
   //
-  PERF_START (NULL, "CoreDispatcher", "DxeMain", 0);
   CoreDispatcher ();
-  PERF_END (NULL, "CoreDispatcher", "DxeMain", 0);
 
   //
   // Display Architectural protocols that were not loaded if this is DEBUG 
build
   //
   DEBUG_CODE_BEGIN ();
diff --git a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c 
b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
index 33dd0bd0b7c..ab3cc0c07e5 100644
--- a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
+++ b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
@@ -625,32 +625,32 @@ CoreConnectSingleController (
 DriverBinding = NULL;
 DriverFound = FALSE;
 for (Index = 0; (Index < NumberOfSortedDriverBindingProtocols) && 
!DriverFound; Index++) {
   if (SortedDriverBindingProtocols[Index] != NULL) {
 DriverBinding = SortedDriverBindingProtocols[Index];
-PERF_START (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 
0);
+PERF_DRIVER_BINDING_SUPPORT_BEGIN (DriverBinding->DriverBindingHandle, 
ControllerHandle);
 Status = DriverBinding->Supported(
   DriverBinding,
   ControllerHandle,
   RemainingDevicePath
   );
-PERF_END (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 0);
+PERF_DRIVER_BINDING_SUPPORT_END (DriverBinding->DriverBindingHandle, 
ControllerHandle);
 if (!EFI_ERROR (Status)) {
   SortedDriverBindingProtocols[Index] = NULL;
   DriverFound = TRUE;
 
   //
   // A driver was found that supports ControllerHandle, so attempt to 
start the driver

[edk2] [patch 6/9] ShellPkg/dp: Update dp tool to parse new Perf record

2018-06-19 Thread Dandan Bi
Since performance library instances have been updated
to create new FPDT records for new Perf macros.
So enhance dp tool to parse the new FPDT records.
Enhancement mainly includes:
1. parse the single records for PERF_EVENT macro
2. Parse the new added FPDT_DUAL_GUID_STRING_EVENT_RECORD

Cc: Liming Gao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 75 +++
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h |  1 +
 2 files changed, 66 insertions(+), 10 deletions(-)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index 38766613175..925341303a4 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -428,15 +428,29 @@ GetMeasurementInfo (
   break;
 default:
   ASSERT(FALSE);
 }
 
-if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
-  Measurement->Handle = &(((FPDT_GUID_EVENT_RECORD 
*)RecordHeader)->Guid);
+if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, 
ALit_PEIM) == 0) {
+  Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Guid);
 } else {
   GetHandleFormModuleGuid(ModuleGuid, );
-  Measurement->Handle = StartHandle;
+  Measurement->Handle = StartHandle;
+  //
+  // When no perf entry to record the PEI and DXE phase,
+  // For start image, we need detect the PEIM and non PEIM here.
+  //
+  if (Measurement->Token == NULL) {
+if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
+  Measurement->Token  = ALit_PEIM;
+  Measurement->Module = ALit_PEIM;
+  Measurement->Handle = ModuleGuid;
+} else {
+  Measurement->Token  = ALit_START_IMAGE;
+  Measurement->Module = ALit_START_IMAGE;
+}
+  }
 }
 break;
 
   case FPDT_DYNAMIC_STRING_EVENT_TYPE:
 ModuleGuid= &(((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Guid);
@@ -481,15 +495,27 @@ GetMeasurementInfo (
   break;
 }
 
 Measurement->Module   = ((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->String;
 
-if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
+if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, 
ALit_PEIM) == 0) {
   Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Guid);
 } else {
   GetHandleFormModuleGuid(ModuleGuid, );
   Measurement->Handle = StartHandle;
+  //
+  // When no perf entry to record the PEI and DXE phase,
+  // For start image, we need detect the PEIM and non PEIM here.
+  //
+  if (Measurement->Token == NULL  && (Measurement->Identifier == 
MODULE_START_ID || Measurement->Identifier == MODULE_END_ID)) {
+if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
+  Measurement->Token  = ALit_PEIM;
+  Measurement->Handle = ModuleGuid;
+} else {
+  Measurement->Token  = ALit_START_IMAGE;
+}
+  }
 }
 break;
 
   case FPDT_GUID_QWORD_EVENT_TYPE:
 ModuleGuid= &(((FPDT_GUID_QWORD_EVENT_RECORD 
*)RecordHeader)->Guid);
@@ -551,10 +577,24 @@ GetMeasurementInfo (
 }
 GetHandleFormModuleGuid(ModuleGuid, );
 Measurement->Handle = StartHandle;
 break;
 
+  case FPDT_DUAL_GUID_STRING_EVENT_TYPE:
+ModuleGuid= &(((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->Guid1);
+Measurement->Identifier   = 
((UINT32)((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
+if (IsStart) {
+  Measurement->StartTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+} else {
+  Measurement->EndTimeStamp   = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+}
+Measurement->Token= ((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->String;
+Measurement->Module   = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD 
*)RecordHeader)->String;
+GetHandleFormModuleGuid(ModuleGuid, );
+Measurement->Handle = StartHandle;
+break;
+
   default:
 break;
   }
 }
 
@@ -578,10 +618,18 @@ SearchMeasurement (
   (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) 
== 0) &&
   (AsciiStrCmp (mMeasurementList[Index].Module, 
EndMeasureMent->Module) == 0)) {
 mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
 break;
   }
+} else if (EndMeasureMent->Identifier == PERF_CROSSMODULE_END_ID) {
+  if (mM

[edk2] [patch 4/9] MdeModulePkg/ExtendedFirmwarePerf: Remove PerfId definitions

2018-06-19 Thread Dandan Bi
Remove the definitions of performance identifier since they
have been added into PerformanceLib.h.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Include/Guid/ExtendedFirmwarePerformance.h | 25 --
 1 file changed, 25 deletions(-)

diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h 
b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h
index f2db02ddf49..465b4082750 100644
--- a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h
+++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h
@@ -30,35 +30,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #define DRIVERBINDING_STOP_TOK  "DB:Stop:"///< Driver Binding 
Stop() function call
 #define LOAD_IMAGE_TOK  "LoadImage:"  ///< Load a 
dispatched module
 #define START_IMAGE_TOK "StartImage:" ///< Dispatched 
Modules Entry Point execution
 #define PEIM_TOK"PEIM"///< PEIM Modules 
Entry Point execution
 
-//
-// Public Progress Identifiers for Event Records to map the above known token
-//
-#define MODULE_START_ID 0x01
-#define MODULE_END_ID   0x02
-#define MODULE_LOADIMAGE_START_ID   0x03
-#define MODULE_LOADIMAGE_END_ID 0x04
-#define MODULE_DB_START_ID  0x05
-#define MODULE_DB_END_ID0x06
-#define MODULE_DB_SUPPORT_START_ID  0x07
-#define MODULE_DB_SUPPORT_END_ID0x08
-#define MODULE_DB_STOP_START_ID 0x09
-#define MODULE_DB_STOP_END_ID   0x0A
-
-#define PERF_EVENTSIGNAL_START_ID   0x10
-#define PERF_EVENTSIGNAL_END_ID 0x11
-#define PERF_CALLBACK_START_ID  0x20
-#define PERF_CALLBACK_END_ID0x21
-#define PERF_FUNCTION_START_ID  0x30
-#define PERF_FUNCTION_END_ID0x31
-#define PERF_INMODULE_START_ID  0x40
-#define PERF_INMODULE_END_ID0x41
-#define PERF_CROSSMODULE_START_ID   0x50
-#define PERF_CROSSMODULE_END_ID 0x51
-
 //
 // Misc defines
 //
 #define FPDT_RECORD_REVISION_1  (0x01)
 
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/9] MdeModulePkg: Add PERFORMANCE_MEASUREMENT_PROTOCOL

2018-06-19 Thread Dandan Bi
Add PerformanceMeasurement protocol to log performance info.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Include/Guid/PerformanceMeasurement.h | 91 ++
 MdeModulePkg/MdeModulePkg.dec  |  3 +
 2 files changed, 94 insertions(+)
 create mode 100644 MdeModulePkg/Include/Guid/PerformanceMeasurement.h

diff --git a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h 
b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
new file mode 100644
index 000..f2955c73589
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
@@ -0,0 +1,91 @@
+/** @file
+
+Copyright (c) 2017, Microsoft Corporation
+Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Performance measurement protocol, allows logging performance data.
+
+**/
+
+#ifndef _PERFORMANCE_MEASUREMENT_H_
+#define _PERFORMANCE_MEASUREMENT_H_
+
+//
+// GUID for Performance measurement Protocol
+//
+#define PERFORMANCE_MEASUREMENT_PROTOCOL_GUID \
+  { 0xc85d06be, 0x5f75, 0x48ce, {0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87, 
0xb1 } }
+
+#define SMM_PERFORMANCE_MEASUREMENT_PROTOCOL_GUID \
+  { 0xd56b6d73, 0x1a7b, 0x4015, {0x9b, 0xb4, 0x7b, 0x07, 0x17, 0x29, 0xed, 
0x24 } }
+
+typedef struct _EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL 
EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL;
+
+typedef enum {
+  PerfStartEntry,// used in 
StartPerformanceMeasurement()/StartPerformanceMeasurementEx()
+ // (map to PERF_START/PERF_START_EX)
+  PerfEndEntry,  // used in 
EndPerformanceMeasurement()/EndPerformanceMeasurementEx()
+ // (map to PERF_END/PERF_END_EX)
+  PerfEntry  // used in LogPerformanceMeasurement()
+ // (map to other Perf macros except 
above 4 macros)
+} PERF_MEASUREMENT_ATTRIBUTE;
+
+/**
+  Create performance record with event description and a timestamp.
+
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID.
+  @param Guid  - Pointer to a GUID.
+  @param String- Pointer to a string describing the measurement.
+  @param TimeStamp - 64-bit time stamp.
+  @param Address   - Pointer to a location in memory relevant to the 
measurement.
+  @param Identifier- Performance identifier describing the type of 
measurement.
+  @param Attribute - The attribute of the measurement. According to 
attribute can create a start
+ record for PERF_START/PERF_START_EX, or a end 
record for PERF_END/PERF_END_EX,
+ or a general record for other Perf macros.
+
+  @retval EFI_SUCCESS   - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
+  @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+  pointer or invalid PerfId.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *CREATE_PERFORMANCE_MEASUREMENT)(
+  IN CONST VOID*CallerIdentifier, OPTIONAL
+  IN CONST VOID*Guid, OPTIONAL
+  IN CONST CHAR8   *String,   OPTIONAL
+  IN   UINT64  TimeStamp, OPTIONAL
+  IN   UINT64  Address,   OPTIONAL
+  IN   UINT32  Identifier,
+  IN   PERF_MEASUREMENT_ATTRIBUTE  Attribute
+  );
+
+struct _EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL {
+  CREATE_PERFORMANCE_MEASUREMENT CreatePerformanceMeasurement;
+};
+
+exter

[edk2] [patch 3/9] MdePkg/PerformanceLib.h: Add new Perf macros

2018-06-19 Thread Dandan Bi
1. Add new Perf macros for performance measurement
and related APIs and definitions in Performance
library class.

2. Update NULL performance library instance in MdePkg.

Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Include/Library/PerformanceLib.h| 408 -
 .../BasePerformanceLibNull/PerformanceLib.c|  57 ++-
 MdePkg/MdePkg.dec  |   9 +-
 MdePkg/MdePkg.uni  |   6 +
 4 files changed, 477 insertions(+), 3 deletions(-)

diff --git a/MdePkg/Include/Library/PerformanceLib.h 
b/MdePkg/Include/Library/PerformanceLib.h
index 3ecd62bd201..8a8f5e3694a 100644
--- a/MdePkg/Include/Library/PerformanceLib.h
+++ b/MdePkg/Include/Library/PerformanceLib.h
@@ -1,9 +1,9 @@
 /** @file
   Provides services to log the execution times and retrieve them later.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -18,10 +18,49 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 ///
 /// Performance library propery mask bits
 ///
 #define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED  0x0001
 
+//
+// Public Progress Identifiers for Event Records.
+//
+#define PERF_EVENT_ID   0x00
+
+#define MODULE_START_ID 0x01
+#define MODULE_END_ID   0x02
+#define MODULE_LOADIMAGE_START_ID   0x03
+#define MODULE_LOADIMAGE_END_ID 0x04
+#define MODULE_DB_START_ID  0x05
+#define MODULE_DB_END_ID0x06
+#define MODULE_DB_SUPPORT_START_ID  0x07
+#define MODULE_DB_SUPPORT_END_ID0x08
+#define MODULE_DB_STOP_START_ID 0x09
+#define MODULE_DB_STOP_END_ID   0x0A
+
+#define PERF_EVENTSIGNAL_START_ID   0x10
+#define PERF_EVENTSIGNAL_END_ID 0x11
+#define PERF_CALLBACK_START_ID  0x20
+#define PERF_CALLBACK_END_ID0x21
+#define PERF_FUNCTION_START_ID  0x30
+#define PERF_FUNCTION_END_ID0x31
+#define PERF_INMODULE_START_ID  0x40
+#define PERF_INMODULE_END_ID0x41
+#define PERF_CROSSMODULE_START_ID   0x50
+#define PERF_CROSSMODULE_END_ID 0x51
+
+//
+// Declare bits for PcdPerformanceLibraryPropertyMask and
+// also used as the Type parameter of LogPerformanceMeasurementEnabled().
+//
+#define PERF_CORE_START_IMAGE0x0002
+#define PERF_CORE_LOAD_IMAGE 0x0004
+#define PERF_CORE_DB_SUPPORT 0x0008
+#define PERF_CORE_DB_START   0x0010
+#define PERF_CORE_DB_STOP0x0020
+
+#define PERF_GENERAL_TYPE0x0040
+
 /**
   Creates a record for the beginning of a performance measurement. 
   
   Creates a record that contains the Handle, Token, and Module.
   If TimeStamp is not zero, then TimeStamp is added to the record as the start 
time.
@@ -269,10 +308,377 @@ BOOLEAN
 EFIAPI
 PerformanceMeasurementEnabled (
   VOID
   );
 
+
+/**
+  Check whether the specified performance measurement can be logged.
+
+  This function returns TRUE when the 
PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of 
PcdPerformanceLibraryPropertyMask is set
+  and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.
+
+  @param Type- Type of the performance measurement entry.
+
+  @retval TRUE The performance measurement can be logged.
+  @retval FALSEThe performance measurement can NOT be logged.
+
+**/
+BOOLEAN
+EFIAPI
+LogPerformanceMeasurementEnabled (
+  IN  CONST UINTNType
+  );
+
+/**
+  Create performance record with event description.
+
+  @param CallerIdentifier - Image handle or pointer to caller ID GUID
+  @param Guid - Pointer to a GUID.
+Used for event signal perf and callback perf to 
cache the event guid.
+  @param String   - Pointer to a string describing the measurement
+  @param Address  - Pointer to a location in memory relevant to the 
measurement.
+  @param Identifier   - Performance identifier describing the type of 
measurement.
+
+  @retval RETURN_SUCCESS   - Successfully created performance record
+  @retval RETURN_OUT_OF_RESOURCES  - Ran out of space to store the records
+  @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - 
NULL
+ pointer or invalid Identifier.
+
+**/
+RETURN_STATUS
+EFIAPI
+LogPerformanceMeasurement (
+  IN CONST VOID   *CallerIdentifier, OPTIONAL
+  IN CONST VOID   *Guid,OPTIONAL
+  IN CONST CHAR8  *String,  OPTIONAL
+  IN UINT64

[edk2] [patch 2/9] MdeModulePkg: Update Performance instances to use new protocol

2018-06-19 Thread Dandan Bi
Update Update Performance instances in MdeModulePkg to use new
PerformanceMeasurement protocol.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 325 +---
 .../DxeCorePerformanceLib.inf  |   6 +-
 .../DxeCorePerformanceLibInternal.h| 216 ++
 .../Library/DxePerformanceLib/DxePerformanceLib.c  | 125 +++-
 .../DxePerformanceLib/DxePerformanceLib.inf|   5 +-
 .../SmmCorePerformanceLib/SmmCorePerformanceLib.c  | 327 +
 .../SmmCorePerformanceLib.inf  |   7 +-
 .../SmmCorePerformanceLibInternal.h| 215 ++
 .../Library/SmmPerformanceLib/SmmPerformanceLib.c  | 130 +++-
 .../SmmPerformanceLib/SmmPerformanceLib.inf|   5 +-
 10 files changed, 283 insertions(+), 1078 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 68b29ac5a9e..79820605184 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -80,25 +80,14 @@ UINT8   *mBootRecordBuffer= NULL;
 BOOLEAN  mLockInsertRecord= FALSE;
 
 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL  *mDevicePathToText = NULL;
 
 //
-// Interfaces for Performance Protocol.
+// Interfaces for PerformanceMeasurement Protocol.
 //
-PERFORMANCE_PROTOCOL mPerformanceInterface = {
-  StartGauge,
-  EndGauge,
-  GetGauge
-  };
-
-//
-// Interfaces for PerformanceEx Protocol.
-//
-PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = {
-  StartGaugeEx,
-  EndGaugeEx,
-  GetGaugeEx
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
+  CreatePerformanceMeasurement,
   };
 
 PERFORMANCE_PROPERTY  mPerformanceProperty;
 
 /**
@@ -797,22 +786,15 @@ InsertFpdtMeasurement (
 
   StringPtr = NULL;
   UseModuleName = FALSE;
   ZeroMem (ModuleName, sizeof (ModuleName));
 
-  if (mLockInsertRecord) {
-return EFI_UNSUPPORTED;
-  }
-
-  mLockInsertRecord = TRUE;
-
   //
   // Get record info (type, size, ProgressID and Module Guid).
   //
   Status = GetFpdtRecordInfo (IsStart, Handle, Token, Module, , 
);
   if (EFI_ERROR (Status)) {
-mLockInsertRecord = FALSE;
 return Status;
   }
 
   //
   // If PERF_START()/PERF_END() have specified the ProgressID,it has high 
priority.
@@ -822,11 +804,10 @@ InsertFpdtMeasurement (
   // If it is start pref: the lower 4 bits of the ID should be 0.
   // If it is end pref: the lower 4 bits of the ID should not be 0.
   // If input ID doesn't follow the rule, we will adjust it.
   //
   if ((Identifier != 0) && (IsKnownID (Identifier)) && (!IsKnownTokens 
(Token))) {
-mLockInsertRecord = FALSE;
 return EFI_UNSUPPORTED;
   } else if ((Identifier != 0) && (!IsKnownID (Identifier)) && (!IsKnownTokens 
(Token))) {
 if (IsStart && ((Identifier & 0x000F) != 0)) {
   Identifier &= 0xFFF0;
 } else if ((!IsStart) && ((Identifier & 0x000F) == 0)) {
@@ -842,11 +823,10 @@ InsertFpdtMeasurement (
 if (mBootRecordSize + RecordInfo.RecordSize > mBootRecordMaxSize) {
   if (!mLackSpaceIsReported) {
 DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save 
boot records\n"));
 mLackSpaceIsReported = TRUE;
   }
-  mLockInsertRecord = FALSE;
   return EFI_OUT_OF_RESOURCES;
 } else {
   //
   // Save boot record into BootPerformance table
   //
@@ -864,11 +844,10 @@ InsertFpdtMeasurement (
   mPerformanceLength + RecordInfo.RecordSize + 
FIRMWARE_RECORD_BUFFER,
   mPerformancePointer
   );
 
   if (mPerformancePointer == NULL) {
-mLockInsertRecord = FALSE;
 return EFI_OUT_OF_RESOURCES;
   }
   mMaxPerformanceLength = mPerformanceLength + RecordInfo.RecordSize + 
FIRMWARE_RECORD_BUFFER;
 }
 //
@@ -961,15 +940,13 @@ InsertFpdtMeasurement (
 
   default:
 //
 // Record is not supported in current DXE phase, return EFI_ABORTED
 //
-mLockInsertRecord = FALSE;
 return EFI_UNSUPPORTED;
   }
 
-  mLockInsertRecord = FALSE;
   return EFI_SUCCESS;
 }
 
 /**
   Dumps all the PEI performance.
@@ -1061,223 +1038,10 @@ ReportFpdtRecordBuffer (
 //
 mFpdtBufferIsReported = TRUE;
   }
 }
 
-/**
-  Adds a record at the end of the performance measurement log
-  that records the start time of a performance measurement.
-
-  Adds a record to the end of the performance measurement log
-  that contains the Handle, Token, Module and Identifier.
-  The end time of the new record must be set to zero.
-  If TimeStamp is not zero, then TimeStamp is used to fill in the start time 
in th

[edk2] [patch 0/9] Add new Perf macros

2018-06-19 Thread Dandan Bi
Add a group of new Perf macros in performance library for performance
logging. Which will simplify the usage model of performance measurement.
And also introduce new control functionality to disable different
perf types.

Patch 1-2:
Add a new internal protocol PERFORMANCE_MEASUREMENT_PROTOCOL,
which can be used to log performance info.

Patch 3-5:
Add new Perf macros and update library instances in MdeModulePkg
to for the implementation of new perf macros.

Patch 6:
Enhance the logic in DP tool since some new record and control
functionality are introduced by new Perf macros.

Patch 7-9:
update the consumer codes in core to use the new Perf macros.

Unit test:
1.DP tool can dump the performance data saved in the ACPI FPDT
  when set PcdEdkiiFpdtStringRecordEnableOnly to TRUE/FALSE.
2.Can disable specific knids of Perf entry through
  setting PcdPerformanceLibraryPropertyMask.

Cc: Liming Gao 
Cc: Star Zeng 
Cc: Michael Kinney 

Dandan Bi (9):
  MdeModulePkg: Add PERFORMANCE_MEASUREMENT_PROTOCOL
  MdeModulePkg: Update Performance instances to use new protocol
  MdePkg/PerformanceLib.h: Add new Perf macros
  MdeModulePkg/ExtendedFirmwarePerf: Remove PerfId definitions
  MdeModulePkg: Update performance library instances
  ShellPkg/dp: Update dp tool to parse new Perf record
  MdeModulePkg: Use new added Perf macros
  SecurityPkg: Use new added Perf macros
  UefiCpuPkg: Use new added Perf macros

 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c  |   7 +
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c|   8 +-
 MdeModulePkg/Core/Dxe/Hand/DriverSupport.c |   8 +-
 MdeModulePkg/Core/Dxe/Image/Image.c|  30 +-
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c  |   8 +-
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c|  17 +-
 MdeModulePkg/Core/PiSmmCore/Dispatcher.c   |  15 +-
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c|   4 +-
 .../Include/Guid/ExtendedFirmwarePerformance.h |  25 -
 MdeModulePkg/Include/Guid/PerformanceMeasurement.h |  91 +++
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 893 +++--
 .../DxeCorePerformanceLib.inf  |   7 +-
 .../DxeCorePerformanceLibInternal.h| 217 +
 .../Library/DxePerformanceLib/DxePerformanceLib.c  | 193 +++--
 .../DxePerformanceLib/DxePerformanceLib.inf|   5 +-
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c  | 442 --
 .../SmmCorePerformanceLib/SmmCorePerformanceLib.c  | 689 ++--
 .../SmmCorePerformanceLib.inf  |   7 +-
 .../SmmCorePerformanceLibInternal.h| 215 +
 .../Library/SmmPerformanceLib/SmmPerformanceLib.c  | 198 ++---
 .../SmmPerformanceLib/SmmPerformanceLib.inf|   5 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   |   2 +-
 .../Library/UefiBootManagerLib/BmConsole.c |   9 +-
 MdeModulePkg/MdeModulePkg.dec  |   3 +
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c   |  21 +-
 MdePkg/Include/Library/PerformanceLib.h| 408 +-
 .../BasePerformanceLibNull/PerformanceLib.c|  57 +-
 MdePkg/MdePkg.dec  |   9 +-
 MdePkg/MdePkg.uni  |   6 +
 .../DxeRsa2048Sha256GuidedSectionExtractLib.c  |  16 +-
 .../PeiRsa2048Sha256GuidedSectionExtractLib.c  |  16 +-
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c  |  75 +-
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h  |   1 +
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c  |  16 +-
 34 files changed, 2460 insertions(+), 1263 deletions(-)
 create mode 100644 MdeModulePkg/Include/Guid/PerformanceMeasurement.h

-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch V2 1/3] ShellPkg/Dp: make sure memory is freed before exit

2018-06-11 Thread Dandan Bi
Run dp command now:
Firstly it will get performance records from FPDT and then
parse the DP command. And if encounter invalid parameters,
it will exit directly. Thus the performance records got before
are invalid. And what's worse is that the memory allocated in
getting performance records phase is not freed.

This patch update the code to parse the command firstly and
then get the performance records. And make sure that all the
clean work has been done before exiting.

Cc: Liming Gao 
Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
Reviewed-by: Ruiyu Ni 
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 70 ++-
 1 file changed, 37 insertions(+), 33 deletions(-)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index aa9c2cdf7a8..fe85937f557 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -390,11 +390,11 @@ BuildCachedGuidHandleTable (
   }
   if (HandleBuffer != NULL) {
 FreePool (HandleBuffer);
 HandleBuffer = NULL;
   }
-  return Status;
+  return EFI_SUCCESS;
 }
 
 /**
   Get Measurement form Fpdt records.
 
@@ -729,39 +729,10 @@ RunDp (
   // initialize the shell lib (we must be in non-auto-init...)
   //
   Status = ShellInitialize();
   ASSERT_EFI_ERROR(Status);
 
-  //
-  // DP dump performance data by parsing FPDT table in ACPI table.
-  // Folloing 3 steps are to get the measurement form the FPDT table.
-  //
-
-  //
-  //1. Get FPDT from ACPI table.
-  //
-  Status = GetBootPerformanceTable ();
-  if (EFI_ERROR(Status)) {
-return Status;
-  }
-
-  //
-  //2. Cache the ModuleGuid and hanlde mapping table.
-  //
-  Status = BuildCachedGuidHandleTable();
-  if (EFI_ERROR (Status)) {
-return Status;
-  }
-
-  //
-  //3. Build the measurement array form the FPDT records.
-  //
-  Status = BuildMeasurementList ();
-  if (EFI_ERROR(Status)) {
-return Status;
-  }
-
   //
   // Process Command Line arguments
   //
   Status = ShellCommandLineParse (ParamList, , NULL, TRUE);
   if (EFI_ERROR(Status)) {
@@ -809,10 +780,42 @@ RunDp (
 #if PROFILING_IMPLEMENTED
 ProfileMode = TRUE;
 #endif  // PROFILING_IMPLEMENTED
   }
 
+  //
+  // DP dump performance data by parsing FPDT table in ACPI table.
+  // Folloing 3 steps are to get the measurement form the FPDT table.
+  //
+
+  //
+  //1. Get FPDT from ACPI table.
+  //
+  Status = GetBootPerformanceTable ();
+  if (EFI_ERROR (Status)) {
+ShellStatus = Status;
+goto Done;
+  }
+
+  //
+  //2. Cache the ModuleGuid and hanlde mapping table.
+  //
+  Status = BuildCachedGuidHandleTable();
+  if (EFI_ERROR (Status)) {
+ShellStatus = Status;
+goto Done;
+  }
+
+  //
+  //3. Build the measurement array form the FPDT records.
+  //
+  Status = BuildMeasurementList ();
+  if (EFI_ERROR (Status)) {
+ShellStatus = SHELL_OUT_OF_RESOURCES;
+goto Done;
+  }
+
   //
   // Initialize the pre-defined cumulative data.
   //
   InitCumulativeData ();
 
@@ -821,21 +824,22 @@ RunDp (
   //
   CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");
   if (CustomCumulativeToken != NULL) {
 CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));
 if (CustomCumulativeData == NULL) {
-  return SHELL_OUT_OF_RESOURCES;
+  ShellStatus = SHELL_OUT_OF_RESOURCES;
+  goto Done;
 }
 CustomCumulativeData->MinDur = PERF_MAXDUR;
 CustomCumulativeData->MaxDur = 0;
 CustomCumulativeData->Count  = 0;
 CustomCumulativeData->Duration = 0;
 NameSize = StrLen (CustomCumulativeToken) + 1;
 CustomCumulativeData->Name   = AllocateZeroPool (NameSize);
 if (CustomCumulativeData->Name == NULL) {
-  FreePool (CustomCumulativeData);
-  return SHELL_OUT_OF_RESOURCES;
+  ShellStatus = SHELL_OUT_OF_RESOURCES;
+  goto Done;
 }
 UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, 
NameSize);
   }
 
   //
-- 
2.14.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [RFC] MdePkg/PerformanceLib.h: Add new Perf macros

2018-06-06 Thread Dandan Bi
We plan to add a group of new Perf macros in performance library for
performance logging. Which will simplify the usage model of performance
measurement.

New Perf Macros:
Macros 1:
#define PERF_START_IMAGE_BEGIN(ModuleHandle)
#define PERF_START_IMAGE_END(ModuleHandle)

Macros 2:
#define PERF_LOAD_IMAGE_BEGIN(ModuleHandle)
#define PERF_LOAD_IMAGE_END(ModuleHandle)

Macros 3:
#define PERF_DRIVER_BINDING_SUPPORT_BEGIN(ModuleHandle, ControllerHandle)
#define PERF_DRIVER_BINDING_SUPPORT_END(ModuleHandle, ControllerHandle)

Macros 4:
#define PERF_DRIVER_BINDING_START_BEGIN(ModuleHandle, ControllerHandle)
#define PERF_DRIVER_BINDING_START_END(ModuleHandle, ControllerHandle)

Macros 5:
#define PERF_DRIVER_BINDING_STOP_BEGIN(ModuleHandle, ControllerHandle)
#define PERF_DRIVER_BINDING_STOP_END(ModuleHandle, ControllerHandle)

Macros 6:
#define PERF_EVENT(EventString)

Macros 7:
#define PERF_EVENT_SIGNAL_BEGIN(EventGuid)
#define PERF_EVENT_SIGNAL_END(EventGuid)

Macros 8:
#define PERF_CALLBACK_BEGIN(TriggerGuid)
#define PERF_CALLBACK_END(TriggerGuid)

Macros 9:
#define PERF_FUNCTION_BEGIN()
#define PERF_FUNCTION_END()

Macros 10:
#define PERF_INMODULE_BEGIN(MeasurementString)
#define PERF_INMODULE_END(MeasurementString)

Macros 11:
#define PERF_CROSSMODULE_BEGIN(MeasurementString)
#define PERF_CROSSMODULE_END(MeasurementString)

The detailed descriptions and changes are listed here.
1. Reasons of introducing these new Perf macros:
   a. Simplify the usage model of Perf macros.
  New Perf macros will have less input parameters.
  And different use cases can map to different Perf macros.

   b. Introduce new control functionality for performance logging.
  Such as there are lots of DriverBinding Support (Start/Stop) Perf
  entries in core codes. User can stop logging the performance of
  these entries by configure PCD.

   c. User can get more info through the new Perf macros.
  Like the ControllerHandle for DriverBinding Perf entries...

2. Macros 1-11, each macro will be identified by different perf identifiers.
   Macros 1-5 are for core use cases and used in the
   PeiCore, DxeCore and SmmCore.
   Macros 6-11 are for general use cases and can be used in any modules.
   Map each pair of core macros in Macros 1-5 to a core Perf type:
   PERF_CORE_START_IMAGE
   PERF_CORE_LOAD_IMAGE
   PERF_CORE_DB_SUPPORT
   PERF_CORE_DB_START
   PERF_CORE_DB_STOP
   And map all general Perf macros in Macros 6-11 to PERF_GENERAL_TYPE
   Then we can configure PCD to disable different Perf macros.

3. Update PcdPerformanceLibraryPropertyMask to control performance logging.
   Now BIT0 of PcdPerformanceLibraryPropertyMaskis is to enable the
   performance measurement. We will add BIT1-BIT6 to control different
   Perf types. Only when performance measurement is enabled, we can check
   BIT1-BIT6 to see whether a specific Perf type is disabled or not.
   This configuration are compatible with current performance enable
   behavior, set BIT0 can enable all the performance measurement.
   PcdPerformanceLibraryPropertyMask in MdePkg
   #  BIT0 - Enable Performance Measurement.
   #  BIT1 - Disable Start Image Logging.
   #  BIT2 - Disable Load Image logging.
   #  BIT3 - Disable Binding Support logging.
   #  BIT4 - Disable Binding Start logging.
   #  BIT5 - Disable Binding Stop logging.
   #  BIT6 - Disable all other general Perfs.
   #  BIT1-BIT6 are evaluated when BIT0 is set.

4. Introduce two new Library APIs for PerformanceLib library class.
   a. LogPerformanceMeasurementEnabled (Type);
   b. LogPerformanceMeasurement (CallerId, Guid, String, Address, PerfId);
   LogPerformanceMeasurementEnabled (Type):
   check whether a specified performance measurement can be logged.
   LogPerformanceMeasurement (CallerId, Guid, String, Address, PerfId):
   Log performance measurement info.

5. Code updates
   a. Performance library instances update:
  MdePkg:
  BasePerformanceLibNull
  MdeModulePkg:
  PeiPerformanceLib
  DxePerformanceLib
  DxeCorePerformanceLib
  SmmPerformanceLib
  SmmCorePerformanceLib

   b. Consumer code update:
  Update the old perf macros to use new perf macros for
  MdeModulePkg, UefiCpuPkg and SecurityPkg.
  For other packages, if old Perf macros are used, packages owners
  can decide whether using new Perf macros to replace old ones.

Can refer to the following patch for more detailed code changes and
description of new macros, APIs, definitions and PCD updating.

Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Include/Library/PerformanceLib.h | 407 +++-
 MdePkg/MdePkg.dec   |   9 +-
 2 files changed, 414 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Library/PerformanceLib.h 
b/MdePkg/Include/Library/PerformanceLib.h
index 3ecd62bd201..dea79a9ff53 100644
--- a/MdePkg/Include/Library/PerformanceLib.h
+++ b

  1   2   3   4   5   6   7   >