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
;
602 Converts a decimal value to a Null-terminated Unicode string.
604 Converts the decimal number specified by Value to a Null-terminated Unicode
605 string specified by Buffer containing at most Width characters. No padding of spaces
606 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
607 The number of Unicode characters in Buffer is returned not including the Null-terminator.
608 If the conversion contains more than Width characters, then only the first
609 Width characters are returned, and the total number of characters
610 required to perform the conversion is returned.
611 Additional conversion parameters are specified in Flags.
613 The Flags bit LEFT_JUSTIFY is always ignored.
614 All conversions are left justified in Buffer.
615 If Width is 0, PREFIX_ZERO is ignored in Flags.
616 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
617 are inserted every 3rd digit starting from the right.
618 If RADIX_HEX is set in Flags, then the output buffer will be
619 formatted in hexadecimal format.
620 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
621 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
622 then Buffer is padded with '0' characters so the combination of the optional '-'
623 sign character, '0' characters, digit characters for Value, and the Null-terminator
624 add up to Width characters.
625 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
626 If Buffer is NULL, then ASSERT().
627 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
628 If unsupported bits are set in Flags, then ASSERT().
629 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
630 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
632 @param Buffer Pointer to the output buffer for the produced Null-terminated
634 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
635 @param Value The 64-bit signed value to convert to a string.
636 @param Width The maximum number of Unicode characters to place in Buffer, not including
639 @return The number of Unicode characters in Buffer not including the Null-terminator.
644 UnicodeValueToString (
645 IN OUT CHAR16
*Buffer
,
651 RETURN_STATUS Status
;
655 BufferSize
= (MAXIMUM_VALUE_CHARACTERS
+ 1) * sizeof (CHAR16
);
657 BufferSize
= (Width
+ 1) * sizeof (CHAR16
);
660 Status
= mPrint2SProtocol
->UnicodeValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
);
661 if (RETURN_ERROR (Status
)) {
665 return StrnLenS (Buffer
, BufferSize
/ sizeof (CHAR16
));
669 Converts a decimal value to a Null-terminated Unicode string.
671 Converts the decimal number specified by Value to a Null-terminated Unicode
672 string specified by Buffer containing at most Width characters. No padding of
673 spaces is ever performed. If Width is 0 then a width of
674 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than
675 Width characters, then only the first Width characters are placed in Buffer.
676 Additional conversion parameters are specified in Flags.
678 The Flags bit LEFT_JUSTIFY is always ignored.
679 All conversions are left justified in Buffer.
680 If Width is 0, PREFIX_ZERO is ignored in Flags.
681 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and
682 commas are inserted every 3rd digit starting from the right.
683 If RADIX_HEX is set in Flags, then the output buffer will be formatted in
685 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in
687 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then
688 Buffer is padded with '0' characters so the combination of the optional '-'
689 sign character, '0' characters, digit characters for Value, and the
690 Null-terminator add up to Width characters.
692 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
693 If an error would be returned, then the function will also ASSERT().
695 @param Buffer The pointer to the output buffer for the produced
696 Null-terminated Unicode string.
697 @param BufferSize The size of Buffer in bytes, including the
699 @param Flags The bitmask of flags that specify left justification,
700 zero pad, and commas.
701 @param Value The 64-bit signed value to convert to a string.
702 @param Width The maximum number of Unicode characters to place in
703 Buffer, not including the Null-terminator.
705 @retval RETURN_SUCCESS The decimal value is converted.
706 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
708 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
709 If PcdMaximumUnicodeStringLength is not
710 zero, and BufferSize is greater than
711 (PcdMaximumUnicodeStringLength *
712 sizeof (CHAR16) + 1).
713 If unsupported bits are set in Flags.
714 If both COMMA_TYPE and RADIX_HEX are set in
716 If Width >= MAXIMUM_VALUE_CHARACTERS.
721 UnicodeValueToStringS (
722 IN OUT CHAR16
*Buffer
,
729 return mPrint2SProtocol
->UnicodeValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
);
733 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
734 ASCII format string and a VA_LIST argument list.
736 This function is similar as vsnprintf_s defined in C11.
738 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
740 The ASCII string is produced by parsing the format string specified by FormatString.
741 Arguments are pulled from the variable argument list specified by Marker based on
742 the contents of the format string.
743 The number of ASCII characters in the produced output buffer is returned not including
746 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
747 unmodified and 0 is returned.
748 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
749 unmodified and 0 is returned.
750 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
751 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
752 is unmodified and 0 is returned.
753 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
754 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
755 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
757 If BufferSize is 0, then no output buffer is produced and 0 is returned.
759 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
761 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
762 @param FormatString A Null-terminated ASCII format string.
763 @param Marker VA_LIST marker for the variable argument list.
765 @return The number of ASCII characters in the produced output buffer not including the
772 OUT CHAR8
*StartOfBuffer
,
774 IN CONST CHAR8
*FormatString
,
778 UINT64 BaseListMarker
[256 / sizeof (UINT64
)];
781 Converted
= DxePrintLibPrint2ProtocolVaListToBaseList (
785 (BASE_LIST
)BaseListMarker
,
786 sizeof (BaseListMarker
) - 8
792 return AsciiBSPrint (StartOfBuffer
, BufferSize
, FormatString
, (BASE_LIST
)BaseListMarker
);
796 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
797 ASCII format string and a BASE_LIST argument list.
799 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
801 The ASCII string is produced by parsing the format string specified by FormatString.
802 Arguments are pulled from the variable argument list specified by Marker based on
803 the contents of the format string.
804 The number of ASCII characters in the produced output buffer is returned not including
807 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
808 unmodified and 0 is returned.
809 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
810 unmodified and 0 is returned.
811 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
812 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
813 is unmodified and 0 is returned.
814 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
815 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
816 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
818 If BufferSize is 0, then no output buffer is produced and 0 is returned.
820 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
822 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
823 @param FormatString A Null-terminated ASCII format string.
824 @param Marker BASE_LIST marker for the variable argument list.
826 @return The number of ASCII characters in the produced output buffer not including the
833 OUT CHAR8
*StartOfBuffer
,
835 IN CONST CHAR8
*FormatString
,
839 return mPrint2SProtocol
->AsciiBSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
843 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
844 ASCII format string and variable argument list.
846 This function is similar as snprintf_s defined in C11.
848 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
850 The ASCII string is produced by parsing the format string specified by FormatString.
851 Arguments are pulled from the variable argument list based on the contents of the
853 The number of ASCII characters in the produced output buffer is returned not including
856 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
857 unmodified and 0 is returned.
858 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
859 unmodified and 0 is returned.
860 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
861 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
862 is unmodified and 0 is returned.
863 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
864 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
865 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
867 If BufferSize is 0, then no output buffer is produced and 0 is returned.
869 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
871 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
872 @param FormatString A Null-terminated ASCII format string.
873 @param ... Variable argument list whose contents are accessed based on the
874 format string specified by FormatString.
876 @return The number of ASCII characters in the produced output buffer not including the
883 OUT CHAR8
*StartOfBuffer
,
885 IN CONST CHAR8
*FormatString
,
890 UINTN NumberOfPrinted
;
892 VA_START (Marker
, FormatString
);
893 NumberOfPrinted
= AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
895 return NumberOfPrinted
;
899 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
900 Unicode format string and a VA_LIST argument list.
902 This function is similar as vsnprintf_s defined in C11.
904 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
906 The ASCII string is produced by parsing the format string specified by FormatString.
907 Arguments are pulled from the variable argument list specified by Marker based on
908 the contents of the format string.
909 The number of ASCII characters in the produced output buffer is returned not including
912 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
914 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
915 unmodified and 0 is returned.
916 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
917 unmodified and 0 is returned.
918 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
919 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
920 is unmodified and 0 is returned.
921 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
922 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
923 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
925 If BufferSize is 0, then no output buffer is produced and 0 is returned.
927 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
929 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
930 @param FormatString A Null-terminated Unicode format string.
931 @param Marker VA_LIST marker for the variable argument list.
933 @return The number of ASCII characters in the produced output buffer not including the
939 AsciiVSPrintUnicodeFormat (
940 OUT CHAR8
*StartOfBuffer
,
942 IN CONST CHAR16
*FormatString
,
946 UINT64 BaseListMarker
[256 / sizeof (UINT64
)];
949 ASSERT_UNICODE_BUFFER (FormatString
);
951 Converted
= DxePrintLibPrint2ProtocolVaListToBaseList (
953 (CHAR8
*)FormatString
,
955 (BASE_LIST
)BaseListMarker
,
956 sizeof (BaseListMarker
) - 8
962 return AsciiBSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, (BASE_LIST
)BaseListMarker
);
966 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
967 Unicode format string and a BASE_LIST argument list.
969 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
971 The ASCII string is produced by parsing the format string specified by FormatString.
972 Arguments are pulled from the variable argument list specified by Marker based on
973 the contents of the format string.
974 The number of ASCII characters in the produced output buffer is returned not including
977 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
979 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
980 unmodified and 0 is returned.
981 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
982 unmodified and 0 is returned.
983 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
984 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
985 is unmodified and 0 is returned.
986 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
987 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
988 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
990 If BufferSize is 0, then no output buffer is produced and 0 is returned.
992 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
994 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
995 @param FormatString A Null-terminated Unicode format string.
996 @param Marker BASE_LIST marker for the variable argument list.
998 @return The number of ASCII characters in the produced output buffer not including the
1004 AsciiBSPrintUnicodeFormat (
1005 OUT CHAR8
*StartOfBuffer
,
1006 IN UINTN BufferSize
,
1007 IN CONST CHAR16
*FormatString
,
1011 ASSERT_UNICODE_BUFFER (FormatString
);
1012 return mPrint2SProtocol
->AsciiBSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
1016 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
1017 Unicode format string and variable argument list.
1019 This function is similar as snprintf_s defined in C11.
1021 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
1023 The ASCII string is produced by parsing the format string specified by FormatString.
1024 Arguments are pulled from the variable argument list based on the contents of the
1026 The number of ASCII characters in the produced output buffer is returned not including
1027 the Null-terminator.
1029 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
1031 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
1032 unmodified and 0 is returned.
1033 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
1034 unmodified and 0 is returned.
1035 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
1036 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
1037 is unmodified and 0 is returned.
1038 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
1039 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
1040 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
1042 If BufferSize is 0, then no output buffer is produced and 0 is returned.
1044 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
1046 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
1047 @param FormatString A Null-terminated Unicode format string.
1048 @param ... Variable argument list whose contents are accessed based on the
1049 format string specified by FormatString.
1051 @return The number of ASCII characters in the produced output buffer not including the
1057 AsciiSPrintUnicodeFormat (
1058 OUT CHAR8
*StartOfBuffer
,
1059 IN UINTN BufferSize
,
1060 IN CONST CHAR16
*FormatString
,
1065 UINTN NumberOfPrinted
;
1067 VA_START (Marker
, FormatString
);
1068 NumberOfPrinted
= AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
1070 return NumberOfPrinted
;
1075 Converts a decimal value to a Null-terminated ASCII string.
1077 Converts the decimal number specified by Value to a Null-terminated ASCII string
1078 specified by Buffer containing at most Width characters. No padding of spaces
1080 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
1081 The number of ASCII characters in Buffer is returned not including the Null-terminator.
1082 If the conversion contains more than Width characters, then only the first Width
1083 characters are returned, and the total number of characters required to perform
1084 the conversion is returned.
1085 Additional conversion parameters are specified in Flags.
1086 The Flags bit LEFT_JUSTIFY is always ignored.
1087 All conversions are left justified in Buffer.
1088 If Width is 0, PREFIX_ZERO is ignored in Flags.
1089 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
1090 are inserted every 3rd digit starting from the right.
1091 If RADIX_HEX is set in Flags, then the output buffer will be
1092 formatted in hexadecimal format.
1093 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
1094 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
1095 then Buffer is padded with '0' characters so the combination of the optional '-'
1096 sign character, '0' characters, digit characters for Value, and the Null-terminator
1097 add up to Width characters.
1099 If Buffer is NULL, then ASSERT().
1100 If unsupported bits are set in Flags, then ASSERT().
1101 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
1102 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
1104 @param Buffer Pointer to the output buffer for the produced Null-terminated
1106 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
1107 @param Value The 64-bit signed value to convert to a string.
1108 @param Width The maximum number of ASCII characters to place in Buffer, not including
1109 the Null-terminator.
1111 @return The number of ASCII characters in Buffer not including the Null-terminator.
1116 AsciiValueToString (
1123 RETURN_STATUS Status
;
1127 BufferSize
= (MAXIMUM_VALUE_CHARACTERS
+ 1) * sizeof (CHAR8
);
1129 BufferSize
= (Width
+ 1) * sizeof (CHAR8
);
1132 Status
= mPrint2SProtocol
->AsciiValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
);
1133 if (RETURN_ERROR (Status
)) {
1137 return AsciiStrnLenS (Buffer
, BufferSize
/ sizeof (CHAR8
));
1141 Converts a decimal value to a Null-terminated Ascii string.
1143 Converts the decimal number specified by Value to a Null-terminated Ascii
1144 string specified by Buffer containing at most Width characters. No padding of
1145 spaces is ever performed. If Width is 0 then a width of
1146 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than
1147 Width characters, then only the first Width characters are placed in Buffer.
1148 Additional conversion parameters are specified in Flags.
1150 The Flags bit LEFT_JUSTIFY is always ignored.
1151 All conversions are left justified in Buffer.
1152 If Width is 0, PREFIX_ZERO is ignored in Flags.
1153 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and
1154 commas are inserted every 3rd digit starting from the right.
1155 If RADIX_HEX is set in Flags, then the output buffer will be formatted in
1157 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in
1159 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then
1160 Buffer is padded with '0' characters so the combination of the optional '-'
1161 sign character, '0' characters, digit characters for Value, and the
1162 Null-terminator add up to Width characters.
1164 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
1165 If an error would be returned, then the function will also ASSERT().
1167 @param Buffer The pointer to the output buffer for the produced
1168 Null-terminated Ascii string.
1169 @param BufferSize The size of Buffer in bytes, including the
1171 @param Flags The bitmask of flags that specify left justification,
1172 zero pad, and commas.
1173 @param Value The 64-bit signed value to convert to a string.
1174 @param Width The maximum number of Ascii characters to place in
1175 Buffer, not including the Null-terminator.
1177 @retval RETURN_SUCCESS The decimal value is converted.
1178 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
1180 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
1181 If PcdMaximumAsciiStringLength is not
1182 zero, and BufferSize is greater than
1183 PcdMaximumAsciiStringLength.
1184 If unsupported bits are set in Flags.
1185 If both COMMA_TYPE and RADIX_HEX are set in
1187 If Width >= MAXIMUM_VALUE_CHARACTERS.
1192 AsciiValueToStringS (
1193 IN OUT CHAR8
*Buffer
,
1194 IN UINTN BufferSize
,
1200 return mPrint2SProtocol
->AsciiValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
);
1203 #define PREFIX_SIGN BIT1
1204 #define PREFIX_BLANK BIT2
1205 #define LONG_TYPE BIT4
1206 #define OUTPUT_UNICODE BIT6
1207 #define FORMAT_UNICODE BIT8
1208 #define PAD_TO_WIDTH BIT9
1209 #define ARGUMENT_UNICODE BIT10
1210 #define PRECISION BIT11
1211 #define ARGUMENT_REVERSED BIT12
1212 #define COUNT_ONLY_NO_PRINT BIT13
1213 #define UNSIGNED_TYPE BIT14
1216 // Record date and time information
1232 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr
[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
1235 Internal function that convert a number to a string in Buffer.
1237 Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer.
1239 @param Buffer Location to place the ASCII string of Value.
1240 @param Value The value to convert to a Decimal or Hexadecimal string in Buffer.
1241 @param Radix Radix of the value
1243 @return A pointer to the end of buffer filled with ASCII string.
1247 InternalPrintLibValueToString (
1248 IN OUT CHAR8
*Buffer
,
1256 // Loop to convert one digit at a time in reverse order
1260 Value
= (INT64
)DivU64x32Remainder ((UINT64
)Value
, (UINT32
)Radix
, &Remainder
);
1261 *(++Buffer
) = mHexStr
[Remainder
];
1262 } while (Value
!= 0);
1265 // Return pointer of the end of filled buffer.
1271 Worker function that produces a Null-terminated string in an output buffer
1272 based on a Null-terminated format string and a VA_LIST argument list.
1274 VSPrint function to process format and place the results in Buffer. Since a
1275 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
1276 this is the main print working routine.
1278 If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.
1280 @param[out] Buffer The character buffer to print the results of the
1281 parsing of Format into.
1282 @param[in] BufferSize The maximum number of characters to put into
1284 @param[in] Flags Initial flags value.
1285 Can only have FORMAT_UNICODE, OUTPUT_UNICODE,
1286 and COUNT_ONLY_NO_PRINT set.
1287 @param[in] Format A Null-terminated format string.
1288 @param[in] VaListMarker VA_LIST style variable argument list consumed by
1290 @param[in] BaseListMarker BASE_LIST style variable argument list consumed
1291 by processing Format.
1293 @return The number of characters printed not including the Null-terminator.
1294 If COUNT_ONLY_NO_PRINT was set returns the same, but without any
1295 modification to Buffer.
1299 InternalPrintLibSPrintMarker (
1301 IN UINTN BufferSize
,
1303 IN CONST CHAR8
*Format
,
1304 IN VA_LIST VaListMarker
, OPTIONAL
1305 IN BASE_LIST BaseListMarker OPTIONAL
1309 Worker function that produces a Null-terminated string in an output buffer
1310 based on a Null-terminated format string and variable argument list.
1312 VSPrint function to process format and place the results in Buffer. Since a
1313 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
1314 this is the main print working routine
1316 @param StartOfBuffer The character buffer to print the results of the parsing
1318 @param BufferSize The maximum number of characters to put into buffer.
1319 Zero means no limit.
1320 @param Flags Initial flags value.
1321 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
1322 @param FormatString A Null-terminated format string.
1323 @param ... The variable argument list.
1325 @return The number of characters printed.
1330 InternalPrintLibSPrint (
1331 OUT CHAR8
*StartOfBuffer
,
1332 IN UINTN BufferSize
,
1334 IN CONST CHAR8
*FormatString
,
1339 UINTN NumberOfPrinted
;
1341 VA_START (Marker
, FormatString
);
1342 NumberOfPrinted
= InternalPrintLibSPrintMarker (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
, NULL
);
1344 return NumberOfPrinted
;
1347 #define WARNING_STATUS_NUMBER 5
1348 #define ERROR_STATUS_NUMBER 33
1350 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8
* CONST mStatusString
[] = {
1351 "Success", // RETURN_SUCCESS = 0
1352 "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1
1353 "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
1354 "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3
1355 "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4
1356 "Warning Stale Data", // RETURN_WARN_STALE_DATA = 5
1357 "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT
1358 "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT
1359 "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT
1360 "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT
1361 "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT
1362 "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT
1363 "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT
1364 "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT
1365 "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT
1366 "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT
1367 "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT
1368 "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT
1369 "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT
1370 "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT
1371 "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT
1372 "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT
1373 "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT
1374 "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT
1375 "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT
1376 "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT
1377 "Aborted", // RETURN_ABORTED = 21 | MAX_BIT
1378 "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
1379 "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
1380 "Protocol Error", // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
1381 "Incompatible Version", // RETURN_INCOMPATIBLE_VERSION = 25 | MAX_BIT
1382 "Security Violation", // RETURN_SECURITY_VIOLATION = 26 | MAX_BIT
1383 "CRC Error", // RETURN_CRC_ERROR = 27 | MAX_BIT
1384 "End of Media", // RETURN_END_OF_MEDIA = 28 | MAX_BIT
1385 "Reserved (29)", // RESERVED = 29 | MAX_BIT
1386 "Reserved (30)", // RESERVED = 30 | MAX_BIT
1387 "End of File", // RETURN_END_OF_FILE = 31 | MAX_BIT
1388 "Invalid Language", // RETURN_INVALID_LANGUAGE = 32 | MAX_BIT
1389 "Compromised Data" // RETURN_COMPROMISED_DATA = 33 | MAX_BIT
1393 Internal function that places the character into the Buffer.
1395 Internal function that places ASCII or Unicode character into the Buffer.
1397 @param Buffer The buffer to place the Unicode or ASCII string.
1398 @param EndBuffer The end of the input Buffer. No characters will be
1400 @param Length The count of character to be placed into Buffer.
1401 (Negative value indicates no buffer fill.)
1402 @param Character The character to be placed into Buffer.
1403 @param Increment The character increment in Buffer.
1409 InternalPrintLibFillBuffer (
1411 IN CHAR8
*EndBuffer
,
1419 for (Index
= 0; Index
< Length
&& Buffer
< EndBuffer
; Index
++) {
1420 *Buffer
= (CHAR8
) Character
;
1421 if (Increment
!= 1) {
1422 *(Buffer
+ 1) = (CHAR8
)(Character
>> 8);
1424 Buffer
+= Increment
;
1431 Worker function that produces a Null-terminated string in an output buffer
1432 based on a Null-terminated format string and a VA_LIST argument list.
1434 VSPrint function to process format and place the results in Buffer. Since a
1435 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
1436 this is the main print working routine.
1438 If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.
1440 @param[out] Buffer The character buffer to print the results of the
1441 parsing of Format into.
1442 @param[in] BufferSize The maximum number of characters to put into
1444 @param[in] Flags Initial flags value.
1445 Can only have FORMAT_UNICODE, OUTPUT_UNICODE,
1446 and COUNT_ONLY_NO_PRINT set.
1447 @param[in] Format A Null-terminated format string.
1448 @param[in] VaListMarker VA_LIST style variable argument list consumed by
1450 @param[in] BaseListMarker BASE_LIST style variable argument list consumed
1451 by processing Format.
1453 @return The number of characters printed not including the Null-terminator.
1454 If COUNT_ONLY_NO_PRINT was set returns the same, but without any
1455 modification to Buffer.
1459 InternalPrintLibSPrintMarker (
1461 IN UINTN BufferSize
,
1463 IN CONST CHAR8
*Format
,
1464 IN VA_LIST VaListMarker
, OPTIONAL
1465 IN BASE_LIST BaseListMarker OPTIONAL
1468 CHAR8
*OriginalBuffer
;
1470 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
1471 UINT32 BytesPerOutputCharacter
;
1472 UINTN BytesPerFormatCharacter
;
1474 UINTN FormatCharacter
;
1478 CONST CHAR8
*ArgumentString
;
1484 INTN BytesPerArgumentCharacter
;
1485 UINTN ArgumentCharacter
;
1493 RETURN_STATUS Status
;
1497 UINTN LengthToReturn
;
1500 // If you change this code be sure to match the 2 versions of this function.
1501 // Nearly identical logic is found in the BasePrintLib and
1502 // DxePrintLibPrint2Protocol (both PrintLib instances).
1506 // 1. Buffer shall not be a null pointer when both BufferSize > 0 and
1507 // COUNT_ONLY_NO_PRINT is not set in Flags.
1509 if ((BufferSize
> 0) && ((Flags
& COUNT_ONLY_NO_PRINT
) == 0)) {
1510 SAFE_PRINT_CONSTRAINT_CHECK ((Buffer
!= NULL
), 0);
1514 // 2. Format shall not be a null pointer when BufferSize > 0 or when
1515 // COUNT_ONLY_NO_PRINT is set in Flags.
1517 if ((BufferSize
> 0) || ((Flags
& COUNT_ONLY_NO_PRINT
) != 0)) {
1518 SAFE_PRINT_CONSTRAINT_CHECK ((Format
!= NULL
), 0);
1522 // 3. BufferSize shall not be greater than RSIZE_MAX for Unicode output or
1523 // ASCII_RSIZE_MAX for Ascii output.
1525 if ((Flags
& OUTPUT_UNICODE
) != 0) {
1526 if (RSIZE_MAX
!= 0) {
1527 SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize
<= RSIZE_MAX
), 0);
1529 BytesPerOutputCharacter
= 2;
1531 if (ASCII_RSIZE_MAX
!= 0) {
1532 SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize
<= ASCII_RSIZE_MAX
), 0);
1534 BytesPerOutputCharacter
= 1;
1538 // 4. Format shall not contain more than RSIZE_MAX Unicode characters or
1539 // ASCII_RSIZE_MAX Ascii characters.
1541 if ((Flags
& FORMAT_UNICODE
) != 0) {
1542 if (RSIZE_MAX
!= 0) {
1543 SAFE_PRINT_CONSTRAINT_CHECK ((StrnLenS ((CHAR16
*)Format
, RSIZE_MAX
+ 1) <= RSIZE_MAX
), 0);
1545 BytesPerFormatCharacter
= 2;
1546 FormatMask
= 0xffff;
1548 if (ASCII_RSIZE_MAX
!= 0) {
1549 SAFE_PRINT_CONSTRAINT_CHECK ((AsciiStrnLenS (Format
, ASCII_RSIZE_MAX
+ 1) <= ASCII_RSIZE_MAX
), 0);
1551 BytesPerFormatCharacter
= 1;
1555 if ((Flags
& COUNT_ONLY_NO_PRINT
) != 0) {
1556 if (BufferSize
== 0) {
1561 // We can run without a Buffer for counting only.
1563 if (BufferSize
== 0) {
1570 OriginalBuffer
= NULL
;
1573 // Reserve space for the Null terminator.
1575 if (Buffer
!= NULL
) {
1577 OriginalBuffer
= Buffer
;
1580 // Set the tag for the end of the input Buffer.
1582 EndBuffer
= Buffer
+ BufferSize
* BytesPerOutputCharacter
;
1586 // Get the first character from the format string
1588 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1591 // Loop until the end of the format string is reached or the output buffer is full
1593 while (FormatCharacter
!= 0) {
1594 if ((Buffer
!= NULL
) && (Buffer
>= EndBuffer
)) {
1598 // Clear all the flag bits except those that may have been passed in
1600 Flags
&= (UINTN
) (OUTPUT_UNICODE
| FORMAT_UNICODE
| COUNT_ONLY_NO_PRINT
);
1603 // Set the default width to zero, and the default precision to 1
1613 switch (FormatCharacter
) {
1616 // Parse Flags and Width
1618 for (Done
= FALSE
; !Done
; ) {
1619 Format
+= BytesPerFormatCharacter
;
1620 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1621 switch (FormatCharacter
) {
1626 Flags
|= LEFT_JUSTIFY
;
1629 Flags
|= PREFIX_SIGN
;
1632 Flags
|= PREFIX_BLANK
;
1635 Flags
|= COMMA_TYPE
;
1642 if ((Flags
& PRECISION
) == 0) {
1643 Flags
|= PAD_TO_WIDTH
;
1644 if (BaseListMarker
== NULL
) {
1645 Width
= VA_ARG (VaListMarker
, UINTN
);
1647 Width
= BASE_ARG (BaseListMarker
, UINTN
);
1650 if (BaseListMarker
== NULL
) {
1651 Precision
= VA_ARG (VaListMarker
, UINTN
);
1653 Precision
= BASE_ARG (BaseListMarker
, UINTN
);
1658 if ((Flags
& PRECISION
) == 0) {
1659 Flags
|= PREFIX_ZERO
;
1670 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
1671 Count
= (Count
* 10) + FormatCharacter
- '0';
1672 Format
+= BytesPerFormatCharacter
;
1673 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1675 Format
-= BytesPerFormatCharacter
;
1676 if ((Flags
& PRECISION
) == 0) {
1677 Flags
|= PAD_TO_WIDTH
;
1686 // Make no output if Format string terminates unexpectedly when
1687 // looking up for flag, width, precision and type.
1689 Format
-= BytesPerFormatCharacter
;
1692 // break skipped on purpose.
1701 // Handle each argument type
1703 switch (FormatCharacter
) {
1706 // Flag space, +, 0, L & l are invalid for type p.
1708 Flags
&= ~((UINTN
) (PREFIX_BLANK
| PREFIX_SIGN
| PREFIX_ZERO
| LONG_TYPE
));
1709 if (sizeof (VOID
*) > 4) {
1713 // break skipped on purpose
1716 Flags
|= PREFIX_ZERO
;
1718 // break skipped on purpose
1723 // break skipped on purpose
1726 if ((Flags
& RADIX_HEX
) == 0) {
1727 Flags
&= ~((UINTN
) (PREFIX_SIGN
));
1728 Flags
|= UNSIGNED_TYPE
;
1731 // break skipped on purpose
1734 if ((Flags
& LONG_TYPE
) == 0) {
1736 // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
1737 // This assumption is made so the format string definition is compatible with the ANSI C
1738 // Specification for formatted strings. It is recommended that the Base Types be used
1739 // everywhere, but in this one case, compliance with ANSI C is more important, and
1740 // provides an implementation that is compatible with that largest possible set of CPU
1741 // architectures. This is why the type "int" is used in this one case.
1743 if (BaseListMarker
== NULL
) {
1744 Value
= VA_ARG (VaListMarker
, int);
1746 Value
= BASE_ARG (BaseListMarker
, int);
1749 if (BaseListMarker
== NULL
) {
1750 Value
= VA_ARG (VaListMarker
, INT64
);
1752 Value
= BASE_ARG (BaseListMarker
, INT64
);
1755 if ((Flags
& PREFIX_BLANK
) != 0) {
1758 if ((Flags
& PREFIX_SIGN
) != 0) {
1761 if ((Flags
& COMMA_TYPE
) != 0) {
1764 if ((Flags
& RADIX_HEX
) == 0) {
1767 Flags
&= ~((UINTN
) PREFIX_ZERO
);
1770 if (Value
< 0 && (Flags
& UNSIGNED_TYPE
) == 0) {
1771 Flags
|= PREFIX_SIGN
;
1774 } else if ((Flags
& UNSIGNED_TYPE
) != 0 && (Flags
& LONG_TYPE
) == 0) {
1776 // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
1777 // This assumption is made so the format string definition is compatible with the ANSI C
1778 // Specification for formatted strings. It is recommended that the Base Types be used
1779 // everywhere, but in this one case, compliance with ANSI C is more important, and
1780 // provides an implementation that is compatible with that largest possible set of CPU
1781 // architectures. This is why the type "unsigned int" is used in this one case.
1783 Value
= (unsigned int)Value
;
1788 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
1790 // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
1791 // This assumption is made so the format string definition is compatible with the ANSI C
1792 // Specification for formatted strings. It is recommended that the Base Types be used
1793 // everywhere, but in this one case, compliance with ANSI C is more important, and
1794 // provides an implementation that is compatible with that largest possible set of CPU
1795 // architectures. This is why the type "unsigned int" is used in this one case.
1797 Value
= (unsigned int)Value
;
1801 // Convert Value to a reversed string
1803 Count
= InternalPrintLibValueToString (ValueBuffer
, Value
, Radix
) - ValueBuffer
;
1804 if (Value
== 0 && Precision
== 0) {
1807 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
1811 Digits
= 3 - Digits
;
1813 if (Comma
&& Count
!= 0) {
1814 Count
+= ((Count
- 1) / 3);
1820 Flags
|= ARGUMENT_REVERSED
;
1822 if ((Flags
& PREFIX_ZERO
) != 0) {
1823 if ((Flags
& LEFT_JUSTIFY
) == 0) {
1824 if ((Flags
& PAD_TO_WIDTH
) != 0) {
1825 if ((Flags
& PRECISION
) == 0) {
1835 Flags
|= ARGUMENT_UNICODE
;
1837 // break skipped on purpose
1840 if (BaseListMarker
== NULL
) {
1841 ArgumentString
= VA_ARG (VaListMarker
, CHAR8
*);
1843 ArgumentString
= BASE_ARG (BaseListMarker
, CHAR8
*);
1845 if (ArgumentString
== NULL
) {
1846 Flags
&= (~(UINTN
)ARGUMENT_UNICODE
);
1847 ArgumentString
= "<null string>";
1850 // Set the default precision for string to be zero if not specified.
1852 if ((Flags
& PRECISION
) == 0) {
1858 if (BaseListMarker
== NULL
) {
1859 Character
= VA_ARG (VaListMarker
, UINTN
) & 0xffff;
1861 Character
= BASE_ARG (BaseListMarker
, UINTN
) & 0xffff;
1863 ArgumentString
= (CHAR8
*)&Character
;
1864 Flags
|= ARGUMENT_UNICODE
;
1868 if (BaseListMarker
== NULL
) {
1869 TmpGuid
= VA_ARG (VaListMarker
, GUID
*);
1871 TmpGuid
= BASE_ARG (BaseListMarker
, GUID
*);
1873 if (TmpGuid
== NULL
) {
1874 ArgumentString
= "<null guid>";
1876 GuidData1
= ReadUnaligned32 (&(TmpGuid
->Data1
));
1877 GuidData2
= ReadUnaligned16 (&(TmpGuid
->Data2
));
1878 GuidData3
= ReadUnaligned16 (&(TmpGuid
->Data3
));
1879 InternalPrintLibSPrint (
1881 MAXIMUM_VALUE_CHARACTERS
,
1883 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
1896 ArgumentString
= ValueBuffer
;
1901 if (BaseListMarker
== NULL
) {
1902 TmpTime
= VA_ARG (VaListMarker
, TIME
*);
1904 TmpTime
= BASE_ARG (BaseListMarker
, TIME
*);
1906 if (TmpTime
== NULL
) {
1907 ArgumentString
= "<null time>";
1909 InternalPrintLibSPrint (
1911 MAXIMUM_VALUE_CHARACTERS
,
1913 "%02d/%02d/%04d %02d:%02d",
1920 ArgumentString
= ValueBuffer
;
1925 if (BaseListMarker
== NULL
) {
1926 Status
= VA_ARG (VaListMarker
, RETURN_STATUS
);
1928 Status
= BASE_ARG (BaseListMarker
, RETURN_STATUS
);
1930 ArgumentString
= ValueBuffer
;
1931 if (RETURN_ERROR (Status
)) {
1935 Index
= Status
& ~MAX_BIT
;
1936 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
1937 ArgumentString
= mStatusString
[Index
+ WARNING_STATUS_NUMBER
];
1941 if (Index
<= WARNING_STATUS_NUMBER
) {
1942 ArgumentString
= mStatusString
[Index
];
1945 if (ArgumentString
== ValueBuffer
) {
1946 InternalPrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
1951 Format
+= BytesPerFormatCharacter
;
1952 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1953 if (FormatCharacter
== '\n') {
1955 // Translate '\r\n' to '\r\n'
1957 ArgumentString
= "\r\n";
1960 // Translate '\r' to '\r'
1962 ArgumentString
= "\r";
1963 Format
-= BytesPerFormatCharacter
;
1969 // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
1971 ArgumentString
= "\r\n";
1972 Format
+= BytesPerFormatCharacter
;
1973 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1974 if (FormatCharacter
!= '\r') {
1975 Format
-= BytesPerFormatCharacter
;
1982 // if the type is '%' or unknown, then print it to the screen
1984 ArgumentString
= (CHAR8
*)&FormatCharacter
;
1985 Flags
|= ARGUMENT_UNICODE
;
1991 Format
+= BytesPerFormatCharacter
;
1992 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
1993 if (FormatCharacter
== '\n') {
1995 // Translate '\r\n' to '\r\n'
1997 ArgumentString
= "\r\n";
2000 // Translate '\r' to '\r'
2002 ArgumentString
= "\r";
2003 Format
-= BytesPerFormatCharacter
;
2009 // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
2011 ArgumentString
= "\r\n";
2012 Format
+= BytesPerFormatCharacter
;
2013 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
2014 if (FormatCharacter
!= '\r') {
2015 Format
-= BytesPerFormatCharacter
;
2020 ArgumentString
= (CHAR8
*)&FormatCharacter
;
2021 Flags
|= ARGUMENT_UNICODE
;
2026 // Retrieve the ArgumentString attriubutes
2028 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
2029 ArgumentMask
= 0xffff;
2030 BytesPerArgumentCharacter
= 2;
2032 ArgumentMask
= 0xff;
2033 BytesPerArgumentCharacter
= 1;
2035 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
2036 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
2039 // Compute the number of characters in ArgumentString and store it in Count
2040 // ArgumentString is either null-terminated, or it contains Precision characters
2042 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
2043 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
2044 if (ArgumentCharacter
== 0) {
2050 if (Precision
< Count
) {
2055 // Pad before the string
2057 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
2058 LengthToReturn
+= ((Width
- Precision
) * BytesPerOutputCharacter
);
2059 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2060 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
2066 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2067 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2068 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
2071 LengthToReturn
+= ((Precision
- Count
) * BytesPerOutputCharacter
);
2072 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2073 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
2076 LengthToReturn
+= ((Precision
- Count
) * BytesPerOutputCharacter
);
2077 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2078 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
2081 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2082 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2083 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
2089 // Output the Prefix character if it is present
2097 // Copy the string into the output buffer performing the required type conversions
2099 while (Index
< Count
) {
2100 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
2102 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2103 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2104 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
2106 ArgumentString
+= BytesPerArgumentCharacter
;
2113 if (Index
< Count
) {
2114 LengthToReturn
+= (1 * BytesPerOutputCharacter
);
2115 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2116 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', BytesPerOutputCharacter
);
2124 // Pad after the string
2126 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
2127 LengthToReturn
+= ((Width
- Precision
) * BytesPerOutputCharacter
);
2128 if ((Flags
& COUNT_ONLY_NO_PRINT
) == 0 && Buffer
!= NULL
) {
2129 Buffer
= InternalPrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
2134 // Get the next character from the format string
2136 Format
+= BytesPerFormatCharacter
;
2139 // Get the next character from the format string
2141 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
2144 if ((Flags
& COUNT_ONLY_NO_PRINT
) != 0) {
2145 return (LengthToReturn
/ BytesPerOutputCharacter
);
2148 ASSERT (Buffer
!= NULL
);
2150 // Null terminate the Unicode or ASCII string
2152 InternalPrintLibFillBuffer (Buffer
, EndBuffer
+ BytesPerOutputCharacter
, 1, 0, BytesPerOutputCharacter
);
2154 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
2158 Returns the number of characters that would be produced by if the formatted
2159 output were produced not including the Null-terminator.
2161 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
2163 If FormatString is NULL, then ASSERT() and 0 is returned.
2164 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more
2165 than PcdMaximumUnicodeStringLength Unicode characters not including the
2166 Null-terminator, then ASSERT() and 0 is returned.
2168 @param[in] FormatString A Null-terminated Unicode format string.
2169 @param[in] Marker VA_LIST marker for the variable argument list.
2171 @return The number of characters that would be produced, not including the
2177 IN CONST CHAR16
*FormatString
,
2181 ASSERT_UNICODE_BUFFER (FormatString
);
2182 return InternalPrintLibSPrintMarker (NULL
, 0, FORMAT_UNICODE
| OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);
2186 Returns the number of characters that would be produced by if the formatted
2187 output were produced not including the Null-terminator.
2189 If FormatString is NULL, then ASSERT() and 0 is returned.
2190 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more
2191 than PcdMaximumAsciiStringLength Ascii characters not including the
2192 Null-terminator, then ASSERT() and 0 is returned.
2194 @param[in] FormatString A Null-terminated ASCII format string.
2195 @param[in] Marker VA_LIST marker for the variable argument list.
2197 @return The number of characters that would be produced, not including the
2202 SPrintLengthAsciiFormat (
2203 IN CONST CHAR8
*FormatString
,
2207 return InternalPrintLibSPrintMarker (NULL
, 0, OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);