* [PATCH 01/17] MdePkg/DebugLib.h: Add a new api DebugVPrint for DebugLib
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 02/17] MdePkg/BaseDebugLibNull: " Zhichao Gao
` (15 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint prototype definition in the
DebugLib header file. This api would expose a print
routine with VaList 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 | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h
index 2eed87129c..dfa204e90a 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
@@ -100,6 +100,29 @@ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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 an assert message containing a filename, line number, and description.
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 02/17] MdePkg/BaseDebugLibNull: Add a new api DebugVPrint for DebugLib
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
2019-03-14 9:03 ` [PATCH 01/17] MdePkg/DebugLib.h: Add a new api " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 03/17] MdePkg/BaseDebugLibSerialPort: Add a new api DebugVPrint Zhichao Gao
` (14 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/MdePkg/Library/BaseDebugLibNull/DebugLib.c b/MdePkg/Library/BaseDebugLibNull/DebugLib.c
index 1a7d4aba79..f8200e1ba7 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
@@ -40,6 +40,31 @@ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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 an assert message containing a filename, line number, and description.
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 03/17] MdePkg/BaseDebugLibSerialPort: Add a new api DebugVPrint
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
2019-03-14 9:03 ` [PATCH 01/17] MdePkg/DebugLib.h: Add a new api " Zhichao Gao
2019-03-14 9:03 ` [PATCH 02/17] MdePkg/BaseDebugLibNull: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 04/17] MdePkg/UefidebugLibConOut: " Zhichao Gao
` (13 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 41 ++++++++++++++++++++----
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c b/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c
index ffb84b39e5..c3ae3161cc 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
@@ -70,9 +70,41 @@ DebugPrint (
...
)
{
- CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
VA_LIST Marker;
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
+{
+ CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
+
//
// If Format is NULL, then ASSERT().
//
@@ -88,9 +120,7 @@ DebugPrint (
//
// Convert the DEBUG() message to an ASCII String
//
- VA_START (Marker, Format);
- AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
- VA_END (Marker);
+ AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
//
// Send the print string to a Serial Port
@@ -98,7 +128,6 @@ DebugPrint (
SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
}
-
/**
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] 20+ messages in thread
* [PATCH 04/17] MdePkg/UefidebugLibConOut: Add a new api DebugVPrint
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (2 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 03/17] MdePkg/BaseDebugLibSerialPort: Add a new api DebugVPrint Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 05/17] MdePkg/UefiDebugLibStdErr: " Zhichao Gao
` (12 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 44 ++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c
index f04207c93f..4028098f92 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
@@ -50,9 +50,44 @@ DebugPrint (
...
)
{
- CHAR16 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
VA_LIST Marker;
+ ASSERT(Format != NULL);
+
+ //
+ // Convert the DEBUG() message to a Unicode String
+ //
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
+{
+ CHAR16 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
+
//
// If Format is NULL, then ASSERT().
//
@@ -68,9 +103,7 @@ DebugPrint (
//
// Convert the DEBUG() message to a Unicode String
//
- VA_START (Marker, Format);
- UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, Marker);
- VA_END (Marker);
+ UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, VaListMarker);
//
@@ -81,7 +114,6 @@ DebugPrint (
}
}
-
/**
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] 20+ messages in thread
* [PATCH 05/17] MdePkg/UefiDebugLibStdErr: Add a new api DebugVPrint
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (3 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 04/17] MdePkg/UefidebugLibConOut: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 06/17] MdePkg/DxeRuntimeDebugLibSerialPort: " Zhichao Gao
` (11 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 41 ++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c
index 6830a3caa1..69387938b4 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
@@ -51,9 +51,41 @@ DebugPrint (
IN CONST CHAR8 *Format,
...
)
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
{
CHAR16 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
- VA_LIST Marker;
//
// If Format is NULL, then ASSERT().
@@ -70,9 +102,7 @@ DebugPrint (
//
// Convert the DEBUG() message to a Unicode String
//
- VA_START (Marker, Format);
- UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, Marker);
- VA_END (Marker);
+ UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, VaListMarker);
//
// Send the print string to the Standard Error device
@@ -82,7 +112,6 @@ DebugPrint (
}
}
-
/**
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] 20+ messages in thread
* [PATCH 06/17] MdePkg/DxeRuntimeDebugLibSerialPort: Add a new api DebugVPrint
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (4 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 05/17] MdePkg/UefiDebugLibStdErr: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 07/17] MdePkg/UefiDebuglibDebugPortProtocol: " Zhichao Gao
` (10 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 40 ++++++++++++++++++----
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c b/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
index e1266f77fa..e9811d2034 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
@@ -125,9 +125,40 @@ DebugPrint (
IN CONST CHAR8 *Format,
...
)
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
{
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
- VA_LIST Marker;
if (mEfiAtRuntime) {
return;
@@ -148,9 +179,7 @@ DebugPrint (
//
// Convert the DEBUG() message to an ASCII String
//
- VA_START (Marker, Format);
- AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
- VA_END (Marker);
+ AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
//
// Send the print string to a Serial Port
@@ -158,7 +187,6 @@ DebugPrint (
SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
}
-
/**
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] 20+ messages in thread
* [PATCH 07/17] MdePkg/UefiDebuglibDebugPortProtocol: Add a new api DebugVPrint
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (5 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 06/17] MdePkg/DxeRuntimeDebugLibSerialPort: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 08/17] ArmPkg/SemiHostingDebugLib: " Zhichao Gao
` (9 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 41 ++++++++++++++++++----
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c
index c2209f4123..399b4e0625 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
@@ -106,9 +106,41 @@ DebugPrint (
IN CONST CHAR8 *Format,
...
)
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
{
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
- VA_LIST Marker;
//
// If Format is NULL, then ASSERT().
@@ -125,9 +157,7 @@ DebugPrint (
//
// Convert the DEBUG() message to an ASCII String
//
- VA_START (Marker, Format);
- AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
- VA_END (Marker);
+ AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
//
// Send the print string to EFI_DEBUGPORT_PROTOCOL.Write.
@@ -135,7 +165,6 @@ DebugPrint (
UefiDebugLibDebugPortProtocolWrite (Buffer, AsciiStrLen (Buffer));
}
-
/**
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] 20+ messages in thread
* [PATCH 08/17] ArmPkg/SemiHostingDebugLib: Add a new api DebugVPrint
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (6 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 07/17] MdePkg/UefiDebuglibDebugPortProtocol: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 09/17] OvmfPkg/PlatformDebugLibIoPort: " Zhichao Gao
` (8 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 41 +++++++++++++++++++++++----
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/ArmPkg/Library/SemiHostingDebugLib/DebugLib.c b/ArmPkg/Library/SemiHostingDebugLib/DebugLib.c
index ec03edb774..e725853c92 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
@@ -48,9 +48,41 @@ DebugPrint (
IN CONST CHAR8 *Format,
...
)
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
{
CHAR8 AsciiBuffer[MAX_DEBUG_MESSAGE_LENGTH];
- VA_LIST Marker;
//
// If Format is NULL, then ASSERT().
@@ -67,14 +99,11 @@ DebugPrint (
//
// Convert the DEBUG() message to a Unicode String
//
- VA_START (Marker, Format);
- AsciiVSPrint (AsciiBuffer, sizeof (AsciiBuffer), Format, Marker);
- VA_END (Marker);
+ AsciiVSPrint (AsciiBuffer, sizeof (AsciiBuffer), Format, VaListMarker);
SemihostWriteString (AsciiBuffer);
}
-
/**
Prints an assert message containing a filename, line number, and description.
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 09/17] OvmfPkg/PlatformDebugLibIoPort: Add a new api DebugVPrint
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (7 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 08/17] ArmPkg/SemiHostingDebugLib: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 13:07 ` Laszlo Ersek
2019-03-14 9:03 ` [PATCH 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: " Zhichao Gao
` (7 subsequent siblings)
16 siblings, 1 reply; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 41 +++++++++++++++++++----
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
index 36cde54976..1e64eeec11 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
@@ -51,9 +51,41 @@ DebugPrint (
IN CONST CHAR8 *Format,
...
)
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
{
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
- VA_LIST Marker;
UINTN Length;
//
@@ -72,9 +104,7 @@ DebugPrint (
//
// Convert the DEBUG() message to an ASCII String
//
- VA_START (Marker, Format);
- Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
- VA_END (Marker);
+ Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
//
// Send the print string to the debug I/O port
@@ -82,7 +112,6 @@ DebugPrint (
IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);
}
-
/**
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] 20+ messages in thread
* Re: [PATCH 09/17] OvmfPkg/PlatformDebugLibIoPort: Add a new api DebugVPrint
2019-03-14 9:03 ` [PATCH 09/17] OvmfPkg/PlatformDebugLibIoPort: " Zhichao Gao
@ 2019-03-14 13:07 ` Laszlo Ersek
2019-03-15 0:44 ` Gao, Zhichao
0 siblings, 1 reply; 20+ messages in thread
From: Laszlo Ersek @ 2019-03-14 13:07 UTC (permalink / raw)
To: Zhichao Gao, edk2-devel
Cc: Jordan Justen, Ard Biesheuvel, Liming Gao, Sean Brogan,
Michael Turner, Bret Barkelew
On 03/14/19 10:03, Zhichao Gao wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
>
> Add a new api DebugVPrint implementation in the
> DebugLib instance. This api would expose a print
> routine with VaList 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 | 41 +++++++++++++++++++----
> 1 file changed, 35 insertions(+), 6 deletions(-)
>
> diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> index 36cde54976..1e64eeec11 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
> @@ -51,9 +51,41 @@ DebugPrint (
> IN CONST CHAR8 *Format,
> ...
> )
> +{
> + VA_LIST Marker;
> +
> + ASSERT(Format != NULL);
(1) I think this ASSERT() is redundant. The rest of this function will
work fine with the ASSERT() removed, and the DebugVPrint() function will
itself contain an ASSERT(), with the same condition. So I'd prefer
removing this one. (The function-level comments will remain valid.)
> +
> + VA_START(Marker, Format);
> + DebugVPrint(ErrorLevel, Format, Marker);
> + VA_END(Marker);
(2) Please insert a space character before each opening parenthesis.
> +}
> +
> +/**
> + 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().
> + If the length of the message string specificed by Format is larger than the maximum allowable
> + record length, then directly return and not print it.
(3) The last sentence is not enforced by the implementation.
We should
- either implement the check,
- or extend the sentence, saying that there is no such limit in this
library instance,
- or remove the sentence.
I think I'd prefer simply removing the sentence, given that the
DebugPrint() comments lack it as well.
> +
> + @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
> + )
> {
> CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
> - VA_LIST Marker;
> UINTN Length;
>
> //
> @@ -72,9 +104,7 @@ DebugPrint (
> //
> // Convert the DEBUG() message to an ASCII String
> //
> - VA_START (Marker, Format);
> - Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
> - VA_END (Marker);
> + Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
>
> //
> // Send the print string to the debug I/O port
> @@ -82,7 +112,6 @@ DebugPrint (
> IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);
> }
>
> -
> /**
> Prints an assert message containing a filename, line number, and description.
> This may be followed by a breakpoint or a dead loop.
>
(4) This hunk (the last hunk of the patch), which only removes an empty
line, looks superfluous to me. I suggest dropping it.
Thanks
Laszlo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 09/17] OvmfPkg/PlatformDebugLibIoPort: Add a new api DebugVPrint
2019-03-14 13:07 ` Laszlo Ersek
@ 2019-03-15 0:44 ` Gao, Zhichao
0 siblings, 0 replies; 20+ messages in thread
From: Gao, Zhichao @ 2019-03-15 0:44 UTC (permalink / raw)
To: Laszlo Ersek, edk2-devel@lists.01.org
Cc: Justen, Jordan L, Ard Biesheuvel, Gao, Liming, Sean Brogan,
Michael Turner, Bret Barkelew
Thanks for your careful review.
> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, March 14, 2019 9:08 PM
> To: Gao, Zhichao <zhichao.gao@intel.com>; edk2-devel@lists.01.org
> Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Ard Biesheuvel
> <ard.biesheuvel@linaro.org>; 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: Re: [PATCH 09/17] OvmfPkg/PlatformDebugLibIoPort: Add a new api
> DebugVPrint
>
> On 03/14/19 10:03, Zhichao Gao wrote:
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1395
> >
> > Add a new api DebugVPrint implementation in the DebugLib instance.
> > This api would expose a print routine with VaList 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 | 41
> > +++++++++++++++++++----
> > 1 file changed, 35 insertions(+), 6 deletions(-)
> >
> > diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> > b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
> > index 36cde54976..1e64eeec11 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 @@ -51,9 +51,41 @@ DebugPrint (
> > IN CONST CHAR8 *Format,
> > ...
> > )
> > +{
> > + VA_LIST Marker;
> > +
> > + ASSERT(Format != NULL);
>
> (1) I think this ASSERT() is redundant. The rest of this function will work fine
> with the ASSERT() removed, and the DebugVPrint() function will itself
> contain an ASSERT(), with the same condition. So I'd prefer removing this one.
> (The function-level comments will remain valid.)
You are right. I would remove it.
>
> > +
> > + VA_START(Marker, Format);
> > + DebugVPrint(ErrorLevel, Format, Marker); VA_END(Marker);
>
> (2) Please insert a space character before each opening parenthesis.
Good catch. Thanks.
>
> > +}
> > +
> > +/**
> > + 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().
> > + If the length of the message string specificed by Format is larger
> > + than the maximum allowable record length, then directly return and not
> print it.
>
> (3) The last sentence is not enforced by the implementation.
>
> We should
> - either implement the check,
> - or extend the sentence, saying that there is no such limit in this library
> instance,
> - or remove the sentence.
>
> I think I'd prefer simply removing the sentence, given that the
> DebugPrint() comments lack it as well.
Agree with you. Removing it is better.
>
> > +
> > + @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
> > + )
> > {
> > CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
> > - VA_LIST Marker;
> > UINTN Length;
> >
> > //
> > @@ -72,9 +104,7 @@ DebugPrint (
> > //
> > // Convert the DEBUG() message to an ASCII String
> > //
> > - VA_START (Marker, Format);
> > - Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
> > - VA_END (Marker);
> > + Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format,
> > + VaListMarker);
> >
> > //
> > // Send the print string to the debug I/O port @@ -82,7 +112,6 @@
> > DebugPrint (
> > IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer); }
> >
> > -
> > /**
> > Prints an assert message containing a filename, line number, and
> description.
> > This may be followed by a breakpoint or a dead loop.
> >
>
> (4) This hunk (the last hunk of the patch), which only removes an empty line,
> looks superfluous to me. I suggest dropping it.
My coding style is putting one blank line between two function. It seems the lib prefers to putting two blank line. I would unify it for this lib.
>
> Thanks
> Laszlo
Thanks,
Zhichao
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: Add a new api DebugVPrint
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (8 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 09/17] OvmfPkg/PlatformDebugLibIoPort: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: " Zhichao Gao
` (6 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 40 +++++++++++++++++++---
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
index 73bb08e357..4f2b8f1d83 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
@@ -62,9 +62,41 @@ DebugPrint (
IN CONST CHAR8 *Format,
...
)
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
{
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
- VA_LIST Marker;
//
// If Format is NULL, then ASSERT().
@@ -88,9 +120,7 @@ DebugPrint (
//
// Convert the DEBUG() message to an ASCII String
//
- VA_START (Marker, Format);
- AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
- VA_END (Marker);
+ AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
//
// Send the print string to a Serial Port
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: Add a new api DebugVPrint
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (9 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 10/17] IntelFsp2Pkg/BaseFspDebugLibSerialPort: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 12/17] IntelFramworkModulePkg/PeiDxeDebugLibReportStatusCode: Add a new api Zhichao Gao
` (5 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 40 +++++++++++++++++++---
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c b/IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
index 73bb08e357..4f2b8f1d83 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
@@ -62,9 +62,41 @@ DebugPrint (
IN CONST CHAR8 *Format,
...
)
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
{
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
- VA_LIST Marker;
//
// If Format is NULL, then ASSERT().
@@ -88,9 +120,7 @@ DebugPrint (
//
// Convert the DEBUG() message to an ASCII String
//
- VA_START (Marker, Format);
- AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
- VA_END (Marker);
+ AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
//
// Send the print string to a Serial Port
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 12/17] IntelFramworkModulePkg/PeiDxeDebugLibReportStatusCode: Add a new api
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (10 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 11/17] IntelFspPkg/BaseFspDebugLibSerialPort: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
` (4 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 a new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 39 +++++++++++++++++++---
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index b0445115a9..c8437dd233 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
@@ -52,12 +52,44 @@ DebugPrint (
IN CONST CHAR8 *Format,
...
)
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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 Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1];
EFI_DEBUG_INFO *DebugInfo;
UINTN TotalSize;
UINTN DestBufferSize;
- VA_LIST VaListMarker;
BASE_LIST BaseListMarker;
CHAR8 *FormatString;
BOOLEAN Long;
@@ -129,7 +161,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.
@@ -214,11 +245,9 @@ DebugPrint (
// If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then return
//
if ((CHAR8 *)BaseListMarker > FormatString) {
- VA_END (VaListMarker);
return;
}
}
- VA_END (VaListMarker);
//
// Send the DebugInfo record
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: Add a new api
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (11 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 12/17] IntelFramworkModulePkg/PeiDxeDebugLibReportStatusCode: Add a new api Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 14/17] MdeModulePkg: Add definitions for EDKII DEBUG PPI Zhichao Gao
` (3 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 new api DebugVPrint implementation in the
DebugLib instance. This api would expose a print
routine with VaList 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 | 39 +++++++++++++++++++---
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index 6f0f416273..4eb620ddb4 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
@@ -52,11 +52,43 @@ DebugPrint (
IN CONST CHAR8 *Format,
...
)
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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 Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1];
EFI_DEBUG_INFO *DebugInfo;
UINTN TotalSize;
- VA_LIST VaListMarker;
BASE_LIST BaseListMarker;
CHAR8 *FormatString;
BOOLEAN Long;
@@ -125,7 +157,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.
@@ -215,11 +246,9 @@ DebugPrint (
// If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then return
//
if ((CHAR8 *)BaseListMarker > FormatString) {
- VA_END (VaListMarker);
return;
}
}
- VA_END (VaListMarker);
//
// Send the DebugInfo record
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 14/17] MdeModulePkg: Add definitions for EDKII DEBUG PPI
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (12 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 13/17] MdeModulePkg/PeiDxeDebugLibReportStatusCode: " Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 15/17] MdeModulePkg: Add a PEIM to install Debug PPI Zhichao Gao
` (2 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 PEIM
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..deb03a4319
--- /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] VaListMarker VA_LIST marker for the variable argument list.
+
+**/
+typedef
+VOID
+(EFIAPI *EDKII_DEBUG_VPRINT)(
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EDKII_DEBUG_PPI *This,
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN VA_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_VPRINT DebugVPrint;
+ EDKII_DEBUG_ASSERT DebugAssert;
+};
+
+extern EFI_GUID gEdkiiDebugPpiGuid;
+
+#endif
+
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index a90a038b85..43992b7f65 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -498,6 +498,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] 20+ messages in thread
* [PATCH 15/17] MdeModulePkg: Add a PEIM to install Debug PPI
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (13 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 14/17] MdeModulePkg: Add definitions for EDKII DEBUG PPI Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib Zhichao Gao
2019-03-14 9:03 ` [PATCH 17/17] MdeModulePkg: Add PEIM and lib to dsc file Zhichao Gao
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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..24bc2df797
--- /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] VaListMarker VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+PeiDebugVPrint(
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EDKII_DEBUG_PPI *This,
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST Marker
+ )
+{
+ DebugVPrint(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..f7a5c4320c
--- /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] VaListMarker VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+PeiDebugVPrint(
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EDKII_DEBUG_PPI *This,
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN VA_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..9c6f89faef
--- /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 = {
+ PeiDebugVPrint,
+ 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 - 2018, 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] 20+ messages in thread
* [PATCH 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (14 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 15/17] MdeModulePkg: Add a PEIM to install Debug PPI Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
2019-03-14 9:03 ` [PATCH 17/17] MdeModulePkg: Add PEIM and lib to dsc file Zhichao Gao
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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 | 298 +++++++++++++++++++++
.../PeiDebugLibDebugPpi/PeiDebugLibDebugPpi.inf | 55 ++++
2 files changed, 353 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..0d9bc7b1c6
--- /dev/null
+++ b/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
@@ -0,0 +1,298 @@
+/** @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 The format string for the debug message to print.
+ @param ... The variable argument list whose contents are accessed
+ based on the format string specified by Format.
+
+**/
+VOID
+EFIAPI
+DebugPrint (
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+{
+ VA_LIST Marker;
+
+ ASSERT(Format != NULL);
+
+ 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.
+
+ 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().
+ If the length of the message string specificed by Format is larger than the maximum allowable
+ record length, then directly return and not print it.
+
+ @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
+ )
+{
+ 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->DebugVPrint (
+ mPeiServicesTablePointer,
+ mDebugPpi,
+ ErrorLevel,
+ Format,
+ VaListMarker
+ );
+}
+
+/**
+ 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] 20+ messages in thread
* [PATCH 17/17] MdeModulePkg: Add PEIM and lib to dsc file
2019-03-14 9:03 [PATCH 00/17] Add a new API DebugVPrint for DebugLib Zhichao Gao
` (15 preceding siblings ...)
2019-03-14 9:03 ` [PATCH 16/17] MdeModulePkg/PeiDebugLibDebugPpi: Add PEI debug lib Zhichao Gao
@ 2019-03-14 9:03 ` Zhichao Gao
16 siblings, 0 replies; 20+ messages in thread
From: Zhichao Gao @ 2019-03-14 9:03 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] 20+ messages in thread