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