2 Mde UEFI library API implementation.
3 Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE
5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiLibInternal.h"
18 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors
[16] = {
19 { 0x00, 0x00, 0x00, 0x00 },
20 { 0x98, 0x00, 0x00, 0x00 },
21 { 0x00, 0x98, 0x00, 0x00 },
22 { 0x98, 0x98, 0x00, 0x00 },
23 { 0x00, 0x00, 0x98, 0x00 },
24 { 0x98, 0x00, 0x98, 0x00 },
25 { 0x00, 0x98, 0x98, 0x00 },
26 { 0x98, 0x98, 0x98, 0x00 },
27 { 0x10, 0x10, 0x10, 0x00 },
28 { 0xff, 0x10, 0x10, 0x00 },
29 { 0x10, 0xff, 0x10, 0x00 },
30 { 0xff, 0xff, 0x10, 0x00 },
31 { 0x10, 0x10, 0xff, 0x00 },
32 { 0xf0, 0x10, 0xff, 0x00 },
33 { 0x10, 0xff, 0xff, 0x00 },
34 { 0xff, 0xff, 0xff, 0x00 }
38 Internal function which prints a formatted Unicode string to the console output device
41 This function prints a formatted Unicode string to the console output device
42 specified by Console and returns the number of Unicode characters that printed
43 to it. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize,
44 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.
45 If Format is NULL, then ASSERT().
46 If Format is not aligned on a 16-bit boundary, then ASSERT().
48 @param Format A Null-terminated Unicode format string.
49 @param Console The output console.
50 @param Marker A VA_LIST marker for the variable argument list.
52 @return The number of Unicode characters in the produced
53 output buffer, not including the Null-terminator.
57 IN CONST CHAR16
*Format
,
58 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Console
,
67 ASSERT (Format
!= NULL
);
68 ASSERT (((UINTN
) Format
& BIT0
) == 0);
69 ASSERT (Console
!= NULL
);
71 BufferSize
= (PcdGet32 (PcdUefiLibMaxPrintBufferSize
) + 1) * sizeof (CHAR16
);
73 Buffer
= (CHAR16
*) AllocatePool(BufferSize
);
74 ASSERT (Buffer
!= NULL
);
76 Return
= UnicodeVSPrint (Buffer
, BufferSize
, Format
, Marker
);
78 if (Console
!= NULL
&& Return
> 0) {
80 // To be extra safe make sure Console has been initialized
82 Status
= Console
->OutputString (Console
, Buffer
);
83 if (EFI_ERROR (Status
)) {
94 Prints a formatted Unicode string to the console output device specified by
95 ConOut defined in the EFI_SYSTEM_TABLE.
97 This function prints a formatted Unicode string to the console output device
98 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
99 characters that printed to ConOut. If the length of the formatted Unicode
100 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
101 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
102 If Format is NULL, then ASSERT().
103 If Format is not aligned on a 16-bit boundary, then ASSERT().
104 If gST->ConOut is NULL, then ASSERT().
106 @param Format A Null-terminated Unicode format string.
107 @param ... A Variable argument list whose contents are accessed based
108 on the format string specified by Format.
110 @return The number of Unicode characters printed to ConOut.
116 IN CONST CHAR16
*Format
,
123 VA_START (Marker
, Format
);
125 Return
= InternalPrint (Format
, gST
->ConOut
, Marker
);
133 Prints a formatted Unicode string to the console output device specified by
134 StdErr defined in the EFI_SYSTEM_TABLE.
136 This function prints a formatted Unicode string to the console output device
137 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
138 characters that printed to StdErr. If the length of the formatted Unicode
139 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
140 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
141 If Format is NULL, then ASSERT().
142 If Format is not aligned on a 16-bit boundary, then ASSERT().
143 If gST->StdErr is NULL, then ASSERT().
145 @param Format A Null-terminated Unicode format string.
146 @param ... Variable argument list whose contents are accessed based
147 on the format string specified by Format.
149 @return The number of Unicode characters printed to StdErr.
155 IN CONST CHAR16
*Format
,
162 VA_START (Marker
, Format
);
164 Return
= InternalPrint( Format
, gST
->StdErr
, Marker
);
173 Internal function which prints a formatted ASCII string to the console output device
176 This function prints a formatted ASCII string to the console output device
177 specified by Console and returns the number of ASCII characters that printed
178 to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,
179 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.
181 If Format is NULL, then ASSERT().
183 @param Format A Null-terminated ASCII format string.
184 @param Console The output console.
185 @param Marker VA_LIST marker for the variable argument list.
187 @return The number of Unicode characters in the produced
188 output buffer not including the Null-terminator.
193 IN CONST CHAR8
*Format
,
194 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Console
,
203 ASSERT (Format
!= NULL
);
204 ASSERT (Console
!= NULL
);
206 BufferSize
= (PcdGet32 (PcdUefiLibMaxPrintBufferSize
) + 1) * sizeof (CHAR16
);
208 Buffer
= (CHAR16
*) AllocatePool(BufferSize
);
209 ASSERT (Buffer
!= NULL
);
211 Return
= UnicodeVSPrintAsciiFormat (Buffer
, BufferSize
, Format
, Marker
);
213 if (Console
!= NULL
) {
215 // To be extra safe make sure Console has been initialized
217 Status
= Console
->OutputString (Console
, Buffer
);
218 if (EFI_ERROR (Status
)) {
229 Prints a formatted ASCII string to the console output device specified by
230 ConOut defined in the EFI_SYSTEM_TABLE.
232 This function prints a formatted ASCII string to the console output device
233 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
234 characters that printed to ConOut. If the length of the formatted ASCII
235 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
236 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
237 If Format is NULL, then ASSERT().
238 If gST->ConOut is NULL, then ASSERT().
240 @param Format A Null-terminated ASCII format string.
241 @param ... Variable argument list whose contents are accessed based
242 on the format string specified by Format.
244 @return The number of ASCII characters printed to ConOut.
250 IN CONST CHAR8
*Format
,
256 ASSERT (Format
!= NULL
);
258 VA_START (Marker
, Format
);
260 Return
= AsciiInternalPrint( Format
, gST
->ConOut
, Marker
);
268 Prints a formatted ASCII string to the console output device specified by
269 StdErr defined in the EFI_SYSTEM_TABLE.
271 This function prints a formatted ASCII string to the console output device
272 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
273 characters that printed to StdErr. If the length of the formatted ASCII
274 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
275 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
276 If Format is NULL, then ASSERT().
277 If gST->StdErr is NULL, then ASSERT().
279 @param Format A Null-terminated ASCII format string.
280 @param ... Variable argument list whose contents are accessed based
281 on the format string specified by Format.
283 @return The number of ASCII characters printed to ConErr.
289 IN CONST CHAR8
*Format
,
296 ASSERT (Format
!= NULL
);
298 VA_START (Marker
, Format
);
300 Return
= AsciiInternalPrint( Format
, gST
->StdErr
, Marker
);
308 Internal function to print a formatted Unicode string to a graphics console device specified by
309 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
311 This function prints a formatted Unicode string to the graphics console device
312 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
313 Unicode characters printed. The EFI_HII_FONT_PROTOCOL is used to convert the
314 string to a bitmap using the glyphs registered with the
315 HII database. No wrapping is performed, so any portions of the string the fall
316 outside the active display region will not be displayed.
318 If a graphics console device is not associated with the ConsoleOutputHandle
319 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
320 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
321 string is printed, and 0 is returned.
323 @param PointX An X coordinate to print the string.
324 @param PointY A Y coordinate to print the string.
325 @param Foreground The foreground color of the string being printed. This is
326 an optional parameter that may be NULL. If it is NULL,
327 then the foreground color of the current ConOut device
328 in the EFI_SYSTEM_TABLE is used.
329 @param Background The background color of the string being printed. This is
330 an optional parameter that may be NULL. If it is NULL,
331 then the background color of the current ConOut device
332 in the EFI_SYSTEM_TABLE is used.
333 @param Buffer A Null-terminated Unicode formatted string.
334 @param PrintNum The number of Unicode formatted string to be printed.
336 @return The number of Unicode Characters printed. Zero means no any character
337 displayed successfully.
341 InternalPrintGraphic (
344 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
345 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
,
351 UINT32 HorizontalResolution
;
352 UINT32 VerticalResolution
;
355 EFI_HII_FONT_PROTOCOL
*HiiFont
;
356 EFI_IMAGE_OUTPUT
*Blt
;
357 EFI_FONT_DISPLAY_INFO FontInfo
;
358 EFI_HII_ROW_INFO
*RowInfoArray
;
359 UINTN RowInfoArraySize
;
360 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
361 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
362 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Sto
;
363 EFI_HANDLE ConsoleHandle
;
368 HorizontalResolution
= 0;
369 VerticalResolution
= 0;
373 ConsoleHandle
= gST
->ConsoleOutHandle
;
375 ASSERT( ConsoleHandle
!= NULL
);
377 Status
= gBS
->HandleProtocol (
379 &gEfiGraphicsOutputProtocolGuid
,
380 (VOID
**) &GraphicsOutput
384 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
386 // If no GOP available, try to open UGA Draw protocol if supported.
388 GraphicsOutput
= NULL
;
390 Status
= gBS
->HandleProtocol (
392 &gEfiUgaDrawProtocolGuid
,
396 if (EFI_ERROR (Status
)) {
400 Status
= gBS
->HandleProtocol (
402 &gEfiSimpleTextOutProtocolGuid
,
406 if (EFI_ERROR (Status
)) {
410 if (GraphicsOutput
!= NULL
) {
411 HorizontalResolution
= GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
412 VerticalResolution
= GraphicsOutput
->Mode
->Info
->VerticalResolution
;
413 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
414 UgaDraw
->GetMode (UgaDraw
, &HorizontalResolution
, &VerticalResolution
, &ColorDepth
, &RefreshRate
);
419 ASSERT ((HorizontalResolution
!= 0) && (VerticalResolution
!=0));
421 Status
= gBS
->LocateProtocol (&gEfiHiiFontProtocolGuid
, NULL
, (VOID
**) &HiiFont
);
422 if (EFI_ERROR (Status
)) {
426 Blt
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
427 ASSERT (Blt
!= NULL
);
429 Blt
->Width
= (UINT16
) (HorizontalResolution
);
430 Blt
->Height
= (UINT16
) (VerticalResolution
);
432 ZeroMem (&FontInfo
, sizeof (EFI_FONT_DISPLAY_INFO
));
434 if (Foreground
!= NULL
) {
435 CopyMem (&FontInfo
.ForegroundColor
, Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
438 &FontInfo
.ForegroundColor
,
439 &mEfiColors
[Sto
->Mode
->Attribute
& 0x0f],
440 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
443 if (Background
!= NULL
) {
444 CopyMem (&FontInfo
.BackgroundColor
, Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
447 &FontInfo
.BackgroundColor
,
448 &mEfiColors
[Sto
->Mode
->Attribute
>> 4],
449 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
453 if (GraphicsOutput
!= NULL
) {
454 Blt
->Image
.Screen
= GraphicsOutput
;
456 Status
= HiiFont
->StringToImage (
458 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_OUT_FLAG_CLIP
|
459 EFI_HII_OUT_FLAG_CLIP_CLEAN_X
| EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
|
460 EFI_HII_IGNORE_LINE_BREAK
| EFI_HII_DIRECT_TO_SCREEN
,
470 if (EFI_ERROR (Status
)) {
474 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
475 ASSERT (UgaDraw
!= NULL
);
478 // Ensure Width * Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow.
480 if (Blt
->Width
> DivU64x32 (MAX_UINTN
, Blt
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
))) {
484 Blt
->Image
.Bitmap
= AllocateZeroPool ((UINT32
) Blt
->Width
* Blt
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
485 ASSERT (Blt
->Image
.Bitmap
!= NULL
);
488 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
489 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
491 Status
= HiiFont
->StringToImage (
493 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_OUT_FLAG_CLIP
|
494 EFI_HII_OUT_FLAG_CLIP_CLEAN_X
| EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
|
495 EFI_HII_IGNORE_LINE_BREAK
,
506 if (!EFI_ERROR (Status
)) {
507 ASSERT (RowInfoArray
!= NULL
);
509 // Explicit Line break characters are ignored, so the updated parameter RowInfoArraySize by StringToImage will
510 // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.
512 ASSERT (RowInfoArraySize
<= 1);
514 if (RowInfoArraySize
!= 0) {
515 Width
= RowInfoArray
[0].LineWidth
;
516 Height
= RowInfoArray
[0].LineHeight
;
517 Delta
= Blt
->Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
);
523 Status
= UgaDraw
->Blt (
525 (EFI_UGA_PIXEL
*) Blt
->Image
.Bitmap
,
526 EfiUgaBltBufferToVideo
,
538 FreePool (Blt
->Image
.Bitmap
);
543 // Calculate the number of actual printed characters
545 if (RowInfoArraySize
!= 0) {
546 PrintNum
= RowInfoArray
[0].EndIndex
- RowInfoArray
[0].StartIndex
+ 1;
551 FreePool (RowInfoArray
);
563 Prints a formatted Unicode string to a graphics console device specified by
564 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
566 This function prints a formatted Unicode string to the graphics console device
567 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
568 Unicode characters displayed, not including partial characters that may be clipped
569 by the right edge of the display. If the length of the formatted Unicode string is
570 greater than PcdUefiLibMaxPrintBufferSize, then at most the first
571 PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL
572 StringToImage() service is used to convert the string to a bitmap using the glyphs
573 registered with the HII database. No wrapping is performed, so any portions of the
574 string the fall outside the active display region will not be displayed. Please see
575 Section 27.2.6 of the UEFI Specification for a description of the supported string
576 format including the set of control codes supported by the StringToImage() service.
578 If a graphics console device is not associated with the ConsoleOutputHandle
579 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
580 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
581 string is printed, and 0 is returned.
582 If Format is NULL, then ASSERT().
583 If Format is not aligned on a 16-bit boundary, then ASSERT().
584 If gST->ConsoleOutputHandle is NULL, then ASSERT().
586 @param PointX An X coordinate to print the string.
587 @param PointY A Y coordinate to print the string.
588 @param ForeGround The foreground color of the string being printed. This is
589 an optional parameter that may be NULL. If it is NULL,
590 then the foreground color of the current ConOut device
591 in the EFI_SYSTEM_TABLE is used.
592 @param BackGround The background color of the string being printed. This is
593 an optional parameter that may be NULL. If it is NULL,
594 then the background color of the current ConOut device
595 in the EFI_SYSTEM_TABLE is used.
596 @param Format A Null-terminated Unicode format string. See Print Library
597 for the supported format string syntax.
598 @param ... A Variable argument list whose contents are accessed based on
599 the format string specified by Format.
601 @return The number of Unicode characters printed.
609 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
610 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
611 IN CONST CHAR16
*Format
,
621 ASSERT (Format
!= NULL
);
622 ASSERT (((UINTN
) Format
& BIT0
) == 0);
624 VA_START (Marker
, Format
);
626 BufferSize
= (PcdGet32 (PcdUefiLibMaxPrintBufferSize
) + 1) * sizeof (CHAR16
);
628 Buffer
= (CHAR16
*) AllocatePool (BufferSize
);
629 ASSERT (Buffer
!= NULL
);
631 PrintNum
= UnicodeVSPrint (Buffer
, BufferSize
, Format
, Marker
);
635 ReturnNum
= InternalPrintGraphic (PointX
, PointY
, ForeGround
, BackGround
, Buffer
, PrintNum
);
643 Prints a formatted ASCII string to a graphics console device specified by
644 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
646 This function prints a formatted ASCII string to the graphics console device
647 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
648 ASCII characters displayed, not including partial characters that may be clipped
649 by the right edge of the display. If the length of the formatted ASCII string is
650 greater than PcdUefiLibMaxPrintBufferSize, then at most the first
651 PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL
652 StringToImage() service is used to convert the string to a bitmap using the glyphs
653 registered with the HII database. No wrapping is performed, so any portions of the
654 string the fall outside the active display region will not be displayed. Please see
655 Section 27.2.6 of the UEFI Specification for a description of the supported string
656 format including the set of control codes supported by the StringToImage() service.
658 If a graphics console device is not associated with the ConsoleOutputHandle
659 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
660 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
661 string is printed, and 0 is returned.
662 If Format is NULL, then ASSERT().
663 If gST->ConsoleOutputHandle is NULL, then ASSERT().
665 @param PointX An X coordinate to print the string.
666 @param PointY A Y coordinate to print the string.
667 @param ForeGround The foreground color of the string being printed. This is
668 an optional parameter that may be NULL. If it is NULL,
669 then the foreground color of the current ConOut device
670 in the EFI_SYSTEM_TABLE is used.
671 @param BackGround The background color of the string being printed. This is
672 an optional parameter that may be NULL. If it is NULL,
673 then the background color of the current ConOut device
674 in the EFI_SYSTEM_TABLE is used.
675 @param Format A Null-terminated ASCII format string. See Print Library
676 for the supported format string syntax.
677 @param ... Variable argument list whose contents are accessed based on
678 the format string specified by Format.
680 @return The number of ASCII characters printed.
688 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
689 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
690 IN CONST CHAR8
*Format
,
700 ASSERT (Format
!= NULL
);
702 VA_START (Marker
, Format
);
704 BufferSize
= (PcdGet32 (PcdUefiLibMaxPrintBufferSize
) + 1) * sizeof (CHAR16
);
706 Buffer
= (CHAR16
*) AllocatePool (BufferSize
);
707 ASSERT (Buffer
!= NULL
);
709 PrintNum
= UnicodeSPrintAsciiFormat (Buffer
, BufferSize
, Format
, Marker
);
713 ReturnNum
= InternalPrintGraphic (PointX
, PointY
, ForeGround
, BackGround
, Buffer
, PrintNum
);
721 Appends a formatted Unicode string to a Null-terminated Unicode string
723 This function appends a formatted Unicode string to the Null-terminated
724 Unicode string specified by String. String is optional and may be NULL.
725 Storage for the formatted Unicode string returned is allocated using
726 AllocatePool(). The pointer to the appended string is returned. The caller
727 is responsible for freeing the returned string.
729 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().
730 If FormatString is NULL, then ASSERT().
731 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
733 @param[in] String A Null-terminated Unicode string.
734 @param[in] FormatString A Null-terminated Unicode format string.
735 @param[in] Marker VA_LIST marker for the variable argument list.
737 @retval NULL There was not enough available memory.
738 @return Null-terminated Unicode string is that is the formatted
739 string appended to String.
744 IN CHAR16
*String
, OPTIONAL
745 IN CONST CHAR16
*FormatString
,
749 UINTN CharactersRequired
;
751 CHAR16
*BufferToReturn
;
754 VA_COPY (ExtraMarker
, Marker
);
755 CharactersRequired
= SPrintLength(FormatString
, ExtraMarker
);
756 VA_END (ExtraMarker
);
758 if (String
!= NULL
) {
759 SizeRequired
= StrSize(String
) + (CharactersRequired
* sizeof(CHAR16
));
761 SizeRequired
= sizeof(CHAR16
) + (CharactersRequired
* sizeof(CHAR16
));
764 BufferToReturn
= AllocatePool(SizeRequired
);
766 if (BufferToReturn
== NULL
) {
769 BufferToReturn
[0] = L
'\0';
772 if (String
!= NULL
) {
773 StrCpyS(BufferToReturn
, SizeRequired
/ sizeof(CHAR16
), String
);
776 UnicodeVSPrint(BufferToReturn
+ StrLen(BufferToReturn
), (CharactersRequired
+1) * sizeof(CHAR16
), FormatString
, Marker
);
778 ASSERT(StrSize(BufferToReturn
)==SizeRequired
);
780 return (BufferToReturn
);
784 Appends a formatted Unicode string to a Null-terminated Unicode string
786 This function appends a formatted Unicode string to the Null-terminated
787 Unicode string specified by String. String is optional and may be NULL.
788 Storage for the formatted Unicode string returned is allocated using
789 AllocatePool(). The pointer to the appended string is returned. The caller
790 is responsible for freeing the returned string.
792 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().
793 If FormatString is NULL, then ASSERT().
794 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
796 @param[in] String A Null-terminated Unicode string.
797 @param[in] FormatString A Null-terminated Unicode format string.
798 @param[in] ... The variable argument list whose contents are
799 accessed based on the format string specified by
802 @retval NULL There was not enough available memory.
803 @return Null-terminated Unicode string is that is the formatted
804 string appended to String.
809 IN CHAR16
*String
, OPTIONAL
810 IN CONST CHAR16
*FormatString
,
817 VA_START (Marker
, FormatString
);
818 NewString
= CatVSPrint(String
, FormatString
, Marker
);