/** @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
- 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
} \\r
} while (FALSE)\r
\r
-EFI_PRINT2_PROTOCOL *mPrint2Protocol = NULL;\r
+EFI_PRINT2S_PROTOCOL *mPrint2SProtocol = NULL;\r
\r
/**\r
- The constructor function caches the pointer to Print2 protocol.\r
+ The constructor function caches the pointer to Print2S protocol.\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
EFI_STATUS Status;\r
\r
Status = SystemTable->BootServices->LocateProtocol (\r
- &gEfiPrint2ProtocolGuid,\r
+ &gEfiPrint2SProtocolGuid,\r
NULL,\r
- (VOID**) &mPrint2Protocol\r
+ (VOID**) &mPrint2SProtocol\r
);\r
ASSERT_EFI_ERROR (Status);\r
- ASSERT (mPrint2Protocol != NULL);\r
+ ASSERT (mPrint2SProtocol != NULL);\r
\r
return Status;\r
}\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
ASSERT_UNICODE_BUFFER (StartOfBuffer);\r
- return mPrint2Protocol->UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
+ return mPrint2SProtocol->UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
}\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
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
ASSERT_UNICODE_BUFFER (FormatString);\r
- return mPrint2Protocol->AsciiBSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
+ return mPrint2SProtocol->AsciiBSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
}\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