public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib
@ 2019-03-19 15:25 Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 01/17] MdePkg/DebugLib.h: Add new APIs " Zhichao Gao
                   ` (16 more replies)
  0 siblings, 17 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel

Add a new API DebugVPrint to all the instances of DebugLib.
This API is added to provide a function who want to implement
special debug function with '...' parameter.
Add a PEIM to install gEdkiiDebugPpiGuid, and implement a PEI
debug library instance base on it. All PEIMs except pei core
type can use the PeiDebugLibDebugPpi to reduce its image size.

V2: 
Remove redundant code in DebugPrint.
Fix some coding sytle issues.
Remove some unenforced descirption in the comments of DebugVPrint.

V3:
Add the new API DebugBPrint, it is more useful for consumers which
are care of compatible issue.
Change the interface in gEdkiiDebugPpiGuid. VA_LIST is inappropriate
to appeared in protocol or ppi because different compilers compile
it to different type. It may be a pointer or a structure.

Liming Gao (1):
  MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib

Zhichao Gao (16):
  MdePkg/DebugLib.h: Add new APIs for DebugLib
  MdePkg/BaseDebugLibNull: Add new APIs for DebugLib
  MdePkg/BaseDebugLibSerialPort: Add new APIs
  MdePkg/UefidebugLibConOut: Add new APIs
  MdePkg/UefiDebugLibStdErr: Add new APIs
  MdePkg/DxeRuntimeDebugLibSerialPort: Add new APIs
  MdePkg/UefiDebuglibDebugPortProtocol: Add new APIs
  ArmPkg/SemiHostingDebugLib: Add new APIs
  OvmfPkg/PlatformDebugLibIoPort: Add new APIs
  IntelFsp2Pkg/BaseFspDebugLibSerialPort: Add new APIs
  IntelFspPkg/BaseFspDebugLibSerialPort: Add new APIs
  IntelFramworkModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
  MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
  MdeModulePkg: Add definitions for EDKII DEBUG PPI
  MdeModulePkg: Add a PEIM to install Debug PPI
  MdeModulePkg: Add PEIM and lib to dsc file

 ArmPkg/Library/SemiHostingDebugLib/DebugLib.c      | 106 ++++-
 .../PeiDxeDebugLibReportStatusCode/DebugLib.c      | 142 ++++++-
 .../Library/BaseFspDebugLibSerialPort/DebugLib.c   | 103 ++++-
 .../Library/BaseFspDebugLibSerialPort/DebugLib.c   | 103 ++++-
 MdeModulePkg/Include/Ppi/Debug.h                   |  90 ++++
 .../Library/PeiDebugLibDebugPpi/DebugLib.c         | 469 +++++++++++++++++++++
 .../PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf    |  55 +++
 .../PeiDxeDebugLibReportStatusCode/DebugLib.c      | 144 ++++++-
 MdeModulePkg/MdeModulePkg.dec                      |   3 +
 MdeModulePkg/MdeModulePkg.dsc                      |   3 +
 .../Universal/DebugServicePei/DebugService.c       |  68 +++
 .../Universal/DebugServicePei/DebugService.h       |  64 +++
 .../Universal/DebugServicePei/DebugServicePei.c    |  54 +++
 .../Universal/DebugServicePei/DebugServicePei.inf  |  51 +++
 .../Universal/DebugServicePei/DebugServicePei.uni  |  20 +
 MdePkg/Include/Library/DebugLib.h                  |  52 ++-
 MdePkg/Library/BaseDebugLibNull/DebugLib.c         |  56 ++-
 MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c   | 106 ++++-
 .../DxeRuntimeDebugLibSerialPort/DebugLib.c        | 106 ++++-
 MdePkg/Library/UefiDebugLibConOut/DebugLib.c       | 106 ++++-
 .../UefiDebugLibDebugPortProtocol/DebugLib.c       | 106 ++++-
 MdePkg/Library/UefiDebugLibStdErr/DebugLib.c       | 107 ++++-
 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c  | 106 ++++-
 23 files changed, 2142 insertions(+), 78 deletions(-)
 create mode 100644 MdeModulePkg/Include/Ppi/Debug.h
 create mode 100644 MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
 create mode 100644 MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugService.c
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugService.h
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni

-- 
2.16.2.windows.1



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

* [PATCH V3 01/17] MdePkg/DebugLib.h: Add new APIs for DebugLib
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-21  7:00   ` Gao, Liming
  2019-03-19 15:25 ` [PATCH V3 02/17] MdePkg/BaseDebugLibNull: " Zhichao Gao
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Michael D Kinney, Liming Gao, Sean Brogan, Michael Turner,
	Bret Barkelew

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

Add new APIs DebugVPrint and DebugBPrint prototype
definition in the DebugLib header file. These APIs
would expose a print routine with VaList parameter
and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 MdePkg/Include/Library/DebugLib.h | 52 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h
index e6a7a357b2..77fb1ee259 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -8,7 +8,7 @@
   of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
   defined, then debug and assert related macros wrapped by it are the NULL implementations.
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
 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
@@ -101,6 +101,56 @@ DebugPrint (
   );
 
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  );
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  );
+
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 02/17] MdePkg/BaseDebugLibNull: Add new APIs for DebugLib
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 01/17] MdePkg/DebugLib.h: Add new APIs " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 03/17] MdePkg/BaseDebugLibSerialPort: Add new APIs Zhichao Gao
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Michael D Kinney, Liming Gao, Sean Brogan, Michael Turner,
	Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 MdePkg/Library/BaseDebugLibNull/DebugLib.c | 56 +++++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Library/BaseDebugLibNull/DebugLib.c b/MdePkg/Library/BaseDebugLibNull/DebugLib.c
index 1a7d4aba79..f9c9ac7189 100644
--- a/MdePkg/Library/BaseDebugLibNull/DebugLib.c
+++ b/MdePkg/Library/BaseDebugLibNull/DebugLib.c
@@ -1,7 +1,7 @@
 /** @file
   Null Base Debug Library instance with empty functions.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   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
@@ -41,6 +41,60 @@ DebugPrint (
 }
 
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+}
+
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 03/17] MdePkg/BaseDebugLibSerialPort: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 01/17] MdePkg/DebugLib.h: Add new APIs " Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 02/17] MdePkg/BaseDebugLibNull: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 04/17] MdePkg/UefidebugLibConOut: " Zhichao Gao
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Michael D Kinney, Liming Gao, Sean Brogan, Michael Turner,
	Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c | 106 +++++++++++++++++++++--
 1 file changed, 101 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c b/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c
index ffb84b39e5..d875050371 100644
--- a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c
+++ b/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c
@@ -7,7 +7,7 @@
   being blocked.  This may occur if a key(s) are pressed in a terminal emulator
   used to monitor the DEBUG() and ASSERT() messages.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   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
@@ -32,6 +32,12 @@
 //
 #define MAX_DEBUG_MESSAGE_LENGTH  0x100
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
   The constructor function initialize the Serial Port Library
 
@@ -70,9 +76,41 @@ DebugPrint (
   ...
   )
 {
-  CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
   VA_LIST  Marker;
 
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
+
   //
   // If Format is NULL, then ASSERT().
   //
@@ -88,9 +126,11 @@ DebugPrint (
   //
   // Convert the DEBUG() message to an ASCII String
   //
-  VA_START (Marker, Format);
-  AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
-  VA_END (Marker);
+  if (BaseListMarker == NULL) {
+    AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
+  } else {
+    AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
+  }
 
   //
   // Send the print string to a Serial Port
@@ -99,6 +139,62 @@ DebugPrint (
 }
 
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 04/17] MdePkg/UefidebugLibConOut: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (2 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 03/17] MdePkg/BaseDebugLibSerialPort: Add new APIs Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 05/17] MdePkg/UefiDebugLibStdErr: " Zhichao Gao
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Michael D Kinney, Liming Gao, Sean Brogan, Michael Turner,
	Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 MdePkg/Library/UefiDebugLibConOut/DebugLib.c | 106 +++++++++++++++++++++++++--
 1 file changed, 101 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c
index f04207c93f..c60ac04a24 100644
--- a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c
+++ b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c
@@ -1,7 +1,7 @@
 /** @file
   UEFI Debug Library that sends messages to the Console Output Device in the EFI System Table.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   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
@@ -27,6 +27,12 @@
 //
 #define MAX_DEBUG_MESSAGE_LENGTH  0x100
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
   Prints a debug message to the debug output device if the specified error level is enabled.
 
@@ -50,9 +56,41 @@ DebugPrint (
   ...
   )
 {
-  CHAR16   Buffer[MAX_DEBUG_MESSAGE_LENGTH];
   VA_LIST  Marker;
 
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  CHAR16   Buffer[MAX_DEBUG_MESSAGE_LENGTH];
+
   //
   // If Format is NULL, then ASSERT().
   //
@@ -68,9 +106,11 @@ DebugPrint (
   //
   // Convert the DEBUG() message to a Unicode String
   //
-  VA_START (Marker, Format);
-  UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH,  Format, Marker);
-  VA_END (Marker);
+  if (BaseListMarker == NULL) {
+    UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH,  Format, VaListMarker);
+  } else {
+    UnicodeBSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH,  Format, BaseListMarker);
+  }
 
 
   //
@@ -82,6 +122,62 @@ DebugPrint (
 }
 
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 05/17] MdePkg/UefiDebugLibStdErr: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (3 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 04/17] MdePkg/UefidebugLibConOut: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 06/17] MdePkg/DxeRuntimeDebugLibSerialPort: " Zhichao Gao
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Michael D Kinney, Liming Gao, Sean Brogan, Michael Turner,
	Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 MdePkg/Library/UefiDebugLibStdErr/DebugLib.c | 107 +++++++++++++++++++++++++--
 1 file changed, 102 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c
index 6830a3caa1..81fcf168e5 100644
--- a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c
+++ b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c
@@ -1,7 +1,7 @@
 /** @file
   UEFI Debug Lib that sends messages to the Standard Error Device in the EFI System Table.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   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
@@ -29,6 +29,13 @@
 #define MAX_DEBUG_MESSAGE_LENGTH  0x100
 
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
+
 /**
   Prints a debug message to the debug output device if the specified error level is enabled.
 
@@ -51,9 +58,41 @@ DebugPrint (
   IN  CONST CHAR8  *Format,
   ...
   )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
 {
   CHAR16   Buffer[MAX_DEBUG_MESSAGE_LENGTH];
-  VA_LIST  Marker;
 
   //
   // If Format is NULL, then ASSERT().
@@ -70,9 +109,11 @@ DebugPrint (
   //
   // Convert the DEBUG() message to a Unicode String
   //
-  VA_START (Marker, Format);
-  UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, Marker);
-  VA_END (Marker);
+  if (BaseListMarker == NULL) {
+    UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, VaListMarker);
+  } else {
+    UnicodeBSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, BaseListMarker);
+  }
 
   //
   // Send the print string to the Standard Error device
@@ -83,6 +124,62 @@ DebugPrint (
 }
 
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 06/17] MdePkg/DxeRuntimeDebugLibSerialPort: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (4 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 05/17] MdePkg/UefiDebugLibStdErr: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 07/17] MdePkg/UefiDebuglibDebugPortProtocol: " Zhichao Gao
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Michael D Kinney, Liming Gao, Sean Brogan, Michael Turner,
	Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 .../DxeRuntimeDebugLibSerialPort/DebugLib.c        | 106 ++++++++++++++++++++-
 1 file changed, 101 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c b/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
index e1266f77fa..4af1cde488 100644
--- a/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
+++ b/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
@@ -4,7 +4,7 @@
   been called, to prevent touching hardware that is no longer owned by the
   firmware.
 
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
 
   This program and the accompanying materials
@@ -34,6 +34,12 @@ STATIC BOOLEAN        mEfiAtRuntime = FALSE;
 //
 #define MAX_DEBUG_MESSAGE_LENGTH  0x100
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
   Set AtRuntime flag as TRUE after ExitBootServices.
 
@@ -125,9 +131,41 @@ DebugPrint (
   IN  CONST CHAR8  *Format,
   ...
   )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
 {
   CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
-  VA_LIST  Marker;
 
   if (mEfiAtRuntime) {
     return;
@@ -148,9 +186,11 @@ DebugPrint (
   //
   // Convert the DEBUG() message to an ASCII String
   //
-  VA_START (Marker, Format);
-  AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
-  VA_END (Marker);
+  if (BaseListMarker == NULL) {
+    AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
+  } else {
+    AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
+  }
 
   //
   // Send the print string to a Serial Port
@@ -159,6 +199,62 @@ DebugPrint (
 }
 
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 07/17] MdePkg/UefiDebuglibDebugPortProtocol: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (5 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 06/17] MdePkg/DxeRuntimeDebugLibSerialPort: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 08/17] ArmPkg/SemiHostingDebugLib: " Zhichao Gao
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Michael D Kinney, Liming Gao, Sean Brogan, Michael Turner,
	Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 .../UefiDebugLibDebugPortProtocol/DebugLib.c       | 106 ++++++++++++++++++++-
 1 file changed, 101 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c
index c2209f4123..b1ad2af20a 100644
--- a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c
+++ b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c
@@ -1,7 +1,7 @@
 /** @file
   UEFI Debug Library that sends messages to EFI_DEBUGPORT_PROTOCOL.Write.
 
-  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
   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
@@ -37,6 +37,12 @@
 
 EFI_DEBUGPORT_PROTOCOL *mDebugPort = NULL;
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
   Send message to DebugPort Protocol.
 
@@ -106,9 +112,41 @@ DebugPrint (
   IN  CONST CHAR8  *Format,
   ...
   )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
 {
   CHAR8      Buffer[MAX_DEBUG_MESSAGE_LENGTH];
-  VA_LIST    Marker;
 
   //
   // If Format is NULL, then ASSERT().
@@ -125,9 +163,11 @@ DebugPrint (
   //
   // Convert the DEBUG() message to an ASCII String
   //
-  VA_START (Marker, Format);
-  AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
-  VA_END (Marker);
+  if (BaseListMarker == NULL) {
+    AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
+  } else {
+    AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
+  }
 
   //
   // Send the print string to EFI_DEBUGPORT_PROTOCOL.Write.
@@ -136,6 +176,62 @@ DebugPrint (
 }
 
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 08/17] ArmPkg/SemiHostingDebugLib: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (6 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 07/17] MdePkg/UefiDebuglibDebugPortProtocol: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 09/17] OvmfPkg/PlatformDebugLibIoPort: " Zhichao Gao
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Leif Lindholm, Ard Biesheuvel, Liming Gao, Sean Brogan,
	Michael Turner, Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 ArmPkg/Library/SemiHostingDebugLib/DebugLib.c | 106 ++++++++++++++++++++++++--
 1 file changed, 101 insertions(+), 5 deletions(-)

diff --git a/ArmPkg/Library/SemiHostingDebugLib/DebugLib.c b/ArmPkg/Library/SemiHostingDebugLib/DebugLib.c
index ec03edb774..a368dd43b8 100644
--- a/ArmPkg/Library/SemiHostingDebugLib/DebugLib.c
+++ b/ArmPkg/Library/SemiHostingDebugLib/DebugLib.c
@@ -1,7 +1,7 @@
 /** @file
   UEFI Debug Library that uses PrintLib to send messages to STDERR.
 
-  Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -27,6 +27,12 @@
 //
 #define MAX_DEBUG_MESSAGE_LENGTH  0x100
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
 
   Prints a debug message to the debug output device if the specified error level is enabled.
@@ -48,9 +54,41 @@ DebugPrint (
   IN  CONST CHAR8  *Format,
   ...
   )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
 {
   CHAR8    AsciiBuffer[MAX_DEBUG_MESSAGE_LENGTH];
-  VA_LIST  Marker;
 
   //
   // If Format is NULL, then ASSERT().
@@ -67,14 +105,72 @@ DebugPrint (
   //
   // Convert the DEBUG() message to a Unicode String
   //
-  VA_START (Marker, Format);
-  AsciiVSPrint (AsciiBuffer, sizeof (AsciiBuffer), Format, Marker);
-  VA_END (Marker);
+  if (BaseListMarker == NULL) {
+    AsciiVSPrint (AsciiBuffer, sizeof (AsciiBuffer), Format, VaListMarker);
+  } else {
+    AsciiBSPrint (AsciiBuffer, sizeof (AsciiBuffer), Format, BaseListMarker);
+  }
 
   SemihostWriteString (AsciiBuffer);
 }
 
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
+
 /**
 
   Prints an assert message containing a filename, line number, and description.
-- 
2.16.2.windows.1



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

* [PATCH V3 09/17] OvmfPkg/PlatformDebugLibIoPort: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (7 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 08/17] ArmPkg/SemiHostingDebugLib: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-20 16:57   ` Laszlo Ersek
  2019-03-19 15:25 ` [PATCH V3 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: " Zhichao Gao
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Liming Gao,
	Sean Brogan, Michael Turner, Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 106 +++++++++++++++++++++-
 1 file changed, 101 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
index 36cde54976..cda35faf66 100644
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
@@ -2,7 +2,7 @@
   Base Debug library instance for QEMU debug port.
   It uses PrintLib to send debug messages to a fixed I/O port.
 
-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2012, Red Hat, Inc.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -29,6 +29,12 @@
 //
 #define MAX_DEBUG_MESSAGE_LENGTH  0x100
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
   Prints a debug message to the debug output device if the specified error level is enabled.
 
@@ -51,9 +57,41 @@ DebugPrint (
   IN  CONST CHAR8  *Format,
   ...
   )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
 {
   CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
-  VA_LIST  Marker;
   UINTN    Length;
 
   //
@@ -72,9 +110,11 @@ DebugPrint (
   //
   // Convert the DEBUG() message to an ASCII String
   //
-  VA_START (Marker, Format);
-  Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
-  VA_END (Marker);
+  if (BaseListMarker == NULL) {
+    Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
+  } else {
+    Length = AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
+  }
 
   //
   // Send the print string to the debug I/O port
@@ -83,6 +123,62 @@ DebugPrint (
 }
 
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (8 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 09/17] OvmfPkg/PlatformDebugLibIoPort: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 23:37   ` Chiu, Chasel
  2019-03-19 15:25 ` [PATCH V3 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: " Zhichao Gao
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Chasel Chiu, Nate DeSimone, Star Zeng, Liming Gao, Sean Brogan,
	Michael Turner, Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 .../Library/BaseFspDebugLibSerialPort/DebugLib.c   | 103 ++++++++++++++++++++-
 1 file changed, 98 insertions(+), 5 deletions(-)

diff --git a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
index 73bb08e357..8b322c038e 100644
--- a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
+++ b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
   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
@@ -28,6 +28,12 @@
 
 CONST CHAR8  *mHexTable = "0123456789ABCDEF";
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
   Get stack frame pointer of function call.
 
@@ -62,9 +68,40 @@ DebugPrint (
   IN  CONST CHAR8  *Format,
   ...
   )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
 {
   CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
-  VA_LIST  Marker;
 
   //
   // If Format is NULL, then ASSERT().
@@ -88,9 +125,11 @@ DebugPrint (
   //
   // Convert the DEBUG() message to an ASCII String
   //
-  VA_START (Marker, Format);
-  AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
-  VA_END (Marker);
+  if (BaseListMarker == NULL) {
+    AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
+  } else {
+    AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
+  }
 
   //
   // Send the print string to a Serial Port
@@ -98,6 +137,60 @@ DebugPrint (
   SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
 }
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
 /**
   Convert an UINT32 value into HEX string sepcified by Buffer.
 
-- 
2.16.2.windows.1



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

* [PATCH V3 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (9 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 23:37   ` Chiu, Chasel
  2019-03-19 15:25 ` [PATCH V3 12/17] IntelFramworkModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Chasel Chiu, Nate DeSimone, Star Zeng, Liming Gao, Sean Brogan,
	Michael Turner, Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 .../Library/BaseFspDebugLibSerialPort/DebugLib.c   | 103 ++++++++++++++++++++-
 1 file changed, 98 insertions(+), 5 deletions(-)

diff --git a/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c b/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
index 73bb08e357..8b322c038e 100644
--- a/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
+++ b/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
   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
@@ -28,6 +28,12 @@
 
 CONST CHAR8  *mHexTable = "0123456789ABCDEF";
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
   Get stack frame pointer of function call.
 
@@ -62,9 +68,40 @@ DebugPrint (
   IN  CONST CHAR8  *Format,
   ...
   )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
 {
   CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
-  VA_LIST  Marker;
 
   //
   // If Format is NULL, then ASSERT().
@@ -88,9 +125,11 @@ DebugPrint (
   //
   // Convert the DEBUG() message to an ASCII String
   //
-  VA_START (Marker, Format);
-  AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
-  VA_END (Marker);
+  if (BaseListMarker == NULL) {
+    AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
+  } else {
+    AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
+  }
 
   //
   // Send the print string to a Serial Port
@@ -98,6 +137,60 @@ DebugPrint (
   SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
 }
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
 /**
   Convert an UINT32 value into HEX string sepcified by Buffer.
 
-- 
2.16.2.windows.1



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

* [PATCH V3 12/17] IntelFramworkModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (10 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Sean Brogan, Michael Turner, Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 .../PeiDxeDebugLibReportStatusCode/DebugLib.c      | 142 ++++++++++++++++++---
 1 file changed, 127 insertions(+), 15 deletions(-)

diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index b0445115a9..e020e3c207 100644
--- a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
+++ b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
@@ -4,7 +4,7 @@
   Note that if the debug message length is larger than the maximum allowable
   record length, then the debug message will be ignored directly.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   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
@@ -27,6 +27,12 @@
 #include <Library/PcdLib.h>
 #include <Library/DebugPrintErrorLevelLib.h>
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
   Prints a debug message to the debug output device if the specified error level is enabled.
 
@@ -52,13 +58,44 @@ DebugPrint (
   IN  CONST CHAR8  *Format,
   ...
   )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
 {
   UINT64          Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1];
   EFI_DEBUG_INFO  *DebugInfo;
   UINTN           TotalSize;
   UINTN           DestBufferSize;
-  VA_LIST         VaListMarker;
-  BASE_LIST       BaseListMarker;
+  BASE_LIST       BaseListMarkerPointer;
   CHAR8           *FormatString;
   BOOLEAN         Long;
 
@@ -110,7 +147,7 @@ DebugPrint (
   //
   DebugInfo             = (EFI_DEBUG_INFO *)(Buffer) + 1;
   DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
-  BaseListMarker        = (BASE_LIST)(DebugInfo + 1);
+  BaseListMarkerPointer = (BASE_LIST)(DebugInfo + 1);
   FormatString          = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
 
   //
@@ -129,7 +166,6 @@ DebugPrint (
   // of format in DEBUG string, which is followed by the DEBUG format string.
   // Here we will process the variable arguments and pack them in this area.
   //
-  VA_START (VaListMarker, Format);
   for (; *Format != '\0'; Format++) {
     //
     // Only format with prefix % is processed.
@@ -166,7 +202,11 @@ DebugPrint (
         // '*' in format field means the precision of the field is specified by
         // a UINTN argument in the argument list.
         //
-        BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
+        if (BaseListMarker == NULL) {
+          BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);
+        } else {
+          BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);
+        }
         continue;
       }
       if (*Format == '\0') {
@@ -191,16 +231,36 @@ DebugPrint (
     }
     if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {
       if (Long) {
-        BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
+        if (BaseListMarker == NULL) {
+          BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG (VaListMarker, INT64);
+        } else {
+          BASE_ARG (BaseListMarkerPointer, INT64) = BASE_ARG (BaseListMarker, INT64);
+        }
       } else {
-        BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
+        if (BaseListMarker == NULL) {
+          BASE_ARG (BaseListMarkerPointer, int) = VA_ARG (VaListMarker, int);
+        } else {
+          BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG (BaseListMarker, int);
+        }
       }
     } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') {
-      BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
+      if (BaseListMarker == NULL) {
+        BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG (VaListMarker, VOID *);
+      } else {
+        BASE_ARG (BaseListMarkerPointer, VOID *) = BASE_ARG (BaseListMarker, VOID *);
+      }
     } else if (*Format == 'c') {
-      BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
+      if (BaseListMarker == NULL) {
+        BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);
+      } else {
+        BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);
+      }
     } else if (*Format == 'r') {
-      BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);
+      if (BaseListMarker == NULL) {
+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);
+      } else {
+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = BASE_ARG (BaseListMarker, RETURN_STATUS);
+      }
     }
 
     //
@@ -208,17 +268,15 @@ DebugPrint (
     // This indicates that the DEBUG() macro is passing in more argument than can be handled by
     // the EFI_DEBUG_INFO record
     //
-    ASSERT ((CHAR8 *)BaseListMarker <= FormatString);
+    ASSERT ((CHAR8 *)BaseListMarkerPointer <= FormatString);
 
     //
     // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then return
     //
-    if ((CHAR8 *)BaseListMarker > FormatString) {
-      VA_END (VaListMarker);
+    if ((CHAR8 *)BaseListMarkerPointer > FormatString) {
       return;
     }
   }
-  VA_END (VaListMarker);
 
   //
   // Send the DebugInfo record
@@ -234,6 +292,60 @@ DebugPrint (
     );
 }
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (11 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 12/17] IntelFramworkModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-21  5:22   ` Wu, Hao A
  2019-03-21  6:57   ` Gao, Liming
  2019-03-19 15:25 ` [PATCH V3 14/17] MdeModulePkg: Add definitions for EDKII DEBUG PPI Zhichao Gao
                   ` (3 subsequent siblings)
  16 siblings, 2 replies; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Jian J Wang, Hao Wu, Ray Ni, Star Zeng, Liming Gao, Sean Brogan,
	Michael Turner, Bret Barkelew

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

Add new APIs' implementation (DebugVPrint, DebugBPrint)
in the DebugLib instance. These APIs would expose print
routines with VaList parameter and BaseList parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 .../PeiDxeDebugLibReportStatusCode/DebugLib.c      | 144 ++++++++++++++++++---
 1 file changed, 128 insertions(+), 16 deletions(-)

diff --git a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index 6f0f416273..f1d31cb619 100644
--- a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
+++ b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
@@ -4,7 +4,7 @@
   Note that if the debug message length is larger than the maximum allowable
   record length, then the debug message will be ignored directly.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   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
@@ -27,6 +27,12 @@
 #include <Library/PcdLib.h>
 #include <Library/DebugPrintErrorLevelLib.h>
 
+//
+// VA_LIST can not initialize to NULL for all compiler, so we use this to
+// indicate a null VA_LIST
+//
+VA_LIST     mVaListNull;
+
 /**
   Prints a debug message to the debug output device if the specified error level is enabled.
 
@@ -52,12 +58,43 @@ DebugPrint (
   IN  CONST CHAR8  *Format,
   ...
   )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled base on Null-terminated format string and a
+  VA_LIST argument list or a BASE_LIST argument list.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  VaListMarker    VA_LIST marker for the variable argument list.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+DebugPrintMarker (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker,
+  IN  BASE_LIST     BaseListMarker
+  )
 {
   UINT64          Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1];
   EFI_DEBUG_INFO  *DebugInfo;
   UINTN           TotalSize;
-  VA_LIST         VaListMarker;
-  BASE_LIST       BaseListMarker;
+  BASE_LIST       BaseListMarkerPointer;
   CHAR8           *FormatString;
   BOOLEAN         Long;
 
@@ -96,7 +133,7 @@ DebugPrint (
   // If the TotalSize is larger than the maximum record size, then return
   //
   if (TotalSize > sizeof (Buffer)) {
-    TotalSize = sizeof (Buffer);
+    return;
   }
 
   //
@@ -109,7 +146,7 @@ DebugPrint (
   //
   DebugInfo             = (EFI_DEBUG_INFO *)(Buffer) + 1;
   DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
-  BaseListMarker        = (BASE_LIST)(DebugInfo + 1);
+  BaseListMarkerPointer = (BASE_LIST)(DebugInfo + 1);
   FormatString          = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
 
   //
@@ -125,7 +162,6 @@ DebugPrint (
   // of format in DEBUG string, which is followed by the DEBUG format string.
   // Here we will process the variable arguments and pack them in this area.
   //
-  VA_START (VaListMarker, Format);
 
   //
   // Use the actual format string.
@@ -167,7 +203,11 @@ DebugPrint (
         // '*' in format field means the precision of the field is specified by
         // a UINTN argument in the argument list.
         //
-        BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
+        if (BaseListMarker == NULL) {
+          BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);
+        } else {
+          BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);
+        }
         continue;
       }
       if (*Format == '\0') {
@@ -192,16 +232,36 @@ DebugPrint (
     }
     if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {
       if (Long) {
-        BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
+        if (BaseListMarker == NULL) {
+          BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG (VaListMarker, INT64);
+        } else {
+          BASE_ARG (BaseListMarkerPointer, INT64) = BASE_ARG (BaseListMarker, INT64);
+        }
       } else {
-        BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
+        if (BaseListMarker == NULL) {
+          BASE_ARG (BaseListMarkerPointer, int) = VA_ARG (VaListMarker, int);
+        } else {
+          BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG (BaseListMarker, int);
+        }
       }
     } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') {
-      BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
+      if (BaseListMarker == NULL) {
+        BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG (VaListMarker, VOID *);
+      } else {
+        BASE_ARG (BaseListMarkerPointer, VOID *) = BASE_ARG (BaseListMarker, VOID *);
+      }
     } else if (*Format == 'c') {
-      BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
+      if (BaseListMarker == NULL) {
+        BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);
+      } else {
+        BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);
+      }
     } else if (*Format == 'r') {
-      BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);
+      if (BaseListMarker == NULL) {
+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);
+      } else {
+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = BASE_ARG (BaseListMarker, RETURN_STATUS);
+      }
     }
 
     //
@@ -209,17 +269,15 @@ DebugPrint (
     // This indicates that the DEBUG() macro is passing in more argument than can be handled by
     // the EFI_DEBUG_INFO record
     //
-    ASSERT ((CHAR8 *)BaseListMarker <= FormatString);
+    ASSERT ((CHAR8 *)BaseListMarkerPointer <= FormatString);
 
     //
     // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then return
     //
-    if ((CHAR8 *)BaseListMarker > FormatString) {
-      VA_END (VaListMarker);
+    if ((CHAR8 *)BaseListMarkerPointer > FormatString) {
       return;
     }
   }
-  VA_END (VaListMarker);
 
   //
   // Send the DebugInfo record
@@ -235,6 +293,60 @@ DebugPrint (
     );
 }
 
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
+}
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
+}
+
 /**
   Prints an assert message containing a filename, line number, and description.
   This may be followed by a breakpoint or a dead loop.
-- 
2.16.2.windows.1



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

* [PATCH V3 14/17] MdeModulePkg: Add definitions for EDKII DEBUG PPI
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (12 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-21  5:22   ` Wu, Hao A
  2019-03-19 15:25 ` [PATCH V3 15/17] MdeModulePkg: Add a PEIM to install Debug PPI Zhichao Gao
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Jian J Wang, Hao Wu, Ray Ni, Star Zeng, Liming Gao, Sean Brogan,
	Michael Turner, Bret Barkelew

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

Add a debug PPI for PEI phase. This PPI will provide basic
services of debug. PEI debug lib instance can use these
services to implement debug function to reduce the PEIMs
which consume the debug lib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 MdeModulePkg/Include/Ppi/Debug.h | 90 ++++++++++++++++++++++++++++++++++++++++
 MdeModulePkg/MdeModulePkg.dec    |  3 ++
 2 files changed, 93 insertions(+)
 create mode 100644 MdeModulePkg/Include/Ppi/Debug.h

diff --git a/MdeModulePkg/Include/Ppi/Debug.h b/MdeModulePkg/Include/Ppi/Debug.h
new file mode 100644
index 0000000000..40db304f3d
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/Debug.h
@@ -0,0 +1,90 @@
+/** @file
+  Define the EDKII_DEBUG_PPI that PEIMs can use to dump info to debug port.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+
+  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.
+
+**/
+
+#ifndef __EDKII_DEBUG_PPI_H__
+#define __EDKII_DEBUG_PPI_H__
+
+#include <Pi/PiPeiCis.h>
+
+//
+// Global ID for the EDKII_DEBUG_PPI
+//
+#define EDKII_DEBUG_PPI_GUID \
+  { \
+    0x999e699c, 0xb013, 0x475e, {0xb1, 0x7b, 0xf3, 0xa8, 0xae, 0x5c, 0x48, 0x75} \
+  }
+
+///
+/// Forward declaration for the PEI_DEBUG_LIB_DEBUG_PPI EDKII_DEBUG_PPI
+///
+typedef struct _EDKII_DEBUG_PPI EDKII_DEBUG_PPI;
+
+/**
+  Print a debug message to debug output device if the specified error level
+  is enabled.
+
+  @param[in] PeiServices              The pointer to the PEI Services Table.
+  @param[in] This                     The pointer to this instance of EDKII_DEBUG_PPI
+  @param[in] ErrorLevel               The error level of the debug message.
+  @param[in] Format                   Format string for the debug message to print.
+  @param[in] Marker                   BASE_LIST marker for the variable argument list.
+
+**/
+typedef
+VOID
+(EFIAPI *EDKII_DEBUG_BPRINT)(
+  IN CONST EFI_PEI_SERVICES         **PeiServices,
+  IN EDKII_DEBUG_PPI                *This,
+  IN UINTN                          ErrorLevel,
+  IN CONST CHAR8                    *Format,
+  IN BASE_LIST                      Marker
+  );
+
+/**
+  Print an assert message containing a filename, line number, and description.
+  This may be followed by a breakpoint or a dead loop.
+
+  @param[in] PeiServices              The pointer to the PEI Services Table.
+  @param[in] This                     The pointer to this instance of EDKII_DEBUG_PPI
+  @param[in] FileName                 The pointer to the name of the source file that
+                                      generated the assert condition.
+  @param[in] LineNumber               The line number in the source file that generated
+                                      the assert condition
+  @param[in] Description              The pointer to the description of the assert condition.
+
+**/
+typedef
+VOID
+(EFIAPI *EDKII_DEBUG_ASSERT)(
+  IN CONST EFI_PEI_SERVICES         **PeiServices,
+  IN EDKII_DEBUG_PPI                *This,
+  IN CONST CHAR8                    *FileName,
+  IN UINTN                          LineNumber,
+  IN CONST CHAR8                    *Description
+  );
+
+///
+/// This PPI contains a set of services to print message to debug output device
+///
+struct _EDKII_DEBUG_PPI {
+  EDKII_DEBUG_BPRINT                DebugBPrint;
+  EDKII_DEBUG_ASSERT                DebugAssert;
+};
+
+extern EFI_GUID gEdkiiDebugPpiGuid;
+
+#endif
+
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index a2130bc439..9bbd0572f5 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -492,6 +492,9 @@
   ## Include/Ppi/AtaPassThru.h
   gEdkiiPeiAtaPassThruPpiGuid               = { 0xa16473fd, 0xd474, 0x4c89, { 0xae, 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9  } }
 
+  ## Include/Ppi/Debug.h
+  gEdkiiDebugPpiGuid                        = { 0x999e699c, 0xb013, 0x475e, { 0xb1, 0x7b, 0xf3, 0xa8, 0xae, 0x5c, 0x48, 0x75 } }
+
 [Protocols]
   ## Load File protocol provides capability to load and unload EFI image into memory and execute it.
   #  Include/Protocol/LoadPe32Image.h
-- 
2.16.2.windows.1



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

* [PATCH V3 15/17] MdeModulePkg: Add a PEIM to install Debug PPI
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (13 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 14/17] MdeModulePkg: Add definitions for EDKII DEBUG PPI Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-21  5:22   ` Wu, Hao A
  2019-03-19 15:25 ` [PATCH V3 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib Zhichao Gao
  2019-03-19 15:25 ` [PATCH V3 17/17] MdeModulePkg: Add PEIM and lib to dsc file Zhichao Gao
  16 siblings, 1 reply; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Jian J Wang, Hao Wu, Ray Ni, Star Zeng, Liming Gao, Sean Brogan,
	Michael Turner, Bret Barkelew

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

