+++ /dev/null
-/** @file\r
-Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
-simple implemenation of SPrint() and Print() to support debug.\r
-\r
-You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a\r
-time. This makes the implementation very simple.\r
-\r
-VSPrint, Print, SPrint format specification has the follwoing form\r
-\r
-%type\r
-\r
-type:\r
- 'S','s' - argument is an Unicode string\r
- 'c' - argument is an ascii character\r
- '%' - Print a %\r
-\r
-\r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "Setup.h"\r
-\r
-/**\r
- The internal function prints to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL\r
- protocol instance.\r
-\r
- @param Column The position of the output string.\r
- @param Row The position of the output string.\r
- @param Out The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
- @param Fmt The format string.\r
- @param Args The additional argument for the variables in the format string.\r
-\r
- @return Number of Unicode character printed.\r
-\r
-**/\r
-UINTN\r
-PrintInternal (\r
- IN UINTN Column,\r
- IN UINTN Row,\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Out,\r
- IN CHAR16 *Fmt,\r
- IN VA_LIST Args\r
- )\r
-{\r
- CHAR16 *Buffer;\r
- CHAR16 *BackupBuffer;\r
- UINTN Index;\r
- UINTN PreviousIndex;\r
- UINTN Count;\r
-\r
- //\r
- // For now, allocate an arbitrarily long buffer\r
- //\r
- Buffer = AllocateZeroPool (0x10000);\r
- BackupBuffer = AllocateZeroPool (0x10000);\r
- ASSERT (Buffer);\r
- ASSERT (BackupBuffer);\r
-\r
- if (Column != (UINTN) -1) {\r
- Out->SetCursorPosition (Out, Column, Row);\r
- }\r
-\r
- UnicodeVSPrint (Buffer, 0x10000, Fmt, Args);\r
-\r
- Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;\r
-\r
- Out->SetAttribute (Out, Out->Mode->Attribute);\r
-\r
- Index = 0;\r
- PreviousIndex = 0;\r
- Count = 0;\r
-\r
- do {\r
- for (; (Buffer[Index] != NARROW_CHAR) && (Buffer[Index] != WIDE_CHAR) && (Buffer[Index] != 0); Index++) {\r
- BackupBuffer[Index] = Buffer[Index];\r
- }\r
-\r
- if (Buffer[Index] == 0) {\r
- break;\r
- }\r
- //\r
- // Null-terminate the temporary string\r
- //\r
- BackupBuffer[Index] = 0;\r
-\r
- //\r
- // Print this out, we are about to switch widths\r
- //\r
- Out->OutputString (Out, &BackupBuffer[PreviousIndex]);\r
- Count += StrLen (&BackupBuffer[PreviousIndex]);\r
-\r
- //\r
- // Preserve the current index + 1, since this is where we will start printing from next\r
- //\r
- PreviousIndex = Index + 1;\r
-\r
- //\r
- // We are at a narrow or wide character directive. Set attributes and strip it and print it\r
- //\r
- if (Buffer[Index] == NARROW_CHAR) {\r
- //\r
- // Preserve bits 0 - 6 and zero out the rest\r
- //\r
- Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;\r
- Out->SetAttribute (Out, Out->Mode->Attribute);\r
- } else {\r
- //\r
- // Must be wide, set bit 7 ON\r
- //\r
- Out->Mode->Attribute = Out->Mode->Attribute | EFI_WIDE_ATTRIBUTE;\r
- Out->SetAttribute (Out, Out->Mode->Attribute);\r
- }\r
-\r
- Index++;\r
-\r
- } while (Buffer[Index] != 0);\r
-\r
- //\r
- // We hit the end of the string - print it\r
- //\r
- Out->OutputString (Out, &BackupBuffer[PreviousIndex]);\r
- Count += StrLen (&BackupBuffer[PreviousIndex]);\r
-\r
- FreePool (Buffer);\r
- FreePool (BackupBuffer);\r
- return Count;\r
-}\r
-\r
-\r
-/**\r
- Prints a formatted unicode string to the default console.\r
-\r
- @param Fmt Format string\r
- @param ... Variable argument list for format string.\r
-\r
- @return Length of string printed to the console.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-ConsolePrint (\r
- IN CHAR16 *Fmt,\r
- ...\r
- )\r
-{\r
- VA_LIST Args;\r
- UINTN LengthOfPrinted;\r
-\r
- VA_START (Args, Fmt);\r
- LengthOfPrinted = PrintInternal ((UINTN) -1, (UINTN) -1, gST->ConOut, Fmt, Args);\r
- VA_END (Args);\r
- return LengthOfPrinted;\r
-}\r
-\r
-\r
-/**\r
- Prints a unicode string to the default console,\r
- using L"%s" format.\r
-\r
- @param String String pointer.\r
-\r
- @return Length of string printed to the console\r
-\r
-**/\r
-UINTN\r
-PrintString (\r
- IN CHAR16 *String\r
- )\r
-{\r
- return ConsolePrint (L"%s", String);\r
-}\r
-\r
-\r
-/**\r
- Prints a chracter to the default console,\r
- using L"%c" format.\r
-\r
- @param Character Character to print.\r
-\r
- @return Length of string printed to the console.\r
-\r
-**/\r
-UINTN\r
-PrintChar (\r
- CHAR16 Character\r
- )\r
-{\r
- return ConsolePrint (L"%c", Character);\r
-}\r
-\r
-\r
-/**\r
- Prints a formatted unicode string to the default console, at\r
- the supplied cursor position.\r
-\r
- @param Column The cursor position to print the string at.\r
- @param Row The cursor position to print the string at.\r
- @param Fmt Format string.\r
- @param ... Variable argument list for format string.\r
-\r
- @return Length of string printed to the console\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-PrintAt (\r
- IN UINTN Column,\r
- IN UINTN Row,\r
- IN CHAR16 *Fmt,\r
- ...\r
- )\r
-{\r
- VA_LIST Args;\r
- UINTN LengthOfPrinted;\r
-\r
- VA_START (Args, Fmt);\r
- LengthOfPrinted = PrintInternal (Column, Row, gST->ConOut, Fmt, Args);\r
- VA_END (Args);\r
- return LengthOfPrinted;\r
-}\r
-\r
-\r
-/**\r
- Prints a unicode string to the default console, at\r
- the supplied cursor position, using L"%s" format.\r
-\r
- @param Column The cursor position to print the string at.\r
- @param Row The cursor position to print the string at\r
- @param String String pointer.\r
-\r
- @return Length of string printed to the console\r
-\r
-**/\r
-UINTN\r
-PrintStringAt (\r
- IN UINTN Column,\r
- IN UINTN Row,\r
- IN CHAR16 *String\r
- )\r
-{\r
- return PrintAt (Column, Row, L"%s", String);\r
-}\r
-\r
-\r
-/**\r
- Prints a chracter to the default console, at\r
- the supplied cursor position, using L"%c" format.\r
-\r
- @param Column The cursor position to print the string at.\r
- @param Row The cursor position to print the string at.\r
- @param Character Character to print.\r
-\r
- @return Length of string printed to the console.\r
-\r
-**/\r
-UINTN\r
-PrintCharAt (\r
- IN UINTN Column,\r
- IN UINTN Row,\r
- CHAR16 Character\r
- )\r
-{\r
- return PrintAt (Column, Row, L"%c", Character);\r
-}\r