]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PrintDxe/Print.c
MdeModulePkg/CapsulePei: Change debug MACRO
[mirror_edk2.git] / MdeModulePkg / Universal / PrintDxe / Print.c
index b97b1de84a4575262dbe66dabceab25375a4fbb3..c417a2c811def7fbc24f82032de06705a91d1c8a 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
-  This driver produces Print2 protocol layered on top of the PrintLib from the MdePkg.\r
+  This driver produces Print2 protocols layered on top of the PrintLib from the MdePkg.\r
 \r
-Copyright (c) 2009, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -20,6 +14,94 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DebugLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 \r
+/**\r
+  Implementaion of the UnicodeValueToString service in EFI_PRINT2_PROTOCOL.\r
+\r
+  If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().\r
+\r
+  @param  Buffer  The pointer to the output buffer for the produced\r
+                  Null-terminated Unicode string.\r
+  @param  Flags   The bitmask of flags that specify left justification, zero\r
+                  pad, and commas.\r
+  @param  Value   The 64-bit signed value to convert to a string.\r
+  @param  Width   The maximum number of Unicode characters to place in Buffer,\r
+                  not including the Null-terminator.\r
+\r
+  @return If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, return 0.\r
+          Otherwise, return the number of Unicode characters in Buffer not\r
+          including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PrintDxeUnicodeValueToString (\r
+  IN OUT CHAR16  *Buffer,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width\r
+  )\r
+{\r
+#ifdef DISABLE_NEW_DEPRECATED_INTERFACES\r
+  //\r
+  // If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then the\r
+  // PrintLib API UnicodeValueToString is already deprecated.\r
+  // In this case, ASSERT will be triggered and zero will be returned for the\r
+  // implementation of the UnicodeValueToString service in EFI_PRINT2_PROTOCOL\r
+  // to indicate that the service is no longer supported.\r
+  //\r
+  DEBUG ((DEBUG_ERROR, "PrintDxe: The UnicodeValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));\r
+  DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the UnicodeValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));\r
+  ASSERT (FALSE);\r
+  return 0;\r
+#else\r
+  return UnicodeValueToString (Buffer, Flags, Value, Width);\r
+#endif\r
+}\r
+\r
+/**\r
+  Implementaion of the AsciiValueToString service in EFI_PRINT2_PROTOCOL.\r
+\r
+  If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().\r
+\r
+  @param  Buffer  A pointer to the output buffer for the produced\r
+                  Null-terminated ASCII string.\r
+  @param  Flags   The bitmask of flags that specify left justification, zero\r
+                  pad, and commas.\r
+  @param  Value   The 64-bit signed value to convert to a string.\r
+  @param  Width   The maximum number of ASCII characters to place in Buffer,\r
+                  not including the Null-terminator.\r
+\r
+  @return If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, return 0.\r
+          Otherwise, return the number of ASCII characters in Buffer not\r
+          including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PrintDxeAsciiValueToString (\r
+  OUT CHAR8      *Buffer,\r
+  IN  UINTN      Flags,\r
+  IN  INT64      Value,\r
+  IN  UINTN      Width\r
+  )\r
+{\r
+#ifdef DISABLE_NEW_DEPRECATED_INTERFACES\r
+  //\r
+  // If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then the\r
+  // PrintLib API AsciiValueToString is already deprecated.\r
+  // In this case, ASSERT will be triggered and zero will be returned for the\r
+  // implementation of the AsciiValueToString service in EFI_PRINT2_PROTOCOL\r
+  // to indicate that the service is no longer supported.\r
+  //\r
+  DEBUG ((DEBUG_ERROR, "PrintDxe: The AsciiValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));\r
+  DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the AsciiValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));\r
+  ASSERT (FALSE);\r
+  return 0;\r
+#else\r
+  return AsciiValueToString (Buffer, Flags, Value, Width);\r
+#endif\r
+}\r
+\r
 EFI_HANDLE  mPrintThunkHandle = NULL;\r
 \r
 CONST EFI_PRINT2_PROTOCOL mPrint2Protocol = {\r
@@ -27,12 +109,25 @@ CONST EFI_PRINT2_PROTOCOL mPrint2Protocol = {
   UnicodeSPrint,\r
   UnicodeBSPrintAsciiFormat,\r
   UnicodeSPrintAsciiFormat,\r
-  UnicodeValueToString,\r
+  PrintDxeUnicodeValueToString,\r
+  AsciiBSPrint,\r
+  AsciiSPrint,\r
+  AsciiBSPrintUnicodeFormat,\r
+  AsciiSPrintUnicodeFormat,\r
+  PrintDxeAsciiValueToString\r
+};\r
+\r
+CONST EFI_PRINT2S_PROTOCOL mPrint2SProtocol = {\r
+  UnicodeBSPrint,\r
+  UnicodeSPrint,\r
+  UnicodeBSPrintAsciiFormat,\r
+  UnicodeSPrintAsciiFormat,\r
+  UnicodeValueToStringS,\r
   AsciiBSPrint,\r
   AsciiSPrint,\r
   AsciiBSPrintUnicodeFormat,\r
   AsciiSPrintUnicodeFormat,\r
-  AsciiValueToString\r
+  AsciiValueToStringS\r
 };\r
 \r
 /**\r
@@ -59,6 +154,7 @@ PrintEntryPoint (
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &mPrintThunkHandle,\r
                   &gEfiPrint2ProtocolGuid, &mPrint2Protocol,\r
+                  &gEfiPrint2SProtocolGuid, &mPrint2SProtocol,\r
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r