]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
MdeModulePkg/PrintLib: Use EFI_PRINT2S_PROTOCOL for this instance
[mirror_edk2.git] / MdeModulePkg / Library / DxePrintLibPrint2Protocol / PrintLib.c
index 438ac9e84706dcce9a81dc313b776c7596254a8f..b3e7cb2a25fbd98f8e77df365f1f1634b05730b6 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
 /** @file\r
-  Instance of Print Library based on gEfiPrint2ProtocolGuid.\r
+  Instance of Print Library based on gEfiPrint2SProtocolGuid.\r
 \r
   Implement the print library instance by wrap the interface \r
 \r
   Implement the print library instance by wrap the interface \r
-  provided in the Print2 protocol. This protocol is defined as the internal\r
+  provided in the Print2S protocol. This protocol is defined as the internal\r
   protocol related to this implementation, not in the public spec. So, this \r
   library instance is only for this code base.\r
 \r
   protocol related to this implementation, not in the public spec. So, this \r
   library instance is only for this code base.\r
 \r
@@ -43,12 +43,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     } \\r
   } while (FALSE)\r
 \r
     } \\r
   } while (FALSE)\r
 \r
-EFI_PRINT2_PROTOCOL  *mPrint2Protocol = NULL;\r
+EFI_PRINT2S_PROTOCOL  *mPrint2SProtocol = NULL;\r
 \r
 /**\r
 \r
 /**\r
-  The constructor function caches the pointer to Print2 protocol.\r
+  The constructor function caches the pointer to Print2S protocol.\r
   \r
   \r
-  The constructor function locates Print2 protocol from protocol database.\r
+  The constructor function locates Print2S protocol from protocol database.\r
   It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
 \r
   @param  ImageHandle   The firmware allocated handle for the EFI image.\r
   It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
 \r
   @param  ImageHandle   The firmware allocated handle for the EFI image.\r
@@ -67,12 +67,12 @@ PrintLibConstructor (
   EFI_STATUS                   Status;\r
 \r
   Status = SystemTable->BootServices->LocateProtocol (\r
   EFI_STATUS                   Status;\r
 \r
   Status = SystemTable->BootServices->LocateProtocol (\r
-                                        &gEfiPrint2ProtocolGuid,\r
+                                        &gEfiPrint2SProtocolGuid,\r
                                         NULL,\r
                                         NULL,\r
-                                        (VOID**) &mPrint2Protocol\r
+                                        (VOID**) &mPrint2SProtocol\r
                                         );\r
   ASSERT_EFI_ERROR (Status);\r
                                         );\r
   ASSERT_EFI_ERROR (Status);\r
-  ASSERT (mPrint2Protocol != NULL);\r
+  ASSERT (mPrint2SProtocol != NULL);\r
 \r
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
@@ -362,7 +362,7 @@ UnicodeBSPrint (
 {\r
   ASSERT_UNICODE_BUFFER (StartOfBuffer);\r
   ASSERT_UNICODE_BUFFER (FormatString);\r
 {\r
   ASSERT_UNICODE_BUFFER (StartOfBuffer);\r
   ASSERT_UNICODE_BUFFER (FormatString);\r
-  return mPrint2Protocol->UnicodeBSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
+  return mPrint2SProtocol->UnicodeBSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -537,7 +537,7 @@ UnicodeBSPrintAsciiFormat (
   )\r
 {\r
   ASSERT_UNICODE_BUFFER (StartOfBuffer);\r
   )\r
 {\r
   ASSERT_UNICODE_BUFFER (StartOfBuffer);\r
-  return mPrint2Protocol->UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
+  return mPrint2SProtocol->UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -648,7 +648,21 @@ UnicodeValueToString (
   IN UINTN       Width\r
   )\r
 {\r
   IN UINTN       Width\r
   )\r
 {\r
-  return mPrint2Protocol->UnicodeValueToString (Buffer, Flags, Value, Width);\r
+  RETURN_STATUS  Status;\r
+  UINTN          BufferSize;\r
+\r
+  if (Width == 0) {\r
+    BufferSize = (MAXIMUM_VALUE_CHARACTERS + 1) * sizeof (CHAR16);\r
+  } else {\r
+    BufferSize = (Width + 1) * sizeof (CHAR16);\r
+  }\r
+\r
+  Status = mPrint2SProtocol->UnicodeValueToStringS (Buffer, BufferSize, Flags, Value, Width);\r
+  if (RETURN_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  return StrnLenS (Buffer, BufferSize / sizeof (CHAR16));\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -758,7 +772,7 @@ AsciiBSPrint (
   IN  BASE_LIST     Marker\r
   )\r
 {\r
   IN  BASE_LIST     Marker\r
   )\r
 {\r
-  return mPrint2Protocol->AsciiBSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
+  return mPrint2SProtocol->AsciiBSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -931,7 +945,7 @@ AsciiBSPrintUnicodeFormat (
   )\r
 {\r
   ASSERT_UNICODE_BUFFER (FormatString);\r
   )\r
 {\r
   ASSERT_UNICODE_BUFFER (FormatString);\r
-  return mPrint2Protocol->AsciiBSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
+  return mPrint2SProtocol->AsciiBSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -1042,7 +1056,21 @@ AsciiValueToString (
   IN  UINTN      Width\r
   )\r
 {\r
   IN  UINTN      Width\r
   )\r
 {\r
-  return mPrint2Protocol->AsciiValueToString (Buffer, Flags, Value, Width);\r
+  RETURN_STATUS  Status;\r
+  UINTN          BufferSize;\r
+\r
+  if (Width == 0) {\r
+    BufferSize = (MAXIMUM_VALUE_CHARACTERS + 1) * sizeof (CHAR8);\r
+  } else {\r
+    BufferSize = (Width + 1) * sizeof (CHAR8);\r
+  }\r
+\r
+  Status = mPrint2SProtocol->AsciiValueToStringS (Buffer, BufferSize, Flags, Value, Width);\r
+  if (RETURN_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  return AsciiStrnLenS (Buffer, BufferSize / sizeof (CHAR8));\r
 }\r
 \r
 #define PREFIX_SIGN           BIT1\r
 }\r
 \r
 #define PREFIX_SIGN           BIT1\r