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
)BaseListMarker
- (UINTN
)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 an error would be returned, then the function will ASSERT().
1178 @param Buffer The pointer to the output buffer for the produced
1179 Null-terminated Ascii string.
1180 @param BufferSize The size of Buffer in bytes, including the
1182 @param Flags The bitmask of flags that specify left justification,
1183 zero pad, and commas.
1184 @param Value The 64-bit signed value to convert to a string.
1185 @param Width The maximum number of Ascii characters to place in
1186 Buffer, not including the Null-terminator.
1188 @retval RETURN_SUCCESS The decimal value is converted.
1189 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
1191 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
1192 If PcdMaximumAsciiStringLength is not
1193 zero, and BufferSize is greater than
1194 PcdMaximumAsciiStringLength.
1195 If unsupported bits are set in Flags.
1196 If both COMMA_TYPE and RADIX_HEX are set in
1198 If Width >= MAXIMUM_VALUE_CHARACTERS.
1203 AsciiValueToStringS (
1204 IN OUT CHAR8
*Buffer
,
1205 IN UINTN BufferSize
,
1211 return mPrint2SProtocol
->AsciiValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
);
1214 #define PREFIX_SIGN BIT1
1215 #define PREFIX_BLANK BIT2
1216 #define LONG_TYPE BIT4
1217 #define OUTPUT_UNICODE BIT6
1218 #define FORMAT_UNICODE BIT8
1219 #define PAD_TO_WIDTH BIT9
1220 #define ARGUMENT_UNICODE BIT10
1221 #define PRECISION BIT11
1222 #define ARGUMENT_REVERSED BIT12
1223 #define COUNT_ONLY_NO_PRINT BIT13
1224 #define UNSIGNED_TYPE BIT14
1227 // Record date and time information
1243 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr
[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
1246 Internal function that convert a number to a string in Buffer.
1248 Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer.
1250 @param Buffer Location to place the ASCII string of Value.
1251 @param Value The value to convert to a Decimal or Hexadecimal string in Buffer.
1252 @param Radix Radix of the value
1254 @return A pointer to the end of buffer filled with ASCII string.
1258 InternalPrintLibValueToString (
1259 IN OUT CHAR8
*Buffer
,
1267 // Loop to convert one digit at a time in reverse order
1271 Value
= (INT64
)DivU64x32Remainder ((UINT64
)Value
, (UINT32
)Radix
, &Remainder
);
1272 *(++Buffer
) = mHexStr
[Remainder
];
1273 } while (Value
!= 0);
1276 // Return pointer of the end of filled buffer.
1282 Worker function that produces a Null-terminated string in an output buffer
1283 based on a Null-terminated format string and a VA_LIST argument list.
1285 VSPrint function to process format and place the results in Buffer. Since a
1286 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
1287 this is the main print working routine.
1289 If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.
1291 @param[out] Buffer The character buffer to print the results of the
1292 parsing of Format into.
1293 @param[in] BufferSize The maximum number of characters to put into
1295 @param[in] Flags Initial flags value.
1296 Can only have FORMAT_UNICODE, OUTPUT_UNICODE,
1297 and COUNT_ONLY_NO_PRINT set.
1298 @param[in] Format A Null-terminated format string.
1299 @param[in] VaListMarker VA_LIST style variable argument list consumed by
1301 @param[in] BaseListMarker BASE_LIST style variable argument list consumed
1302 by processing Format.
1304 @return The number of characters printed not including the Null-terminator.
1305 If COUNT_ONLY_NO_PRINT was set returns the same, but without any
1306 modification to Buffer.
1310 InternalPrintLibSPrintMarker (
1312 IN UINTN BufferSize
,
1314 IN CONST CHAR8
*Format
,
1315 IN VA_LIST VaListMarker
, OPTIONAL
1316 IN BASE_LIST BaseListMarker OPTIONAL
1320 Worker function that produces a Null-terminated string in an output buffer
1321 based on a Null-terminated format string and variable argument list.
1323 VSPrint function to process format and place the results in Buffer. Since a
1324 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
1325 this is the main print working routine
1327 @param StartOfBuffer The character buffer to print the results of the parsing
1329 @param BufferSize The maximum number of characters to put into buffer.
1330 Zero means no limit.
1331 @param Flags Initial flags value.
1332 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
1333 @param FormatString A Null-terminated format string.
1334 @param ... The variable argument list.
1336 @return The number of characters printed.
1341 InternalPrintLibSPrint (
1342 OUT CHAR8
*StartOfBuffer
,
1343 IN UINTN BufferSize
,
1345 IN CONST CHAR8
*FormatString
,
1350 UINTN NumberOfPrinted
;
1352 VA_START (Marker
, FormatString
);
1353 NumberOfPrinted
= InternalPrintLibSPrintMarker (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
, NULL
);
1355 return NumberOfPrinted
;
1358 #define WARNING_STATUS_NUMBER 5
1359 #define ERROR_STATUS_NUMBER 33
1361 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8
* CONST mStatusString
[] = {
1362 "Success", // RETURN_SUCCESS = 0
1363 "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1
1364 "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
1365 "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3
1366 "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4
1367 "Warning Stale Data", // RETURN_WARN_STALE_DATA = 5
1368 "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT
1369 "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT
1370 "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT
1371 "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT
1372 "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT
1373 "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT
1374 "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT
1375 "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT
1376 "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT
1377 "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT
1378 "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT
1379 "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT
1380 "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT
1381 "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT
1382 "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT
1383 "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT
1384 "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT
1385 "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT
1386 "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT
1387 "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT
1388 "Aborted", // RETURN_ABORTED = 21 | MAX_BIT
1389 "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
1390 "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
1391 "Protocol Error", // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
1392 "Incompatible Version", // RETURN_INCOMPATIBLE_VERSION = 25 | MAX_BIT
1393 "Security Violation", // RETURN_SECURITY_VIOLATION = 26 | MAX_BIT
1394 "CRC Error", // RETURN_CRC_ERROR = 27 | MAX_BIT
1395 "End of Media", // RETURN_END_OF_MEDIA = 28 | MAX_BIT
1396 "Reserved (29)", // RESERVED = 29 | MAX_BIT
1397 "Reserved (30)", // RESERVED = 30 | MAX_BIT
1398 "End of File", // RETURN_END_OF_FILE = 31 | MAX_BIT
1399 "Invalid Language", // RETURN_INVALID_LANGUAGE = 32 | MAX_BIT
1400 "Compromised Data" // RETURN_COMPROMISED_DATA = 33 | MAX_BIT
1404 Internal function that places the character into the Buffer.
1406 Internal function that places ASCII or Unicode character into the Buffer.
1408 @param Buffer The buffer to place the Unicode or ASCII string.
1409 @param EndBuffer The end of the input Buffer. No characters will be
1411 @param Length The count of character to be placed into Buffer.
1412 (Negative value indicates no buffer fill.)
1413 @param Character The character to be placed into Buffer.
1414 @param Increment The character increment in Buffer.
1420 InternalPrintLibFillBuffer (
1422 IN CHAR8
*EndBuffer
,
1430 for (Index
= 0; Index
< Length
&& Buffer
< EndBuffer
; Index
++) {
1431 *Buffer
= (CHAR8
) Character
;
1432 if (Increment
!= 1) {
1433 *(Buffer
+ 1) = (CHAR8
)(Character
>> 8);
1435 Buffer
+= Increment
;
1442 Worker function that produces a Null-terminated string in an output buffer
1443 based on a Null-terminated format string and a VA_LIST argument list.
1445 VSPrint function to process format and place the results in Buffer. Since a
1446 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
1447 this is the main print working routine.
1449 If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.
1451 @param[out] Buffer The character buffer to print the results of the
1452 parsing of Format into.
1453 @param[in] BufferSize The maximum number of characters to put into
1455 @param[in] Flags Initial flags value.
1456 Can only have FORMAT_UNICODE, OUTPUT_UNICODE,
1457 and COUNT_ONLY_NO_PRINT set.
1458 @param[in] Format A Null-terminated format string.
1459 @param[in] VaListMarker VA_LIST style variable argument list consumed by
1461 @param[in] BaseListMarker BASE_LIST style variable argument list consumed
1462 by processing Format.
1464 @return The number of characters printed not including the Null-terminator.
1465 If COUNT_ONLY_NO_PRINT was set returns the same, but without any
1466 modification to Buffer.
1470 InternalPrintLibSPrintMarker (
1472 IN UINTN BufferSize
,
1474 IN CONST CHAR8
*Format
,
1475 IN VA_LIST VaListMarker
, OPTIONAL
1476 IN BASE_LIST BaseListMarker OPTIONAL
1479 CHAR8
*OriginalBuffer
;
1481 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
1482 UINT32 BytesPerOutputCharacter
;
1483 UINTN BytesPerFormatCharacter
;
1485 UINTN FormatCharacter
;
1489 CONST CHAR8
*ArgumentString
;
1495 INTN BytesPerArgumentCharacter
;
1496 UINTN ArgumentCharacter
;
1504 RETURN_STATUS Status
;
1508 UINTN LengthToReturn
;
1511 // If you change this code be sure to match the 2 versions of this function.
1512 // Nearly identical logic is found in the BasePrintLib and
1513 // DxePrintLibPrint2Protocol (both PrintLib instances).
1517 // 1. Buffer shall not be a null pointer when both BufferSize > 0 and
1518 // COUNT_ONLY_NO_PRINT is not set in Flags.
1520 if ((BufferSize
> 0) && ((Flags
& COUNT_ONLY_NO_PRINT
) == 0)) {
1521 SAFE_PRINT_CONSTRAINT_CHECK ((Buffer
!= NULL
), 0);
1525 // 2. Format shall not be a null pointer when BufferSize > 0 or when
1526 // COUNT_ONLY_NO_PRINT is set in Flags.
1528 if ((BufferSize
> 0) || ((Flags
& COUNT_ONLY_NO_PRINT
) != 0)) {
1529 SAFE_PRINT_CONSTRAINT_CHECK ((Format
!= NULL
), 0);
1533 // 3. BufferSize shall not be greater than RSIZE_MAX for Unicode output or
1534 // ASCII_RSIZE_MAX for Ascii output.
1536 if ((Flags
& OUTPUT_UNICODE
) != 0) {
1537 if (RSIZE_MAX
!= 0) {
1538 SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize
<= RSIZE_MAX
), 0);
1540 BytesPerOutputCharacter
= 2;
1542 if (ASCII_RSIZE_MAX
!= 0) {
1543 SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize
<= ASCII_RSIZE_MAX
), 0);
1545 BytesPerOutputCharacter
= 1;
1549 // 4. Format shall not contain more than RSIZE_MAX Unicode characters or
1550 // ASCII_RSIZE_MAX Ascii characters.
1552 if ((Flags
& FORMAT_UNICODE
) != 0) {
1553 if (RSIZE_MAX
!= 0) {
1554 SAFE_PRINT_CONSTRAINT_CHECK ((StrnLenS ((CHAR16
*)Format
, RSIZE_MAX
+ 1) <= RSIZE_MAX
), 0);
1556 BytesPerFormatCharacter
= 2;
1557 FormatMask
= 0xffff;
1559 if (ASCII_RSIZE_MAX
!= 0) {
1560 SAFE_PRINT_CONSTRAINT_CHECK ((AsciiStrnLenS (Format
, ASCII_RSIZE_MAX
+ 1) <= ASCII_RSIZE_MAX
), 0);
1562 BytesPerFormatCharacter
= 1;
1566 if ((Flags
& COUNT_ONLY_NO_PRINT
) != 0) {
1567 if (BufferSize
== 0) {
1572 // We can run without a Buffer for counting only.
1574 if (BufferSize
== 0) {
1581 OriginalBuffer
= NULL
;
1584 // Reserve space for the Null terminator.
1586 if (Buffer
!= NULL
) {
1588 OriginalBuffer
= Buffer
;
1591 // Set the tag for the end of the input Buffer.
1593 EndBuffer
= Buffer
+ BufferSize
* BytesPerOutputCharacter
;
1597 // Get the first character from the format string
1599 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1602 // Loop until the end of the format string is reached or the output buffer is full
1604 while (FormatCharacter
!= 0) {
1605 if ((Buffer
!= NULL
) && (Buffer
>= EndBuffer
)) {
1609 // Clear all the flag bits except those that may have been passed in
1611 Flags
&= (UINTN
) (OUTPUT_UNICODE
| FORMAT_UNICODE
| COUNT_ONLY_NO_PRINT
);
1614 // Set the default width to zero, and the default precision to 1
1624 switch (FormatCharacter
) {
1627 // Parse Flags and Width
1629 for (Done
= FALSE
; !Done
; ) {
1630 Format
+= BytesPerFormatCharacter
;
1631 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1632 switch (FormatCharacter
) {
1637 Flags
|= LEFT_JUSTIFY
;
1640 Flags
|= PREFIX_SIGN
;
1643 Flags
|= PREFIX_BLANK
;
1646 Flags
|= COMMA_TYPE
;
1653 if ((Flags
& PRECISION
) == 0) {
1654 Flags
|= PAD_TO_WIDTH
;
1655 if (BaseListMarker
== NULL
) {
1656 Width
= VA_ARG (VaListMarker
, UINTN
);
1658 Width
= BASE_ARG (BaseListMarker
, UINTN
);
1661 if (BaseListMarker
== NULL
) {
1662 Precision
= VA_ARG (VaListMarker
, UINTN
);
1664 Precision
= BASE_ARG (BaseListMarker
, UINTN
);
1669 if ((Flags
& PRECISION
) == 0) {
1670 Flags
|= PREFIX_ZERO
;
1681 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
1682 Count
= (Count
* 10) + FormatCharacter
- '0';
1683 Format
+= BytesPerFormatCharacter
;
1684 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1686 Format
-= BytesPerFormatCharacter
;
1687 if ((Flags
& PRECISION
) == 0) {
1688 Flags
|= PAD_TO_WIDTH
;
1697 // Make no output if Format string terminates unexpectedly when
1698 // looking up for flag, width, precision and type.
1700 Format
-= BytesPerFormatCharacter
;
1703 // break skipped on purpose.
1712 // Handle each argument type
1714 switch (FormatCharacter
) {
1717 // Flag space, +, 0, L & l are invalid for type p.
1719 Flags
&= ~((UINTN
) (PREFIX_BLANK
| PREFIX_SIGN
| PREFIX_ZERO
| LONG_TYPE
));
1720 if (sizeof (VOID
*) > 4) {
1724 // break skipped on purpose
1727 Flags
|= PREFIX_ZERO
;
1729 // break skipped on purpose
1734 // break skipped on purpose
1737 if ((Flags
& RADIX_HEX
) == 0) {
1738 Flags
&= ~((UINTN
) (PREFIX_SIGN
));
1739 Flags
|= UNSIGNED_TYPE
;
1742 // break skipped on purpose
1745 if ((Flags
& LONG_TYPE
) == 0) {
1747 // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
1748 // This assumption is made so the format string definition is compatible with the ANSI C
1749 // Specification for formatted strings. It is recommended that the Base Types be used
1750 // everywhere, but in this one case, compliance with ANSI C is more important, and
1751 // provides an implementation that is compatible with that largest possible set of CPU
1752 // architectures. This is why the type "int" is used in this one case.
1754 if (BaseListMarker
== NULL
) {
1755 Value
= VA_ARG (VaListMarker
, int);
1757 Value
= BASE_ARG (BaseListMarker
, int);
1760 if (BaseListMarker
== NULL
) {
1761 Value
= VA_ARG (VaListMarker
, INT64
);
1763 Value
= BASE_ARG (BaseListMarker
, INT64
);
1766 if ((Flags
& PREFIX_BLANK
) != 0) {
1769 if ((Flags
& PREFIX_SIGN
) != 0) {
1772 if ((Flags
& COMMA_TYPE
) != 0) {
1775 if ((Flags
& RADIX_HEX
) == 0) {
1778 Flags
&= ~((UINTN
) PREFIX_ZERO
);
1781 if (Value
< 0 && (Flags
& UNSIGNED_TYPE
) == 0) {
1782 Flags
|= PREFIX_SIGN
;
1785 } else if ((Flags
& UNSIGNED_TYPE
) != 0 && (Flags
& LONG_TYPE
) == 0) {
1787 // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
1788 // This assumption is made so the format string definition is compatible with the ANSI C
1789 // Specification for formatted strings. It is recommended that the Base Types be used
1790 // everywhere, but in this one case, compliance with ANSI C is more important, and
1791 // provides an implementation that is compatible with that largest possible set of CPU
1792 // architectures. This is why the type "unsigned int" is used in this one case.
1794 Value
= (unsigned int)Value
;
1799 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
1801 // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
1802 // This assumption is made so the format string definition is compatible with the ANSI C
1803 // Specification for formatted strings. It is recommended that the Base Types be used
1804 // everywhere, but in this one case, compliance with ANSI C is more important, and
1805 // provides an implementation that is compatible with that largest possible set of CPU
1806 // architectures. This is why the type "unsigned int" is used in this one case.
1808 Value
= (unsigned int)Value
;
1812 // Convert Value to a reversed string
1814 Count
= InternalPrintLibValueToString (ValueBuffer
, Value
, Radix
) - ValueBuffer
;
1815 if (Value
== 0 && Precision
== 0) {
1818 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
1822 Digits
= 3 - Digits
;
1824 if (Comma
&& Count
!= 0) {
1825 Count
+= ((Count
- 1) / 3);
1831 Flags
|= ARGUMENT_REVERSED
;
1833 if ((Flags
& PREFIX_ZERO
) != 0) {
1834 if ((Flags
& LEFT_JUSTIFY
) == 0) {
1835 if ((Flags
& PAD_TO_WIDTH
) != 0) {
1836 if ((Flags
& PRECISION
) == 0) {
1846 Flags
|= ARGUMENT_UNICODE
;
1848 // break skipped on purpose
1851 if (BaseListMarker
== NULL
) {
1852 ArgumentString
= VA_ARG (VaListMarker
, CHAR8
*);
1854 ArgumentString
= BASE_ARG (BaseListMarker
, CHAR8
*);
1856 if (ArgumentString
== NULL
) {
1857 Flags
&= (~(UINTN
)ARGUMENT_UNICODE
);
1858 ArgumentString
= "<null string>";
1861 // Set the default precision for string to be zero if not specified.
1863 if ((Flags
& PRECISION
) == 0) {
1869 if (BaseListMarker
== NULL
) {
1870 Character
= VA_ARG (VaListMarker
, UINTN
) & 0xffff;
1872 Character
= BASE_ARG (BaseListMarker
, UINTN
) & 0xffff;
1874 ArgumentString
= (CHAR8
*)&Character
;
1875 Flags
|= ARGUMENT_UNICODE
;
1879 if (BaseListMarker
== NULL
) {
1880 TmpGuid
= VA_ARG (VaListMarker
, GUID
*);
1882 TmpGuid
= BASE_ARG (BaseListMarker
, GUID
*);
1884 if (TmpGuid
== NULL
) {
1885 ArgumentString
= "<null guid>";
1887 GuidData1
= ReadUnaligned32 (&(TmpGuid
->Data1
));
1888 GuidData2
= ReadUnaligned16 (&(TmpGuid
->Data2
));
1889 GuidData3
= ReadUnaligned16 (&(TmpGuid
->Data3
));
1890 InternalPrintLibSPrint (
1892 MAXIMUM_VALUE_CHARACTERS
,
1894 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
1907 ArgumentString
= ValueBuffer
;
1912 if (BaseListMarker
== NULL
) {
1913 TmpTime
= VA_ARG (VaListMarker
, TIME
*);
1915 TmpTime
= BASE_ARG (BaseListMarker
, TIME
*);
1917 if (TmpTime
== NULL
) {
1918 ArgumentString
= "<null time>";
1920 InternalPrintLibSPrint (
1922 MAXIMUM_VALUE_CHARACTERS
,
1924 "%02d/%02d/%04d %02d:%02d",
1931 ArgumentString
= ValueBuffer
;
1936 if (BaseListMarker
== NULL
) {
1937 Status
= VA_ARG (VaListMarker
, RETURN_STATUS
);
1939 Status
= BASE_ARG (BaseListMarker
, RETURN_STATUS
);
1941 ArgumentString
= ValueBuffer
;
1942 if (RETURN_ERROR (Status
)) {
1946 Index
= Status
& ~MAX_BIT
;
1947 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
1948 ArgumentString
= mStatusString
[Index
+ WARNING_STATUS_NUMBER
];
1952 if (Index
<= WARNING_STATUS_NUMBER
) {
1953 ArgumentString
= mStatusString
[Index
];
1956 if (ArgumentString
== ValueBuffer
) {
1957 InternalPrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
1962 Format
+= BytesPerFormatCharacter
;
1963 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1964 if (FormatCharacter
== '\n') {
1966 // Translate '\r\n' to '\r\n'
1968 ArgumentString
= "\r\n";
1971 // Translate '\r' to '\r'
1973 ArgumentString
= "\r";
1974 Format
-= BytesPerFormatCharacter
;
1980 // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
1982 ArgumentString
= "\r\n";
1983 Format
+= BytesPerFormatCharacter
;
1984 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1985 if (FormatCharacter
!= '\r') {
1986 Format
-= BytesPerFormatCharacter
;
1993 // if the type is '%' or unknown, then print it to the screen
1995 ArgumentString
= (CHAR8
*)&FormatCharacter
;
1996 Flags
|= ARGUMENT_UNICODE
;
2002 Format
+= BytesPerFormatCharacter
;
2003 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
2004 if (FormatCharacter
== '\n') {
2006 // Translate '\r\n' to '\r\n'
2008 ArgumentString
= "\r\n";
2011 // Translate '\r' to '\r'
2013 ArgumentString
= "\r";
2014 Format
-= BytesPerFormatCharacter
;
2020 // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
2022 ArgumentString
= "\r\n";
2023 Format
+= BytesPerFormatCharacter
;
2024 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
2025 if (FormatCharacter
!= '\r') {
2026 Format
-= BytesPerFormatCharacter
;
2031 ArgumentString
= (CHAR8
*)&FormatCharacter
;
2032 Flags
|= ARGUMENT_UNICODE
;
2037 // Retrieve the ArgumentString attriubutes
2039 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
2040 ArgumentMask
= 0xffff;
2041 BytesPerArgumentCharacter
= 2;
2043 ArgumentMask
= 0xff;
2044 BytesPerArgumentCharacter
= 1;
2046 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
2047 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
2050 // Compute the number of characters in ArgumentString and store it in Count
2051 // ArgumentString is either null-terminated, or it contains Precision characters
2053 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
2054 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
2055 if (ArgumentCharacter
== 0) {
2061 if (Precision
< Count
) {
2066 // Pad before the string
2068 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
2069 LengthToReturn
+= ((Width
- Precision
) * BytesPerOutputCharacter
);
2070 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2071 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
2077 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2078 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2079 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
2082 LengthToReturn
+= ((Precision
- Count
) * BytesPerOutputCharacter
);
2083 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2084 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
2087 LengthToReturn
+= ((Precision
- Count
) * BytesPerOutputCharacter
);
2088 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2089 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
2092 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2093 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2094 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
2100 // Output the Prefix character if it is present
2108 // Copy the string into the output buffer performing the required type conversions
2110 while (Index
< Count
) {
2111 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
2113 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2114 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2115 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
2117 ArgumentString
+= BytesPerArgumentCharacter
;
2124 if (Index
< Count
) {
2125 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2126 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2127 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', BytesPerOutputCharacter
);
2135 // Pad after the string
2137 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
2138 LengthToReturn
+= ((Width
- Precision
) * BytesPerOutputCharacter
);
2139 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2140 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
2145 // Get the next character from the format string
2147 Format
+= BytesPerFormatCharacter
;
2150 // Get the next character from the format string
2152 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
2155 if ((Flags
& COUNT_ONLY_NO_PRINT
) != 0) {
2156 return (LengthToReturn
/ BytesPerOutputCharacter
);
2159 ASSERT (Buffer
!= NULL
);
2161 // Null terminate the Unicode or ASCII string
2163 InternalPrintLibFillBuffer (Buffer
, EndBuffer
+ BytesPerOutputCharacter
, 1, 0, BytesPerOutputCharacter
);
2165 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
2169 Returns the number of characters that would be produced by if the formatted
2170 output were produced not including the Null-terminator.
2172 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
2174 If FormatString is NULL, then ASSERT() and 0 is returned.
2175 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more
2176 than PcdMaximumUnicodeStringLength Unicode characters not including the
2177 Null-terminator, then ASSERT() and 0 is returned.
2179 @param[in] FormatString A Null-terminated Unicode format string.
2180 @param[in] Marker VA_LIST marker for the variable argument list.
2182 @return The number of characters that would be produced, not including the
2188 IN CONST CHAR16
*FormatString
,
2192 ASSERT_UNICODE_BUFFER (FormatString
);
2193 return InternalPrintLibSPrintMarker (NULL
, 0, FORMAT_UNICODE
| OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);
2197 Returns the number of characters that would be produced by if the formatted
2198 output were produced not including the Null-terminator.
2200 If FormatString is NULL, then ASSERT() and 0 is returned.
2201 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more
2202 than PcdMaximumAsciiStringLength Ascii characters not including the
2203 Null-terminator, then ASSERT() and 0 is returned.
2205 @param[in] FormatString A Null-terminated ASCII format string.
2206 @param[in] Marker VA_LIST marker for the variable argument list.
2208 @return The number of characters that would be produced, not including the
2213 SPrintLengthAsciiFormat (
2214 IN CONST CHAR8
*FormatString
,
2218 return InternalPrintLibSPrintMarker (NULL
, 0, OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);