Add a PEIM to install Debug PPI so that PEI debug library
instance can locate gEdkiiDebugPpiGuid to implement the
debug functions. Using this PPI can reduce the size of
PEIMs which consume the debug library.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 .../Universal/DebugServicePei/DebugService.c       | 68 ++++++++++++++++++++++
 .../Universal/DebugServicePei/DebugService.h       | 64 ++++++++++++++++++++
 .../Universal/DebugServicePei/DebugServicePei.c    | 54 +++++++++++++++++
 .../Universal/DebugServicePei/DebugServicePei.inf  | 51 ++++++++++++++++
 .../Universal/DebugServicePei/DebugServicePei.uni  | 20 +++++++
 5 files changed, 257 insertions(+)
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugService.c
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugService.h
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
 create mode 100644 MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni

diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugService.c b/MdeModulePkg/Universal/DebugServicePei/DebugService.c
new file mode 100644
index 0000000000..54ae6974d1
--- /dev/null
+++ b/MdeModulePkg/Universal/DebugServicePei/DebugService.c
@@ -0,0 +1,68 @@
+/** @file
+  Debug services instances for PEI phase.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+
+  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 <Ppi/Debug.h>
+#include <Library/DebugLib.h>
+
+/**
+  Print a debug message to debug output device if the specified error level
+  is enabled.
+
+  @param[in] PeiServices              The pointer to the PEI Services Table.
+  @param[in] This                     The pointer to this instance of EDKII_DEBUG_PPI
+  @param[in] ErrorLevel               The error level of the debug message.
+  @param[in] Format                   Format string for the debug message to print.
+  @param[in] Marker                   BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+PeiDebugBPrint(
+  IN CONST EFI_PEI_SERVICES         **PeiServices,
+  IN EDKII_DEBUG_PPI                *This,
+  IN UINTN                          ErrorLevel,
+  IN CONST CHAR8                    *Format,
+  IN BASE_LIST                      Marker
+  )
+{
+  DebugBPrint(ErrorLevel, Format, Marker);
+}
+
+/**
+  Print an assert message containing a filename, line number, and description.
+  This may be followed by a breakpoint or a dead loop.
+
+  @param[in] PeiServices              The pointer to the PEI Services Table.
+  @param[in] This                     The pointer to this instance of EDKII_DEBUG_PPI
+  @param[in] FileName                 The pointer to the name of the source file that
+                                      generated the assert condition.
+  @param[in] LineNumber               The line number in the source file that generated
+                                      the assert condition
+  @param[in] Description              The pointer to the description of the assert condition.
+
+**/
+VOID
+EFIAPI
+PeiDebugAssert(
+  IN CONST EFI_PEI_SERVICES         **PeiServices,
+  IN EDKII_DEBUG_PPI                *This,
+  IN CONST CHAR8                    *FileName,
+  IN UINTN                          LineNumber,
+  IN CONST CHAR8                    *Description
+  )
+{
+  DebugAssert(FileName, LineNumber, Description);
+}
+
diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugService.h b/MdeModulePkg/Universal/DebugServicePei/DebugService.h
new file mode 100644
index 0000000000..21b44248bb
--- /dev/null
+++ b/MdeModulePkg/Universal/DebugServicePei/DebugService.h
@@ -0,0 +1,64 @@
+/** @file
+  Header file of Debug services instances.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+
+  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.
+
+**/
+#ifndef __DEBUG_SERVICE_H__
+#define __DEBUG_SERVICE_H__
+
+#include <Ppi/Debug.h>
+
+/**
+  Print a debug message to debug output device if the specified error level
+  is enabled.
+
+  @param[in] PeiServices              The pointer to the PEI Services Table.
+  @param[in] This                     The pointer to this instance of EDKII_DEBUG_PPI
+  @param[in] ErrorLevel               The error level of the debug message.
+  @param[in] Format                   Format string for the debug message to print.
+  @param[in] Marker                   BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+PeiDebugBPrint(
+  IN CONST EFI_PEI_SERVICES         **PeiServices,
+  IN EDKII_DEBUG_PPI                *This,
+  IN UINTN                          ErrorLevel,
+  IN CONST CHAR8                    *Format,
+  IN BASE_LIST                      Marker
+  );
+
+/**
+  Prints an assert message containing a filename, line number, and description.
+  This may be followed by a breakpoint or a dead loop.
+
+  @param[in] PeiServices              The pointer to the PEI Services Table.
+  @param[in] This                     The pointer to this instance of EDKII_DEBUG_PPI
+  @param[in] FileName                 The pointer to the name of the source file that
+                                      generated the assert condition.
+  @param[in] LineNumber               The line number in the source file that generated
+                                      the assert condition
+  @param[in] Description              The pointer to the description of the assert condition.
+
+**/
+VOID
+EFIAPI
+PeiDebugAssert(
+  IN CONST EFI_PEI_SERVICES         **PeiServices,
+  IN EDKII_DEBUG_PPI                *This,
+  IN CONST CHAR8                    *FileName,
+  IN UINTN                          LineNumber,
+  IN CONST CHAR8                    *Description
+  );
+
+#endif
diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
new file mode 100644
index 0000000000..a502dd150b
--- /dev/null
+++ b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
@@ -0,0 +1,54 @@
+/** @file
+  This driver installs gEdkiiPeiDebugLibDebugGuid PPI to provide
+  debug services for PEIMs.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+
+  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 <Uefi/UefiBaseType.h>
+#include <Library/PeimEntryPoint.h>
+#include <Library/PeiServicesLib.h>
+#include "DebugService.h"
+
+EDKII_DEBUG_PPI mDebugPpi = {
+  PeiDebugBPrint,
+  PeiDebugAssert
+};
+
+EFI_PEI_PPI_DESCRIPTOR mDebugServicePpi = {
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+  &gEdkiiDebugPpiGuid,
+  (VOID *)&mDebugPpi
+};
+
+/**
+  Entry point of Debug Service PEIM
+
+  This funciton installs EDKII DEBUG PPI
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCESS  The entry point of Debug Service PEIM executes successfully.
+  @retval Others      Some error occurs during the execution of this function.
+
+**/
+EFI_STATUS
+EFIAPI
+DebugSerivceInitialize (
+  IN EFI_PEI_FILE_HANDLE        FileHandle,
+  IN CONST EFI_PEI_SERVICES     **PeiServices
+  )
+{
+  return PeiServicesInstallPpi (&mDebugServicePpi);
+}
+
diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
new file mode 100644
index 0000000000..f9563ed1b3
--- /dev/null
+++ b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
@@ -0,0 +1,51 @@
+## @file
+#  Debug services for PEI phase
+#
+#  This module installs gEdkiiFaultTolerantWriteGuid PPI to inform the check for FTW last write data has been done.
+#
+#  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+#
+#  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.
+#
+##
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = DebugServicePei
+  MODULE_UNI_FILE                = DebugServicePei.uni
+  FILE_GUID                      = B73F81B9-1DFC-487C-824C-0509EE2B0128
+  MODULE_TYPE                    = PEIM
+  VERSION_STRING                 = 1.0
+
+  ENTRY_POINT                    = DebugSerivceInitialize
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 EBC
+#
+
+[Sources]
+  DebugServicePei.c
+  DebugService.c
+  DebugService.h
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  PeimEntryPoint
+  PeiServicesLib
+  DebugLib
+
+[Ppis]
+  gEdkiiDebugPpiGuid                    ## PRODUCE
+
+[Depex]
+  TRUE
+
diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni
new file mode 100644
index 0000000000..2ac1d997d0
--- /dev/null
+++ b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni
@@ -0,0 +1,20 @@
+///** @file
+//  This driver installs gEdkiiPeiDebugLibDebugGuid PPI to provide
+//  debug services for PEIMs.
+//
+//  Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.<BR>
+//
+//  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.
+//
+//**/
+
+#string STR_MODULE_ABSTRACT             #language en-US "Provide debug services at PEI phase."
+
+#string STR_MODULE_DESCRIPTION          #language en-US "It produces gEdkiiPeiDebugLibDebugGuid to print message to debug output device"
+
-- 
2.16.2.windows.1



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

