]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/UefiLib/UefiLibPrint.c
Clean up the unused EDK_RELEASE_VERSION, PI_SPECIFICATION_VERSION and EFI_SPECIFICATI...
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiLibPrint.c
1 /** @file
2 Mde UEFI library API implemention.
3 Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE
4
5 Copyright (c) 2007, Intel Corporation<BR>
6 All rights reserved. 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
10
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.
13
14 **/
15
16 #include "UefiLibInternal.h"
17
18 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 }
35 };
36
37 /**
38 Internal function which prints a formatted Unicode string to the console output device
39 specified by Console
40
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().
47
48 @param Format Null-terminated Unicode format string.
49 @param Console The output console.
50 @param Marker VA_LIST marker for the variable argument list.
51
52 @return The number of Unicode characters in the produced
53 output buffer not including the Null-terminator.
54 **/
55 UINTN
56 InternalPrint (
57 IN CONST CHAR16 *Format,
58 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,
59 IN VA_LIST Marker
60 )
61 {
62 UINTN Return;
63 CHAR16 *Buffer;
64 UINTN BufferSize;
65
66 ASSERT (Format != NULL);
67 ASSERT (((UINTN) Format & BIT0) == 0);
68
69 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
70
71 Buffer = (CHAR16 *) AllocatePool(BufferSize);
72 ASSERT (Buffer != NULL);
73
74 Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
75
76 if (Console != NULL && Return > 0) {
77 //
78 // To be extra safe make sure Console has been initialized
79 //
80 Console->OutputString (Console, Buffer);
81 }
82
83 FreePool (Buffer);
84
85 return Return;
86 }
87
88 /**
89 Prints a formatted Unicode string to the console output device specified by
90 ConOut defined in the EFI_SYSTEM_TABLE.
91
92 This function prints a formatted Unicode string to the console output device
93 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
94 characters that printed to ConOut. If the length of the formatted Unicode
95 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
96 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
97 If Format is NULL, then ASSERT().
98 If Format is not aligned on a 16-bit boundary, then ASSERT().
99
100 @param Format Null-terminated Unicode format string.
101 @param ... Variable argument list whose contents are accessed based
102 on the format string specified by Format.
103
104 @return The number of Unicode characters in the produced
105 output buffer not including the Null-terminator.
106
107 **/
108 UINTN
109 EFIAPI
110 Print (
111 IN CONST CHAR16 *Format,
112 ...
113 )
114 {
115 VA_LIST Marker;
116 UINTN Return;
117
118 VA_START (Marker, Format);
119
120 Return = InternalPrint (Format, gST->ConOut, Marker);
121
122 VA_END (Marker);
123
124 return Return;
125 }
126
127 /**
128 Prints a formatted Unicode string to the console output device specified by
129 StdErr defined in the EFI_SYSTEM_TABLE.
130
131 This function prints a formatted Unicode string to the console output device
132 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
133 characters that printed to StdErr. If the length of the formatted Unicode
134 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
135 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
136 If Format is NULL, then ASSERT().
137 If Format is not aligned on a 16-bit boundary, then ASSERT().
138
139 @param Format Null-terminated Unicode format string.
140 @param ... Variable argument list whose contents are accessed based
141 on the format string specified by Format.
142
143 @return The number of Unicode characters in the produced
144 output buffer not including the Null-terminator.
145 **/
146 UINTN
147 EFIAPI
148 ErrorPrint (
149 IN CONST CHAR16 *Format,
150 ...
151 )
152 {
153 VA_LIST Marker;
154 UINTN Return;
155
156 VA_START (Marker, Format);
157
158 Return = InternalPrint( Format, gST->StdErr, Marker);
159
160 VA_END (Marker);
161
162 return Return;
163 }
164
165
166 /**
167 Internal function which prints a formatted ASCII string to the console output device
168 specified by Console
169
170 This function prints a formatted ASCII string to the console output device
171 specified by Console and returns the number of ASCII characters that printed
172 to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,
173 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.
174
175 If Format is NULL, then ASSERT().
176
177 @param Format Null-terminated ASCII format string.
178 @param Console The output console.
179 @param Marker VA_LIST marker for the variable argument list.
180
181 @return The number of Unicode characters in the produced
182 output buffer not including the Null-terminator.
183
184 **/
185 UINTN
186 AsciiInternalPrint (
187 IN CONST CHAR8 *Format,
188 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,
189 IN VA_LIST Marker
190 )
191 {
192 UINTN Return;
193 CHAR16 *Buffer;
194 UINTN BufferSize;
195
196 ASSERT (Format != NULL);
197
198 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
199
200 Buffer = (CHAR16 *) AllocatePool(BufferSize);
201 ASSERT (Buffer != NULL);
202
203 Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);
204
205 if (Console != NULL) {
206 //
207 // To be extra safe make sure Console has been initialized
208 //
209 Console->OutputString (Console, Buffer);
210 }
211
212 FreePool (Buffer);
213
214 return Return;
215 }
216
217 /**
218 Prints a formatted ASCII string to the console output device specified by
219 ConOut defined in the EFI_SYSTEM_TABLE.
220
221 This function prints a formatted ASCII string to the console output device
222 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
223 characters that printed to ConOut. If the length of the formatted ASCII
224 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
225 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
226 If Format is NULL, then ASSERT().
227
228 @param Format Null-terminated ASCII format string.
229 @param ... Variable argument list whose contents are accessed based
230 on the format string specified by Format.
231
232 @return The number of Ascii characters in the produced
233 output buffer not including the Null-terminator.
234
235 **/
236 UINTN
237 EFIAPI
238 AsciiPrint (
239 IN CONST CHAR8 *Format,
240 ...
241 )
242 {
243 VA_LIST Marker;
244 UINTN Return;
245 ASSERT (Format != NULL);
246
247 VA_START (Marker, Format);
248
249 Return = AsciiInternalPrint( Format, gST->ConOut, Marker);
250
251 VA_END (Marker);
252
253 return Return;
254 }
255
256 /**
257 Prints a formatted ASCII string to the console output device specified by
258 StdErr defined in the EFI_SYSTEM_TABLE.
259
260 This function prints a formatted ASCII string to the console output device
261 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
262 characters that printed to StdErr. If the length of the formatted ASCII
263 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
264 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
265 If Format is NULL, then ASSERT().
266
267 @param Format Null-terminated ASCII format string.
268 @param ... Variable argument list whose contents are accessed based
269 on the format string specified by Format.
270
271 @return The number of Ascii characters in the produced output
272 buffer not including the Null-terminator.
273
274 **/
275 UINTN
276 EFIAPI
277 AsciiErrorPrint (
278 IN CONST CHAR8 *Format,
279 ...
280 )
281 {
282 VA_LIST Marker;
283 UINTN Return;
284
285 ASSERT (Format != NULL);
286
287 VA_START (Marker, Format);
288
289 Return = AsciiInternalPrint( Format, gST->StdErr, Marker);
290
291 VA_END (Marker);
292
293 return Return;
294 }
295
296 /**
297 Internal function to print a formatted Unicode string to a graphics console device specified by
298 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
299
300 This function prints a formatted Unicode string to the graphics console device
301 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
302 Unicode characters printed. The EFI_HII_FONT_PROTOCOL is used to convert the
303 string to a bitmap using the glyphs registered with the
304 HII database. No wrapping is performed, so any portions of the string the fall
305 outside the active display region will not be displayed.
306
307 If a graphics console device is not associated with the ConsoleOutputHandle
308 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
309 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
310 string is printed, and 0 is returned.
311
312 @param X X coordinate to print the string.
313 @param Y Y coordinate to print the string.
314 @param ForeGround The forground color of the string being printed. This is
315 an optional parameter that may be NULL. If it is NULL,
316 then the foreground color of the current ConOut device
317 in the EFI_SYSTEM_TABLE is used.
318 @param BackGround The background color of the string being printed. This is
319 an optional parameter that may be NULL. If it is NULL,
320 then the background color of the current ConOut device
321 in the EFI_SYSTEM_TABLE is used.
322 @param Buffer Null-terminated Unicode formatted string.
323 @param PrintNum The number of Unicode formatted string to be printed.
324
325 @return Number of Unicode Characters printed. Zero means no any character
326 displayed successfully.
327
328 **/
329 UINTN
330 InternalPrintGraphic (
331 IN UINTN X,
332 IN UINTN Y,
333 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
334 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background,
335 IN CHAR16 *Buffer,
336 IN UINTN PrintNum
337 )
338 {
339 EFI_STATUS Status;
340 UINTN Index;
341 CHAR16 *UnicodeWeight;
342 UINT32 HorizontalResolution;
343 UINT32 VerticalResolution;
344 UINT32 ColorDepth;
345 UINT32 RefreshRate;
346 UINTN LineBufferLen;
347 EFI_HII_FONT_PROTOCOL *HiiFont;
348 EFI_IMAGE_OUTPUT *Blt;
349 EFI_FONT_DISPLAY_INFO FontInfo;
350 EFI_HII_ROW_INFO *RowInfoArray;
351 UINTN RowInfoArraySize;
352 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
353 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
354 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;
355 EFI_HANDLE ConsoleHandle;
356
357 HorizontalResolution = 0;
358 VerticalResolution = 0;
359 Blt = NULL;
360
361 ConsoleHandle = gST->ConsoleOutHandle;
362
363 Status = gBS->HandleProtocol (
364 ConsoleHandle,
365 &gEfiGraphicsOutputProtocolGuid,
366 (VOID **) &GraphicsOutput
367 );
368
369 UgaDraw = NULL;
370 if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
371 //
372 // If no GOP available, try to open UGA Draw protocol if supported.
373 //
374 GraphicsOutput = NULL;
375
376 Status = gBS->HandleProtocol (
377 ConsoleHandle,
378 &gEfiUgaDrawProtocolGuid,
379 (VOID **) &UgaDraw
380 );
381 }
382 if (EFI_ERROR (Status)) {
383 return 0;
384 }
385
386 Status = gBS->HandleProtocol (
387 ConsoleHandle,
388 &gEfiSimpleTextOutProtocolGuid,
389 (VOID **) &Sto
390 );
391
392 if (EFI_ERROR (Status)) {
393 return 0;
394 }
395
396 if (GraphicsOutput != NULL) {
397 HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
398 VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
399 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
400 UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);
401 } else {
402 Status = EFI_UNSUPPORTED;
403 goto Error;
404 }
405
406 ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));
407
408 Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);
409 if (EFI_ERROR (Status)) {
410 goto Error;
411 }
412
413 UnicodeWeight = Buffer;
414
415 for (Index = 0; UnicodeWeight[Index] != 0; Index++) {
416 if (UnicodeWeight[Index] == CHAR_BACKSPACE ||
417 UnicodeWeight[Index] == CHAR_LINEFEED ||
418 UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {
419 UnicodeWeight[Index] = 0;
420 }
421 }
422
423 LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;
424 if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * PrintNum > LineBufferLen) {
425 Status = EFI_INVALID_PARAMETER;
426 goto Error;
427 }
428
429 Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
430 ASSERT (Blt != NULL);
431
432 Blt->Width = (UINT16) (HorizontalResolution);
433 Blt->Height = (UINT16) (VerticalResolution);
434
435 ZeroMem (&FontInfo, sizeof (EFI_FONT_DISPLAY_INFO));
436
437 if (Foreground != NULL) {
438 CopyMem (&FontInfo.ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
439 } else {
440 CopyMem (
441 &FontInfo.ForegroundColor,
442 &mEfiColors[Sto->Mode->Attribute & 0x0f],
443 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
444 );
445 }
446 if (Background != NULL) {
447 CopyMem (&FontInfo.BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
448 } else {
449 CopyMem (
450 &FontInfo.BackgroundColor,
451 &mEfiColors[Sto->Mode->Attribute >> 4],
452 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
453 );
454 }
455
456 if (GraphicsOutput != NULL) {
457 Blt->Image.Screen = GraphicsOutput;
458
459 Status = HiiFont->StringToImage (
460 HiiFont,
461 EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,
462 Buffer,
463 &FontInfo,
464 &Blt,
465 X,
466 Y,
467 NULL,
468 NULL,
469 NULL
470 );
471
472 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
473 ASSERT (UgaDraw!= NULL);
474
475 Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
476 ASSERT (Blt->Image.Bitmap != NULL);
477
478 RowInfoArray = NULL;
479 //
480 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
481 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
482 //
483 Status = HiiFont->StringToImage (
484 HiiFont,
485 EFI_HII_IGNORE_IF_NO_GLYPH,
486 Buffer,
487 &FontInfo,
488 &Blt,
489 X,
490 Y,
491 &RowInfoArray,
492 &RowInfoArraySize,
493 NULL
494 );
495
496 if (!EFI_ERROR (Status)) {
497 ASSERT (RowInfoArray != NULL);
498 //
499 // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will
500 // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.
501 //
502 ASSERT (RowInfoArraySize <= 1);
503
504 Status = UgaDraw->Blt (
505 UgaDraw,
506 (EFI_UGA_PIXEL *) Blt->Image.Bitmap,
507 EfiUgaBltBufferToVideo,
508 X,
509 Y,
510 X,
511 Y,
512 RowInfoArray[0].LineWidth,
513 RowInfoArray[0].LineHeight,
514 Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
515 );
516 }
517
518 FreePool (RowInfoArray);
519 FreePool (Blt->Image.Bitmap);
520
521 } else {
522 Status = EFI_UNSUPPORTED;
523 }
524
525 FreePool (Blt);
526
527 Error:
528 if (EFI_ERROR (Status)) {
529 return 0;
530 } else {
531 return PrintNum;
532 }
533 }
534
535 /**
536 Prints a formatted Unicode string to a graphics console device specified by
537 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
538
539 This function prints a formatted Unicode string to the graphics console device
540 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
541 Unicode characters printed. If the length of the formatted Unicode string is
542 greater than PcdUefiLibMaxPrintBufferSize, then only the first
543 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
544 is used to convert the string to a bitmap using the glyphs registered with the
545 HII database. No wrapping is performed, so any portions of the string the fall
546 outside the active display region will not be displayed.
547
548 If a graphics console device is not associated with the ConsoleOutputHandle
549 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
550 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
551 string is printed, and 0 is returned.
552 If Format is NULL, then ASSERT().
553 If Format is not aligned on a 16-bit boundary, then ASSERT().
554
555 @param X X coordinate to print the string.
556 @param Y Y coordinate to print the string.
557 @param ForeGround The forground color of the string being printed. This is
558 an optional parameter that may be NULL. If it is NULL,
559 then the foreground color of the current ConOut device
560 in the EFI_SYSTEM_TABLE is used.
561 @param BackGround The background color of the string being printed. This is
562 an optional parameter that may be NULL. If it is NULL,
563 then the background color of the current ConOut device
564 in the EFI_SYSTEM_TABLE is used.
565 @param Format Null-terminated Unicode format string. See Print Library
566 for the supported format string syntax.
567 @param ... Variable argument list whose contents are accessed based on
568 the format string specified by Format.
569
570 @return The number of characters printed.
571
572 **/
573 UINTN
574 EFIAPI
575 PrintXY (
576 IN UINTN X,
577 IN UINTN Y,
578 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL
579 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL
580 IN CONST CHAR16 *Format,
581 ...
582 )
583 {
584 VA_LIST Marker;
585 CHAR16 *Buffer;
586 UINTN BufferSize;
587 UINTN PrintNum;
588 UINTN ReturnNum;
589
590 ASSERT (Format != NULL);
591 ASSERT (((UINTN) Format & BIT0) == 0);
592
593 VA_START (Marker, Format);
594
595 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
596
597 Buffer = (CHAR16 *) AllocatePool (BufferSize);
598 ASSERT (Buffer != NULL);
599
600 PrintNum = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
601
602 ReturnNum = InternalPrintGraphic (X, Y, ForeGround, BackGround, Buffer, PrintNum);
603
604 FreePool (Buffer);
605
606 return ReturnNum;
607 }
608
609 /**
610 Prints a formatted ASCII string to a graphics console device specified by
611 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
612
613 This function prints a formatted ASCII string to the graphics console device
614 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
615 Unicode characters printed. If the length of the formatted ASCII string is
616 greater than PcdUefiLibMaxPrintBufferSize, then only the first
617 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
618 is used to convert the string to a bitmap using the glyphs registered with the
619 HII database. No wrapping is performed, so any portions of the string the fall
620 outside the active display region will not be displayed.
621
622 If a graphics console device is not associated with the ConsoleOutputHandle
623 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
624 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
625 string is printed, and 0 is returned.
626 If Format is NULL, then ASSERT().
627
628 @param X X coordinate to print the string.
629 @param Y Y coordinate to print the string.
630 @param ForeGround The forground color of the string being printed. This is
631 an optional parameter that may be NULL. If it is NULL,
632 then the foreground color of the current ConOut device
633 in the EFI_SYSTEM_TABLE is used.
634 @param BackGround The background color of the string being printed. This is
635 an optional parameter that may be NULL. If it is NULL,
636 then the background color of the current ConOut device
637 in the EFI_SYSTEM_TABLE is used.
638 @param Format Null-terminated ASCII format string. See Print Library
639 for the supported format string syntax.
640 @param ... Variable argument list whose contents are accessed based on
641 the format string specified by Format.
642
643 @return The number of characters printed.
644
645 **/
646 UINTN
647 EFIAPI
648 AsciiPrintXY (
649 IN UINTN X,
650 IN UINTN Y,
651 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL
652 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL
653 IN CONST CHAR8 *Format,
654 ...
655 )
656 {
657 VA_LIST Marker;
658 CHAR16 *Buffer;
659 UINTN BufferSize;
660 UINTN PrintNum;
661 UINTN ReturnNum;
662
663 ASSERT (Format != NULL);
664
665 VA_START (Marker, Format);
666
667 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
668
669 Buffer = (CHAR16 *) AllocatePool (BufferSize);
670 ASSERT (Buffer != NULL);
671
672 PrintNum = UnicodeSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);
673
674 ReturnNum = InternalPrintGraphic (X, Y, ForeGround, BackGround, Buffer, PrintNum);
675
676 FreePool (Buffer);
677
678 return ReturnNum;
679 }
680