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