]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PrintLib: Use EFI_PRINT2S_PROTOCOL for this instance
authorHao Wu <hao.a.wu@intel.com>
Wed, 8 Feb 2017 05:43:02 +0000 (13:43 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 21 Feb 2017 05:56:31 +0000 (13:56 +0800)
The commit updates the PrintLib instance
MdeModulePkg/Library/DxePrintLibPrint2Protocol to use EFI_PRINT2S_PROTOCOL
to implement the APIs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.uni
MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c

index 55ee940a82aaf5d3b80d371edb160c97c36300bc..1cda2dc5cf90974a2f3c2b057d99f95f41340af4 100644 (file)
   PcdLib\r
 \r
 [Protocols]\r
   PcdLib\r
 \r
 [Protocols]\r
-  gEfiPrint2ProtocolGuid                         ## CONSUMES\r
+  gEfiPrint2SProtocolGuid                        ## CONSUMES\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength     ## SOMETIMES_CONSUMES\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength   ## SOMETIMES_CONSUMES\r
 \r
 [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER]\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength     ## SOMETIMES_CONSUMES\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength   ## SOMETIMES_CONSUMES\r
 \r
 [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER]\r
-  gEfiPrint2ProtocolGuid\r
+  gEfiPrint2SProtocolGuid\r
index 29aa37cf2299266597f586f344b59e73c36c1345..3a9fb583a8435433017001e680ac4617505d1d4e 100644 (file)
@@ -1,9 +1,9 @@
 // /** @file\r
 // /** @file\r
-// Library instance that implements Print Library class based on protocol gEfiPrint2ProtocolGuid.\r
+// Library instance that implements Print Library class based on protocol gEfiPrint2SProtocolGuid.\r
 //\r
 //\r
-// Library instance that implements Print Library class based on protocol gEfiPrint2ProtocolGuid.\r
+// Library instance that implements Print Library class based on protocol gEfiPrint2SProtocolGuid.\r
 //\r
 //\r
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+// Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
 //\r
 // This program and the accompanying materials\r
 // are licensed and made available under the terms and conditions of the BSD License\r
 //\r
 // This program and the accompanying materials\r
 // are licensed and made available under the terms and conditions of the BSD License\r
@@ -15,7 +15,7 @@
 // **/\r
 \r
 \r
 // **/\r
 \r
 \r
-#string STR_MODULE_ABSTRACT             #language en-US "Implements Print Library class based on protocol gEfiPrint2ProtocolGuid"\r
+#string STR_MODULE_ABSTRACT             #language en-US "Implements Print Library class based on protocol gEfiPrint2SProtocolGuid"\r
 \r
 \r
-#string STR_MODULE_DESCRIPTION          #language en-US "Library instance that implements Print Library class based on protocol gEfiPrint2ProtocolGuid."\r
+#string STR_MODULE_DESCRIPTION          #language en-US "Library instance that implements Print Library class based on protocol gEfiPrint2SProtocolGuid."\r
 \r
 \r
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