* [PATCH V3 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (14 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 15/17] MdeModulePkg: Add a PEIM to install Debug PPI Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-21  5:22   ` Wu, Hao A
  2019-03-19 15:25 ` [PATCH V3 17/17] MdeModulePkg: Add PEIM and lib to dsc file Zhichao Gao
  16 siblings, 1 reply; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Liming Gao, Jian J Wang, Hao Wu, Ray Ni, Star Zeng, Sean Brogan,
	Michael Turner, Bret Barkelew

From: Liming Gao <liming.gao@intel.com>

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

Add a PEI debug library instance PeiDebugLibDebugPpi base on
DebugPpi. Using the combination of the DebugServicePei and
this lib instance can reduce the image size of PEI drivers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 .../Library/PeiDebugLibDebugPpi/DebugLib.c         | 469 +++++++++++++++++++++
 .../PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf    |  55 +++
 2 files changed, 524 insertions(+)
 create mode 100644 MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
 create mode 100644 MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf

diff --git a/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c b/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
new file mode 100644
index 0000000000..839dff5268
--- /dev/null
+++ b/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
@@ -0,0 +1,469 @@
+/** @file
+  PEI debug lib instance base on DebugPpi to save size
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+
+  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 <PiPei.h>
+#include <Ppi/Debug.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/DebugPrintErrorLevelLib.h>
+#include <Library/PeiServicesTablePointerLib.h>
+
+EDKII_DEBUG_PPI             *mDebugPpi = NULL;
+CONST EFI_PEI_SERVICES      **mPeiServicesTablePointer = NULL;
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugPrint (
+  IN  UINTN        ErrorLevel,
+  IN  CONST CHAR8  *Format,
+  ...
+  )
+{
+  VA_LIST         Marker;
+
+  VA_START (Marker, Format);
+  DebugVPrint (ErrorLevel, Format, Marker);
+  VA_END (Marker);
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+  This function use BASE_LIST which would provide a more compatible
+  service than VA_LIST.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel      The error level of the debug message.
+  @param  Format          Format string for the debug message to print.
+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugBPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  BASE_LIST     BaseListMarker
+  )
+{
+  EFI_STATUS      Status;
+
+  //
+  // If Format is NULL, then ASSERT().
+  //
+  ASSERT (Format != NULL);
+
+  //
+  // Check driver Debug Level value and global debug level
+  //
+  if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {
+    return;
+  }
+
+  if (mDebugPpi == NULL) {
+    Status = PeiServicesLocatePpi (
+                &gEdkiiDebugPpiGuid,
+                0,
+                NULL,
+                (VOID **)&mDebugPpi
+                );
+    if (EFI_ERROR (Status)) {
+      CpuDeadLoop();
+    }
+  }
+
+  if (mPeiServicesTablePointer == NULL) {
+    mPeiServicesTablePointer = GetPeiServicesTablePointer ();
+  }
+
+  mDebugPpi->DebugBPrint (
+              mPeiServicesTablePointer,
+              mDebugPpi,
+              ErrorLevel,
+              Format,
+              BaseListMarker
+              );
+}
+
+
+/**
+  Worker function that convert a VA_LIST to a BASE_LIST based on a
+  Null-terminated format string.
+
+  @param  Format          Null-terminated format string.
+  @param  VaListMarker    VA_LIST style variable argument list consumed
+                          by processing Format.
+  @param  BaseListMarker  BASE_LIST style variable argument list consumed
+                          by processing Format.
+  @param  Size            The size, in bytes, of the BaseListMarker buffer.
+
+  @return TRUE   The VA_LIST has been converted to BASE_LIST.
+  @return FALSE  The VA_LIST has not been converted to BASE_LIST.
+
+**/
+BOOLEAN
+VaListToBaseList (
+  IN  CONST CHAR8  *Format,
+  IN  VA_LIST      VaListMarker,
+  OUT BASE_LIST    BaseListMarker,
+  IN  UINTN        Size
+  )
+{
+  BASE_LIST       BaseListStart;
+  BOOLEAN         Long;
+
+  ASSERT (Format != NULL);
+
+  ASSERT (BaseListMarker != NULL);
+
+  BaseListStart = BaseListMarker;
+
+  for (; *Format != '\0'; Format++) {
+    //
+    // Only format with prefix % is processed.
+    //
+    if (*Format != '%') {
+      continue;
+    }
+
+    Long = FALSE;
+
+    //
+    // Parse Flags and Width
+    //
+    for (Format++; TRUE; Format++) {
+      if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') {
+        //
+        // These characters in format field are omitted.
+        //
+        continue;
+      }
+      if (*Format >= '0' && *Format <= '9') {
+        //
+        // These characters in format field are omitted.
+        //
+        continue;
+      }
+      if (*Format == 'L' || *Format == 'l') {
+        //
+        // 'L" or "l" in format field means the number being printed is a UINT64
+        //
+        Long = TRUE;
+        continue;
+      }
+      if (*Format == '*') {
+        //
+        // '*' in format field means the precision of the field is specified by
+        // a UINTN argument in the argument list.
+        //
+        BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
+        continue;
+      }
+      if (*Format == '\0') {
+        //
+        // Make no output if Format string terminates unexpectedly when
+        // looking up for flag, width, precision and type.
+        //
+        Format--;
+      }
+      //
+      // When valid argument type detected or format string terminates unexpectedly,
+      // the inner loop is done.
+      //
+      break;
+    }
+
+    //
+    // Pack variable arguments into the storage area following EFI_DEBUG_INFO.
+    //
+    if ((*Format == 'p') && (sizeof (VOID *) > 4)) {
+      Long = TRUE;
+    }
+    if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {
+      if (Long) {
+        BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
+      } else {
+        BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
+      }
+    } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') {
+      BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
+    } else if (*Format == 'c') {
+      BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
+    } else if (*Format == 'r') {
+      BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);
+    }
+
+    //
+    // If the converted BASE_LIST is larger than the size of BaseListMarker, then return FALSE
+    //
+    if (((UINTN)BaseListMarker - (UINTN)BaseListStart) > Size) {
+      return FALSE;
+    }
+  }
+
+  return TRUE;
+}
+
+
+/**
+  Prints a debug message to the debug output device if the specified
+  error level is enabled.
+
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
+  GetDebugPrintErrorLevel (), then print the message specified by Format and
+  the associated variable argument list to the debug output device.
+
+  If Format is NULL, then ASSERT().
+
+  @param  ErrorLevel    The error level of the debug message.
+  @param  Format        Format string for the debug message to print.
+  @param  VaListMarker  VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+DebugVPrint (
+  IN  UINTN         ErrorLevel,
+  IN  CONST CHAR8   *Format,
+  IN  VA_LIST       VaListMarker
+  )
+{
+  UINT64            BaseListMarker[256 / sizeof (UINT64)];
+  BOOLEAN           Converted;
+
+  //
+  // Convert the VaList to BaseList
+  //
+  Converted = VaListToBaseList (
+                Format,
+                VaListMarker,
+                (BASE_LIST)BaseListMarker,
+                 sizeof (BaseListMarker) - 8
+                );
+
+  if (!Converted) {
+    return;
+  }
+
+  DebugBPrint (ErrorLevel, Format, (BASE_LIST)BaseListMarker);
+}
+
+
+/**
+  Prints an assert message containing a filename, line number, and description.
+  This may be followed by a breakpoint or a dead loop.
+
+  Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"
+  to the debug output device.  If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of
+  PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
+  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then
+  CpuDeadLoop() is called.  If neither of these bits are set, then this function
+  returns immediately after the message is printed to the debug output device.
+  DebugAssert() must actively prevent recursion.  If DebugAssert() is called while
+  processing another DebugAssert(), then DebugAssert() must return immediately.
+
+  If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
+  If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
+
+  @param  FileName     The pointer to the name of the source file that generated the assert condition.
+  @param  LineNumber   The line number in the source file that generated the assert condition
+  @param  Description  The pointer to the description of the assert condition.
+
+**/
+VOID
+EFIAPI
+DebugAssert (
+  IN CONST CHAR8  *FileName,
+  IN UINTN        LineNumber,
+  IN CONST CHAR8  *Description
+  )
+{
+  EFI_STATUS      Status;
+
+  if (mDebugPpi == NULL) {
+    Status = PeiServicesLocatePpi (
+                &gEdkiiDebugPpiGuid,
+                0,
+                NULL,
+                (VOID **)&mDebugPpi
+                );
+    if (EFI_ERROR (Status)) {
+      CpuDeadLoop();
+    }
+  }
+
+  if (mPeiServicesTablePointer == NULL) {
+    mPeiServicesTablePointer = GetPeiServicesTablePointer ();
+  }
+
+  mDebugPpi->DebugAssert (
+              mPeiServicesTablePointer,
+              mDebugPpi,
+              FileName,
+              LineNumber,
+              Description
+              );
+}
+
+
+/**
+  Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
+
+  This function fills Length bytes of Buffer with the value specified by
+  PcdDebugClearMemoryValue, and returns Buffer.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param   Buffer  The pointer to the target buffer to be filled with PcdDebugClearMemoryValue.
+  @param   Length  The number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
+
+  @return  Buffer  The pointer to the target buffer filled with PcdDebugClearMemoryValue.
+
+**/
+VOID *
+EFIAPI
+DebugClearMemory (
+  OUT VOID  *Buffer,
+  IN UINTN  Length
+  )
+{
+  ASSERT (Buffer != NULL);
+
+  return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
+}
+
+
+/**
+  Returns TRUE if ASSERT() macros are enabled.
+
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
+  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
+
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugAssertEnabled (
+  VOID
+  )
+{
+  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+}
+
+
+/**
+  Returns TRUE if DEBUG() macros are enabled.
+
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
+  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
+
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugPrintEnabled (
+  VOID
+  )
+{
+  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+}
+
+
+/**
+  Returns TRUE if DEBUG_CODE() macros are enabled.
+
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
+  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
+
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugCodeEnabled (
+  VOID
+  )
+{
+  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
+
+
+/**
+  Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.
+
+  This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of
+  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
+
+  @retval  TRUE    The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.
+  @retval  FALSE   The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugClearMemoryEnabled (
+  VOID
+  )
+{
+  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+}
+
+
+/**
+  Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel.
+
+  This function compares the bit mask of ErrorLevel and PcdFixedDebugPrintErrorLevel.
+
+  @retval  TRUE    Current ErrorLevel is supported.
+  @retval  FALSE   Current ErrorLevel is not supported.
+
+**/
+BOOLEAN
+EFIAPI
+DebugPrintLevelEnabled (
+  IN  CONST UINTN        ErrorLevel
+  )
+{
+  return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);
+}
+
diff --git a/MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf b/MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf
new file mode 100644
index 0000000000..4ab21e577e
--- /dev/null
+++ b/MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf
@@ -0,0 +1,55 @@
+## @file
+#  Debug Lib instance through DebugServicePei for PEI phase
+#
+#  This module installs gEdkiiFaultTolerantWriteGuid PPI to inform the check for FTW last write data has been done.
+#
+#  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+#
+#  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.
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = PeiDebugLibDebugPpi
+  FILE_GUID                      = 2E08836C-4D1C-42F7-BBBE-EC5D25F1FDD4
+  MODULE_TYPE                    = PEIM
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = DebugLib|PEIM
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 EBC
+#
+
+[Sources]
+  DebugLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  PcdLib
+  BaseMemoryLib
+  DebugPrintErrorLevelLib
+  PeiServicesLib
+  PeiServicesTablePointerLib
+
+[Ppis]
+  gEdkiiDebugPpiGuid                                        ## CONSUMES
+
+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue         ## SOMETIMES_CONSUMES
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask             ## CONSUMES
+  gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel     ## CONSUMES
+
+[Depex]
+  gEdkiiDebugPpiGuid
+
-- 
2.16.2.windows.1



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

