]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/PlatformDebugLibIoPort: write messages with IoWriteFifo8()
authorLaszlo Ersek <lersek@redhat.com>
Mon, 4 Sep 2017 14:30:40 +0000 (16:30 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Mon, 11 Sep 2017 20:28:25 +0000 (22:28 +0200)
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>
OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c

index 44850a9dbad06117840a703666930f949fdb847a..5435767c1c69a8c0bef1fdf60500a013980a49b6 100644 (file)
@@ -69,7 +69,7 @@ DebugPrint (
 {\r
   CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];\r
   VA_LIST  Marker;\r
-  UINT8    *Ptr;\r
+  UINTN    Length;\r
 \r
   //\r
   // If Format is NULL, then ASSERT().\r
@@ -87,15 +87,13 @@ DebugPrint (
   // Convert the DEBUG() message to an ASCII String\r
   //\r
   VA_START (Marker, Format);\r
-  AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
+  Length = AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
   VA_END (Marker);\r
 \r
   //\r
   // Send the print string to the debug I/O port\r
   //\r
-  for (Ptr = (UINT8 *) Buffer; *Ptr; Ptr++) {\r
-    IoWrite8 (PcdGet16(PcdDebugIoPort), *Ptr);\r
-  }\r
+  IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);\r
 }\r
 \r
 \r
@@ -129,20 +127,18 @@ DebugAssert (
   )\r
 {\r
   CHAR8  Buffer[MAX_DEBUG_MESSAGE_LENGTH];\r
-  UINT8 *Ptr;\r
+  UINTN  Length;\r
 \r
   //\r
   // Generate the ASSERT() message in Ascii format\r
   //\r
-  AsciiSPrint (Buffer, sizeof Buffer, "ASSERT %a(%Lu): %a\n", FileName,\r
-    (UINT64)LineNumber, Description);\r
+  Length = AsciiSPrint (Buffer, sizeof Buffer, "ASSERT %a(%Lu): %a\n",\r
+             FileName, (UINT64)LineNumber, Description);\r
 \r
   //\r
-  // Send the print string to the Console Output device\r
+  // Send the print string to the debug I/O port\r
   //\r
-  for (Ptr = (UINT8 *) Buffer; *Ptr; Ptr++) {\r
-    IoWrite8 (PcdGet16(PcdDebugIoPort), *Ptr);\r
-  }\r
+  IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);\r
 \r
   //\r
   // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings\r