]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c
Fix several minor coding style issues.
[mirror_edk2.git] / IntelFrameworkPkg / Library / FrameworkUefiLib / UefiLibPrint.c
CommitLineData
79964ac8 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
bf428cb3 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
79964ac8 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
bf428cb3 45 If Format is NULL, then ASSERT().\r
46 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
79964ac8 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
bf428cb3 51 \r
52 @return The number of Unicode characters in the produced\r
53 output buffer not including the Null-terminator.\r
79964ac8 54**/\r
79964ac8 55UINTN\r
56InternalPrint (\r
b51e6bc4 57 IN CONST CHAR16 *Format,\r
58 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
59 IN VA_LIST Marker\r
79964ac8 60 )\r
61{\r
62 UINTN Return;\r
63 CHAR16 *Buffer;\r
64 UINTN BufferSize;\r
65\r
66 ASSERT (Format != NULL);\r
bf428cb3 67 ASSERT (((UINTN) Format & BIT0) == 0);\r
79964ac8 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
bf428cb3 76 if (Console != NULL && Return > 0) {\r
79964ac8 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
bf428cb3 88/** \r
89 Prints a formatted Unicode string to the console output device specified by \r
79964ac8 90 ConOut defined in the EFI_SYSTEM_TABLE.\r
91\r
bf428cb3 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
79964ac8 96 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
bf428cb3 97 If Format is NULL, then ASSERT().\r
98 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
79964ac8 99\r
100 @param Format Null-terminated Unicode format string.\r
00a1f552 101 @param ... Variable argument list whose contents are accessed based \r
102 on the format string specified by Format.\r
bf428cb3 103 \r
104 @return Number of Unicode characters printed to ConOut.\r
79964ac8 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
bf428cb3 126/** \r
127 Prints a formatted Unicode string to the console output device specified by \r
79964ac8 128 StdErr defined in the EFI_SYSTEM_TABLE.\r
129\r
bf428cb3 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
79964ac8 134 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
bf428cb3 135 If Format is NULL, then ASSERT().\r
136 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
79964ac8 137\r
138 @param Format Null-terminated Unicode format string.\r
00a1f552 139 @param ... Variable argument list whose contents are accessed based \r
140 on the format string specified by Format.\r
bf428cb3 141 \r
142 @return Number of Unicode characters printed to StdErr.\r
79964ac8 143\r
144**/\r
79964ac8 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
bf428cb3 174 If Format is NULL, then ASSERT().\r
175\r
79964ac8 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
bf428cb3 180 @return The number of Unicode characters in the produced\r
181 output buffer not including the Null-terminator.\r
79964ac8 182\r
183**/\r
79964ac8 184UINTN\r
185AsciiInternalPrint (\r
b51e6bc4 186 IN CONST CHAR8 *Format,\r
187 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
188 IN VA_LIST Marker\r
79964ac8 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
bf428cb3 216/** \r
217 Prints a formatted ASCII string to the console output device specified by \r
79964ac8 218 ConOut defined in the EFI_SYSTEM_TABLE.\r
219\r
bf428cb3 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
79964ac8 224 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
bf428cb3 225 If Format is NULL, then ASSERT().\r
79964ac8 226\r
227 @param Format Null-terminated ASCII format string.\r
00a1f552 228 @param ... Variable argument list whose contents are accessed based \r
229 on the format string specified by Format.\r
bf428cb3 230 \r
231 @return Number of ASCII characters printed to ConOut.\r
79964ac8 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
bf428cb3 243 ASSERT (Format != NULL);\r
244 \r
79964ac8 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
bf428cb3 254/** \r
255 Prints a formatted ASCII string to the console output device specified by \r
79964ac8 256 StdErr defined in the EFI_SYSTEM_TABLE.\r
257\r
bf428cb3 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
79964ac8 262 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
bf428cb3 263 If Format is NULL, then ASSERT().\r
79964ac8 264\r
265 @param Format Null-terminated ASCII format string.\r
00a1f552 266 @param ... Variable argument list whose contents are accessed based \r
267 on the format string specified by Format.\r
bf428cb3 268 \r
269 @return Number of ASCII characters printed to ConErr.\r
79964ac8 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
bf428cb3 282 ASSERT (Format != NULL);\r
283 \r
79964ac8 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
bf428cb3 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 X X coordinate to print the string.\r
310 @param Y Y coordinate to print the string.\r
e6813189 311 @param Foreground The forground color of the string being printed. This is\r
bf428cb3 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
e6813189 315 @param Background The background color of the string being printed. This is\r
bf428cb3 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 X,\r
329 IN UINTN Y,\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 UINTN Index;\r
338 CHAR16 *UnicodeWeight;\r
339 UINT32 HorizontalResolution;\r
340 UINT32 VerticalResolution;\r
341 UINT32 ColorDepth;\r
342 UINT32 RefreshRate;\r
343 UINTN LineBufferLen;\r
344 EFI_HII_FONT_PROTOCOL *HiiFont;\r
345 EFI_IMAGE_OUTPUT *Blt;\r
346 EFI_FONT_DISPLAY_INFO FontInfo;\r
347 EFI_HII_ROW_INFO *RowInfoArray;\r
348 UINTN RowInfoArraySize;\r
349 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
350 EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
351 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;\r
352 EFI_HANDLE ConsoleHandle;\r
353\r
354 HorizontalResolution = 0;\r
355 VerticalResolution = 0;\r
356 Blt = NULL;\r
357\r
358 ConsoleHandle = gST->ConsoleOutHandle;\r
359\r
360 Status = gBS->HandleProtocol (\r
361 ConsoleHandle,\r
362 &gEfiGraphicsOutputProtocolGuid,\r
363 (VOID **) &GraphicsOutput\r
364 );\r
365\r
366 UgaDraw = NULL;\r
367 if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
368 //\r
369 // If no GOP available, try to open UGA Draw protocol if supported.\r
370 //\r
371 GraphicsOutput = NULL;\r
372\r
373 Status = gBS->HandleProtocol (\r
374 ConsoleHandle,\r
375 &gEfiUgaDrawProtocolGuid,\r
376 (VOID **) &UgaDraw\r
377 );\r
378 }\r
379 if (EFI_ERROR (Status)) {\r
380 return 0;\r
381 }\r
382\r
383 Status = gBS->HandleProtocol (\r
384 ConsoleHandle,\r
385 &gEfiSimpleTextOutProtocolGuid,\r
386 (VOID **) &Sto\r
387 );\r
388\r
389 if (EFI_ERROR (Status)) {\r
390 return 0;\r
391 }\r
392\r
393 if (GraphicsOutput != NULL) {\r
394 HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
395 VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
4af947e5 396 } else if (FeaturePcdGet (PcdUgaConsumeSupport) && UgaDraw != NULL) {\r
bf428cb3 397 UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
398 } else {\r
399 Status = EFI_UNSUPPORTED;\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 UnicodeWeight = Buffer;\r
411\r
412 for (Index = 0; UnicodeWeight[Index] != 0; Index++) {\r
413 if (UnicodeWeight[Index] == CHAR_BACKSPACE ||\r
414 UnicodeWeight[Index] == CHAR_LINEFEED ||\r
415 UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {\r
416 UnicodeWeight[Index] = 0;\r
417 }\r
418 }\r
419\r
420 LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;\r
421 if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * PrintNum > LineBufferLen) {\r
422 Status = EFI_INVALID_PARAMETER;\r
423 goto Error;\r
424 }\r
425\r
426 Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
427 ASSERT (Blt != NULL);\r
428\r
429 Blt->Width = (UINT16) (HorizontalResolution);\r
430 Blt->Height = (UINT16) (VerticalResolution);\r
431\r
432 ZeroMem (&FontInfo, sizeof (EFI_FONT_DISPLAY_INFO));\r
433\r
434 if (Foreground != NULL) {\r
435 CopyMem (&FontInfo.ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
436 } else {\r
437 CopyMem (\r
438 &FontInfo.ForegroundColor,\r
439 &mEfiColors[Sto->Mode->Attribute & 0x0f],\r
440 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
441 );\r
442 }\r
443 if (Background != NULL) {\r
444 CopyMem (&FontInfo.BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
445 } else {\r
446 CopyMem (\r
447 &FontInfo.BackgroundColor,\r
448 &mEfiColors[Sto->Mode->Attribute >> 4],\r
449 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
450 );\r
451 }\r
452\r
453 if (GraphicsOutput != NULL) {\r
454 Blt->Image.Screen = GraphicsOutput;\r
455 \r
456 Status = HiiFont->StringToImage (\r
457 HiiFont,\r
458 EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
459 Buffer,\r
460 &FontInfo,\r
461 &Blt,\r
462 X,\r
463 Y,\r
464 NULL,\r
465 NULL,\r
466 NULL\r
467 );\r
468\r
4af947e5 469 } else if (FeaturePcdGet (PcdUgaConsumeSupport) && UgaDraw != NULL) {\r
bf428cb3 470\r
471 Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
472 ASSERT (Blt->Image.Bitmap != NULL);\r
473\r
474 RowInfoArray = NULL;\r
475 //\r
476 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,\r
477 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.\r
478 //\r
479 Status = HiiFont->StringToImage (\r
480 HiiFont,\r
481 EFI_HII_IGNORE_IF_NO_GLYPH,\r
482 Buffer,\r
483 &FontInfo,\r
484 &Blt,\r
485 X,\r
486 Y,\r
487 &RowInfoArray,\r
488 &RowInfoArraySize,\r
489 NULL\r
490 );\r
491\r
492 if (!EFI_ERROR (Status)) {\r
493 ASSERT (RowInfoArray != NULL);\r
494 //\r
495 // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will\r
496 // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.\r
497 //\r
498 ASSERT (RowInfoArraySize <= 1);\r
499\r
500 Status = UgaDraw->Blt (\r
501 UgaDraw,\r
502 (EFI_UGA_PIXEL *) Blt->Image.Bitmap,\r
503 EfiUgaBltBufferToVideo,\r
504 X,\r
505 Y,\r
506 X,\r
507 Y,\r
508 RowInfoArray[0].LineWidth,\r
509 RowInfoArray[0].LineHeight,\r
510 Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
511 );\r
512 }\r
513\r
514 FreePool (RowInfoArray);\r
515 FreePool (Blt->Image.Bitmap);\r
516\r
517 } else {\r
518 Status = EFI_UNSUPPORTED;\r
519 }\r
520\r
521 FreePool (Blt);\r
522\r
523Error:\r
524 if (EFI_ERROR (Status)) {\r
525 return 0;\r
526 } else {\r
527 return PrintNum;\r
528 }\r
529}\r
530\r
531/**\r
532 Prints a formatted Unicode string to a graphics console device specified by \r
533 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
534\r
535 This function prints a formatted Unicode string to the graphics console device \r
536 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of \r
537 Unicode characters printed. If the length of the formatted Unicode string is\r
538 greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
539 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL\r
540 is used to convert the string to a bitmap using the glyphs registered with the \r
541 HII database. No wrapping is performed, so any portions of the string the fall\r
542 outside the active display region will not be displayed.\r
543\r
544 If a graphics console device is not associated with the ConsoleOutputHandle \r
545 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
546 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no \r
547 string is printed, and 0 is returned.\r
548 If Format is NULL, then ASSERT().\r
549 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
550\r
551 @param X X coordinate to print the string.\r
552 @param Y Y coordinate to print the string.\r
553 @param ForeGround The forground color of the string being printed. This is\r
554 an optional parameter that may be NULL. If it is NULL,\r
555 then the foreground color of the current ConOut device\r
556 in the EFI_SYSTEM_TABLE is used.\r
557 @param BackGround The background 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 background color of the current ConOut device\r
560 in the EFI_SYSTEM_TABLE is used.\r
561 @param Format Null-terminated Unicode format string. See Print Library \r
562 for the supported format string syntax.\r
563 @param ... Variable argument list whose contents are accessed based on \r
564 the format string specified by Format. \r
565\r
566 @return The number of Unicode characters printed.\r
567\r
568**/\r
569UINTN\r
570EFIAPI\r
571PrintXY (\r
572 IN UINTN X,\r
573 IN UINTN Y,\r
574 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL\r
575 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL\r
576 IN CONST CHAR16 *Format,\r
577 ...\r
578 )\r
579{\r
580 VA_LIST Marker;\r
581 CHAR16 *Buffer;\r
582 UINTN BufferSize;\r
583 UINTN PrintNum;\r
584 UINTN ReturnNum;\r
585\r
586 ASSERT (Format != NULL);\r
587 ASSERT (((UINTN) Format & BIT0) == 0);\r
588\r
589 VA_START (Marker, Format);\r
590\r
591 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
592\r
593 Buffer = (CHAR16 *) AllocatePool (BufferSize);\r
594 ASSERT (Buffer != NULL);\r
595 \r
596 PrintNum = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
597\r
598 ReturnNum = InternalPrintGraphic (X, Y, ForeGround, BackGround, Buffer, PrintNum);\r
599\r
600 FreePool (Buffer);\r
601\r
602 return ReturnNum;\r
603}\r
604\r
605/**\r
606 Prints a formatted ASCII string to a graphics console device specified by \r
607 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
608\r
609 This function prints a formatted ASCII string to the graphics console device \r
610 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of \r
611 ASCII characters printed. If the length of the formatted ASCII string is\r
612 greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
613 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL\r
614 is used to convert the string to a bitmap using the glyphs registered with the \r
615 HII database. No wrapping is performed, so any portions of the string the fall\r
616 outside the active display region will not be displayed.\r
617\r
618 If a graphics console device is not associated with the ConsoleOutputHandle \r
619 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
620 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no \r
621 string is printed, and 0 is returned.\r
622 If Format is NULL, then ASSERT().\r
623\r
624 @param X X coordinate to print the string.\r
625 @param Y Y coordinate to print the string.\r
626 @param ForeGround The forground color of the string being printed. This is\r
627 an optional parameter that may be NULL. If it is NULL,\r
628 then the foreground color of the current ConOut device\r
629 in the EFI_SYSTEM_TABLE is used.\r
630 @param BackGround The background 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 background color of the current ConOut device\r
633 in the EFI_SYSTEM_TABLE is used.\r
634 @param Format Null-terminated ASCII format string. See Print Library \r
635 for the supported format string syntax.\r
636 @param ... Variable argument list whose contents are accessed based on \r
637 the format string specified by Format. \r
638\r
639 @return The number of ASCII characters printed.\r
640\r
641**/\r
642UINTN\r
643EFIAPI\r
644AsciiPrintXY (\r
645 IN UINTN X,\r
646 IN UINTN Y,\r
647 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL\r
648 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL\r
649 IN CONST CHAR8 *Format,\r
650 ...\r
651 )\r
652{\r
653 VA_LIST Marker;\r
654 CHAR16 *Buffer;\r
655 UINTN BufferSize;\r
656 UINTN PrintNum;\r
657 UINTN ReturnNum;\r
658\r
659 ASSERT (Format != NULL);\r
660\r
661 VA_START (Marker, Format);\r
662\r
663 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
664\r
665 Buffer = (CHAR16 *) AllocatePool (BufferSize);\r
666 ASSERT (Buffer != NULL);\r
667 \r
668 PrintNum = UnicodeSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);\r
669\r
670 ReturnNum = InternalPrintGraphic (X, Y, ForeGround, BackGround, Buffer, PrintNum);\r
671\r
672 FreePool (Buffer);\r
673 \r
674 return ReturnNum;\r
675}\r
676\r