* [PATCH V3 17/17] MdeModulePkg: Add PEIM and lib to dsc file
  2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
                   ` (15 preceding siblings ...)
  2019-03-19 15:25 ` [PATCH V3 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib Zhichao Gao
@ 2019-03-19 15:25 ` Zhichao Gao
  2019-03-21  5:22   ` Wu, Hao A
  16 siblings, 1 reply; 31+ messages in thread
From: Zhichao Gao @ 2019-03-19 15:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Jian J Wang, Hao Wu, Ray Ni, Star Zeng, Liming Gao, Sean Brogan,
	Michael Turner, Bret Barkelew

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

Add the new PEIM DebugServicePei and library instance
PeiDebugLibDebugPpi to dsc file to verify it can build
correctly.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
---
 MdeModulePkg/MdeModulePkg.dsc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 6cd1727a0d..dec441e23e 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -297,6 +297,7 @@
   MdeModulePkg/Library/PlatformHookLibSerialPortPpi/PlatformHookLibSerialPortPpi.inf
   MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
   MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+  MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf
   MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
   MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManagerLibNull.inf
   MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
@@ -423,6 +424,8 @@
   MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
   MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf
 
+  MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
+
   MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf
   MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.inf
   MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
-- 
2.16.2.windows.1



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

* Re: [PATCH V3 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: Add new APIs
  2019-03-19 15:25 ` [PATCH V3 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: " Zhichao Gao
@ 2019-03-19 23:37   ` Chiu, Chasel
  0 siblings, 0 replies; 31+ messages in thread
From: Chiu, Chasel @ 2019-03-19 23:37 UTC (permalink / raw)
  To: Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Desimone, Nathaniel L, Zeng, Star, Gao, Liming, Sean Brogan,
	Michael Turner, Bret Barkelew


Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

> -----Original Message-----
> From: Gao, Zhichao
> Sent: Tuesday, March 19, 2019 11:26 PM
> To: edk2-devel@lists.01.org
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; Gao,
> Liming <liming.gao@intel.com>; Sean Brogan <sean.brogan@microsoft.com>;
> Michael Turner <Michael.Turner@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>
> Subject: [PATCH V3 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: Add new
> APIs
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> 
> Add new APIs' implementation (DebugVPrint, DebugBPrint) in the DebugLib
> instance. These APIs would expose print routines with VaList parameter and
> BaseList parameter.
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> ---
>  .../Library/BaseFspDebugLibSerialPort/DebugLib.c   | 103
> ++++++++++++++++++++-
>  1 file changed, 98 insertions(+), 5 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> index 73bb08e357..8b322c038e 100644
> --- a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> +++ b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> @@ -1,6 +1,6 @@
>  /** @file
> 
> -  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2014 - 2019, Intel Corporation. All rights
> + reserved.<BR>
>    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 @@ -28,6 +28,12 @@
> 
>  CONST CHAR8  *mHexTable = "0123456789ABCDEF";
> 
> +//
> +// VA_LIST can not initialize to NULL for all compiler, so we use this
> +to // indicate a null VA_LIST //
> +VA_LIST     mVaListNull;
> +
>  /**
>    Get stack frame pointer of function call.
> 
> @@ -62,9 +68,40 @@ DebugPrint (
>    IN  CONST CHAR8  *Format,
>    ...
>    )
> +{
> +  VA_LIST         Marker;
> +
> +  VA_START (Marker, Format);
> +  DebugVPrint (ErrorLevel, Format, Marker);
> +  VA_END (Marker);
> +}
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled base on Null-terminated format string and a
> +  VA_LIST argument list or a BASE_LIST argument list.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> + function  GetDebugPrintErrorLevel (), then print the message specified
> + by Format and  the associated variable argument list to the debug output
> device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel      The error level of the debug message.
> +  @param  Format          Format string for the debug message to print.
> +  @param  VaListMarker    VA_LIST marker for the variable argument list.
> +  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +DebugPrintMarker (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  VA_LIST       VaListMarker,
> +  IN  BASE_LIST     BaseListMarker
> +  )
>  {
>    CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
> -  VA_LIST  Marker;
> 
>    //
>    // If Format is NULL, then ASSERT().
> @@ -88,9 +125,11 @@ DebugPrint (
>    //
>    // Convert the DEBUG() message to an ASCII String
>    //
> -  VA_START (Marker, Format);
> -  AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
> -  VA_END (Marker);
> +  if (BaseListMarker == NULL) {
> +    AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);  }
> + else {
> +    AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);  }
> 
>    //
>    // Send the print string to a Serial Port @@ -98,6 +137,60 @@ DebugPrint (
>    SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));  }
> 
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> + function  GetDebugPrintErrorLevel (), then print the message specified
> + by Format and  the associated variable argument list to the debug output
> device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel    The error level of the debug message.
> +  @param  Format        Format string for the debug message to print.
> +  @param  VaListMarker  VA_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugVPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  VA_LIST       VaListMarker
> +  )
> +{
> +  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL); }
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +  This function use BASE_LIST which would provide a more compatible
> +  service than VA_LIST.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> + function  GetDebugPrintErrorLevel (), then print the message specified
> + by Format and  the associated variable argument list to the debug output
> device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel      The error level of the debug message.
> +  @param  Format          Format string for the debug message to print.
> +  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugBPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  BASE_LIST     BaseListMarker
> +  )
> +{
> +  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker); }
> +
>  /**
>    Convert an UINT32 value into HEX string sepcified by Buffer.
> 
> --
> 2.16.2.windows.1



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

* Re: [PATCH V3 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: Add new APIs
  2019-03-19 15:25 ` [PATCH V3 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: " Zhichao Gao
@ 2019-03-19 23:37   ` Chiu, Chasel
  0 siblings, 0 replies; 31+ messages in thread
From: Chiu, Chasel @ 2019-03-19 23:37 UTC (permalink / raw)
  To: Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Desimone, Nathaniel L, Zeng, Star, Gao, Liming, Sean Brogan,
	Michael Turner, Bret Barkelew


Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

> -----Original Message-----
> From: Gao, Zhichao
> Sent: Tuesday, March 19, 2019 11:26 PM
> To: edk2-devel@lists.01.org
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; Gao,
> Liming <liming.gao@intel.com>; Sean Brogan <sean.brogan@microsoft.com>;
> Michael Turner <Michael.Turner@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>
> Subject: [PATCH V3 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: Add new
> APIs
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> 
> Add new APIs' implementation (DebugVPrint, DebugBPrint) in the DebugLib
> instance. These APIs would expose print routines with VaList parameter and
> BaseList parameter.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> ---
>  .../Library/BaseFspDebugLibSerialPort/DebugLib.c   | 103
> ++++++++++++++++++++-
>  1 file changed, 98 insertions(+), 5 deletions(-)
> 
> diff --git a/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> b/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> index 73bb08e357..8b322c038e 100644
> --- a/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> +++ b/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> @@ -1,6 +1,6 @@
>  /** @file
> 
> -  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2014 - 2019, Intel Corporation. All rights
> + reserved.<BR>
>    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 @@ -28,6 +28,12 @@
> 
>  CONST CHAR8  *mHexTable = "0123456789ABCDEF";
> 
> +//
> +// VA_LIST can not initialize to NULL for all compiler, so we use this
> +to // indicate a null VA_LIST //
> +VA_LIST     mVaListNull;
> +
>  /**
>    Get stack frame pointer of function call.
> 
> @@ -62,9 +68,40 @@ DebugPrint (
>    IN  CONST CHAR8  *Format,
>    ...
>    )
> +{
> +  VA_LIST         Marker;
> +
> +  VA_START (Marker, Format);
> +  DebugVPrint (ErrorLevel, Format, Marker);
> +  VA_END (Marker);
> +}
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled base on Null-terminated format string and a
> +  VA_LIST argument list or a BASE_LIST argument list.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> + function  GetDebugPrintErrorLevel (), then print the message specified
> + by Format and  the associated variable argument list to the debug output
> device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel      The error level of the debug message.
> +  @param  Format          Format string for the debug message to print.
> +  @param  VaListMarker    VA_LIST marker for the variable argument list.
> +  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +DebugPrintMarker (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  VA_LIST       VaListMarker,
> +  IN  BASE_LIST     BaseListMarker
> +  )
>  {
>    CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
> -  VA_LIST  Marker;
> 
>    //
>    // If Format is NULL, then ASSERT().
> @@ -88,9 +125,11 @@ DebugPrint (
>    //
>    // Convert the DEBUG() message to an ASCII String
>    //
> -  VA_START (Marker, Format);
> -  AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
> -  VA_END (Marker);
> +  if (BaseListMarker == NULL) {
> +    AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);  }
> + else {
> +    AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);  }
> 
>    //
>    // Send the print string to a Serial Port @@ -98,6 +137,60 @@ DebugPrint (
>    SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));  }
> 
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> + function  GetDebugPrintErrorLevel (), then print the message specified
> + by Format and  the associated variable argument list to the debug output
> device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel    The error level of the debug message.
> +  @param  Format        Format string for the debug message to print.
> +  @param  VaListMarker  VA_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugVPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  VA_LIST       VaListMarker
> +  )
> +{
> +  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL); }
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +  This function use BASE_LIST which would provide a more compatible
> +  service than VA_LIST.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> + function  GetDebugPrintErrorLevel (), then print the message specified
> + by Format and  the associated variable argument list to the debug output
> device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel      The error level of the debug message.
> +  @param  Format          Format string for the debug message to print.
> +  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugBPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  BASE_LIST     BaseListMarker
> +  )
> +{
> +  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker); }
> +
>  /**
>    Convert an UINT32 value into HEX string sepcified by Buffer.
> 
> --
> 2.16.2.windows.1



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

* Re: [PATCH V3 09/17] OvmfPkg/PlatformDebugLibIoPort: Add new APIs
  2019-03-19 15:25 ` [PATCH V3 09/17] OvmfPkg/PlatformDebugLibIoPort: " Zhichao Gao
@ 2019-03-20 16:57   ` Laszlo Ersek
  2019-03-21 10:15     ` Gao, Zhichao
  0 siblings, 1 reply; 31+ messages in thread
From: Laszlo Ersek @ 2019-03-20 16:57 UTC (permalink / raw)
  To: Zhichao Gao, edk2-devel
  Cc: Jordan Justen, Michael Turner, Bret Barkelew, Liming Gao

On 03/19/19 16:25, Zhichao Gao wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> 
> Add new APIs' implementation (DebugVPrint, DebugBPrint)
> in the DebugLib instance. These APIs would expose print
> routines with VaList parameter and BaseList parameter.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> ---
>  OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 106 +++++++++++++++++++++-
>  1 file changed, 101 insertions(+), 5 deletions(-)
> 
> diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> index 36cde54976..cda35faf66 100644
> --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> @@ -2,7 +2,7 @@
>    Base Debug library instance for QEMU debug port.
>    It uses PrintLib to send debug messages to a fixed I/O port.
>  
> -  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
>    Copyright (c) 2012, Red Hat, Inc.<BR>
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of the BSD License
> @@ -29,6 +29,12 @@
>  //
>  #define MAX_DEBUG_MESSAGE_LENGTH  0x100
>  
> +//
> +// VA_LIST can not initialize to NULL for all compiler, so we use this to
> +// indicate a null VA_LIST
> +//
> +VA_LIST     mVaListNull;
> +
>  /**
>    Prints a debug message to the debug output device if the specified error level is enabled.
>  
> @@ -51,9 +57,41 @@ DebugPrint (
>    IN  CONST CHAR8  *Format,
>    ...
>    )
> +{
> +  VA_LIST         Marker;
> +
> +  VA_START (Marker, Format);
> +  DebugVPrint (ErrorLevel, Format, Marker);
> +  VA_END (Marker);
> +}
> +
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled base on Null-terminated format string and a
> +  VA_LIST argument list or a BASE_LIST argument list.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> +  GetDebugPrintErrorLevel (), then print the message specified by Format and
> +  the associated variable argument list to the debug output device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel      The error level of the debug message.
> +  @param  Format          Format string for the debug message to print.
> +  @param  VaListMarker    VA_LIST marker for the variable argument list.
> +  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +DebugPrintMarker (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  VA_LIST       VaListMarker,
> +  IN  BASE_LIST     BaseListMarker
> +  )
>  {
>    CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
> -  VA_LIST  Marker;
>    UINTN    Length;
>  
>    //
> @@ -72,9 +110,11 @@ DebugPrint (
>    //
>    // Convert the DEBUG() message to an ASCII String
>    //
> -  VA_START (Marker, Format);
> -  Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
> -  VA_END (Marker);
> +  if (BaseListMarker == NULL) {
> +    Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
> +  } else {
> +    Length = AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
> +  }
>  
>    //
>    // Send the print string to the debug I/O port
> @@ -83,6 +123,62 @@ DebugPrint (
>  }
>  
>  
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> +  GetDebugPrintErrorLevel (), then print the message specified by Format and
> +  the associated variable argument list to the debug output device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel    The error level of the debug message.
> +  @param  Format        Format string for the debug message to print.
> +  @param  VaListMarker  VA_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugVPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  VA_LIST       VaListMarker
> +  )
> +{
> +  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
> +}
> +
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +  This function use BASE_LIST which would provide a more compatible
> +  service than VA_LIST.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> +  GetDebugPrintErrorLevel (), then print the message specified by Format and
> +  the associated variable argument list to the debug output device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel      The error level of the debug message.
> +  @param  Format          Format string for the debug message to print.
> +  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugBPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  BASE_LIST     BaseListMarker
> +  )
> +{
> +  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
> +}
> +
> +
>  /**
>    Prints an assert message containing a filename, line number, and description.
>    This may be followed by a breakpoint or a dead loop.
> 

I couldn't find the will to review the comments, but the code looks sane
to me.

Acked-by: Laszlo Ersek <lersek@redhat.com>

In the future, for any given person CC'd on at least one patch in the
series, please make sure the person is also CC'd on the cover letter.
Version 3 of this patch is very different from version 2, but I had to
construct the reason myself retro-actively (look up the v3 blurb in my
list folder, read the summary, go back to v2, find Andrew's comments).
This could have been helped at least a little if I had been CC'd on the
v3 blurb.

Thanks
Laszlo


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

* Re: [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
  2019-03-19 15:25 ` [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
@ 2019-03-21  5:22   ` Wu, Hao A
  2019-03-21  6:57   ` Gao, Liming
  1 sibling, 0 replies; 31+ messages in thread
From: Wu, Hao A @ 2019-03-21  5:22 UTC (permalink / raw)
  To: Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Wang, Jian J, Ni, Ray, Zeng, Star, Gao, Liming, Sean Brogan,
	Michael Turner, Bret Barkelew

Sorry for the delayed response.
One minor comment below.


> -----Original Message-----
> From: Gao, Zhichao
> Sent: Tuesday, March 19, 2019 11:26 PM
> To: edk2-devel@lists.01.org
> Cc: Wang, Jian J; Wu, Hao A; Ni, Ray; Zeng, Star; Gao, Liming; Sean Brogan;
> Michael Turner; Bret Barkelew
> Subject: [PATCH V3 13/17]
> MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> 
> Add new APIs' implementation (DebugVPrint, DebugBPrint)
> in the DebugLib instance. These APIs would expose print
> routines with VaList parameter and BaseList parameter.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> ---
>  .../PeiDxeDebugLibReportStatusCode/DebugLib.c      | 144
> ++++++++++++++++++---
>  1 file changed, 128 insertions(+), 16 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> index 6f0f416273..f1d31cb619 100644
> --- a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> +++
> b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> @@ -4,7 +4,7 @@
>    Note that if the debug message length is larger than the maximum
> allowable
>    record length, then the debug message will be ignored directly.
> 
> -  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
>    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
> @@ -27,6 +27,12 @@
>  #include <Library/PcdLib.h>
>  #include <Library/DebugPrintErrorLevelLib.h>
> 
> +//
> +// VA_LIST can not initialize to NULL for all compiler, so we use this to
> +// indicate a null VA_LIST
> +//
> +VA_LIST     mVaListNull;
> +
>  /**
>    Prints a debug message to the debug output device if the specified error
> level is enabled.
> 
> @@ -52,12 +58,43 @@ DebugPrint (
>    IN  CONST CHAR8  *Format,
>    ...
>    )
> +{
> +  VA_LIST         Marker;
> +
> +  VA_START (Marker, Format);
> +  DebugVPrint (ErrorLevel, Format, Marker);
> +  VA_END (Marker);
> +}
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled base on Null-terminated format string and a
> +  VA_LIST argument list or a BASE_LIST argument list.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> +  GetDebugPrintErrorLevel (), then print the message specified by Format
> and
> +  the associated variable argument list to the debug output device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel      The error level of the debug message.
> +  @param  Format          Format string for the debug message to print.
> +  @param  VaListMarker    VA_LIST marker for the variable argument list.
> +  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +DebugPrintMarker (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  VA_LIST       VaListMarker,
> +  IN  BASE_LIST     BaseListMarker
> +  )
>  {
>    UINT64          Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64))
> + 1];
>    EFI_DEBUG_INFO  *DebugInfo;
>    UINTN           TotalSize;
> -  VA_LIST         VaListMarker;
> -  BASE_LIST       BaseListMarker;
> +  BASE_LIST       BaseListMarkerPointer;

Please help to update the comments in DebugPrintMarker() as well to
reflect the above name change of the variable.

Other than that, the patch is good to me:
Reviewed-by: Hao Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu

>    CHAR8           *FormatString;
>    BOOLEAN         Long;
> 
> @@ -96,7 +133,7 @@ DebugPrint (
>    // If the TotalSize is larger than the maximum record size, then return
>    //
>    if (TotalSize > sizeof (Buffer)) {
> -    TotalSize = sizeof (Buffer);
> +    return;
>    }
> 
>    //
> @@ -109,7 +146,7 @@ DebugPrint (
>    //
>    DebugInfo             = (EFI_DEBUG_INFO *)(Buffer) + 1;
>    DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
> -  BaseListMarker        = (BASE_LIST)(DebugInfo + 1);
> +  BaseListMarkerPointer = (BASE_LIST)(DebugInfo + 1);
>    FormatString          = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
> 
>    //
> @@ -125,7 +162,6 @@ DebugPrint (
>    // of format in DEBUG string, which is followed by the DEBUG format string.
>    // Here we will process the variable arguments and pack them in this area.
>    //
> -  VA_START (VaListMarker, Format);
> 
>    //
>    // Use the actual format string.
> @@ -167,7 +203,11 @@ DebugPrint (
>          // '*' in format field means the precision of the field is specified by
>          // a UINTN argument in the argument list.
>          //
> -        BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
> +        if (BaseListMarker == NULL) {
> +          BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker,
> UINTN);
> +        } else {
> +          BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG
> (BaseListMarker, UINTN);
> +        }
>          continue;
>        }
>        if (*Format == '\0') {
> @@ -192,16 +232,36 @@ DebugPrint (
>      }
>      if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' ||
> *Format == 'u') {
>        if (Long) {
> -        BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
> +        if (BaseListMarker == NULL) {
> +          BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG (VaListMarker,
> INT64);
> +        } else {
> +          BASE_ARG (BaseListMarkerPointer, INT64) = BASE_ARG
> (BaseListMarker, INT64);
> +        }
>        } else {
> -        BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
> +        if (BaseListMarker == NULL) {
> +          BASE_ARG (BaseListMarkerPointer, int) = VA_ARG (VaListMarker, int);
> +        } else {
> +          BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG (BaseListMarker,
> int);
> +        }
>        }
>      } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format ==
> 'g' || *Format == 't') {
> -      BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
> +      if (BaseListMarker == NULL) {
> +        BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG (VaListMarker,
> VOID *);
> +      } else {
> +        BASE_ARG (BaseListMarkerPointer, VOID *) = BASE_ARG
> (BaseListMarker, VOID *);
> +      }
>      } else if (*Format == 'c') {
> -      BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
> +      if (BaseListMarker == NULL) {
> +        BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker,
> UINTN);
> +      } else {
> +        BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG
> (BaseListMarker, UINTN);
> +      }
>      } else if (*Format == 'r') {
> -      BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker,
> RETURN_STATUS);
> +      if (BaseListMarker == NULL) {
> +        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = VA_ARG
> (VaListMarker, RETURN_STATUS);
> +      } else {
> +        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = BASE_ARG
> (BaseListMarker, RETURN_STATUS);
> +      }
>      }
> 
>      //
> @@ -209,17 +269,15 @@ DebugPrint (
>      // This indicates that the DEBUG() macro is passing in more argument than
> can be handled by
>      // the EFI_DEBUG_INFO record
>      //
> -    ASSERT ((CHAR8 *)BaseListMarker <= FormatString);
> +    ASSERT ((CHAR8 *)BaseListMarkerPointer <= FormatString);
> 
>      //
>      // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64)
> allocated bytes, then return
>      //
> -    if ((CHAR8 *)BaseListMarker > FormatString) {
> -      VA_END (VaListMarker);
> +    if ((CHAR8 *)BaseListMarkerPointer > FormatString) {
>        return;
>      }
>    }
> -  VA_END (VaListMarker);
> 
>    //
>    // Send the DebugInfo record
> @@ -235,6 +293,60 @@ DebugPrint (
>      );
>  }
> 
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> +  GetDebugPrintErrorLevel (), then print the message specified by Format
> and
> +  the associated variable argument list to the debug output device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel    The error level of the debug message.
> +  @param  Format        Format string for the debug message to print.
> +  @param  VaListMarker  VA_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugVPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  VA_LIST       VaListMarker
> +  )
> +{
> +  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
> +}
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +  This function use BASE_LIST which would provide a more compatible
> +  service than VA_LIST.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> +  GetDebugPrintErrorLevel (), then print the message specified by Format
> and
> +  the associated variable argument list to the debug output device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel      The error level of the debug message.
> +  @param  Format          Format string for the debug message to print.
> +  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugBPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  BASE_LIST     BaseListMarker
> +  )
> +{
> +  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
> +}
> +
>  /**
>    Prints an assert message containing a filename, line number, and
> description.
>    This may be followed by a breakpoint or a dead loop.
> --
> 2.16.2.windows.1



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

* Re: [PATCH V3 14/17] MdeModulePkg: Add definitions for EDKII DEBUG PPI
  2019-03-19 15:25 ` [PATCH V3 14/17] MdeModulePkg: Add definitions for EDKII DEBUG PPI Zhichao Gao
@ 2019-03-21  5:22   ` Wu, Hao A
  0 siblings, 0 replies; 31+ messages in thread
From: Wu, Hao A @ 2019-03-21  5:22 UTC (permalink / raw)
  To: Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Wang, Jian J, Ni, Ray, Zeng, Star, Gao, Liming, Sean Brogan,
	Michael Turner, Bret Barkelew

> -----Original Message-----
> From: Gao, Zhichao
> Sent: Tuesday, March 19, 2019 11:26 PM
> To: edk2-devel@lists.01.org
> Cc: Wang, Jian J; Wu, Hao A; Ni, Ray; Zeng, Star; Gao, Liming; Sean Brogan;
> Michael Turner; Bret Barkelew
> Subject: [PATCH V3 14/17] MdeModulePkg: Add definitions for EDKII DEBUG
> PPI
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> 
> Add a debug PPI for PEI phase. This PPI will provide basic
> services of debug. PEI debug lib instance can use these
> services to implement debug function to reduce the PEIMs
> which consume the debug lib.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> ---
>  MdeModulePkg/Include/Ppi/Debug.h | 90
> ++++++++++++++++++++++++++++++++++++++++
>  MdeModulePkg/MdeModulePkg.dec    |  3 ++
>  2 files changed, 93 insertions(+)
>  create mode 100644 MdeModulePkg/Include/Ppi/Debug.h
> 
> diff --git a/MdeModulePkg/Include/Ppi/Debug.h
> b/MdeModulePkg/Include/Ppi/Debug.h
> new file mode 100644
> index 0000000000..40db304f3d
> --- /dev/null
> +++ b/MdeModulePkg/Include/Ppi/Debug.h
> @@ -0,0 +1,90 @@
> +/** @file
> +  Define the EDKII_DEBUG_PPI that PEIMs can use to dump info to debug
> port.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +
> +  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.
> +
> +**/
> +
> +#ifndef __EDKII_DEBUG_PPI_H__
> +#define __EDKII_DEBUG_PPI_H__
> +
> +#include <Pi/PiPeiCis.h>
> +
> +//
> +// Global ID for the EDKII_DEBUG_PPI
> +//
> +#define EDKII_DEBUG_PPI_GUID \
> +  { \
> +    0x999e699c, 0xb013, 0x475e, {0xb1, 0x7b, 0xf3, 0xa8, 0xae, 0x5c, 0x48,
> 0x75} \
> +  }
> +
> +///
> +/// Forward declaration for the PEI_DEBUG_LIB_DEBUG_PPI
> EDKII_DEBUG_PPI
> +///
> +typedef struct _EDKII_DEBUG_PPI EDKII_DEBUG_PPI;
> +
> +/**
> +  Print a debug message to debug output device if the specified error level
> +  is enabled.
> +
> +  @param[in] PeiServices              The pointer to the PEI Services Table.
> +  @param[in] This                     The pointer to this instance of
> EDKII_DEBUG_PPI
> +  @param[in] ErrorLevel               The error level of the debug message.
> +  @param[in] Format                   Format string for the debug message to print.
> +  @param[in] Marker                   BASE_LIST marker for the variable argument
> list.
> +
> +**/
> +typedef
> +VOID
> +(EFIAPI *EDKII_DEBUG_BPRINT)(
> +  IN CONST EFI_PEI_SERVICES         **PeiServices,
> +  IN EDKII_DEBUG_PPI                *This,
> +  IN UINTN                          ErrorLevel,
> +  IN CONST CHAR8                    *Format,
> +  IN BASE_LIST                      Marker
> +  );

Hello,

I checked the PEIM that implements this PPI (patch 15/17), and I did not
find the parameters 'PeiServices' & 'This' are being used there.

Thus, I suggest to remove those 2 parameters from the interfaces of
EFIAPI *EDKII_DEBUG_BPRINT
EFIAPI *EDKII_DEBUG_ASSERT

Best Regards,
Hao Wu

> +
> +/**
> +  Print an assert message containing a filename, line number, and
> description.
> +  This may be followed by a breakpoint or a dead loop.
> +
> +  @param[in] PeiServices              The pointer to the PEI Services Table.
> +  @param[in] This                     The pointer to this instance of
> EDKII_DEBUG_PPI
> +  @param[in] FileName                 The pointer to the name of the source file
> that
> +                                      generated the assert condition.
> +  @param[in] LineNumber               The line number in the source file that
> generated
> +                                      the assert condition
> +  @param[in] Description              The pointer to the description of the assert
> condition.
> +
> +**/
> +typedef
> +VOID
> +(EFIAPI *EDKII_DEBUG_ASSERT)(
> +  IN CONST EFI_PEI_SERVICES         **PeiServices,
> +  IN EDKII_DEBUG_PPI                *This,
> +  IN CONST CHAR8                    *FileName,
> +  IN UINTN                          LineNumber,
> +  IN CONST CHAR8                    *Description
> +  );
> +
> +///
> +/// This PPI contains a set of services to print message to debug output
> device
> +///
> +struct _EDKII_DEBUG_PPI {
> +  EDKII_DEBUG_BPRINT                DebugBPrint;
> +  EDKII_DEBUG_ASSERT                DebugAssert;
> +};
> +
> +extern EFI_GUID gEdkiiDebugPpiGuid;
> +
> +#endif
> +
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index a2130bc439..9bbd0572f5 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -492,6 +492,9 @@
>    ## Include/Ppi/AtaPassThru.h
>    gEdkiiPeiAtaPassThruPpiGuid               = { 0xa16473fd, 0xd474, 0x4c89, { 0xae,
> 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9  } }
> 
> +  ## Include/Ppi/Debug.h
> +  gEdkiiDebugPpiGuid                        = { 0x999e699c, 0xb013, 0x475e, { 0xb1,
> 0x7b, 0xf3, 0xa8, 0xae, 0x5c, 0x48, 0x75 } }
> +
>  [Protocols]
>    ## Load File protocol provides capability to load and unload EFI image into
> memory and execute it.
>    #  Include/Protocol/LoadPe32Image.h
> --
> 2.16.2.windows.1



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

* Re: [PATCH V3 15/17] MdeModulePkg: Add a PEIM to install Debug PPI
  2019-03-19 15:25 ` [PATCH V3 15/17] MdeModulePkg: Add a PEIM to install Debug PPI Zhichao Gao
@ 2019-03-21  5:22   ` Wu, Hao A
  0 siblings, 0 replies; 31+ messages in thread
From: Wu, Hao A @ 2019-03-21  5:22 UTC (permalink / raw)
  To: Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Wang, Jian J, Ni, Ray, Zeng, Star, Gao, Liming, Sean Brogan,
	Michael Turner, Bret Barkelew

Hello,

Besides the comments in patch 14/17 to remove the 'PeiServices' & 'This'
parameters from the PPI services, some minor comments below:

> -----Original Message-----
> From: Gao, Zhichao
> Sent: Tuesday, March 19, 2019 11:26 PM
> To: edk2-devel@lists.01.org
> Cc: Wang, Jian J; Wu, Hao A; Ni, Ray; Zeng, Star; Gao, Liming; Sean Brogan;
> Michael Turner; Bret Barkelew
> Subject: [PATCH V3 15/17] MdeModulePkg: Add a PEIM to install Debug PPI
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> 
> Add a PEIM to install Debug PPI so that PEI debug library
> instance can locate gEdkiiDebugPpiGuid to implement the
> debug functions. Using this PPI can reduce the size of
> PEIMs which consume the debug library.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> ---
>  .../Universal/DebugServicePei/DebugService.c       | 68
> ++++++++++++++++++++++
>  .../Universal/DebugServicePei/DebugService.h       | 64
> ++++++++++++++++++++
>  .../Universal/DebugServicePei/DebugServicePei.c    | 54
> +++++++++++++++++
>  .../Universal/DebugServicePei/DebugServicePei.inf  | 51
> ++++++++++++++++
>  .../Universal/DebugServicePei/DebugServicePei.uni  | 20 +++++++
>  5 files changed, 257 insertions(+)
>  create mode 100644
> MdeModulePkg/Universal/DebugServicePei/DebugService.c
>  create mode 100644
> MdeModulePkg/Universal/DebugServicePei/DebugService.h
>  create mode 100644
> MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
>  create mode 100644
> MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
>  create mode 100644
> MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni
> 
> diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugService.c
> b/MdeModulePkg/Universal/DebugServicePei/DebugService.c
> new file mode 100644
> index 0000000000..54ae6974d1
> --- /dev/null
> +++ b/MdeModulePkg/Universal/DebugServicePei/DebugService.c
> @@ -0,0 +1,68 @@
> +/** @file
> +  Debug services instances for PEI phase.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +
> +  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 <Ppi/Debug.h>
> +#include <Library/DebugLib.h>
> +
> +/**
> +  Print a debug message to debug output device if the specified error level
> +  is enabled.
> +
> +  @param[in] PeiServices              The pointer to the PEI Services Table.
> +  @param[in] This                     The pointer to this instance of
> EDKII_DEBUG_PPI
> +  @param[in] ErrorLevel               The error level of the debug message.
> +  @param[in] Format                   Format string for the debug message to print.
> +  @param[in] Marker                   BASE_LIST marker for the variable argument
> list.
> +
> +**/
> +VOID
> +EFIAPI
> +PeiDebugBPrint(
> +  IN CONST EFI_PEI_SERVICES         **PeiServices,
> +  IN EDKII_DEBUG_PPI                *This,
> +  IN UINTN                          ErrorLevel,
> +  IN CONST CHAR8                    *Format,
> +  IN BASE_LIST                      Marker
> +  )
> +{
> +  DebugBPrint(ErrorLevel, Format, Marker);
> +}
> +
> +/**
> +  Print an assert message containing a filename, line number, and
> description.
> +  This may be followed by a breakpoint or a dead loop.
> +
> +  @param[in] PeiServices              The pointer to the PEI Services Table.
> +  @param[in] This                     The pointer to this instance of
> EDKII_DEBUG_PPI
> +  @param[in] FileName                 The pointer to the name of the source file
> that
> +                                      generated the assert condition.
> +  @param[in] LineNumber               The line number in the source file that
> generated
> +                                      the assert condition
> +  @param[in] Description              The pointer to the description of the assert
> condition.
> +
> +**/
> +VOID
> +EFIAPI
> +PeiDebugAssert(
> +  IN CONST EFI_PEI_SERVICES         **PeiServices,
> +  IN EDKII_DEBUG_PPI                *This,
> +  IN CONST CHAR8                    *FileName,
> +  IN UINTN                          LineNumber,
> +  IN CONST CHAR8                    *Description
> +  )
> +{
> +  DebugAssert(FileName, LineNumber, Description);
> +}
> +
> diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugService.h
> b/MdeModulePkg/Universal/DebugServicePei/DebugService.h
> new file mode 100644
> index 0000000000..21b44248bb
> --- /dev/null
> +++ b/MdeModulePkg/Universal/DebugServicePei/DebugService.h
> @@ -0,0 +1,64 @@
> +/** @file
> +  Header file of Debug services instances.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +
> +  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.
> +
> +**/
> +#ifndef __DEBUG_SERVICE_H__
> +#define __DEBUG_SERVICE_H__
> +
> +#include <Ppi/Debug.h>
> +
> +/**
> +  Print a debug message to debug output device if the specified error level
> +  is enabled.
> +
> +  @param[in] PeiServices              The pointer to the PEI Services Table.
> +  @param[in] This                     The pointer to this instance of
> EDKII_DEBUG_PPI
> +  @param[in] ErrorLevel               The error level of the debug message.
> +  @param[in] Format                   Format string for the debug message to print.
> +  @param[in] Marker                   BASE_LIST marker for the variable argument
> list.
> +
> +**/
> +VOID
> +EFIAPI
> +PeiDebugBPrint(
> +  IN CONST EFI_PEI_SERVICES         **PeiServices,
> +  IN EDKII_DEBUG_PPI                *This,
> +  IN UINTN                          ErrorLevel,
> +  IN CONST CHAR8                    *Format,
> +  IN BASE_LIST                      Marker
> +  );
> +
> +/**
> +  Prints an assert message containing a filename, line number, and
> description.
> +  This may be followed by a breakpoint or a dead loop.
> +
> +  @param[in] PeiServices              The pointer to the PEI Services Table.
> +  @param[in] This                     The pointer to this instance of
> EDKII_DEBUG_PPI
> +  @param[in] FileName                 The pointer to the name of the source file
> that
> +                                      generated the assert condition.
> +  @param[in] LineNumber               The line number in the source file that
> generated
> +                                      the assert condition
> +  @param[in] Description              The pointer to the description of the assert
> condition.
> +
> +**/
> +VOID
> +EFIAPI
> +PeiDebugAssert(
> +  IN CONST EFI_PEI_SERVICES         **PeiServices,
> +  IN EDKII_DEBUG_PPI                *This,
> +  IN CONST CHAR8                    *FileName,
> +  IN UINTN                          LineNumber,
> +  IN CONST CHAR8                    *Description
> +  );
> +
> +#endif
> diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
> b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
> new file mode 100644
> index 0000000000..a502dd150b
> --- /dev/null
> +++ b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
> @@ -0,0 +1,54 @@
> +/** @file
> +  This driver installs gEdkiiPeiDebugLibDebugGuid PPI to provide

Do you mean 'installs gEdkiiDebugPpiGuid PPI' here?


> +  debug services for PEIMs.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +
> +  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 <Uefi/UefiBaseType.h>
> +#include <Library/PeimEntryPoint.h>
> +#include <Library/PeiServicesLib.h>
> +#include "DebugService.h"
> +
> +EDKII_DEBUG_PPI mDebugPpi = {
> +  PeiDebugBPrint,
> +  PeiDebugAssert
> +};
> +
> +EFI_PEI_PPI_DESCRIPTOR mDebugServicePpi = {
> +  (EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
> +  &gEdkiiDebugPpiGuid,
> +  (VOID *)&mDebugPpi
> +};
> +
> +/**
> +  Entry point of Debug Service PEIM
> +
> +  This funciton installs EDKII DEBUG PPI
> +
> +  @param  FileHandle  Handle of the file being invoked.
> +  @param  PeiServices Describes the list of possible PEI Services.
> +
> +  @retval EFI_SUCESS  The entry point of Debug Service PEIM executes
> successfully.
> +  @retval Others      Some error occurs during the execution of this function.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +DebugSerivceInitialize (
> +  IN EFI_PEI_FILE_HANDLE        FileHandle,
> +  IN CONST EFI_PEI_SERVICES     **PeiServices
> +  )
> +{
> +  return PeiServicesInstallPpi (&mDebugServicePpi);
> +}
> +
> diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
> b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
> new file mode 100644
> index 0000000000..f9563ed1b3
> --- /dev/null
> +++ b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
> @@ -0,0 +1,51 @@
> +## @file
> +#  Debug services for PEI phase
> +#
> +#  This module installs gEdkiiFaultTolerantWriteGuid PPI to inform the check
> for FTW last write data has been done.

Please help to correct the above description for the INF file.


> +#
> +#  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +#
> +#  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.
> +#
> +##
> +[Defines]
> +  INF_VERSION                    = 0x00010005
> +  BASE_NAME                      = DebugServicePei
> +  MODULE_UNI_FILE                = DebugServicePei.uni
> +  FILE_GUID                      = B73F81B9-1DFC-487C-824C-0509EE2B0128
> +  MODULE_TYPE                    = PEIM
> +  VERSION_STRING                 = 1.0
> +
> +  ENTRY_POINT                    = DebugSerivceInitialize
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +#  VALID_ARCHITECTURES           = IA32 X64 EBC
> +#
> +
> +[Sources]
> +  DebugServicePei.c
> +  DebugService.c
> +  DebugService.h
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> +  PeimEntryPoint
> +  PeiServicesLib
> +  DebugLib
> +
> +[Ppis]
> +  gEdkiiDebugPpiGuid                    ## PRODUCE
> +
> +[Depex]
> +  TRUE
> +
> diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni
> b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni
> new file mode 100644
> index 0000000000..2ac1d997d0
> --- /dev/null
> +++ b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni
> @@ -0,0 +1,20 @@
> +///** @file
> +//  This driver installs gEdkiiPeiDebugLibDebugGuid PPI to provide

Same with above, seems should be 'gEdkiiDebugPpiGuid' to me.


> +//  debug services for PEIMs.
> +//
> +//  Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.<BR>

Since this is a new file, please help to update the copyright year to 2019.


> +//
> +//  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.
> +//
> +//**/
> +
> +#string STR_MODULE_ABSTRACT             #language en-US "Provide debug
> services at PEI phase."
> +
> +#string STR_MODULE_DESCRIPTION          #language en-US "It produces
> gEdkiiPeiDebugLibDebugGuid to print message to debug output device"

Same with above, seems should be 'gEdkiiDebugPpiGuid' to me.

Best Regards,
Hao Wu

> +
> --
> 2.16.2.windows.1



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

* Re: [PATCH V3 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib
  2019-03-19 15:25 ` [PATCH V3 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib Zhichao Gao
@ 2019-03-21  5:22   ` Wu, Hao A
  0 siblings, 0 replies; 31+ messages in thread
From: Wu, Hao A @ 2019-03-21  5:22 UTC (permalink / raw)
  To: Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Gao, Liming, Wang, Jian J, Ni, Ray, Zeng, Star, Sean Brogan,
	Michael Turner, Bret Barkelew

Hello,

Besides the comments in patch 14/17 to remove the 'PeiServices' & 'This'
parameters from the PPI services, some minor comments below:

> -----Original Message-----
> From: Gao, Zhichao
> Sent: Tuesday, March 19, 2019 11:26 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming; Wang, Jian J; Wu, Hao A; Ni, Ray; Zeng, Star; Sean Brogan;
> Michael Turner; Bret Barkelew
> Subject: [PATCH V3 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI
> debug lib
> 
> From: Liming Gao <liming.gao@intel.com>
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> 
> Add a PEI debug library instance PeiDebugLibDebugPpi base on
> DebugPpi. Using the combination of the DebugServicePei and
> this lib instance can reduce the image size of PEI drivers.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> ---
>  .../Library/PeiDebugLibDebugPpi/DebugLib.c         | 469
> +++++++++++++++++++++
>  .../PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf    |  55 +++
>  2 files changed, 524 insertions(+)
>  create mode 100644
> MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
>  create mode 100644
> MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf
> 
> diff --git a/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
> b/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
> new file mode 100644
> index 0000000000..839dff5268
> --- /dev/null
> +++ b/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
> @@ -0,0 +1,469 @@
> +/** @file
> +  PEI debug lib instance base on DebugPpi to save size
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +
> +  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 <PiPei.h>
> +#include <Ppi/Debug.h>
> +#include <Library/DebugLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PeiServicesLib.h>
> +#include <Library/DebugPrintErrorLevelLib.h>
> +#include <Library/PeiServicesTablePointerLib.h>
> +
> +EDKII_DEBUG_PPI             *mDebugPpi = NULL;
> +CONST EFI_PEI_SERVICES      **mPeiServicesTablePointer = NULL;

If the EDKII_DEBUG_PPI interface changes, the above variable can be
removed.


> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> +  GetDebugPrintErrorLevel (), then print the message specified by Format
> and
> +  the associated variable argument list to the debug output device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel    The error level of the debug message.
> +  @param  Format        Format string for the debug message to print.
> +  @param  VaListMarker  VA_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugPrint (
> +  IN  UINTN        ErrorLevel,
> +  IN  CONST CHAR8  *Format,
> +  ...
> +  )
> +{
> +  VA_LIST         Marker;
> +
> +  VA_START (Marker, Format);
> +  DebugVPrint (ErrorLevel, Format, Marker);
> +  VA_END (Marker);
> +}
> +
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +  This function use BASE_LIST which would provide a more compatible
> +  service than VA_LIST.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> +  GetDebugPrintErrorLevel (), then print the message specified by Format
> and
> +  the associated variable argument list to the debug output device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel      The error level of the debug message.
> +  @param  Format          Format string for the debug message to print.
> +  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugBPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  BASE_LIST     BaseListMarker
> +  )
> +{
> +  EFI_STATUS      Status;
> +
> +  //
> +  // If Format is NULL, then ASSERT().
> +  //
> +  ASSERT (Format != NULL);
> +
> +  //
> +  // Check driver Debug Level value and global debug level
> +  //
> +  if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {
> +    return;
> +  }
> +
> +  if (mDebugPpi == NULL) {
> +    Status = PeiServicesLocatePpi (
> +                &gEdkiiDebugPpiGuid,
> +                0,
> +                NULL,
> +                (VOID **)&mDebugPpi
> +                );

The indention seems not consistent for the above several lines.


> +    if (EFI_ERROR (Status)) {
> +      CpuDeadLoop();
> +    }
> +  }
> +
> +  if (mPeiServicesTablePointer == NULL) {
> +    mPeiServicesTablePointer = GetPeiServicesTablePointer ();
> +  }

If the EDKII_DEBUG_PPI interface changes, the above lines can be removed.


> +
> +  mDebugPpi->DebugBPrint (
> +              mPeiServicesTablePointer,
> +              mDebugPpi,
> +              ErrorLevel,
> +              Format,
> +              BaseListMarker
> +              );

The indention seems not consistent for the above several lines.


> +}
> +
> +
> +/**
> +  Worker function that convert a VA_LIST to a BASE_LIST based on a
> +  Null-terminated format string.
> +
> +  @param  Format          Null-terminated format string.
> +  @param  VaListMarker    VA_LIST style variable argument list consumed
> +                          by processing Format.
> +  @param  BaseListMarker  BASE_LIST style variable argument list consumed
> +                          by processing Format.
> +  @param  Size            The size, in bytes, of the BaseListMarker buffer.
> +
> +  @return TRUE   The VA_LIST has been converted to BASE_LIST.
> +  @return FALSE  The VA_LIST has not been converted to BASE_LIST.
> +
> +**/
> +BOOLEAN
> +VaListToBaseList (
> +  IN  CONST CHAR8  *Format,
> +  IN  VA_LIST      VaListMarker,
> +  OUT BASE_LIST    BaseListMarker,
> +  IN  UINTN        Size
> +  )
> +{
> +  BASE_LIST       BaseListStart;
> +  BOOLEAN         Long;
> +
> +  ASSERT (Format != NULL);
> +
> +  ASSERT (BaseListMarker != NULL);
> +
> +  BaseListStart = BaseListMarker;
> +
> +  for (; *Format != '\0'; Format++) {
> +    //
> +    // Only format with prefix % is processed.
> +    //
> +    if (*Format != '%') {
> +      continue;
> +    }
> +
> +    Long = FALSE;
> +
> +    //
> +    // Parse Flags and Width
> +    //
> +    for (Format++; TRUE; Format++) {
> +      if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') {
> +        //
> +        // These characters in format field are omitted.
> +        //
> +        continue;
> +      }
> +      if (*Format >= '0' && *Format <= '9') {
> +        //
> +        // These characters in format field are omitted.
> +        //
> +        continue;
> +      }
> +      if (*Format == 'L' || *Format == 'l') {
> +        //
> +        // 'L" or "l" in format field means the number being printed is a UINT64
> +        //
> +        Long = TRUE;
> +        continue;
> +      }
> +      if (*Format == '*') {
> +        //
> +        // '*' in format field means the precision of the field is specified by
> +        // a UINTN argument in the argument list.
> +        //
> +        BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
> +        continue;
> +      }
> +      if (*Format == '\0') {
> +        //
> +        // Make no output if Format string terminates unexpectedly when
> +        // looking up for flag, width, precision and type.
> +        //
> +        Format--;
> +      }
> +      //
> +      // When valid argument type detected or format string terminates
> unexpectedly,
> +      // the inner loop is done.
> +      //
> +      break;
> +    }
> +
> +    //
> +    // Pack variable arguments into the storage area following
> EFI_DEBUG_INFO.
> +    //
> +    if ((*Format == 'p') && (sizeof (VOID *) > 4)) {
> +      Long = TRUE;
> +    }
> +    if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' ||
> *Format == 'u') {
> +      if (Long) {
> +        BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
> +      } else {
> +        BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
> +      }
> +    } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format ==
> 'g' || *Format == 't') {
> +      BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
> +    } else if (*Format == 'c') {
> +      BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
> +    } else if (*Format == 'r') {
> +      BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker,
> RETURN_STATUS);
> +    }
> +
> +    //
> +    // If the converted BASE_LIST is larger than the size of BaseListMarker,
> then return FALSE
> +    //
> +    if (((UINTN)BaseListMarker - (UINTN)BaseListStart) > Size) {
> +      return FALSE;
> +    }
> +  }
> +
> +  return TRUE;
> +}
> +
> +
> +/**
> +  Prints a debug message to the debug output device if the specified
> +  error level is enabled.
> +
> +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> +  GetDebugPrintErrorLevel (), then print the message specified by Format
> and
> +  the associated variable argument list to the debug output device.
> +
> +  If Format is NULL, then ASSERT().
> +
> +  @param  ErrorLevel    The error level of the debug message.
> +  @param  Format        Format string for the debug message to print.
> +  @param  VaListMarker  VA_LIST marker for the variable argument list.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugVPrint (
> +  IN  UINTN         ErrorLevel,
> +  IN  CONST CHAR8   *Format,
> +  IN  VA_LIST       VaListMarker
> +  )
> +{
> +  UINT64            BaseListMarker[256 / sizeof (UINT64)];
> +  BOOLEAN           Converted;
> +
> +  //
> +  // Convert the VaList to BaseList
> +  //
> +  Converted = VaListToBaseList (
> +                Format,
> +                VaListMarker,
> +                (BASE_LIST)BaseListMarker,
> +                 sizeof (BaseListMarker) - 8
> +                );
> +
> +  if (!Converted) {
> +    return;
> +  }
> +
> +  DebugBPrint (ErrorLevel, Format, (BASE_LIST)BaseListMarker);
> +}
> +
> +
> +/**
> +  Prints an assert message containing a filename, line number, and
> description.
> +  This may be followed by a breakpoint or a dead loop.
> +
> +  Print a message of the form "ASSERT <FileName>(<LineNumber>):
> <Description>\n"
> +  to the debug output device.  If
> DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of
> +  PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
> +  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of
> PcdDebugProperyMask is set then
> +  CpuDeadLoop() is called.  If neither of these bits are set, then this function
> +  returns immediately after the message is printed to the debug output
> device.
> +  DebugAssert() must actively prevent recursion.  If DebugAssert() is called
> while
> +  processing another DebugAssert(), then DebugAssert() must return
> immediately.
> +
> +  If FileName is NULL, then a <FileName> string of "(NULL) Filename" is
> printed.
> +  If Description is NULL, then a <Description> string of "(NULL) Description" is
> printed.
> +
> +  @param  FileName     The pointer to the name of the source file that
> generated the assert condition.
> +  @param  LineNumber   The line number in the source file that generated
> the assert condition
> +  @param  Description  The pointer to the description of the assert condition.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugAssert (
> +  IN CONST CHAR8  *FileName,
> +  IN UINTN        LineNumber,
> +  IN CONST CHAR8  *Description
> +  )
> +{
> +  EFI_STATUS      Status;
> +
> +  if (mDebugPpi == NULL) {
> +    Status = PeiServicesLocatePpi (
> +                &gEdkiiDebugPpiGuid,
> +                0,
> +                NULL,
> +                (VOID **)&mDebugPpi
> +                );

The indention seems not consistent for the above several lines.


> +    if (EFI_ERROR (Status)) {
> +      CpuDeadLoop();
> +    }
> +  }
> +
> +  if (mPeiServicesTablePointer == NULL) {
> +    mPeiServicesTablePointer = GetPeiServicesTablePointer ();
> +  }

If the EDKII_DEBUG_PPI interface changes, the above lines can be removed.


> +
> +  mDebugPpi->DebugAssert (
> +              mPeiServicesTablePointer,
> +              mDebugPpi,
> +              FileName,
> +              LineNumber,
> +              Description
> +              );

The indention seems not consistent for the above several lines.


> +}
> +
> +
> +/**
> +  Fills a target buffer with PcdDebugClearMemoryValue, and returns the
> target buffer.
> +
> +  This function fills Length bytes of Buffer with the value specified by
> +  PcdDebugClearMemoryValue, and returns Buffer.
> +
> +  If Buffer is NULL, then ASSERT().
> +  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
> +
> +  @param   Buffer  The pointer to the target buffer to be filled with
> PcdDebugClearMemoryValue.
> +  @param   Length  The number of bytes in Buffer to fill with zeros
> PcdDebugClearMemoryValue.
> +
> +  @return  Buffer  The pointer to the target buffer filled with
> PcdDebugClearMemoryValue.
> +
> +**/
> +VOID *
> +EFIAPI
> +DebugClearMemory (
> +  OUT VOID  *Buffer,
> +  IN UINTN  Length
> +  )
> +{
> +  ASSERT (Buffer != NULL);
> +
> +  return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
> +}
> +
> +
> +/**
> +  Returns TRUE if ASSERT() macros are enabled.
> +
> +  This function returns TRUE if the
> DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
> +  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
> +
> +  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
> PcdDebugProperyMask is set.
> +  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
> PcdDebugProperyMask is clear.
> +
> +**/
> +BOOLEAN
> +EFIAPI
> +DebugAssertEnabled (
> +  VOID
> +  )
> +{
> +  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) &
> DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
> +}
> +
> +
> +/**
> +  Returns TRUE if DEBUG() macros are enabled.
> +
> +  This function returns TRUE if the
> DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
> +  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
> +
> +  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
> PcdDebugProperyMask is set.
> +  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
> PcdDebugProperyMask is clear.
> +
> +**/
> +BOOLEAN
> +EFIAPI
> +DebugPrintEnabled (
> +  VOID
> +  )
> +{
> +  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) &
> DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
> +}
> +
> +
> +/**
> +  Returns TRUE if DEBUG_CODE() macros are enabled.
> +
> +  This function returns TRUE if the
> DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
> +  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
> +
> +  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
> PcdDebugProperyMask is set.
> +  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
> PcdDebugProperyMask is clear.
> +
> +**/
> +BOOLEAN
> +EFIAPI
> +DebugCodeEnabled (
> +  VOID
> +  )
> +{
> +  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) &
> DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
> +}
> +
> +
> +/**
> +  Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.
> +
> +  This function returns TRUE if the
> DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of
> +  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
> +
> +  @retval  TRUE    The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of
> PcdDebugProperyMask is set.
> +  @retval  FALSE   The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of
> PcdDebugProperyMask is clear.
> +
> +**/
> +BOOLEAN
> +EFIAPI
> +DebugClearMemoryEnabled (
> +  VOID
> +  )
> +{
> +  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) &
> DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
> +}
> +
> +
> +/**
> +  Returns TRUE if any one of the bit is set both in ErrorLevel and
> PcdFixedDebugPrintErrorLevel.
> +
> +  This function compares the bit mask of ErrorLevel and
> PcdFixedDebugPrintErrorLevel.
> +
> +  @retval  TRUE    Current ErrorLevel is supported.
> +  @retval  FALSE   Current ErrorLevel is not supported.
> +
> +**/
> +BOOLEAN
> +EFIAPI
> +DebugPrintLevelEnabled (
> +  IN  CONST UINTN        ErrorLevel
> +  )
> +{
> +  return (BOOLEAN) ((ErrorLevel &
> PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);
> +}
> +
> diff --git
> a/MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf
> b/MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf
> new file mode 100644
> index 0000000000..4ab21e577e
> --- /dev/null
> +++
> b/MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf
> @@ -0,0 +1,55 @@
> +## @file
> +#  Debug Lib instance through DebugServicePei for PEI phase
> +#
> +#  This module installs gEdkiiFaultTolerantWriteGuid PPI to inform the check
> for FTW last write data has been done.

Please help to correct the above description for the INF file.

Best Regards,
Hao Wu

> +#
> +#  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +#
> +#  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.
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010005
> +  BASE_NAME                      = PeiDebugLibDebugPpi
> +  FILE_GUID                      = 2E08836C-4D1C-42F7-BBBE-EC5D25F1FDD4
> +  MODULE_TYPE                    = PEIM
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = DebugLib|PEIM
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +#  VALID_ARCHITECTURES           = IA32 X64 EBC
> +#
> +
> +[Sources]
> +  DebugLib.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> +  PcdLib
> +  BaseMemoryLib
> +  DebugPrintErrorLevelLib
> +  PeiServicesLib
> +  PeiServicesTablePointerLib
> +
> +[Ppis]
> +  gEdkiiDebugPpiGuid                                        ## CONSUMES
> +
> +[Pcd]
> +  gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue         ##
> SOMETIMES_CONSUMES
> +  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask             ##
> CONSUMES
> +  gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel     ##
> CONSUMES
> +
> +[Depex]
> +  gEdkiiDebugPpiGuid
> +
> --
> 2.16.2.windows.1



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

* Re: [PATCH V3 17/17] MdeModulePkg: Add PEIM and lib to dsc file
  2019-03-19 15:25 ` [PATCH V3 17/17] MdeModulePkg: Add PEIM and lib to dsc file Zhichao Gao
@ 2019-03-21  5:22   ` Wu, Hao A
  0 siblings, 0 replies; 31+ messages in thread
From: Wu, Hao A @ 2019-03-21  5:22 UTC (permalink / raw)
  To: Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Wang, Jian J, Ni, Ray, Zeng, Star, Gao, Liming, Sean Brogan,
	Michael Turner, Bret Barkelew

Reviewed-by: Hao Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


> -----Original Message-----
> From: Gao, Zhichao
> Sent: Tuesday, March 19, 2019 11:26 PM
> To: edk2-devel@lists.01.org
> Cc: Wang, Jian J; Wu, Hao A; Ni, Ray; Zeng, Star; Gao, Liming; Sean Brogan;
> Michael Turner; Bret Barkelew
> Subject: [PATCH V3 17/17] MdeModulePkg: Add PEIM and lib to dsc file
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> 
> Add the new PEIM DebugServicePei and library instance
> PeiDebugLibDebugPpi to dsc file to verify it can build
> correctly.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> ---
>  MdeModulePkg/MdeModulePkg.dsc | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dsc
> b/MdeModulePkg/MdeModulePkg.dsc
> index 6cd1727a0d..dec441e23e 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -297,6 +297,7 @@
> 
> MdeModulePkg/Library/PlatformHookLibSerialPortPpi/PlatformHookLibSeria
> lPortPpi.inf
> 
> MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompr
> essLib.inf
> 
> MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLib
> ReportStatusCode.inf
> +  MdeModulePkg/Library/PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf
>    MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> 
> MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManage
> rLibNull.inf
>    MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
> @@ -423,6 +424,8 @@
>    MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
>    MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf
> 
> +  MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
> +
>    MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf
> 
> MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNu
> ll.inf
>    MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> --
> 2.16.2.windows.1



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

* Re: [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
  2019-03-19 15:25 ` [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
  2019-03-21  5:22   ` Wu, Hao A
@ 2019-03-21  6:57   ` Gao, Liming
  2019-03-21  7:06     ` Wu, Hao A
  1 sibling, 1 reply; 31+ messages in thread
From: Gao, Liming @ 2019-03-21  6:57 UTC (permalink / raw)
  To: Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Wang, Jian J, Wu, Hao A, Ni, Ray, Zeng, Star, Sean Brogan,
	Michael Turner, Bret Barkelew

Zhichao:
  Why do below change? Seemly, this change is not related to add new APIs. In fact, current log is added as the purpose by commit 137ed15511e2045a7333e33ae7f1e873ce1961dd. 

  if (TotalSize > sizeof (Buffer)) {
    TotalSize = sizeof (Buffer);  ==> return;
  }

Thanks
Liming
>-----Original Message-----
>From: Gao, Zhichao
>Sent: Tuesday, March 19, 2019 11:26 PM
>To: edk2-devel@lists.01.org
>Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
>Ni, Ray <ray.ni@intel.com>; Zeng, Star <star.zeng@intel.com>; Gao, Liming
><liming.gao@intel.com>; Sean Brogan <sean.brogan@microsoft.com>;
>Michael Turner <Michael.Turner@microsoft.com>; Bret Barkelew
><Bret.Barkelew@microsoft.com>
>Subject: [PATCH V3 13/17]
>MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
>
>REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
>
>Add new APIs' implementation (DebugVPrint, DebugBPrint)
>in the DebugLib instance. These APIs would expose print
>routines with VaList parameter and BaseList parameter.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
>Cc: Jian J Wang <jian.j.wang@intel.com>
>Cc: Hao Wu <hao.a.wu@intel.com>
>Cc: Ray Ni <ray.ni@intel.com>
>Cc: Star Zeng <star.zeng@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Sean Brogan <sean.brogan@microsoft.com>
>Cc: Michael Turner <Michael.Turner@microsoft.com>
>Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
>---
> .../PeiDxeDebugLibReportStatusCode/DebugLib.c      | 144
>++++++++++++++++++---
> 1 file changed, 128 insertions(+), 16 deletions(-)
>
>diff --git
>a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
>b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
>index 6f0f416273..f1d31cb619 100644
>--- a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
>+++
>b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
>@@ -4,7 +4,7 @@
>   Note that if the debug message length is larger than the maximum allowable
>   record length, then the debug message will be ignored directly.
>
>-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
>+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
>   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
>@@ -27,6 +27,12 @@
> #include <Library/PcdLib.h>
> #include <Library/DebugPrintErrorLevelLib.h>
>
>+//
>+// VA_LIST can not initialize to NULL for all compiler, so we use this to
>+// indicate a null VA_LIST
>+//
>+VA_LIST     mVaListNull;
>+
> /**
>   Prints a debug message to the debug output device if the specified error
>level is enabled.
>
>@@ -52,12 +58,43 @@ DebugPrint (
>   IN  CONST CHAR8  *Format,
>   ...
>   )
>+{
>+  VA_LIST         Marker;
>+
>+  VA_START (Marker, Format);
>+  DebugVPrint (ErrorLevel, Format, Marker);
>+  VA_END (Marker);
>+}
>+
>+/**
>+  Prints a debug message to the debug output device if the specified
>+  error level is enabled base on Null-terminated format string and a
>+  VA_LIST argument list or a BASE_LIST argument list.
>+
>+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
>+  GetDebugPrintErrorLevel (), then print the message specified by Format
>and
>+  the associated variable argument list to the debug output device.
>+
>+  If Format is NULL, then ASSERT().
>+
>+  @param  ErrorLevel      The error level of the debug message.
>+  @param  Format          Format string for the debug message to print.
>+  @param  VaListMarker    VA_LIST marker for the variable argument list.
>+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
>+
>+**/
>+VOID
>+DebugPrintMarker (
>+  IN  UINTN         ErrorLevel,
>+  IN  CONST CHAR8   *Format,
>+  IN  VA_LIST       VaListMarker,
>+  IN  BASE_LIST     BaseListMarker
>+  )
> {
>   UINT64          Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64))
>+ 1];
>   EFI_DEBUG_INFO  *DebugInfo;
>   UINTN           TotalSize;
>-  VA_LIST         VaListMarker;
>-  BASE_LIST       BaseListMarker;
>+  BASE_LIST       BaseListMarkerPointer;
>   CHAR8           *FormatString;
>   BOOLEAN         Long;
>
>@@ -96,7 +133,7 @@ DebugPrint (
>   // If the TotalSize is larger than the maximum record size, then return
>   //
>   if (TotalSize > sizeof (Buffer)) {
>-    TotalSize = sizeof (Buffer);
>+    return;
>   }
>
>   //
>@@ -109,7 +146,7 @@ DebugPrint (
>   //
>   DebugInfo             = (EFI_DEBUG_INFO *)(Buffer) + 1;
>   DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
>-  BaseListMarker        = (BASE_LIST)(DebugInfo + 1);
>+  BaseListMarkerPointer = (BASE_LIST)(DebugInfo + 1);
>   FormatString          = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
>
>   //
>@@ -125,7 +162,6 @@ DebugPrint (
>   // of format in DEBUG string, which is followed by the DEBUG format string.
>   // Here we will process the variable arguments and pack them in this area.
>   //
>-  VA_START (VaListMarker, Format);
>
>   //
>   // Use the actual format string.
>@@ -167,7 +203,11 @@ DebugPrint (
>         // '*' in format field means the precision of the field is specified by
>         // a UINTN argument in the argument list.
>         //
>-        BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
>+        if (BaseListMarker == NULL) {
>+          BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker,
>UINTN);
>+        } else {
>+          BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG
>(BaseListMarker, UINTN);
>+        }
>         continue;
>       }
>       if (*Format == '\0') {
>@@ -192,16 +232,36 @@ DebugPrint (
>     }
>     if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' ||
>*Format == 'u') {
>       if (Long) {
>-        BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
>+        if (BaseListMarker == NULL) {
>+          BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG (VaListMarker,
>INT64);
>+        } else {
>+          BASE_ARG (BaseListMarkerPointer, INT64) = BASE_ARG
>(BaseListMarker, INT64);
>+        }
>       } else {
>-        BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
>+        if (BaseListMarker == NULL) {
>+          BASE_ARG (BaseListMarkerPointer, int) = VA_ARG (VaListMarker, int);
>+        } else {
>+          BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG (BaseListMarker,
>int);
>+        }
>       }
>     } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g'
>|| *Format == 't') {
>-      BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
>+      if (BaseListMarker == NULL) {
>+        BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG (VaListMarker,
>VOID *);
>+      } else {
>+        BASE_ARG (BaseListMarkerPointer, VOID *) = BASE_ARG
>(BaseListMarker, VOID *);
>+      }
>     } else if (*Format == 'c') {
>-      BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
>+      if (BaseListMarker == NULL) {
>+        BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker,
>UINTN);
>+      } else {
>+        BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG
>(BaseListMarker, UINTN);
>+      }
>     } else if (*Format == 'r') {
>-      BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker,
>RETURN_STATUS);
>+      if (BaseListMarker == NULL) {
>+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = VA_ARG
>(VaListMarker, RETURN_STATUS);
>+      } else {
>+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = BASE_ARG
>(BaseListMarker, RETURN_STATUS);
>+      }
>     }
>
>     //
>@@ -209,17 +269,15 @@ DebugPrint (
>     // This indicates that the DEBUG() macro is passing in more argument than
>can be handled by
>     // the EFI_DEBUG_INFO record
>     //
>-    ASSERT ((CHAR8 *)BaseListMarker <= FormatString);
>+    ASSERT ((CHAR8 *)BaseListMarkerPointer <= FormatString);
>
>     //
>     // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64)
>allocated bytes, then return
>     //
>-    if ((CHAR8 *)BaseListMarker > FormatString) {
>-      VA_END (VaListMarker);
>+    if ((CHAR8 *)BaseListMarkerPointer > FormatString) {
>       return;
>     }
>   }
>-  VA_END (VaListMarker);
>
>   //
>   // Send the DebugInfo record
>@@ -235,6 +293,60 @@ DebugPrint (
>     );
> }
>
>+/**
>+  Prints a debug message to the debug output device if the specified
>+  error level is enabled.
>+
>+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
>+  GetDebugPrintErrorLevel (), then print the message specified by Format
>and
>+  the associated variable argument list to the debug output device.
>+
>+  If Format is NULL, then ASSERT().
>+
>+  @param  ErrorLevel    The error level of the debug message.
>+  @param  Format        Format string for the debug message to print.
>+  @param  VaListMarker  VA_LIST marker for the variable argument list.
>+
>+**/
>+VOID
>+EFIAPI
>+DebugVPrint (
>+  IN  UINTN         ErrorLevel,
>+  IN  CONST CHAR8   *Format,
>+  IN  VA_LIST       VaListMarker
>+  )
>+{
>+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
>+}
>+
>+/**
>+  Prints a debug message to the debug output device if the specified
>+  error level is enabled.
>+  This function use BASE_LIST which would provide a more compatible
>+  service than VA_LIST.
>+
>+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
>+  GetDebugPrintErrorLevel (), then print the message specified by Format
>and
>+  the associated variable argument list to the debug output device.
>+
>+  If Format is NULL, then ASSERT().
>+
>+  @param  ErrorLevel      The error level of the debug message.
>+  @param  Format          Format string for the debug message to print.
>+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
>+
>+**/
>+VOID
>+EFIAPI
>+DebugBPrint (
>+  IN  UINTN         ErrorLevel,
>+  IN  CONST CHAR8   *Format,
>+  IN  BASE_LIST     BaseListMarker
>+  )
>+{
>+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
>+}
>+
> /**
>   Prints an assert message containing a filename, line number, and description.
>   This may be followed by a breakpoint or a dead loop.
>--
>2.16.2.windows.1



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

* Re: [PATCH V3 01/17] MdePkg/DebugLib.h: Add new APIs for DebugLib
  2019-03-19 15:25 ` [PATCH V3 01/17] MdePkg/DebugLib.h: Add new APIs " Zhichao Gao
@ 2019-03-21  7:00   ` Gao, Liming
  0 siblings, 0 replies; 31+ messages in thread
From: Gao, Liming @ 2019-03-21  7:00 UTC (permalink / raw)
  To: Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Kinney, Michael D, Sean Brogan, Michael Turner, Bret Barkelew

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

>-----Original Message-----
>From: Gao, Zhichao
>Sent: Tuesday, March 19, 2019 11:26 PM
>To: edk2-devel@lists.01.org
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
><liming.gao@intel.com>; Sean Brogan <sean.brogan@microsoft.com>;
>Michael Turner <Michael.Turner@microsoft.com>; Bret Barkelew
><Bret.Barkelew@microsoft.com>
>Subject: [PATCH V3 01/17] MdePkg/DebugLib.h: Add new APIs for DebugLib
>
>REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
>
>Add new APIs DebugVPrint and DebugBPrint prototype
>definition in the DebugLib header file. These APIs
>would expose a print routine with VaList parameter
>and BaseList parameter.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
>Cc: Michael D Kinney <michael.d.kinney@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Sean Brogan <sean.brogan@microsoft.com>
>Cc: Michael Turner <Michael.Turner@microsoft.com>
>Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
>---
> MdePkg/Include/Library/DebugLib.h | 52
>++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 51 insertions(+), 1 deletion(-)
>
>diff --git a/MdePkg/Include/Library/DebugLib.h
>b/MdePkg/Include/Library/DebugLib.h
>index e6a7a357b2..77fb1ee259 100644
>--- a/MdePkg/Include/Library/DebugLib.h
>+++ b/MdePkg/Include/Library/DebugLib.h
>@@ -8,7 +8,7 @@
>   of size reduction when compiler optimization is disabled. If
>MDEPKG_NDEBUG is
>   defined, then debug and assert related macros wrapped by it are the NULL
>implementations.
>
>-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
>+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
> 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
>@@ -101,6 +101,56 @@ DebugPrint (
>   );
>
>
>+/**
>+  Prints a debug message to the debug output device if the specified
>+  error level is enabled.
>+
>+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
>+  GetDebugPrintErrorLevel (), then print the message specified by Format
>and
>+  the associated variable argument list to the debug output device.
>+
>+  If Format is NULL, then ASSERT().
>+
>+  @param  ErrorLevel    The error level of the debug message.
>+  @param  Format        Format string for the debug message to print.
>+  @param  VaListMarker  VA_LIST marker for the variable argument list.
>+
>+**/
>+VOID
>+EFIAPI
>+DebugVPrint (
>+  IN  UINTN         ErrorLevel,
>+  IN  CONST CHAR8   *Format,
>+  IN  VA_LIST       VaListMarker
>+  );
>+
>+
>+/**
>+  Prints a debug message to the debug output device if the specified
>+  error level is enabled.
>+  This function use BASE_LIST which would provide a more compatible
>+  service than VA_LIST.
>+
>+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
>+  GetDebugPrintErrorLevel (), then print the message specified by Format
>and
>+  the associated variable argument list to the debug output device.
>+
>+  If Format is NULL, then ASSERT().
>+
>+  @param  ErrorLevel      The error level of the debug message.
>+  @param  Format          Format string for the debug message to print.
>+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
>+
>+**/
>+VOID
>+EFIAPI
>+DebugBPrint (
>+  IN  UINTN         ErrorLevel,
>+  IN  CONST CHAR8   *Format,
>+  IN  BASE_LIST     BaseListMarker
>+  );
>+
>+
> /**
>   Prints an assert message containing a filename, line number, and description.
>   This may be followed by a breakpoint or a dead loop.
>--
>2.16.2.windows.1



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

* Re: [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
  2019-03-21  6:57   ` Gao, Liming
@ 2019-03-21  7:06     ` Wu, Hao A
  2019-03-21  7:29       ` Gao, Zhichao
  0 siblings, 1 reply; 31+ messages in thread
From: Wu, Hao A @ 2019-03-21  7:06 UTC (permalink / raw)
  To: Gao, Liming, Gao, Zhichao, edk2-devel@lists.01.org
  Cc: Wang, Jian J, Ni, Ray, Zeng, Star, Sean Brogan, Michael Turner,
	Bret Barkelew

> -----Original Message-----
> From: Gao, Liming
> Sent: Thursday, March 21, 2019 2:58 PM
> To: Gao, Zhichao; edk2-devel@lists.01.org
> Cc: Wang, Jian J; Wu, Hao A; Ni, Ray; Zeng, Star; Sean Brogan; Michael Turner;
> Bret Barkelew
> Subject: RE: [PATCH V3 13/17]
> MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
> 
> Zhichao:
>   Why do below change? Seemly, this change is not related to add new APIs. In
> fact, current log is added as the purpose by commit
> 137ed15511e2045a7333e33ae7f1e873ce1961dd.

I would suggest to add another separate commit to refine the below
comments to state the message truncating behavior here:

  //
  // If the TotalSize is larger than the maximum record size, then return
                                                              ^^^^^^^^^^^
  //
  if (TotalSize > sizeof (Buffer)) {
    TotalSize = sizeof (Buffer);
  }

Best Regards,
Hao Wu

> 
>   if (TotalSize > sizeof (Buffer)) {
>     TotalSize = sizeof (Buffer);  ==> return;
>   }
> 
> Thanks
> Liming
> >-----Original Message-----
> >From: Gao, Zhichao
> >Sent: Tuesday, March 19, 2019 11:26 PM
> >To: edk2-devel@lists.01.org
> >Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> >Ni, Ray <ray.ni@intel.com>; Zeng, Star <star.zeng@intel.com>; Gao, Liming
> ><liming.gao@intel.com>; Sean Brogan <sean.brogan@microsoft.com>;
> >Michael Turner <Michael.Turner@microsoft.com>; Bret Barkelew
> ><Bret.Barkelew@microsoft.com>
> >Subject: [PATCH V3 13/17]
> >MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
> >
> >REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> >
> >Add new APIs' implementation (DebugVPrint, DebugBPrint)
> >in the DebugLib instance. These APIs would expose print
> >routines with VaList parameter and BaseList parameter.
> >
> >Contributed-under: TianoCore Contribution Agreement 1.1
> >Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> >Cc: Jian J Wang <jian.j.wang@intel.com>
> >Cc: Hao Wu <hao.a.wu@intel.com>
> >Cc: Ray Ni <ray.ni@intel.com>
> >Cc: Star Zeng <star.zeng@intel.com>
> >Cc: Liming Gao <liming.gao@intel.com>
> >Cc: Sean Brogan <sean.brogan@microsoft.com>
> >Cc: Michael Turner <Michael.Turner@microsoft.com>
> >Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> >---
> > .../PeiDxeDebugLibReportStatusCode/DebugLib.c      | 144
> >++++++++++++++++++---
> > 1 file changed, 128 insertions(+), 16 deletions(-)
> >
> >diff --git
> >a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> >b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> >index 6f0f416273..f1d31cb619 100644
> >--- a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> >+++
> >b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> >@@ -4,7 +4,7 @@
> >   Note that if the debug message length is larger than the maximum
> allowable
> >   record length, then the debug message will be ignored directly.
> >
> >-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> >+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
> >   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
> >@@ -27,6 +27,12 @@
> > #include <Library/PcdLib.h>
> > #include <Library/DebugPrintErrorLevelLib.h>
> >
> >+//
> >+// VA_LIST can not initialize to NULL for all compiler, so we use this to
> >+// indicate a null VA_LIST
> >+//
> >+VA_LIST     mVaListNull;
> >+
> > /**
> >   Prints a debug message to the debug output device if the specified error
> >level is enabled.
> >
> >@@ -52,12 +58,43 @@ DebugPrint (
> >   IN  CONST CHAR8  *Format,
> >   ...
> >   )
> >+{
> >+  VA_LIST         Marker;
> >+
> >+  VA_START (Marker, Format);
> >+  DebugVPrint (ErrorLevel, Format, Marker);
> >+  VA_END (Marker);
> >+}
> >+
> >+/**
> >+  Prints a debug message to the debug output device if the specified
> >+  error level is enabled base on Null-terminated format string and a
> >+  VA_LIST argument list or a BASE_LIST argument list.
> >+
> >+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> >+  GetDebugPrintErrorLevel (), then print the message specified by Format
> >and
> >+  the associated variable argument list to the debug output device.
> >+
> >+  If Format is NULL, then ASSERT().
> >+
> >+  @param  ErrorLevel      The error level of the debug message.
> >+  @param  Format          Format string for the debug message to print.
> >+  @param  VaListMarker    VA_LIST marker for the variable argument list.
> >+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> >+
> >+**/
> >+VOID
> >+DebugPrintMarker (
> >+  IN  UINTN         ErrorLevel,
> >+  IN  CONST CHAR8   *Format,
> >+  IN  VA_LIST       VaListMarker,
> >+  IN  BASE_LIST     BaseListMarker
> >+  )
> > {
> >   UINT64          Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64))
> >+ 1];
> >   EFI_DEBUG_INFO  *DebugInfo;
> >   UINTN           TotalSize;
> >-  VA_LIST         VaListMarker;
> >-  BASE_LIST       BaseListMarker;
> >+  BASE_LIST       BaseListMarkerPointer;
> >   CHAR8           *FormatString;
> >   BOOLEAN         Long;
> >
> >@@ -96,7 +133,7 @@ DebugPrint (
> >   // If the TotalSize is larger than the maximum record size, then return
> >   //
> >   if (TotalSize > sizeof (Buffer)) {
> >-    TotalSize = sizeof (Buffer);
> >+    return;
> >   }
> >
> >   //
> >@@ -109,7 +146,7 @@ DebugPrint (
> >   //
> >   DebugInfo             = (EFI_DEBUG_INFO *)(Buffer) + 1;
> >   DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
> >-  BaseListMarker        = (BASE_LIST)(DebugInfo + 1);
> >+  BaseListMarkerPointer = (BASE_LIST)(DebugInfo + 1);
> >   FormatString          = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
> >
> >   //
> >@@ -125,7 +162,6 @@ DebugPrint (
> >   // of format in DEBUG string, which is followed by the DEBUG format string.
> >   // Here we will process the variable arguments and pack them in this area.
> >   //
> >-  VA_START (VaListMarker, Format);
> >
> >   //
> >   // Use the actual format string.
> >@@ -167,7 +203,11 @@ DebugPrint (
> >         // '*' in format field means the precision of the field is specified by
> >         // a UINTN argument in the argument list.
> >         //
> >-        BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
> >+        if (BaseListMarker == NULL) {
> >+          BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker,
> >UINTN);
> >+        } else {
> >+          BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG
> >(BaseListMarker, UINTN);
> >+        }
> >         continue;
> >       }
> >       if (*Format == '\0') {
> >@@ -192,16 +232,36 @@ DebugPrint (
> >     }
> >     if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' ||
> >*Format == 'u') {
> >       if (Long) {
> >-        BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
> >+        if (BaseListMarker == NULL) {
> >+          BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG (VaListMarker,
> >INT64);
> >+        } else {
> >+          BASE_ARG (BaseListMarkerPointer, INT64) = BASE_ARG
> >(BaseListMarker, INT64);
> >+        }
> >       } else {
> >-        BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
> >+        if (BaseListMarker == NULL) {
> >+          BASE_ARG (BaseListMarkerPointer, int) = VA_ARG (VaListMarker, int);
> >+        } else {
> >+          BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG (BaseListMarker,
> >int);
> >+        }
> >       }
> >     } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format ==
> 'g'
> >|| *Format == 't') {
> >-      BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
> >+      if (BaseListMarker == NULL) {
> >+        BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG (VaListMarker,
> >VOID *);
> >+      } else {
> >+        BASE_ARG (BaseListMarkerPointer, VOID *) = BASE_ARG
> >(BaseListMarker, VOID *);
> >+      }
> >     } else if (*Format == 'c') {
> >-      BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
> >+      if (BaseListMarker == NULL) {
> >+        BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker,
> >UINTN);
> >+      } else {
> >+        BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG
> >(BaseListMarker, UINTN);
> >+      }
> >     } else if (*Format == 'r') {
> >-      BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker,
> >RETURN_STATUS);
> >+      if (BaseListMarker == NULL) {
> >+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = VA_ARG
> >(VaListMarker, RETURN_STATUS);
> >+      } else {
> >+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = BASE_ARG
> >(BaseListMarker, RETURN_STATUS);
> >+      }
> >     }
> >
> >     //
> >@@ -209,17 +269,15 @@ DebugPrint (
> >     // This indicates that the DEBUG() macro is passing in more argument than
> >can be handled by
> >     // the EFI_DEBUG_INFO record
> >     //
> >-    ASSERT ((CHAR8 *)BaseListMarker <= FormatString);
> >+    ASSERT ((CHAR8 *)BaseListMarkerPointer <= FormatString);
> >
> >     //
> >     // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64)
> >allocated bytes, then return
> >     //
> >-    if ((CHAR8 *)BaseListMarker > FormatString) {
> >-      VA_END (VaListMarker);
> >+    if ((CHAR8 *)BaseListMarkerPointer > FormatString) {
> >       return;
> >     }
> >   }
> >-  VA_END (VaListMarker);
> >
> >   //
> >   // Send the DebugInfo record
> >@@ -235,6 +293,60 @@ DebugPrint (
> >     );
> > }
> >
> >+/**
> >+  Prints a debug message to the debug output device if the specified
> >+  error level is enabled.
> >+
> >+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> >+  GetDebugPrintErrorLevel (), then print the message specified by Format
> >and
> >+  the associated variable argument list to the debug output device.
> >+
> >+  If Format is NULL, then ASSERT().
> >+
> >+  @param  ErrorLevel    The error level of the debug message.
> >+  @param  Format        Format string for the debug message to print.
> >+  @param  VaListMarker  VA_LIST marker for the variable argument list.
> >+
> >+**/
> >+VOID
> >+EFIAPI
> >+DebugVPrint (
> >+  IN  UINTN         ErrorLevel,
> >+  IN  CONST CHAR8   *Format,
> >+  IN  VA_LIST       VaListMarker
> >+  )
> >+{
> >+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
> >+}
> >+
> >+/**
> >+  Prints a debug message to the debug output device if the specified
> >+  error level is enabled.
> >+  This function use BASE_LIST which would provide a more compatible
> >+  service than VA_LIST.
> >+
> >+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
> >+  GetDebugPrintErrorLevel (), then print the message specified by Format
> >and
> >+  the associated variable argument list to the debug output device.
> >+
> >+  If Format is NULL, then ASSERT().
> >+
> >+  @param  ErrorLevel      The error level of the debug message.
> >+  @param  Format          Format string for the debug message to print.
> >+  @param  BaseListMarker  BASE_LIST marker for the variable argument list.
> >+
> >+**/
> >+VOID
> >+EFIAPI
> >+DebugBPrint (
> >+  IN  UINTN         ErrorLevel,
> >+  IN  CONST CHAR8   *Format,
> >+  IN  BASE_LIST     BaseListMarker
> >+  )
> >+{
> >+  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
> >+}
> >+
> > /**
> >   Prints an assert message containing a filename, line number, and
> description.
> >   This may be followed by a breakpoint or a dead loop.
> >--
> >2.16.2.windows.1



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

* Re: [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
  2019-03-21  7:06     ` Wu, Hao A
@ 2019-03-21  7:29       ` Gao, Zhichao
  0 siblings, 0 replies; 31+ messages in thread
From: Gao, Zhichao @ 2019-03-21  7:29 UTC (permalink / raw)
  To: Wu, Hao A, Gao, Liming, edk2-devel@lists.01.org
  Cc: Wang, Jian J, Ni, Ray, Zeng, Star, Sean Brogan, Michael Turner,
	Bret Barkelew

I have mixed the section with IntelFrameworkModulePkg.
Seems the truncating behavior can work fine. And the comment of this section should be updated.

Thanks,
Zhichao

> -----Original Message-----
> From: Wu, Hao A
> Sent: Thursday, March 21, 2019 3:06 PM
> To: Gao, Liming <liming.gao@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>; edk2-devel@lists.01.org
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Ni, Ray <ray.ni@intel.com>; Zeng,
> Star <star.zeng@intel.com>; Sean Brogan <sean.brogan@microsoft.com>;
> Michael Turner <Michael.Turner@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>
> Subject: RE: [PATCH V3 13/17]
> MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
> 
> > -----Original Message-----
> > From: Gao, Liming
> > Sent: Thursday, March 21, 2019 2:58 PM
> > To: Gao, Zhichao; edk2-devel@lists.01.org
> > Cc: Wang, Jian J; Wu, Hao A; Ni, Ray; Zeng, Star; Sean Brogan; Michael
> > Turner; Bret Barkelew
> > Subject: RE: [PATCH V3 13/17]
> > MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
> >
> > Zhichao:
> >   Why do below change? Seemly, this change is not related to add new
> > APIs. In fact, current log is added as the purpose by commit
> > 137ed15511e2045a7333e33ae7f1e873ce1961dd.
> 
> I would suggest to add another separate commit to refine the below
> comments to state the message truncating behavior here:
> 
>   //
>   // If the TotalSize is larger than the maximum record size, then return
>                                                               ^^^^^^^^^^^
>   //
>   if (TotalSize > sizeof (Buffer)) {
>     TotalSize = sizeof (Buffer);
>   }
> 
> Best Regards,
> Hao Wu
> 
> >
> >   if (TotalSize > sizeof (Buffer)) {
> >     TotalSize = sizeof (Buffer);  ==> return;
> >   }
> >
> > Thanks
> > Liming
> > >-----Original Message-----
> > >From: Gao, Zhichao
> > >Sent: Tuesday, March 19, 2019 11:26 PM
> > >To: edk2-devel@lists.01.org
> > >Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> > ><hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>; Zeng, Star
> > ><star.zeng@intel.com>; Gao, Liming <liming.gao@intel.com>; Sean
> > >Brogan <sean.brogan@microsoft.com>; Michael Turner
> > ><Michael.Turner@microsoft.com>; Bret Barkelew
> > ><Bret.Barkelew@microsoft.com>
> > >Subject: [PATCH V3 13/17]
> > >MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add new APIs
> > >
> > >REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> > >
> > >Add new APIs' implementation (DebugVPrint, DebugBPrint) in the
> > >DebugLib instance. These APIs would expose print routines with VaList
> > >parameter and BaseList parameter.
> > >
> > >Contributed-under: TianoCore Contribution Agreement 1.1
> > >Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> > >Cc: Jian J Wang <jian.j.wang@intel.com>
> > >Cc: Hao Wu <hao.a.wu@intel.com>
> > >Cc: Ray Ni <ray.ni@intel.com>
> > >Cc: Star Zeng <star.zeng@intel.com>
> > >Cc: Liming Gao <liming.gao@intel.com>
> > >Cc: Sean Brogan <sean.brogan@microsoft.com>
> > >Cc: Michael Turner <Michael.Turner@microsoft.com>
> > >Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > >---
> > > .../PeiDxeDebugLibReportStatusCode/DebugLib.c      | 144
> > >++++++++++++++++++---
> > > 1 file changed, 128 insertions(+), 16 deletions(-)
> > >
> > >diff --git
> > >a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> > >b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> > >index 6f0f416273..f1d31cb619 100644
> > >---
> a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> > >+++
> > >b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> > >@@ -4,7 +4,7 @@
> > >   Note that if the debug message length is larger than the maximum
> > allowable
> > >   record length, then the debug message will be ignored directly.
> > >
> > >-  Copyright (c) 2006 - 2018, Intel Corporation. All rights
> > >reserved.<BR>
> > >+  Copyright (c) 2006 - 2019, Intel Corporation. All rights
> > >+ reserved.<BR>
> > >   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 @@ -27,6 +27,12 @@  #include <Library/PcdLib.h>
> > >#include <Library/DebugPrintErrorLevelLib.h>
> > >
> > >+//
> > >+// VA_LIST can not initialize to NULL for all compiler, so we use
> > >+this to // indicate a null VA_LIST //
> > >+VA_LIST     mVaListNull;
> > >+
> > > /**
> > >   Prints a debug message to the debug output device if the specified
> > >error level is enabled.
> > >
> > >@@ -52,12 +58,43 @@ DebugPrint (
> > >   IN  CONST CHAR8  *Format,
> > >   ...
> > >   )
> > >+{
> > >+  VA_LIST         Marker;
> > >+
> > >+  VA_START (Marker, Format);
> > >+  DebugVPrint (ErrorLevel, Format, Marker);
> > >+  VA_END (Marker);
> > >+}
> > >+
> > >+/**
> > >+  Prints a debug message to the debug output device if the specified
> > >+  error level is enabled base on Null-terminated format string and a
> > >+  VA_LIST argument list or a BASE_LIST argument list.
> > >+
> > >+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> > >+ function  GetDebugPrintErrorLevel (), then print the message
> > >+ specified by Format
> > >and
> > >+  the associated variable argument list to the debug output device.
> > >+
> > >+  If Format is NULL, then ASSERT().
> > >+
> > >+  @param  ErrorLevel      The error level of the debug message.
> > >+  @param  Format          Format string for the debug message to print.
> > >+  @param  VaListMarker    VA_LIST marker for the variable argument list.
> > >+  @param  BaseListMarker  BASE_LIST marker for the variable argument
> list.
> > >+
> > >+**/
> > >+VOID
> > >+DebugPrintMarker (
> > >+  IN  UINTN         ErrorLevel,
> > >+  IN  CONST CHAR8   *Format,
> > >+  IN  VA_LIST       VaListMarker,
> > >+  IN  BASE_LIST     BaseListMarker
> > >+  )
> > > {
> > >   UINT64          Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof
> (UINT64))
> > >+ 1];
> > >   EFI_DEBUG_INFO  *DebugInfo;
> > >   UINTN           TotalSize;
> > >-  VA_LIST         VaListMarker;
> > >-  BASE_LIST       BaseListMarker;
> > >+  BASE_LIST       BaseListMarkerPointer;
> > >   CHAR8           *FormatString;
> > >   BOOLEAN         Long;
> > >
> > >@@ -96,7 +133,7 @@ DebugPrint (
> > >   // If the TotalSize is larger than the maximum record size, then return
> > >   //
> > >   if (TotalSize > sizeof (Buffer)) {
> > >-    TotalSize = sizeof (Buffer);
> > >+    return;
> > >   }
> > >
> > >   //
> > >@@ -109,7 +146,7 @@ DebugPrint (
> > >   //
> > >   DebugInfo             = (EFI_DEBUG_INFO *)(Buffer) + 1;
> > >   DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
> > >-  BaseListMarker        = (BASE_LIST)(DebugInfo + 1);
> > >+  BaseListMarkerPointer = (BASE_LIST)(DebugInfo + 1);
> > >   FormatString          = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
> > >
> > >   //
> > >@@ -125,7 +162,6 @@ DebugPrint (
> > >   // of format in DEBUG string, which is followed by the DEBUG format
> string.
> > >   // Here we will process the variable arguments and pack them in this
> area.
> > >   //
> > >-  VA_START (VaListMarker, Format);
> > >
> > >   //
> > >   // Use the actual format string.
> > >@@ -167,7 +203,11 @@ DebugPrint (
> > >         // '*' in format field means the precision of the field is specified by
> > >         // a UINTN argument in the argument list.
> > >         //
> > >-        BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker,
> UINTN);
> > >+        if (BaseListMarker == NULL) {
> > >+          BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG
> > >+ (VaListMarker,
> > >UINTN);
> > >+        } else {
> > >+          BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG
> > >(BaseListMarker, UINTN);
> > >+        }
> > >         continue;
> > >       }
> > >       if (*Format == '\0') {
> > >@@ -192,16 +232,36 @@ DebugPrint (
> > >     }
> > >     if (*Format == 'p' || *Format == 'X' || *Format == 'x' ||
> > >*Format == 'd' || *Format == 'u') {
> > >       if (Long) {
> > >-        BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
> > >+        if (BaseListMarker == NULL) {
> > >+          BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG
> > >+ (VaListMarker,
> > >INT64);
> > >+        } else {
> > >+          BASE_ARG (BaseListMarkerPointer, INT64) = BASE_ARG
> > >(BaseListMarker, INT64);
> > >+        }
> > >       } else {
> > >-        BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
> > >+        if (BaseListMarker == NULL) {
> > >+          BASE_ARG (BaseListMarkerPointer, int) = VA_ARG (VaListMarker,
> int);
> > >+        } else {
> > >+          BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG
> > >+ (BaseListMarker,
> > >int);
> > >+        }
> > >       }
> > >     } else if (*Format == 's' || *Format == 'S' || *Format == 'a' ||
> > > *Format ==
> > 'g'
> > >|| *Format == 't') {
> > >-      BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID
> *);
> > >+      if (BaseListMarker == NULL) {
> > >+        BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG
> > >+ (VaListMarker,
> > >VOID *);
> > >+      } else {
> > >+        BASE_ARG (BaseListMarkerPointer, VOID *) = BASE_ARG
> > >(BaseListMarker, VOID *);
> > >+      }
> > >     } else if (*Format == 'c') {
> > >-      BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker,
> UINTN);
> > >+      if (BaseListMarker == NULL) {
> > >+        BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG
> > >+ (VaListMarker,
> > >UINTN);
> > >+      } else {
> > >+        BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG
> > >(BaseListMarker, UINTN);
> > >+      }
> > >     } else if (*Format == 'r') {
> > >-      BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG
> (VaListMarker,
> > >RETURN_STATUS);
> > >+      if (BaseListMarker == NULL) {
> > >+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = VA_ARG
> > >(VaListMarker, RETURN_STATUS);
> > >+      } else {
> > >+        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = BASE_ARG
> > >(BaseListMarker, RETURN_STATUS);
> > >+      }
> > >     }
> > >
> > >     //
> > >@@ -209,17 +269,15 @@ DebugPrint (
> > >     // This indicates that the DEBUG() macro is passing in more
> > >argument than can be handled by
> > >     // the EFI_DEBUG_INFO record
> > >     //
> > >-    ASSERT ((CHAR8 *)BaseListMarker <= FormatString);
> > >+    ASSERT ((CHAR8 *)BaseListMarkerPointer <= FormatString);
> > >
> > >     //
> > >     // If the converted BASE_LIST is larger than the 12 * sizeof
> > >(UINT64) allocated bytes, then return
> > >     //
> > >-    if ((CHAR8 *)BaseListMarker > FormatString) {
> > >-      VA_END (VaListMarker);
> > >+    if ((CHAR8 *)BaseListMarkerPointer > FormatString) {
> > >       return;
> > >     }
> > >   }
> > >-  VA_END (VaListMarker);
> > >
> > >   //
> > >   // Send the DebugInfo record
> > >@@ -235,6 +293,60 @@ DebugPrint (
> > >     );
> > > }
> > >
> > >+/**
> > >+  Prints a debug message to the debug output device if the specified
> > >+  error level is enabled.
> > >+
> > >+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> > >+ function  GetDebugPrintErrorLevel (), then print the message
> > >+ specified by Format
> > >and
> > >+  the associated variable argument list to the debug output device.
> > >+
> > >+  If Format is NULL, then ASSERT().
> > >+
> > >+  @param  ErrorLevel    The error level of the debug message.
> > >+  @param  Format        Format string for the debug message to print.
> > >+  @param  VaListMarker  VA_LIST marker for the variable argument list.
> > >+
> > >+**/
> > >+VOID
> > >+EFIAPI
> > >+DebugVPrint (
> > >+  IN  UINTN         ErrorLevel,
> > >+  IN  CONST CHAR8   *Format,
> > >+  IN  VA_LIST       VaListMarker
> > >+  )
> > >+{
> > >+  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL); }
> > >+
> > >+/**
> > >+  Prints a debug message to the debug output device if the specified
> > >+  error level is enabled.
> > >+  This function use BASE_LIST which would provide a more compatible
> > >+  service than VA_LIST.
> > >+
> > >+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> > >+ function  GetDebugPrintErrorLevel (), then print the message
> > >+ specified by Format
> > >and
> > >+  the associated variable argument list to the debug output device.
> > >+
> > >+  If Format is NULL, then ASSERT().
> > >+
> > >+  @param  ErrorLevel      The error level of the debug message.
> > >+  @param  Format          Format string for the debug message to print.
> > >+  @param  BaseListMarker  BASE_LIST marker for the variable argument
> list.
> > >+
> > >+**/
> > >+VOID
> > >+EFIAPI
> > >+DebugBPrint (
> > >+  IN  UINTN         ErrorLevel,
> > >+  IN  CONST CHAR8   *Format,
> > >+  IN  BASE_LIST     BaseListMarker
> > >+  )
> > >+{
> > >+  DebugPrintMarker (ErrorLevel, Format, mVaListNull,
> > >+BaseListMarker); }
> > >+
> > > /**
> > >   Prints an assert message containing a filename, line number, and
> > description.
> > >   This may be followed by a breakpoint or a dead loop.
> > >--
> > >2.16.2.windows.1



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

* Re: [PATCH V3 09/17] OvmfPkg/PlatformDebugLibIoPort: Add new APIs
  2019-03-20 16:57   ` Laszlo Ersek
@ 2019-03-21 10:15     ` Gao, Zhichao
  0 siblings, 0 replies; 31+ messages in thread
From: Gao, Zhichao @ 2019-03-21 10:15 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel@lists.01.org
  Cc: Justen, Jordan L, Michael Turner, Bret Barkelew, Gao, Liming

Thanks for your reminder. 
I forgot to add all CCs to cover letter. I would be careful next time.

Thanks,
Zhichao

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, March 21, 2019 12:58 AM
> To: Gao, Zhichao <zhichao.gao@intel.com>; edk2-devel@lists.01.org
> Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Michael Turner
> <Michael.Turner@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>; Gao, Liming <liming.gao@intel.com>
> Subject: Re: [edk2] [PATCH V3 09/17] OvmfPkg/PlatformDebugLibIoPort:
> Add new APIs
> 
> On 03/19/19 16:25, Zhichao Gao wrote:
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> >
> > Add new APIs' implementation (DebugVPrint, DebugBPrint) in the
> > DebugLib instance. These APIs would expose print routines with VaList
> > parameter and BaseList parameter.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> > Cc: Jordan Justen <jordan.l.justen@intel.com>
> > Cc: Laszlo Ersek <lersek@redhat.com>
> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > Cc: Liming Gao <liming.gao@intel.com>
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Cc: Michael Turner <Michael.Turner@microsoft.com>
> > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > ---
> >  OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 106
> > +++++++++++++++++++++-
> >  1 file changed, 101 insertions(+), 5 deletions(-)
> >
> > diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> > b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> > index 36cde54976..cda35faf66 100644
> > --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> > +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> > @@ -2,7 +2,7 @@
> >    Base Debug library instance for QEMU debug port.
> >    It uses PrintLib to send debug messages to a fixed I/O port.
> >
> > -  Copyright (c) 2006 - 2015, Intel Corporation. All rights
> > reserved.<BR>
> > +  Copyright (c) 2006 - 2019, Intel Corporation. All rights
> > + reserved.<BR>
> >    Copyright (c) 2012, Red Hat, Inc.<BR>
> >    This program and the accompanying materials
> >    are licensed and made available under the terms and conditions of
> > the BSD License @@ -29,6 +29,12 @@  //  #define
> > MAX_DEBUG_MESSAGE_LENGTH  0x100
> >
> > +//
> > +// VA_LIST can not initialize to NULL for all compiler, so we use
> > +this to // indicate a null VA_LIST //
> > +VA_LIST     mVaListNull;
> > +
> >  /**
> >    Prints a debug message to the debug output device if the specified error
> level is enabled.
> >
> > @@ -51,9 +57,41 @@ DebugPrint (
> >    IN  CONST CHAR8  *Format,
> >    ...
> >    )
> > +{
> > +  VA_LIST         Marker;
> > +
> > +  VA_START (Marker, Format);
> > +  DebugVPrint (ErrorLevel, Format, Marker);
> > +  VA_END (Marker);
> > +}
> > +
> > +
> > +/**
> > +  Prints a debug message to the debug output device if the specified
> > +  error level is enabled base on Null-terminated format string and a
> > +  VA_LIST argument list or a BASE_LIST argument list.
> > +
> > +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> > + function  GetDebugPrintErrorLevel (), then print the message
> > + specified by Format and  the associated variable argument list to the
> debug output device.
> > +
> > +  If Format is NULL, then ASSERT().
> > +
> > +  @param  ErrorLevel      The error level of the debug message.
> > +  @param  Format          Format string for the debug message to print.
> > +  @param  VaListMarker    VA_LIST marker for the variable argument list.
> > +  @param  BaseListMarker  BASE_LIST marker for the variable argument
> list.
> > +
> > +**/
> > +VOID
> > +DebugPrintMarker (
> > +  IN  UINTN         ErrorLevel,
> > +  IN  CONST CHAR8   *Format,
> > +  IN  VA_LIST       VaListMarker,
> > +  IN  BASE_LIST     BaseListMarker
> > +  )
> >  {
> >    CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
> > -  VA_LIST  Marker;
> >    UINTN    Length;
> >
> >    //
> > @@ -72,9 +110,11 @@ DebugPrint (
> >    //
> >    // Convert the DEBUG() message to an ASCII String
> >    //
> > -  VA_START (Marker, Format);
> > -  Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
> > -  VA_END (Marker);
> > +  if (BaseListMarker == NULL) {
> > +    Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format,
> > + VaListMarker);  } else {
> > +    Length = AsciiBSPrint (Buffer, sizeof (Buffer), Format,
> > + BaseListMarker);  }
> >
> >    //
> >    // Send the print string to the debug I/O port @@ -83,6 +123,62 @@
> > DebugPrint (  }
> >
> >
> > +/**
> > +  Prints a debug message to the debug output device if the specified
> > +  error level is enabled.
> > +
> > +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> > + function  GetDebugPrintErrorLevel (), then print the message
> > + specified by Format and  the associated variable argument list to the
> debug output device.
> > +
> > +  If Format is NULL, then ASSERT().
> > +
> > +  @param  ErrorLevel    The error level of the debug message.
> > +  @param  Format        Format string for the debug message to print.
> > +  @param  VaListMarker  VA_LIST marker for the variable argument list.
> > +
> > +**/
> > +VOID
> > +EFIAPI
> > +DebugVPrint (
> > +  IN  UINTN         ErrorLevel,
> > +  IN  CONST CHAR8   *Format,
> > +  IN  VA_LIST       VaListMarker
> > +  )
> > +{
> > +  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL); }
> > +
> > +
> > +/**
> > +  Prints a debug message to the debug output device if the specified
> > +  error level is enabled.
> > +  This function use BASE_LIST which would provide a more compatible
> > +  service than VA_LIST.
> > +
> > +  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib
> > + function  GetDebugPrintErrorLevel (), then print the message
> > + specified by Format and  the associated variable argument list to the
> debug output device.
> > +
> > +  If Format is NULL, then ASSERT().
> > +
> > +  @param  ErrorLevel      The error level of the debug message.
> > +  @param  Format          Format string for the debug message to print.
> > +  @param  BaseListMarker  BASE_LIST marker for the variable argument
> list.
> > +
> > +**/
> > +VOID
> > +EFIAPI
> > +DebugBPrint (
> > +  IN  UINTN         ErrorLevel,
> > +  IN  CONST CHAR8   *Format,
> > +  IN  BASE_LIST     BaseListMarker
> > +  )
> > +{
> > +  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
> > +}
> > +
> > +
> >  /**
> >    Prints an assert message containing a filename, line number, and
> description.
> >    This may be followed by a breakpoint or a dead loop.
> >
> 
> I couldn't find the will to review the comments, but the code looks sane to
> me.
> 
> Acked-by: Laszlo Ersek <lersek@redhat.com>
> 
> In the future, for any given person CC'd on at least one patch in the series,
> please make sure the person is also CC'd on the cover letter.
> Version 3 of this patch is very different from version 2, but I had to construct
> the reason myself retro-actively (look up the v3 blurb in my list folder, read
> the summary, go back to v2, find Andrew's comments).
> This could have been helped at least a little if I had been CC'd on the
> v3 blurb.
> 
> Thanks
> Laszlo

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

end of thread, other threads:[~2019-03-21 10:15 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-19 15:25 [PATCH V3 00/17] Add new APIs DebugVPrint for DebugLib Zhichao Gao
2019-03-19 15:25 ` [PATCH V3 01/17] MdePkg/DebugLib.h: Add new APIs " Zhichao Gao
2019-03-21  7:00   ` Gao, Liming
2019-03-19 15:25 ` [PATCH V3 02/17] MdePkg/BaseDebugLibNull: " Zhichao Gao
2019-03-19 15:25 ` [PATCH V3 03/17] MdePkg/BaseDebugLibSerialPort: Add new APIs Zhichao Gao
2019-03-19 15:25 ` [PATCH V3 04/17] MdePkg/UefidebugLibConOut: " Zhichao Gao
2019-03-19 15:25 ` [PATCH V3 05/17] MdePkg/UefiDebugLibStdErr: " Zhichao Gao
2019-03-19 15:25 ` [PATCH V3 06/17] MdePkg/DxeRuntimeDebugLibSerialPort: " Zhichao Gao
2019-03-19 15:25 ` [PATCH V3 07/17] MdePkg/UefiDebuglibDebugPortProtocol: " Zhichao Gao
2019-03-19 15:25 ` [PATCH V3 08/17] ArmPkg/SemiHostingDebugLib: " Zhichao Gao
2019-03-19 15:25 ` [PATCH V3 09/17] OvmfPkg/PlatformDebugLibIoPort: " Zhichao Gao
2019-03-20 16:57   ` Laszlo Ersek
2019-03-21 10:15     ` Gao, Zhichao
2019-03-19 15:25 ` [PATCH V3 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: " Zhichao Gao
2019-03-19 23:37   ` Chiu, Chasel
2019-03-19 15:25 ` [PATCH V3 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: " Zhichao Gao
2019-03-19 23:37   ` Chiu, Chasel
2019-03-19 15:25 ` [PATCH V3 12/17] IntelFramworkModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
2019-03-19 15:25 ` [PATCH V3 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
2019-03-21  5:22   ` Wu, Hao A
2019-03-21  6:57   ` Gao, Liming
2019-03-21  7:06     ` Wu, Hao A
2019-03-21  7:29       ` Gao, Zhichao
2019-03-19 15:25 ` [PATCH V3 14/17] MdeModulePkg: Add definitions for EDKII DEBUG PPI Zhichao Gao
2019-03-21  5:22   ` Wu, Hao A
2019-03-19 15:25 ` [PATCH V3 15/17] MdeModulePkg: Add a PEIM to install Debug PPI Zhichao Gao
2019-03-21  5:22   ` Wu, Hao A
2019-03-19 15:25 ` [PATCH V3 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib Zhichao Gao
2019-03-21  5:22   ` Wu, Hao A
2019-03-19 15:25 ` [PATCH V3 17/17] MdeModulePkg: Add PEIM and lib to dsc file Zhichao Gao
2019-03-21  5:22   ` Wu, Hao A

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