2 Instance of Print Library based on gEfiPrint2SProtocolGuid.
4 Implement the print library instance by wrap the interface
5 provided in the Print2S protocol. This protocol is defined as the internal
6 protocol related to this implementation, not in the public spec. So, this
7 library instance is only for this code base.
9 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include <Protocol/Print2.h>
24 #include <Library/PrintLib.h>
26 #include <Library/BaseLib.h>
27 #include <Library/DebugLib.h>
28 #include <Library/PcdLib.h>
30 #define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
35 #define RSIZE_MAX (PcdGet32 (PcdMaximumUnicodeStringLength))
36 #define ASCII_RSIZE_MAX (PcdGet32 (PcdMaximumAsciiStringLength))
38 #define SAFE_PRINT_CONSTRAINT_CHECK(Expression, RetVal) \
40 ASSERT (Expression); \
41 if (!(Expression)) { \
46 EFI_PRINT2S_PROTOCOL
*mPrint2SProtocol
= NULL
;
49 The constructor function caches the pointer to Print2S protocol.
51 The constructor function locates Print2S protocol from protocol database.
52 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
54 @param ImageHandle The firmware allocated handle for the EFI image.
55 @param SystemTable A pointer to the EFI System Table.
57 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
63 IN EFI_HANDLE ImageHandle
,
64 IN EFI_SYSTEM_TABLE
*SystemTable
69 Status
= SystemTable
->BootServices
->LocateProtocol (
70 &gEfiPrint2SProtocolGuid
,
72 (VOID
**) &mPrint2SProtocol
74 ASSERT_EFI_ERROR (Status
);
75 ASSERT (mPrint2SProtocol
!= NULL
);
82 Worker function that converts a VA_LIST to a BASE_LIST based on a Null-terminated
85 @param AsciiFormat TRUE if Format is an ASCII string. FALSE if Format is a Unicode string.
86 @param Format Null-terminated format string.
87 @param VaListMarker VA_LIST style variable argument list consumed by processing Format.
88 @param BaseListMarker BASE_LIST style variable argument list consumed by processing Format.
89 @param Size The size, in bytes, of the BaseListMarker buffer.
91 @return TRUE The VA_LIST has been converted to BASE_LIST.
92 @return FALSE The VA_LIST has not been converted to BASE_LIST.
96 DxePrintLibPrint2ProtocolVaListToBaseList (
97 IN BOOLEAN AsciiFormat
,
98 IN CONST CHAR8
*Format
,
99 IN VA_LIST VaListMarker
,
100 OUT BASE_LIST BaseListMarker
,
104 BASE_LIST BaseListStart
;
105 UINTN BytesPerFormatCharacter
;
107 UINTN FormatCharacter
;
111 ASSERT (BaseListMarker
!= NULL
);
112 SAFE_PRINT_CONSTRAINT_CHECK ((Format
!= NULL
), FALSE
);
114 BaseListStart
= BaseListMarker
;
117 if (ASCII_RSIZE_MAX
!= 0) {
118 SAFE_PRINT_CONSTRAINT_CHECK ((AsciiStrnLenS (Format
, ASCII_RSIZE_MAX
+ 1) <= ASCII_RSIZE_MAX
), FALSE
);
120 BytesPerFormatCharacter
= 1;
123 if (RSIZE_MAX
!= 0) {
124 SAFE_PRINT_CONSTRAINT_CHECK ((StrnLenS ((CHAR16
*)Format
, RSIZE_MAX
+ 1) <= RSIZE_MAX
), FALSE
);
126 BytesPerFormatCharacter
= 2;
131 // Get the first character from the format string
133 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
135 while (FormatCharacter
!= 0) {
136 if (FormatCharacter
== '%') {
140 // Parse Flags and Width
142 for (Done
= FALSE
; !Done
; ) {
144 // Get the next character from the format string
146 Format
+= BytesPerFormatCharacter
;
149 // Get the next character from the format string
151 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
153 switch (FormatCharacter
) {
175 BASE_ARG (BaseListMarker
, UINTN
) = VA_ARG (VaListMarker
, UINTN
);
179 // Make no output if Format string terminates unexpectedly when
180 // looking up for flag, width, precision and type.
182 Format
-= BytesPerFormatCharacter
;
184 // break skipped on purpose.
193 // Handle each argument type
195 switch (FormatCharacter
) {
197 if (sizeof (VOID
*) > 4) {
205 BASE_ARG (BaseListMarker
, INT64
) = VA_ARG (VaListMarker
, INT64
);
207 BASE_ARG (BaseListMarker
, int) = VA_ARG (VaListMarker
, int);
215 BASE_ARG (BaseListMarker
, VOID
*) = VA_ARG (VaListMarker
, VOID
*);
218 BASE_ARG (BaseListMarker
, UINTN
) = VA_ARG (VaListMarker
, UINTN
);
221 BASE_ARG (BaseListMarker
, RETURN_STATUS
) = VA_ARG (VaListMarker
, RETURN_STATUS
);
227 // If BASE_LIST is larger than Size, then return FALSE
229 if ((UINTN
)((UINT8
*)BaseListMarker
- (UINT8
*)BaseListStart
) > Size
) {
230 DEBUG ((DEBUG_ERROR
, "The input variable argument list is too long. Please consider breaking into multiple print calls.\n"));
235 // Get the next character from the format string
237 Format
+= BytesPerFormatCharacter
;
240 // Get the next character from the format string
242 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
248 Produces a Null-terminated Unicode string in an output buffer based on
249 a Null-terminated Unicode format string and a VA_LIST argument list.
251 This function is similar as vsnprintf_s defined in C11.
253 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
255 The Unicode string is produced by parsing the format string specified by FormatString.
256 Arguments are pulled from the variable argument list specified by Marker based on the
257 contents of the format string.
258 The number of Unicode characters in the produced output buffer is returned not including
261 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
262 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
264 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
265 unmodified and 0 is returned.
266 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
267 unmodified and 0 is returned.
268 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
269 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
270 buffer is unmodified and 0 is returned.
271 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
272 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
273 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
275 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.
277 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
279 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
280 @param FormatString A Null-terminated Unicode format string.
281 @param Marker VA_LIST marker for the variable argument list.
283 @return The number of Unicode characters in the produced output buffer not including the
290 OUT CHAR16
*StartOfBuffer
,
292 IN CONST CHAR16
*FormatString
,
296 UINT64 BaseListMarker
[256 / sizeof (UINT64
)];
299 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
300 ASSERT_UNICODE_BUFFER (FormatString
);
302 Converted
= DxePrintLibPrint2ProtocolVaListToBaseList (
304 (CHAR8
*)FormatString
,
306 (BASE_LIST
)BaseListMarker
,
307 sizeof (BaseListMarker
) - 8
313 return UnicodeBSPrint (StartOfBuffer
, BufferSize
, FormatString
, (BASE_LIST
)BaseListMarker
);
317 Produces a Null-terminated Unicode string in an output buffer based on
318 a Null-terminated Unicode format string and a BASE_LIST argument list.
320 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
322 The Unicode string is produced by parsing the format string specified by FormatString.
323 Arguments are pulled from the variable argument list specified by Marker based on the
324 contents of the format string.
325 The number of Unicode characters in the produced output buffer is returned not including
328 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
329 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
331 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
332 unmodified and 0 is returned.
333 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
334 unmodified and 0 is returned.
335 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
336 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
337 buffer is unmodified and 0 is returned.
338 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
339 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
340 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
342 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.
344 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
346 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
347 @param FormatString A Null-terminated Unicode format string.
348 @param Marker BASE_LIST marker for the variable argument list.
350 @return The number of Unicode characters in the produced output buffer not including the
357 OUT CHAR16
*StartOfBuffer
,
359 IN CONST CHAR16
*FormatString
,
363 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
364 ASSERT_UNICODE_BUFFER (FormatString
);
365 return mPrint2SProtocol
->UnicodeBSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
369 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
370 Unicode format string and variable argument list.
372 This function is similar as snprintf_s defined in C11.
374 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
376 The Unicode string is produced by parsing the format string specified by FormatString.
377 Arguments are pulled from the variable argument list based on the contents of the format string.
378 The number of Unicode characters in the produced output buffer is returned not including
381 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
382 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
384 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
385 unmodified and 0 is returned.
386 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
387 unmodified and 0 is returned.
388 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
389 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
390 buffer is unmodified and 0 is returned.
391 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
392 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
393 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
395 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.
397 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
399 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
400 @param FormatString A Null-terminated Unicode format string.
401 @param ... Variable argument list whose contents are accessed based on the
402 format string specified by FormatString.
404 @return The number of Unicode characters in the produced output buffer not including the
411 OUT CHAR16
*StartOfBuffer
,
413 IN CONST CHAR16
*FormatString
,
418 UINTN NumberOfPrinted
;
420 VA_START (Marker
, FormatString
);
421 NumberOfPrinted
= UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
423 return NumberOfPrinted
;
427 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
428 ASCII format string and a VA_LIST argument list.
430 This function is similar as vsnprintf_s defined in C11.
432 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
434 The Unicode string is produced by parsing the format string specified by FormatString.
435 Arguments are pulled from the variable argument list specified by Marker based on the
436 contents of the format string.
437 The number of Unicode characters in the produced output buffer is returned not including
440 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
442 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
443 unmodified and 0 is returned.
444 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
445 unmodified and 0 is returned.
446 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
447 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
448 buffer is unmodified and 0 is returned.
449 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
450 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
451 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
453 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
455 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
457 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
458 @param FormatString A Null-terminated ASCII format string.
459 @param Marker VA_LIST marker for the variable argument list.
461 @return The number of Unicode characters in the produced output buffer not including the
467 UnicodeVSPrintAsciiFormat (
468 OUT CHAR16
*StartOfBuffer
,
470 IN CONST CHAR8
*FormatString
,
474 UINT64 BaseListMarker
[256 / sizeof (UINT64
)];
477 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
479 Converted
= DxePrintLibPrint2ProtocolVaListToBaseList (
483 (BASE_LIST
)BaseListMarker
,
484 sizeof (BaseListMarker
) - 8
490 return UnicodeBSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, (BASE_LIST
)BaseListMarker
);
494 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
495 ASCII format string and a BASE_LIST argument list.
497 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
499 The Unicode string is produced by parsing the format string specified by FormatString.
500 Arguments are pulled from the variable argument list specified by Marker based on the
501 contents of the format string.
502 The number of Unicode characters in the produced output buffer is returned not including
505 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
507 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
508 unmodified and 0 is returned.
509 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
510 unmodified and 0 is returned.
511 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
512 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
513 buffer is unmodified and 0 is returned.
514 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
515 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
516 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
518 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
520 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
522 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
523 @param FormatString A Null-terminated ASCII format string.
524 @param Marker BASE_LIST marker for the variable argument list.
526 @return The number of Unicode characters in the produced output buffer not including the
532 UnicodeBSPrintAsciiFormat (
533 OUT CHAR16
*StartOfBuffer
,
535 IN CONST CHAR8
*FormatString
,
539 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
540 return mPrint2SProtocol
->UnicodeBSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
544 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
545 ASCII format string and variable argument list.
547 This function is similar as snprintf_s defined in C11.
549 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
551 The Unicode string is produced by parsing the format string specified by FormatString.
552 Arguments are pulled from the variable argument list based on the contents of the
554 The number of Unicode characters in the produced output buffer is returned not including
557 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
559 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
560 unmodified and 0 is returned.
561 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
562 unmodified and 0 is returned.
563 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
564 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
565 buffer is unmodified and 0 is returned.
566 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
567 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
568 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
570 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
572 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
574 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
575 @param FormatString A Null-terminated ASCII format string.
576 @param ... Variable argument list whose contents are accessed based on the
577 format string specified by FormatString.
579 @return The number of Unicode characters in the produced output buffer not including the
585 UnicodeSPrintAsciiFormat (
586 OUT CHAR16
*StartOfBuffer
,
588 IN CONST CHAR8
*FormatString
,
593 UINTN NumberOfPrinted
;
595 VA_START (Marker
, FormatString
);
596 NumberOfPrinted
= UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
598 return NumberOfPrinted
;
601 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
604 [ATTENTION] This function is deprecated for security reason.
606 Converts a decimal value to a Null-terminated Unicode string.
608 Converts the decimal number specified by Value to a Null-terminated Unicode
609 string specified by Buffer containing at most Width characters. No padding of spaces
610 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
611 The number of Unicode characters in Buffer is returned not including the Null-terminator.
612 If the conversion contains more than Width characters, then only the first
613 Width characters are returned, and the total number of characters
614 required to perform the conversion is returned.
615 Additional conversion parameters are specified in Flags.
617 The Flags bit LEFT_JUSTIFY is always ignored.
618 All conversions are left justified in Buffer.
619 If Width is 0, PREFIX_ZERO is ignored in Flags.
620 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
621 are inserted every 3rd digit starting from the right.
622 If RADIX_HEX is set in Flags, then the output buffer will be
623 formatted in hexadecimal format.
624 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
625 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
626 then Buffer is padded with '0' characters so the combination of the optional '-'
627 sign character, '0' characters, digit characters for Value, and the Null-terminator
628 add up to Width characters.
629 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
630 If Buffer is NULL, then ASSERT().
631 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
632 If unsupported bits are set in Flags, then ASSERT().
633 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
634 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
636 @param Buffer Pointer to the output buffer for the produced Null-terminated
638 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
639 @param Value The 64-bit signed value to convert to a string.
640 @param Width The maximum number of Unicode characters to place in Buffer, not including
643 @return The number of Unicode characters in Buffer not including the Null-terminator.
648 UnicodeValueToString (
649 IN OUT CHAR16
*Buffer
,
655 RETURN_STATUS Status
;
659 BufferSize
= (MAXIMUM_VALUE_CHARACTERS
+ 1) * sizeof (CHAR16
);
661 BufferSize
= (Width
+ 1) * sizeof (CHAR16
);
664 Status
= mPrint2SProtocol
->UnicodeValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
);
665 if (RETURN_ERROR (Status
)) {
669 return StrnLenS (Buffer
, BufferSize
/ sizeof (CHAR16
));
675 Converts a decimal value to a Null-terminated Unicode string.
677 Converts the decimal number specified by Value to a Null-terminated Unicode
678 string specified by Buffer containing at most Width characters. No padding of
679 spaces is ever performed. If Width is 0 then a width of
680 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than
681 Width characters, then only the first Width characters are placed in Buffer.
682 Additional conversion parameters are specified in Flags.
684 The Flags bit LEFT_JUSTIFY is always ignored.
685 All conversions are left justified in Buffer.
686 If Width is 0, PREFIX_ZERO is ignored in Flags.
687 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and
688 commas are inserted every 3rd digit starting from the right.
689 If RADIX_HEX is set in Flags, then the output buffer will be formatted in
691 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in
693 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then
694 Buffer is padded with '0' characters so the combination of the optional '-'
695 sign character, '0' characters, digit characters for Value, and the
696 Null-terminator add up to Width characters.
698 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
699 If an error would be returned, then the function will also ASSERT().
701 @param Buffer The pointer to the output buffer for the produced
702 Null-terminated Unicode string.
703 @param BufferSize The size of Buffer in bytes, including the
705 @param Flags The bitmask of flags that specify left justification,
706 zero pad, and commas.
707 @param Value The 64-bit signed value to convert to a string.
708 @param Width The maximum number of Unicode characters to place in
709 Buffer, not including the Null-terminator.
711 @retval RETURN_SUCCESS The decimal value is converted.
712 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
714 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
715 If PcdMaximumUnicodeStringLength is not
716 zero, and BufferSize is greater than
717 (PcdMaximumUnicodeStringLength *
718 sizeof (CHAR16) + 1).
719 If unsupported bits are set in Flags.
720 If both COMMA_TYPE and RADIX_HEX are set in
722 If Width >= MAXIMUM_VALUE_CHARACTERS.
727 UnicodeValueToStringS (
728 IN OUT CHAR16
*Buffer
,
735 return mPrint2SProtocol
->UnicodeValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
);
739 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
740 ASCII format string and a VA_LIST argument list.
742 This function is similar as vsnprintf_s defined in C11.
744 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
746 The ASCII string is produced by parsing the format string specified by FormatString.
747 Arguments are pulled from the variable argument list specified by Marker based on
748 the contents of the format string.
749 The number of ASCII characters in the produced output buffer is returned not including
752 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
753 unmodified and 0 is returned.
754 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
755 unmodified and 0 is returned.
756 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
757 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
758 is unmodified and 0 is returned.
759 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
760 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
761 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
763 If BufferSize is 0, then no output buffer is produced and 0 is returned.
765 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
767 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
768 @param FormatString A Null-terminated ASCII format string.
769 @param Marker VA_LIST marker for the variable argument list.
771 @return The number of ASCII characters in the produced output buffer not including the
778 OUT CHAR8
*StartOfBuffer
,
780 IN CONST CHAR8
*FormatString
,
784 UINT64 BaseListMarker
[256 / sizeof (UINT64
)];
787 Converted
= DxePrintLibPrint2ProtocolVaListToBaseList (
791 (BASE_LIST
)BaseListMarker
,
792 sizeof (BaseListMarker
) - 8
798 return AsciiBSPrint (StartOfBuffer
, BufferSize
, FormatString
, (BASE_LIST
)BaseListMarker
);
802 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
803 ASCII format string and a BASE_LIST argument list.
805 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
807 The ASCII string is produced by parsing the format string specified by FormatString.
808 Arguments are pulled from the variable argument list specified by Marker based on
809 the contents of the format string.
810 The number of ASCII characters in the produced output buffer is returned not including
813 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
814 unmodified and 0 is returned.
815 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
816 unmodified and 0 is returned.
817 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
818 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
819 is unmodified and 0 is returned.
820 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
821 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
822 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
824 If BufferSize is 0, then no output buffer is produced and 0 is returned.
826 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
828 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
829 @param FormatString A Null-terminated ASCII format string.
830 @param Marker BASE_LIST marker for the variable argument list.
832 @return The number of ASCII characters in the produced output buffer not including the
839 OUT CHAR8
*StartOfBuffer
,
841 IN CONST CHAR8
*FormatString
,
845 return mPrint2SProtocol
->AsciiBSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
849 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
850 ASCII format string and variable argument list.
852 This function is similar as snprintf_s defined in C11.
854 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
856 The ASCII string is produced by parsing the format string specified by FormatString.
857 Arguments are pulled from the variable argument list based on the contents of the
859 The number of ASCII characters in the produced output buffer is returned not including
862 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
863 unmodified and 0 is returned.
864 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
865 unmodified and 0 is returned.
866 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
867 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
868 is unmodified and 0 is returned.
869 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
870 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
871 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
873 If BufferSize is 0, then no output buffer is produced and 0 is returned.
875 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
877 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
878 @param FormatString A Null-terminated ASCII format string.
879 @param ... Variable argument list whose contents are accessed based on the
880 format string specified by FormatString.
882 @return The number of ASCII characters in the produced output buffer not including the
889 OUT CHAR8
*StartOfBuffer
,
891 IN CONST CHAR8
*FormatString
,
896 UINTN NumberOfPrinted
;
898 VA_START (Marker
, FormatString
);
899 NumberOfPrinted
= AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
901 return NumberOfPrinted
;
905 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
906 Unicode format string and a VA_LIST argument list.
908 This function is similar as vsnprintf_s defined in C11.
910 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
912 The ASCII string is produced by parsing the format string specified by FormatString.
913 Arguments are pulled from the variable argument list specified by Marker based on
914 the contents of the format string.
915 The number of ASCII characters in the produced output buffer is returned not including
918 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
920 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
921 unmodified and 0 is returned.
922 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
923 unmodified and 0 is returned.
924 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
925 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
926 is unmodified and 0 is returned.
927 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
928 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
929 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
931 If BufferSize is 0, then no output buffer is produced and 0 is returned.
933 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
935 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
936 @param FormatString A Null-terminated Unicode format string.
937 @param Marker VA_LIST marker for the variable argument list.
939 @return The number of ASCII characters in the produced output buffer not including the
945 AsciiVSPrintUnicodeFormat (
946 OUT CHAR8
*StartOfBuffer
,
948 IN CONST CHAR16
*FormatString
,
952 UINT64 BaseListMarker
[256 / sizeof (UINT64
)];
955 ASSERT_UNICODE_BUFFER (FormatString
);
957 Converted
= DxePrintLibPrint2ProtocolVaListToBaseList (
959 (CHAR8
*)FormatString
,
961 (BASE_LIST
)BaseListMarker
,
962 sizeof (BaseListMarker
) - 8
968 return AsciiBSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, (BASE_LIST
)BaseListMarker
);
972 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
973 Unicode format string and a BASE_LIST argument list.
975 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
977 The ASCII string is produced by parsing the format string specified by FormatString.
978 Arguments are pulled from the variable argument list specified by Marker based on
979 the contents of the format string.
980 The number of ASCII characters in the produced output buffer is returned not including
983 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
985 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
986 unmodified and 0 is returned.
987 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
988 unmodified and 0 is returned.
989 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
990 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
991 is unmodified and 0 is returned.
992 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
993 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
994 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
996 If BufferSize is 0, then no output buffer is produced and 0 is returned.
998 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
1000 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
1001 @param FormatString A Null-terminated Unicode format string.
1002 @param Marker BASE_LIST marker for the variable argument list.
1004 @return The number of ASCII characters in the produced output buffer not including the
1010 AsciiBSPrintUnicodeFormat (
1011 OUT CHAR8
*StartOfBuffer
,
1012 IN UINTN BufferSize
,
1013 IN CONST CHAR16
*FormatString
,
1017 ASSERT_UNICODE_BUFFER (FormatString
);
1018 return mPrint2SProtocol
->AsciiBSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
1022 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
1023 Unicode format string and variable argument list.
1025 This function is similar as snprintf_s defined in C11.
1027 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
1029 The ASCII string is produced by parsing the format string specified by FormatString.
1030 Arguments are pulled from the variable argument list based on the contents of the
1032 The number of ASCII characters in the produced output buffer is returned not including
1033 the Null-terminator.
1035 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
1037 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
1038 unmodified and 0 is returned.
1039 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
1040 unmodified and 0 is returned.
1041 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
1042 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
1043 is unmodified and 0 is returned.
1044 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
1045 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
1046 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
1048 If BufferSize is 0, then no output buffer is produced and 0 is returned.
1050 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
1052 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
1053 @param FormatString A Null-terminated Unicode format string.
1054 @param ... Variable argument list whose contents are accessed based on the
1055 format string specified by FormatString.
1057 @return The number of ASCII characters in the produced output buffer not including the
1063 AsciiSPrintUnicodeFormat (
1064 OUT CHAR8
*StartOfBuffer
,
1065 IN UINTN BufferSize
,
1066 IN CONST CHAR16
*FormatString
,
1071 UINTN NumberOfPrinted
;
1073 VA_START (Marker
, FormatString
);
1074 NumberOfPrinted
= AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
1076 return NumberOfPrinted
;
1080 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1083 [ATTENTION] This function is deprecated for security reason.
1085 Converts a decimal value to a Null-terminated ASCII string.
1087 Converts the decimal number specified by Value to a Null-terminated ASCII string
1088 specified by Buffer containing at most Width characters. No padding of spaces
1090 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
1091 The number of ASCII characters in Buffer is returned not including the Null-terminator.
1092 If the conversion contains more than Width characters, then only the first Width
1093 characters are returned, and the total number of characters required to perform
1094 the conversion is returned.
1095 Additional conversion parameters are specified in Flags.
1096 The Flags bit LEFT_JUSTIFY is always ignored.
1097 All conversions are left justified in Buffer.
1098 If Width is 0, PREFIX_ZERO is ignored in Flags.
1099 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
1100 are inserted every 3rd digit starting from the right.
1101 If RADIX_HEX is set in Flags, then the output buffer will be
1102 formatted in hexadecimal format.
1103 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
1104 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
1105 then Buffer is padded with '0' characters so the combination of the optional '-'
1106 sign character, '0' characters, digit characters for Value, and the Null-terminator
1107 add up to Width characters.
1109 If Buffer is NULL, then ASSERT().
1110 If unsupported bits are set in Flags, then ASSERT().
1111 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
1112 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
1114 @param Buffer Pointer to the output buffer for the produced Null-terminated
1116 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
1117 @param Value The 64-bit signed value to convert to a string.
1118 @param Width The maximum number of ASCII characters to place in Buffer, not including
1119 the Null-terminator.
1121 @return The number of ASCII characters in Buffer not including the Null-terminator.
1126 AsciiValueToString (
1133 RETURN_STATUS Status
;
1137 BufferSize
= (MAXIMUM_VALUE_CHARACTERS
+ 1) * sizeof (CHAR8
);
1139 BufferSize
= (Width
+ 1) * sizeof (CHAR8
);
1142 Status
= mPrint2SProtocol
->AsciiValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
);
1143 if (RETURN_ERROR (Status
)) {
1147 return AsciiStrnLenS (Buffer
, BufferSize
/ sizeof (CHAR8
));
1153 Converts a decimal value to a Null-terminated Ascii string.
1155 Converts the decimal number specified by Value to a Null-terminated Ascii
1156 string specified by Buffer containing at most Width characters. No padding of
1157 spaces is ever performed. If Width is 0 then a width of
1158 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than
1159 Width characters, then only the first Width characters are placed in Buffer.
1160 Additional conversion parameters are specified in Flags.
1162 The Flags bit LEFT_JUSTIFY is always ignored.
1163 All conversions are left justified in Buffer.
1164 If Width is 0, PREFIX_ZERO is ignored in Flags.
1165 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and
1166 commas are inserted every 3rd digit starting from the right.
1167 If RADIX_HEX is set in Flags, then the output buffer will be formatted in
1169 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in
1171 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then
1172 Buffer is padded with '0' characters so the combination of the optional '-'
1173 sign character, '0' characters, digit characters for Value, and the
1174 Null-terminator add up to Width characters.
1176 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
1177 If an error would be returned, then the function will also ASSERT().
1179 @param Buffer The pointer to the output buffer for the produced
1180 Null-terminated Ascii string.
1181 @param BufferSize The size of Buffer in bytes, including the
1183 @param Flags The bitmask of flags that specify left justification,
1184 zero pad, and commas.
1185 @param Value The 64-bit signed value to convert to a string.
1186 @param Width The maximum number of Ascii characters to place in
1187 Buffer, not including the Null-terminator.
1189 @retval RETURN_SUCCESS The decimal value is converted.
1190 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
1192 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
1193 If PcdMaximumAsciiStringLength is not
1194 zero, and BufferSize is greater than
1195 PcdMaximumAsciiStringLength.
1196 If unsupported bits are set in Flags.
1197 If both COMMA_TYPE and RADIX_HEX are set in
1199 If Width >= MAXIMUM_VALUE_CHARACTERS.
1204 AsciiValueToStringS (
1205 IN OUT CHAR8
*Buffer
,
1206 IN UINTN BufferSize
,
1212 return mPrint2SProtocol
->AsciiValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
);
1215 #define PREFIX_SIGN BIT1
1216 #define PREFIX_BLANK BIT2
1217 #define LONG_TYPE BIT4
1218 #define OUTPUT_UNICODE BIT6
1219 #define FORMAT_UNICODE BIT8
1220 #define PAD_TO_WIDTH BIT9
1221 #define ARGUMENT_UNICODE BIT10
1222 #define PRECISION BIT11
1223 #define ARGUMENT_REVERSED BIT12
1224 #define COUNT_ONLY_NO_PRINT BIT13
1225 #define UNSIGNED_TYPE BIT14
1228 // Record date and time information
1244 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr
[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
1247 Internal function that convert a number to a string in Buffer.
1249 Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer.
1251 @param Buffer Location to place the ASCII string of Value.
1252 @param Value The value to convert to a Decimal or Hexadecimal string in Buffer.
1253 @param Radix Radix of the value
1255 @return A pointer to the end of buffer filled with ASCII string.
1259 InternalPrintLibValueToString (
1260 IN OUT CHAR8
*Buffer
,
1268 // Loop to convert one digit at a time in reverse order
1272 Value
= (INT64
)DivU64x32Remainder ((UINT64
)Value
, (UINT32
)Radix
, &Remainder
);
1273 *(++Buffer
) = mHexStr
[Remainder
];
1274 } while (Value
!= 0);
1277 // Return pointer of the end of filled buffer.
1283 Worker function that produces a Null-terminated string in an output buffer
1284 based on a Null-terminated format string and a VA_LIST argument list.
1286 VSPrint function to process format and place the results in Buffer. Since a
1287 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
1288 this is the main print working routine.
1290 If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.
1292 @param[out] Buffer The character buffer to print the results of the
1293 parsing of Format into.
1294 @param[in] BufferSize The maximum number of characters to put into
1296 @param[in] Flags Initial flags value.
1297 Can only have FORMAT_UNICODE, OUTPUT_UNICODE,
1298 and COUNT_ONLY_NO_PRINT set.
1299 @param[in] Format A Null-terminated format string.
1300 @param[in] VaListMarker VA_LIST style variable argument list consumed by
1302 @param[in] BaseListMarker BASE_LIST style variable argument list consumed
1303 by processing Format.
1305 @return The number of characters printed not including the Null-terminator.
1306 If COUNT_ONLY_NO_PRINT was set returns the same, but without any
1307 modification to Buffer.
1311 InternalPrintLibSPrintMarker (
1313 IN UINTN BufferSize
,
1315 IN CONST CHAR8
*Format
,
1316 IN VA_LIST VaListMarker
, OPTIONAL
1317 IN BASE_LIST BaseListMarker OPTIONAL
1321 Worker function that produces a Null-terminated string in an output buffer
1322 based on a Null-terminated format string and variable argument list.
1324 VSPrint function to process format and place the results in Buffer. Since a
1325 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
1326 this is the main print working routine
1328 @param StartOfBuffer The character buffer to print the results of the parsing
1330 @param BufferSize The maximum number of characters to put into buffer.
1331 Zero means no limit.
1332 @param Flags Initial flags value.
1333 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
1334 @param FormatString A Null-terminated format string.
1335 @param ... The variable argument list.
1337 @return The number of characters printed.
1342 InternalPrintLibSPrint (
1343 OUT CHAR8
*StartOfBuffer
,
1344 IN UINTN BufferSize
,
1346 IN CONST CHAR8
*FormatString
,
1351 UINTN NumberOfPrinted
;
1353 VA_START (Marker
, FormatString
);
1354 NumberOfPrinted
= InternalPrintLibSPrintMarker (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
, NULL
);
1356 return NumberOfPrinted
;
1359 #define WARNING_STATUS_NUMBER 5
1360 #define ERROR_STATUS_NUMBER 33
1362 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8
* CONST mStatusString
[] = {
1363 "Success", // RETURN_SUCCESS = 0
1364 "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1
1365 "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
1366 "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3
1367 "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4
1368 "Warning Stale Data", // RETURN_WARN_STALE_DATA = 5
1369 "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT
1370 "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT
1371 "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT
1372 "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT
1373 "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT
1374 "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT
1375 "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT
1376 "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT
1377 "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT
1378 "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT
1379 "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT
1380 "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT
1381 "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT
1382 "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT
1383 "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT
1384 "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT
1385 "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT
1386 "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT
1387 "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT
1388 "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT
1389 "Aborted", // RETURN_ABORTED = 21 | MAX_BIT
1390 "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
1391 "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
1392 "Protocol Error", // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
1393 "Incompatible Version", // RETURN_INCOMPATIBLE_VERSION = 25 | MAX_BIT
1394 "Security Violation", // RETURN_SECURITY_VIOLATION = 26 | MAX_BIT
1395 "CRC Error", // RETURN_CRC_ERROR = 27 | MAX_BIT
1396 "End of Media", // RETURN_END_OF_MEDIA = 28 | MAX_BIT
1397 "Reserved (29)", // RESERVED = 29 | MAX_BIT
1398 "Reserved (30)", // RESERVED = 30 | MAX_BIT
1399 "End of File", // RETURN_END_OF_FILE = 31 | MAX_BIT
1400 "Invalid Language", // RETURN_INVALID_LANGUAGE = 32 | MAX_BIT
1401 "Compromised Data" // RETURN_COMPROMISED_DATA = 33 | MAX_BIT
1405 Internal function that places the character into the Buffer.
1407 Internal function that places ASCII or Unicode character into the Buffer.
1409 @param Buffer The buffer to place the Unicode or ASCII string.
1410 @param EndBuffer The end of the input Buffer. No characters will be
1412 @param Length The count of character to be placed into Buffer.
1413 (Negative value indicates no buffer fill.)
1414 @param Character The character to be placed into Buffer.
1415 @param Increment The character increment in Buffer.
1421 InternalPrintLibFillBuffer (
1423 IN CHAR8
*EndBuffer
,
1431 for (Index
= 0; Index
< Length
&& Buffer
< EndBuffer
; Index
++) {
1432 *Buffer
= (CHAR8
) Character
;
1433 if (Increment
!= 1) {
1434 *(Buffer
+ 1) = (CHAR8
)(Character
>> 8);
1436 Buffer
+= Increment
;
1443 Worker function that produces a Null-terminated string in an output buffer
1444 based on a Null-terminated format string and a VA_LIST argument list.
1446 VSPrint function to process format and place the results in Buffer. Since a
1447 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
1448 this is the main print working routine.
1450 If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.
1452 @param[out] Buffer The character buffer to print the results of the
1453 parsing of Format into.
1454 @param[in] BufferSize The maximum number of characters to put into
1456 @param[in] Flags Initial flags value.
1457 Can only have FORMAT_UNICODE, OUTPUT_UNICODE,
1458 and COUNT_ONLY_NO_PRINT set.
1459 @param[in] Format A Null-terminated format string.
1460 @param[in] VaListMarker VA_LIST style variable argument list consumed by
1462 @param[in] BaseListMarker BASE_LIST style variable argument list consumed
1463 by processing Format.
1465 @return The number of characters printed not including the Null-terminator.
1466 If COUNT_ONLY_NO_PRINT was set returns the same, but without any
1467 modification to Buffer.
1471 InternalPrintLibSPrintMarker (
1473 IN UINTN BufferSize
,
1475 IN CONST CHAR8
*Format
,
1476 IN VA_LIST VaListMarker
, OPTIONAL
1477 IN BASE_LIST BaseListMarker OPTIONAL
1480 CHAR8
*OriginalBuffer
;
1482 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
1483 UINT32 BytesPerOutputCharacter
;
1484 UINTN BytesPerFormatCharacter
;
1486 UINTN FormatCharacter
;
1490 CONST CHAR8
*ArgumentString
;
1496 INTN BytesPerArgumentCharacter
;
1497 UINTN ArgumentCharacter
;
1505 RETURN_STATUS Status
;
1509 UINTN LengthToReturn
;
1512 // If you change this code be sure to match the 2 versions of this function.
1513 // Nearly identical logic is found in the BasePrintLib and
1514 // DxePrintLibPrint2Protocol (both PrintLib instances).
1518 // 1. Buffer shall not be a null pointer when both BufferSize > 0 and
1519 // COUNT_ONLY_NO_PRINT is not set in Flags.
1521 if ((BufferSize
> 0) && ((Flags
& COUNT_ONLY_NO_PRINT
) == 0)) {
1522 SAFE_PRINT_CONSTRAINT_CHECK ((Buffer
!= NULL
), 0);
1526 // 2. Format shall not be a null pointer when BufferSize > 0 or when
1527 // COUNT_ONLY_NO_PRINT is set in Flags.
1529 if ((BufferSize
> 0) || ((Flags
& COUNT_ONLY_NO_PRINT
) != 0)) {
1530 SAFE_PRINT_CONSTRAINT_CHECK ((Format
!= NULL
), 0);
1534 // 3. BufferSize shall not be greater than RSIZE_MAX for Unicode output or
1535 // ASCII_RSIZE_MAX for Ascii output.
1537 if ((Flags
& OUTPUT_UNICODE
) != 0) {
1538 if (RSIZE_MAX
!= 0) {
1539 SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize
<= RSIZE_MAX
), 0);
1541 BytesPerOutputCharacter
= 2;
1543 if (ASCII_RSIZE_MAX
!= 0) {
1544 SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize
<= ASCII_RSIZE_MAX
), 0);
1546 BytesPerOutputCharacter
= 1;
1550 // 4. Format shall not contain more than RSIZE_MAX Unicode characters or
1551 // ASCII_RSIZE_MAX Ascii characters.
1553 if ((Flags
& FORMAT_UNICODE
) != 0) {
1554 if (RSIZE_MAX
!= 0) {
1555 SAFE_PRINT_CONSTRAINT_CHECK ((StrnLenS ((CHAR16
*)Format
, RSIZE_MAX
+ 1) <= RSIZE_MAX
), 0);
1557 BytesPerFormatCharacter
= 2;
1558 FormatMask
= 0xffff;
1560 if (ASCII_RSIZE_MAX
!= 0) {
1561 SAFE_PRINT_CONSTRAINT_CHECK ((AsciiStrnLenS (Format
, ASCII_RSIZE_MAX
+ 1) <= ASCII_RSIZE_MAX
), 0);
1563 BytesPerFormatCharacter
= 1;
1567 if ((Flags
& COUNT_ONLY_NO_PRINT
) != 0) {
1568 if (BufferSize
== 0) {
1573 // We can run without a Buffer for counting only.
1575 if (BufferSize
== 0) {
1582 OriginalBuffer
= NULL
;
1585 // Reserve space for the Null terminator.
1587 if (Buffer
!= NULL
) {
1589 OriginalBuffer
= Buffer
;
1592 // Set the tag for the end of the input Buffer.
1594 EndBuffer
= Buffer
+ BufferSize
* BytesPerOutputCharacter
;
1598 // Get the first character from the format string
1600 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1603 // Loop until the end of the format string is reached or the output buffer is full
1605 while (FormatCharacter
!= 0) {
1606 if ((Buffer
!= NULL
) && (Buffer
>= EndBuffer
)) {
1610 // Clear all the flag bits except those that may have been passed in
1612 Flags
&= (UINTN
) (OUTPUT_UNICODE
| FORMAT_UNICODE
| COUNT_ONLY_NO_PRINT
);
1615 // Set the default width to zero, and the default precision to 1
1625 switch (FormatCharacter
) {
1628 // Parse Flags and Width
1630 for (Done
= FALSE
; !Done
; ) {
1631 Format
+= BytesPerFormatCharacter
;
1632 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1633 switch (FormatCharacter
) {
1638 Flags
|= LEFT_JUSTIFY
;
1641 Flags
|= PREFIX_SIGN
;
1644 Flags
|= PREFIX_BLANK
;
1647 Flags
|= COMMA_TYPE
;
1654 if ((Flags
& PRECISION
) == 0) {
1655 Flags
|= PAD_TO_WIDTH
;
1656 if (BaseListMarker
== NULL
) {
1657 Width
= VA_ARG (VaListMarker
, UINTN
);
1659 Width
= BASE_ARG (BaseListMarker
, UINTN
);
1662 if (BaseListMarker
== NULL
) {
1663 Precision
= VA_ARG (VaListMarker
, UINTN
);
1665 Precision
= BASE_ARG (BaseListMarker
, UINTN
);
1670 if ((Flags
& PRECISION
) == 0) {
1671 Flags
|= PREFIX_ZERO
;
1682 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
1683 Count
= (Count
* 10) + FormatCharacter
- '0';
1684 Format
+= BytesPerFormatCharacter
;
1685 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1687 Format
-= BytesPerFormatCharacter
;
1688 if ((Flags
& PRECISION
) == 0) {
1689 Flags
|= PAD_TO_WIDTH
;
1698 // Make no output if Format string terminates unexpectedly when
1699 // looking up for flag, width, precision and type.
1701 Format
-= BytesPerFormatCharacter
;
1704 // break skipped on purpose.
1713 // Handle each argument type
1715 switch (FormatCharacter
) {
1718 // Flag space, +, 0, L & l are invalid for type p.
1720 Flags
&= ~((UINTN
) (PREFIX_BLANK
| PREFIX_SIGN
| PREFIX_ZERO
| LONG_TYPE
));
1721 if (sizeof (VOID
*) > 4) {
1725 // break skipped on purpose
1728 Flags
|= PREFIX_ZERO
;
1730 // break skipped on purpose
1735 // break skipped on purpose
1738 if ((Flags
& RADIX_HEX
) == 0) {
1739 Flags
&= ~((UINTN
) (PREFIX_SIGN
));
1740 Flags
|= UNSIGNED_TYPE
;
1743 // break skipped on purpose
1746 if ((Flags
& LONG_TYPE
) == 0) {
1748 // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
1749 // This assumption is made so the format string definition is compatible with the ANSI C
1750 // Specification for formatted strings. It is recommended that the Base Types be used
1751 // everywhere, but in this one case, compliance with ANSI C is more important, and
1752 // provides an implementation that is compatible with that largest possible set of CPU
1753 // architectures. This is why the type "int" is used in this one case.
1755 if (BaseListMarker
== NULL
) {
1756 Value
= VA_ARG (VaListMarker
, int);
1758 Value
= BASE_ARG (BaseListMarker
, int);
1761 if (BaseListMarker
== NULL
) {
1762 Value
= VA_ARG (VaListMarker
, INT64
);
1764 Value
= BASE_ARG (BaseListMarker
, INT64
);
1767 if ((Flags
& PREFIX_BLANK
) != 0) {
1770 if ((Flags
& PREFIX_SIGN
) != 0) {
1773 if ((Flags
& COMMA_TYPE
) != 0) {
1776 if ((Flags
& RADIX_HEX
) == 0) {
1779 Flags
&= ~((UINTN
) PREFIX_ZERO
);
1782 if (Value
< 0 && (Flags
& UNSIGNED_TYPE
) == 0) {
1783 Flags
|= PREFIX_SIGN
;
1786 } else if ((Flags
& UNSIGNED_TYPE
) != 0 && (Flags
& LONG_TYPE
) == 0) {
1788 // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
1789 // This assumption is made so the format string definition is compatible with the ANSI C
1790 // Specification for formatted strings. It is recommended that the Base Types be used
1791 // everywhere, but in this one case, compliance with ANSI C is more important, and
1792 // provides an implementation that is compatible with that largest possible set of CPU
1793 // architectures. This is why the type "unsigned int" is used in this one case.
1795 Value
= (unsigned int)Value
;
1800 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
1802 // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
1803 // This assumption is made so the format string definition is compatible with the ANSI C
1804 // Specification for formatted strings. It is recommended that the Base Types be used
1805 // everywhere, but in this one case, compliance with ANSI C is more important, and
1806 // provides an implementation that is compatible with that largest possible set of CPU
1807 // architectures. This is why the type "unsigned int" is used in this one case.
1809 Value
= (unsigned int)Value
;
1813 // Convert Value to a reversed string
1815 Count
= InternalPrintLibValueToString (ValueBuffer
, Value
, Radix
) - ValueBuffer
;
1816 if (Value
== 0 && Precision
== 0) {
1819 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
1823 Digits
= 3 - Digits
;
1825 if (Comma
&& Count
!= 0) {
1826 Count
+= ((Count
- 1) / 3);
1832 Flags
|= ARGUMENT_REVERSED
;
1834 if ((Flags
& PREFIX_ZERO
) != 0) {
1835 if ((Flags
& LEFT_JUSTIFY
) == 0) {
1836 if ((Flags
& PAD_TO_WIDTH
) != 0) {
1837 if ((Flags
& PRECISION
) == 0) {
1847 Flags
|= ARGUMENT_UNICODE
;
1849 // break skipped on purpose
1852 if (BaseListMarker
== NULL
) {
1853 ArgumentString
= VA_ARG (VaListMarker
, CHAR8
*);
1855 ArgumentString
= BASE_ARG (BaseListMarker
, CHAR8
*);
1857 if (ArgumentString
== NULL
) {
1858 Flags
&= (~(UINTN
)ARGUMENT_UNICODE
);
1859 ArgumentString
= "<null string>";
1862 // Set the default precision for string to be zero if not specified.
1864 if ((Flags
& PRECISION
) == 0) {
1870 if (BaseListMarker
== NULL
) {
1871 Character
= VA_ARG (VaListMarker
, UINTN
) & 0xffff;
1873 Character
= BASE_ARG (BaseListMarker
, UINTN
) & 0xffff;
1875 ArgumentString
= (CHAR8
*)&Character
;
1876 Flags
|= ARGUMENT_UNICODE
;
1880 if (BaseListMarker
== NULL
) {
1881 TmpGuid
= VA_ARG (VaListMarker
, GUID
*);
1883 TmpGuid
= BASE_ARG (BaseListMarker
, GUID
*);
1885 if (TmpGuid
== NULL
) {
1886 ArgumentString
= "<null guid>";
1888 GuidData1
= ReadUnaligned32 (&(TmpGuid
->Data1
));
1889 GuidData2
= ReadUnaligned16 (&(TmpGuid
->Data2
));
1890 GuidData3
= ReadUnaligned16 (&(TmpGuid
->Data3
));
1891 InternalPrintLibSPrint (
1893 MAXIMUM_VALUE_CHARACTERS
,
1895 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
1908 ArgumentString
= ValueBuffer
;
1913 if (BaseListMarker
== NULL
) {
1914 TmpTime
= VA_ARG (VaListMarker
, TIME
*);
1916 TmpTime
= BASE_ARG (BaseListMarker
, TIME
*);
1918 if (TmpTime
== NULL
) {
1919 ArgumentString
= "<null time>";
1921 InternalPrintLibSPrint (
1923 MAXIMUM_VALUE_CHARACTERS
,
1925 "%02d/%02d/%04d %02d:%02d",
1932 ArgumentString
= ValueBuffer
;
1937 if (BaseListMarker
== NULL
) {
1938 Status
= VA_ARG (VaListMarker
, RETURN_STATUS
);
1940 Status
= BASE_ARG (BaseListMarker
, RETURN_STATUS
);
1942 ArgumentString
= ValueBuffer
;
1943 if (RETURN_ERROR (Status
)) {
1947 Index
= Status
& ~MAX_BIT
;
1948 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
1949 ArgumentString
= mStatusString
[Index
+ WARNING_STATUS_NUMBER
];
1953 if (Index
<= WARNING_STATUS_NUMBER
) {
1954 ArgumentString
= mStatusString
[Index
];
1957 if (ArgumentString
== ValueBuffer
) {
1958 InternalPrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
1963 Format
+= BytesPerFormatCharacter
;
1964 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1965 if (FormatCharacter
== '\n') {
1967 // Translate '\r\n' to '\r\n'
1969 ArgumentString
= "\r\n";
1972 // Translate '\r' to '\r'
1974 ArgumentString
= "\r";
1975 Format
-= BytesPerFormatCharacter
;
1981 // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
1983 ArgumentString
= "\r\n";
1984 Format
+= BytesPerFormatCharacter
;
1985 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1986 if (FormatCharacter
!= '\r') {
1987 Format
-= BytesPerFormatCharacter
;
1994 // if the type is '%' or unknown, then print it to the screen
1996 ArgumentString
= (CHAR8
*)&FormatCharacter
;
1997 Flags
|= ARGUMENT_UNICODE
;
2003 Format
+= BytesPerFormatCharacter
;
2004 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
2005 if (FormatCharacter
== '\n') {
2007 // Translate '\r\n' to '\r\n'
2009 ArgumentString
= "\r\n";
2012 // Translate '\r' to '\r'
2014 ArgumentString
= "\r";
2015 Format
-= BytesPerFormatCharacter
;
2021 // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
2023 ArgumentString
= "\r\n";
2024 Format
+= BytesPerFormatCharacter
;
2025 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
2026 if (FormatCharacter
!= '\r') {
2027 Format
-= BytesPerFormatCharacter
;
2032 ArgumentString
= (CHAR8
*)&FormatCharacter
;
2033 Flags
|= ARGUMENT_UNICODE
;
2038 // Retrieve the ArgumentString attriubutes
2040 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
2041 ArgumentMask
= 0xffff;
2042 BytesPerArgumentCharacter
= 2;
2044 ArgumentMask
= 0xff;
2045 BytesPerArgumentCharacter
= 1;
2047 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
2048 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
2051 // Compute the number of characters in ArgumentString and store it in Count
2052 // ArgumentString is either null-terminated, or it contains Precision characters
2054 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
2055 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
2056 if (ArgumentCharacter
== 0) {
2062 if (Precision
< Count
) {
2067 // Pad before the string
2069 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
2070 LengthToReturn
+= ((Width
- Precision
) * BytesPerOutputCharacter
);
2071 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2072 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
2078 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2079 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2080 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
2083 LengthToReturn
+= ((Precision
- Count
) * BytesPerOutputCharacter
);
2084 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2085 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
2088 LengthToReturn
+= ((Precision
- Count
) * BytesPerOutputCharacter
);
2089 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2090 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
2093 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2094 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2095 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
2101 // Output the Prefix character if it is present
2109 // Copy the string into the output buffer performing the required type conversions
2111 while (Index
< Count
) {
2112 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
2114 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2115 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2116 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
2118 ArgumentString
+= BytesPerArgumentCharacter
;
2125 if (Index
< Count
) {
2126 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2127 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2128 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', BytesPerOutputCharacter
);
2136 // Pad after the string
2138 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
2139 LengthToReturn
+= ((Width
- Precision
) * BytesPerOutputCharacter
);
2140 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2141 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
2146 // Get the next character from the format string
2148 Format
+= BytesPerFormatCharacter
;
2151 // Get the next character from the format string
2153 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
2156 if ((Flags
& COUNT_ONLY_NO_PRINT
) != 0) {
2157 return (LengthToReturn
/ BytesPerOutputCharacter
);
2160 ASSERT (Buffer
!= NULL
);
2162 // Null terminate the Unicode or ASCII string
2164 InternalPrintLibFillBuffer (Buffer
, EndBuffer
+ BytesPerOutputCharacter
, 1, 0, BytesPerOutputCharacter
);
2166 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
2170 Returns the number of characters that would be produced by if the formatted
2171 output were produced not including the Null-terminator.
2173 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
2175 If FormatString is NULL, then ASSERT() and 0 is returned.
2176 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more
2177 than PcdMaximumUnicodeStringLength Unicode characters not including the
2178 Null-terminator, then ASSERT() and 0 is returned.
2180 @param[in] FormatString A Null-terminated Unicode format string.
2181 @param[in] Marker VA_LIST marker for the variable argument list.
2183 @return The number of characters that would be produced, not including the
2189 IN CONST CHAR16
*FormatString
,
2193 ASSERT_UNICODE_BUFFER (FormatString
);
2194 return InternalPrintLibSPrintMarker (NULL
, 0, FORMAT_UNICODE
| OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);
2198 Returns the number of characters that would be produced by if the formatted
2199 output were produced not including the Null-terminator.
2201 If FormatString is NULL, then ASSERT() and 0 is returned.
2202 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more
2203 than PcdMaximumAsciiStringLength Ascii characters not including the
2204 Null-terminator, then ASSERT() and 0 is returned.
2206 @param[in] FormatString A Null-terminated ASCII format string.
2207 @param[in] Marker VA_LIST marker for the variable argument list.
2209 @return The number of characters that would be produced, not including the
2214 SPrintLengthAsciiFormat (
2215 IN CONST CHAR8
*FormatString
,
2219 return InternalPrintLibSPrintMarker (NULL
, 0, OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);