+++ /dev/null
-/*++\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
-Module Name:\r
-\r
- StdErr.c\r
-\r
-Abstract:\r
-\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
- %[flags][width]type\r
-\r
- flags:\r
- '-' - Left justify\r
- '+' - Prefix a sign\r
- ' ' - Prefix a blank\r
- ',' - Place commas in numberss\r
- '0' - Prefix for width with zeros\r
- 'l' - UINT64\r
- 'L' - UINT64\r
-\r
- width:\r
- '*' - Get width from a UINTN argumnet from the argument list\r
- Decimal number that represents width of print\r
-\r
- type:\r
- 'X' - argument is a UINTN hex number, prefix '0'\r
- 'x' - argument is a hex number\r
- 'd' - argument is a decimal number\r
- 'a' - argument is an ascii string \r
- 'S','s' - argument is an Unicode string\r
- 'g' - argument is a pointer to an EFI_GUID\r
- 't' - argument is a pointer to an EFI_TIME structure\r
- 'c' - argument is an ascii character\r
- 'r' - argument is EFI_STATUS\r
- '%' - Print a %\r
-\r
---*/\r
-\r
-#include "Tiano.h"\r
-#include "EfiDriverLib.h"\r
-#include "EfiCommonLib.h"\r
-#include "EfiPrintLib.h"\r
-#include "Print.h"\r
-\r
-\r
-UINTN\r
-ErrorPrint (\r
- IN CONST CHAR16 *ErrorString,\r
- IN CONST CHAR8 *Format,\r
- ...\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
- characters.\r
-\r
-Arguments:\r
-\r
- ErrorString - String of error infomation.\r
-\r
- Format - Ascii format string see file header for more details.\r
-\r
- ... - Vararg list consumed by processing Format.\r
-\r
-Returns: \r
-\r
- Number of characters printed.\r
-\r
---*/\r
-{\r
- UINTN Return;\r
- VA_LIST Marker;\r
- UINTN Index;\r
- UINTN MaxIndex;\r
- CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
- CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
-\r
- MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);\r
- if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {\r
- //\r
- // Format string was too long for use to process.\r
- //\r
- return 0;\r
- }\r
-\r
- if (ErrorString != NULL) {\r
- if (gST->StdErr != NULL) {\r
- //\r
- // To be extra safe make sure StdErr has been initialized\r
- //\r
- gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_RED, EFI_BLACK));\r
- gST->StdErr->OutputString (gST->StdErr, (CHAR16 *) ErrorString);\r
- gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK));\r
- }\r
- }\r
-\r
- for (Index = 0; Index < MaxIndex; Index++) {\r
- UnicodeFormat[Index] = (CHAR16) Format[Index];\r
- }\r
-\r
- UnicodeFormat[Index] = 0;\r
-\r
- VA_START (Marker, Format);\r
- Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);\r
- VA_END (Marker);\r
-\r
- //\r
- // Need to convert to Unicode to do an OutputString\r
- //\r
-\r
- if (gST->StdErr != NULL) {\r
- //\r
- // To be extra safe make sure StdErr has been initialized\r
- //\r
- gST->StdErr->OutputString (gST->StdErr, Buffer);\r
- }\r
-\r
- return Return;\r
-}\r
-\r
-\r
-UINTN\r
-Aprint (\r
- IN CONST CHAR8 *Format,\r
- ...\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
- characters.\r
-\r
-Arguments:\r
-\r
- Format - Ascii format string see file header for more details.\r
-\r
- ... - Vararg list consumed by processing Format.\r
-\r
-Returns: \r
-\r
- Number of characters printed.\r
-\r
---*/\r
-{\r
- UINTN Return;\r
- VA_LIST Marker;\r
- UINTN Index;\r
- UINTN MaxIndex;\r
- CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
- CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
-\r
- MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);\r
- if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {\r
- //\r
- // Format string was too long for use to process.\r
- //\r
- return 0;\r
- }\r
-\r
- for (Index = 0; Index <= MaxIndex; Index++) {\r
- UnicodeFormat[Index] = (CHAR16) Format[Index];\r
- }\r
-\r
- VA_START (Marker, Format);\r
- Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);\r
- VA_END (Marker);\r
-\r
- //\r
- // Need to convert to Unicode to do an OutputString\r
- //\r
-\r
- if (gST->ConOut != NULL) {\r
- //\r
- // To be extra safe make sure ConOut has been initialized\r
- //\r
- gST->ConOut->OutputString (gST->ConOut, Buffer);\r
- }\r
-\r
- return Return;\r
-}\r
-\r
-\r
-UINTN\r
-Print (\r
- IN CONST CHAR16 *Format,\r
- ...\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
- characters.\r
-\r
-Arguments:\r
-\r
- Format - Ascii format string see file header for more details.\r
-\r
- ... - Vararg list consumed by processing Format.\r
-\r
-Returns: \r
-\r
- Number of characters printed.\r
-\r
---*/\r
-{\r
- UINTN Return;\r
- VA_LIST Marker;\r
- CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
-\r
- VA_START (Marker, Format);\r
- Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
- VA_END (Marker);\r
-\r
- if (gST->ConOut != NULL) {\r
- //\r
- // To be extra safe make sure ConOut has been initialized\r
- //\r
- gST->ConOut->OutputString (gST->ConOut, Buffer);\r
- }\r
-\r
- return Return;\r
-}\r
-\r
-UINTN\r
-UPrint (\r
- IN CONST CHAR16 *Format,\r
- ...\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
- characters.\r
-\r
-Arguments:\r
-\r
- Format - Ascii format string see file header for more details.\r
-\r
- ... - Vararg list consumed by processing Format.\r
-\r
-Returns: \r
-\r
- Number of characters printed.\r
-\r
---*/\r
-{\r
- UINTN Return;\r
- VA_LIST Marker;\r
- CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
-\r
- VA_START (Marker, Format);\r
- Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
- VA_END (Marker);\r
-\r
- if (gST->ConOut != NULL) {\r
- //\r
- // To be extra safe make sure ConOut has been initialized\r
- //\r
- gST->ConOut->OutputString (gST->ConOut, Buffer);\r
- }\r
-\r
- return Return;\r
-}\r