Since commit 19c6d9feaaf8 ("MdePkg: Expand BaseIoLibIntrinsic (IoLib
class) library", 2017-01-14), IoWriteFifo8() has been widely available to
modules. Use it to print debug messages and assertion failures to the QEMU
debug port, rather than open-coded loops.
In the general case this speeds up logging, because debug messages will
now trap to QEMU once per message (as opposed to once per character), due
to "REP OUTSB" in "MdePkg/Library/BaseIoLibIntrinsic/*/IoFifoSev.nasm".
In SEV guests, there is no speedup (SEV doesn't support the REP prefix).
SEV is detected internally to BaseIoLibIntrinsic.
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
index 44850a9dbad0..5435767c1c69 100644
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
@@ -69,7 +69,7 @@ DebugPrint (
{
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
VA_LIST Marker;
- UINT8 *Ptr;
+ UINTN Length;
//
// If Format is NULL, then ASSERT().
@@ -87,15 +87,13 @@ DebugPrint (
// Convert the DEBUG() message to an ASCII String
//
VA_START (Marker, Format);
- AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
+ Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
VA_END (Marker);
//
// Send the print string to the debug I/O port
//
- for (Ptr = (UINT8 *) Buffer; *Ptr; Ptr++) {
- IoWrite8 (PcdGet16(PcdDebugIoPort), *Ptr);
- }
+ IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);
}
@@ -129,20 +127,18 @@ DebugAssert (
)
{
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
- UINT8 *Ptr;
+ UINTN Length;
//
// Generate the ASSERT() message in Ascii format
//
- AsciiSPrint (Buffer, sizeof Buffer, "ASSERT %a(%Lu): %a\n", FileName,
- (UINT64)LineNumber, Description);
+ Length = AsciiSPrint (Buffer, sizeof Buffer, "ASSERT %a(%Lu): %a\n",
+ FileName, (UINT64)LineNumber, Description);
//
- // Send the print string to the Console Output device
+ // Send the print string to the debug I/O port
//
- for (Ptr = (UINT8 *) Buffer; *Ptr; Ptr++) {
- IoWrite8 (PcdGet16(PcdDebugIoPort), *Ptr);
- }
+ IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);
//
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
--
2.14.1.3.gb7cf6e02401b
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
On 09/04/2017 10:57 AM, Laszlo Ersek wrote: > Since commit 19c6d9feaaf8 ("MdePkg: Expand BaseIoLibIntrinsic (IoLib > class) library", 2017-01-14), IoWriteFifo8() has been widely available to > modules. Use it to print debug messages and assertion failures to the QEMU > debug port, rather than open-coded loops. > > In the general case this speeds up logging, because debug messages will > now trap to QEMU once per message (as opposed to once per character), due > to "REP OUTSB" in "MdePkg/Library/BaseIoLibIntrinsic/*/IoFifoSev.nasm". > > In SEV guests, there is no speedup (SEV doesn't support the REP prefix). > SEV is detected internally to BaseIoLibIntrinsic. > > Cc: Brijesh Singh <brijesh.singh@amd.com> > Cc: Jordan Justen <jordan.l.justen@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Brijesh Singh <brijesh.singh@amd.com> _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.