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