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