]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Library / DxePrintLibPrint2Protocol / PrintLib.c
index e09520c81b248e4f8e325a81cb6533074c649a8a..3a051fd58003d9678e311b73f5752fea99b9d21c 100644 (file)
@@ -1,19 +1,13 @@
 /** @file\r
   Instance of Print Library based on gEfiPrint2SProtocolGuid.\r
 \r
-  Implement the print library instance by wrap the interface \r
+  Implement the print library instance by wrap the interface\r
   provided in the Print2S protocol. This protocol is defined as the internal\r
-  protocol related to this implementation, not in the public spec. So, this \r
+  protocol related to this implementation, not in the public spec. So, this\r
   library instance is only for this code base.\r
 \r
-Copyright (c) 2009 - 2017, 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
+Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -47,13 +41,13 @@ EFI_PRINT2S_PROTOCOL  *mPrint2SProtocol = NULL;
 \r
 /**\r
   The constructor function caches the pointer to Print2S protocol.\r
-  \r
+\r
   The constructor function locates Print2S protocol from protocol database.\r
-  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
+  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
 \r
   @param  ImageHandle   The firmware allocated handle for the EFI image.\r
   @param  SystemTable   A pointer to the EFI System Table.\r
-  \r
+\r
   @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
 \r
 **/\r
@@ -79,7 +73,7 @@ PrintLibConstructor (
 \r
 \r
 /**\r
-  Worker function that converts a VA_LIST to a BASE_LIST based on a Null-terminated \r
+  Worker function that converts a VA_LIST to a BASE_LIST based on a Null-terminated\r
   format string.\r
 \r
   @param  AsciiFormat     TRUE if Format is an ASCII string.  FALSE if Format is a Unicode string.\r
@@ -151,11 +145,11 @@ DxePrintLibPrint2ProtocolVaListToBaseList (
         FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;\r
 \r
         switch (FormatCharacter) {\r
-        case '.': \r
-        case '-': \r
-        case '+': \r
-        case ' ': \r
-        case ',': \r
+        case '.':\r
+        case '-':\r
+        case '+':\r
+        case ' ':\r
+        case ',':\r
         case '0':\r
         case '1':\r
         case '2':\r
@@ -168,7 +162,7 @@ DxePrintLibPrint2ProtocolVaListToBaseList (
         case '9':\r
           break;\r
         case 'L':\r
-        case 'l': \r
+        case 'l':\r
           Long = TRUE;\r
           break;\r
         case '*':\r
@@ -177,7 +171,7 @@ DxePrintLibPrint2ProtocolVaListToBaseList (
         case '\0':\r
           //\r
           // Make no output if Format string terminates unexpectedly when\r
-          // looking up for flag, width, precision and type. \r
+          // looking up for flag, width, precision and type.\r
           //\r
           Format -= BytesPerFormatCharacter;\r
           //\r
@@ -187,8 +181,8 @@ DxePrintLibPrint2ProtocolVaListToBaseList (
           Done = TRUE;\r
           break;\r
         }\r
-      } \r
-        \r
+      }\r
+\r
       //\r
       // Handle each argument type\r
       //\r
@@ -604,26 +598,26 @@ UnicodeSPrintAsciiFormat (
   [ATTENTION] This function is deprecated for security reason.\r
 \r
   Converts a decimal value to a Null-terminated Unicode string.\r
-  \r
-  Converts the decimal number specified by Value to a Null-terminated Unicode \r
-  string specified by Buffer containing at most Width characters. No padding of spaces \r
+\r
+  Converts the decimal number specified by Value to a Null-terminated Unicode\r
+  string specified by Buffer containing at most Width characters. No padding of spaces\r
   is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
   The number of Unicode characters in Buffer is returned not including the Null-terminator.\r
   If the conversion contains more than Width characters, then only the first\r
-  Width characters are returned, and the total number of characters \r
+  Width characters are returned, and the total number of characters\r
   required to perform the conversion is returned.\r
-  Additional conversion parameters are specified in Flags.  \r
-  \r
+  Additional conversion parameters are specified in Flags.\r
+\r
   The Flags bit LEFT_JUSTIFY is always ignored.\r
   All conversions are left justified in Buffer.\r
   If Width is 0, PREFIX_ZERO is ignored in Flags.\r
   If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
   are inserted every 3rd digit starting from the right.\r
-  If RADIX_HEX is set in Flags, then the output buffer will be \r
+  If RADIX_HEX is set in Flags, then the output buffer will be\r
   formatted in hexadecimal format.\r
   If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.\r
-  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
-  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,\r
+  then Buffer is padded with '0' characters so the combination of the optional '-'\r
   sign character, '0' characters, digit characters for Value, and the Null-terminator\r
   add up to Width characters.\r
   If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r
@@ -639,7 +633,7 @@ UnicodeSPrintAsciiFormat (
   @param  Value   The 64-bit signed value to convert to a string.\r
   @param  Width   The maximum number of Unicode characters to place in Buffer, not including\r
                   the Null-terminator.\r
-  \r
+\r
   @return The number of Unicode characters in Buffer not including the Null-terminator.\r
 \r
 **/\r
@@ -1083,29 +1077,29 @@ AsciiSPrintUnicodeFormat (
   [ATTENTION] This function is deprecated for security reason.\r
 \r
   Converts a decimal value to a Null-terminated ASCII string.\r
-  \r
-  Converts the decimal number specified by Value to a Null-terminated ASCII string \r
-  specified by Buffer containing at most Width characters. No padding of spaces \r
+\r
+  Converts the decimal number specified by Value to a Null-terminated ASCII string\r
+  specified by Buffer containing at most Width characters. No padding of spaces\r
   is ever performed.\r
   If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
   The number of ASCII characters in Buffer is returned not including the Null-terminator.\r
   If the conversion contains more than Width characters, then only the first Width\r
   characters are returned, and the total number of characters required to perform\r
   the conversion is returned.\r
-  Additional conversion parameters are specified in Flags.  \r
+  Additional conversion parameters are specified in Flags.\r
   The Flags bit LEFT_JUSTIFY is always ignored.\r
   All conversions are left justified in Buffer.\r
   If Width is 0, PREFIX_ZERO is ignored in Flags.\r
   If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
   are inserted every 3rd digit starting from the right.\r
-  If RADIX_HEX is set in Flags, then the output buffer will be \r
+  If RADIX_HEX is set in Flags, then the output buffer will be\r
   formatted in hexadecimal format.\r
   If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.\r
-  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
-  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,\r
+  then Buffer is padded with '0' characters so the combination of the optional '-'\r
   sign character, '0' characters, digit characters for Value, and the Null-terminator\r
   add up to Width characters.\r
-  \r
+\r
   If Buffer is NULL, then ASSERT().\r
   If unsupported bits are set in Flags, then ASSERT().\r
   If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r
@@ -1117,7 +1111,7 @@ AsciiSPrintUnicodeFormat (
   @param  Value   The 64-bit signed value to convert to a string.\r
   @param  Width   The maximum number of ASCII characters to place in Buffer, not including\r
                   the Null-terminator.\r
-  \r
+\r
   @return The number of ASCII characters in Buffer not including the Null-terminator.\r
 \r
 **/\r
@@ -1256,8 +1250,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','
 **/\r
 CHAR8 *\r
 InternalPrintLibValueToString (\r
-  IN OUT CHAR8  *Buffer, \r
-  IN INT64      Value, \r
+  IN OUT CHAR8  *Buffer,\r
+  IN INT64      Value,\r
   IN UINTN      Radix\r
   )\r
 {\r
@@ -1279,21 +1273,21 @@ InternalPrintLibValueToString (
 }\r
 \r
 /**\r
-  Worker function that produces a Null-terminated string in an output buffer \r
+  Worker function that produces a Null-terminated string in an output buffer\r
   based on a Null-terminated format string and a VA_LIST argument list.\r
 \r
-  VSPrint function to process format and place the results in Buffer. Since a \r
-  VA_LIST is used this routine allows the nesting of Vararg routines. Thus \r
+  VSPrint function to process format and place the results in Buffer. Since a\r
+  VA_LIST is used this routine allows the nesting of Vararg routines. Thus\r
   this is the main print working routine.\r
 \r
   If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.\r
 \r
-  @param[out] Buffer          The character buffer to print the results of the \r
+  @param[out] Buffer          The character buffer to print the results of the\r
                               parsing of Format into.\r
-  @param[in]  BufferSize      The maximum number of characters to put into \r
+  @param[in]  BufferSize      The maximum number of characters to put into\r
                               buffer.\r
   @param[in]  Flags           Initial flags value.\r
-                              Can only have FORMAT_UNICODE, OUTPUT_UNICODE, \r
+                              Can only have FORMAT_UNICODE, OUTPUT_UNICODE,\r
                               and COUNT_ONLY_NO_PRINT set.\r
   @param[in]  Format          A Null-terminated format string.\r
   @param[in]  VaListMarker    VA_LIST style variable argument list consumed by\r
@@ -1317,11 +1311,11 @@ InternalPrintLibSPrintMarker (
   );\r
 \r
 /**\r
-  Worker function that produces a Null-terminated string in an output buffer \r
+  Worker function that produces a Null-terminated string in an output buffer\r
   based on a Null-terminated format string and variable argument list.\r
 \r
-  VSPrint function to process format and place the results in Buffer. Since a \r
-  VA_LIST is used this routine allows the nesting of Vararg routines. Thus \r
+  VSPrint function to process format and place the results in Buffer. Since a\r
+  VA_LIST is used this routine allows the nesting of Vararg routines. Thus\r
   this is the main print working routine\r
 \r
   @param  StartOfBuffer The character buffer to print the results of the parsing\r
@@ -1407,7 +1401,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 * CONST mStatusString[] = {
 \r
   @param  Buffer      The buffer to place the Unicode or ASCII string.\r
   @param  EndBuffer   The end of the input Buffer. No characters will be\r
-                      placed after that. \r
+                      placed after that.\r
   @param  Length      The count of character to be placed into Buffer.\r
                       (Negative value indicates no buffer fill.)\r
   @param  Character   The character to be placed into Buffer.\r
@@ -1426,7 +1420,7 @@ InternalPrintLibFillBuffer (
   )\r
 {\r
   INTN  Index;\r
-  \r
+\r
   for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) {\r
     *Buffer = (CHAR8) Character;\r
     if (Increment != 1) {\r
@@ -1439,21 +1433,21 @@ InternalPrintLibFillBuffer (
 }\r
 \r
 /**\r
-  Worker function that produces a Null-terminated string in an output buffer \r
+  Worker function that produces a Null-terminated string in an output buffer\r
   based on a Null-terminated format string and a VA_LIST argument list.\r
 \r
-  VSPrint function to process format and place the results in Buffer. Since a \r
-  VA_LIST is used this routine allows the nesting of Vararg routines. Thus \r
+  VSPrint function to process format and place the results in Buffer. Since a\r
+  VA_LIST is used this routine allows the nesting of Vararg routines. Thus\r
   this is the main print working routine.\r
 \r
   If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.\r
 \r
-  @param[out] Buffer          The character buffer to print the results of the \r
+  @param[out] Buffer          The character buffer to print the results of the\r
                               parsing of Format into.\r
-  @param[in]  BufferSize      The maximum number of characters to put into \r
+  @param[in]  BufferSize      The maximum number of characters to put into\r
                               buffer.\r
   @param[in]  Flags           Initial flags value.\r
-                              Can only have FORMAT_UNICODE, OUTPUT_UNICODE, \r
+                              Can only have FORMAT_UNICODE, OUTPUT_UNICODE,\r
                               and COUNT_ONLY_NO_PRINT set.\r
   @param[in]  Format          A Null-terminated format string.\r
   @param[in]  VaListMarker    VA_LIST style variable argument list consumed by\r
@@ -1509,7 +1503,7 @@ InternalPrintLibSPrintMarker (
 \r
   //\r
   // If you change this code be sure to match the 2 versions of this function.\r
-  // Nearly identical logic is found in the BasePrintLib and \r
+  // Nearly identical logic is found in the BasePrintLib and\r
   // DxePrintLibPrint2Protocol (both PrintLib instances).\r
   //\r
 \r
@@ -1630,24 +1624,24 @@ InternalPrintLibSPrintMarker (
         Format += BytesPerFormatCharacter;\r
         FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;\r
         switch (FormatCharacter) {\r
-        case '.': \r
-          Flags |= PRECISION; \r
+        case '.':\r
+          Flags |= PRECISION;\r
           break;\r
-        case '-': \r
-          Flags |= LEFT_JUSTIFY; \r
+        case '-':\r
+          Flags |= LEFT_JUSTIFY;\r
           break;\r
-        case '+': \r
-          Flags |= PREFIX_SIGN;  \r
+        case '+':\r
+          Flags |= PREFIX_SIGN;\r
           break;\r
-        case ' ': \r
-          Flags |= PREFIX_BLANK; \r
+        case ' ':\r
+          Flags |= PREFIX_BLANK;\r
           break;\r
-        case ',': \r
-          Flags |= COMMA_TYPE; \r
+        case ',':\r
+          Flags |= COMMA_TYPE;\r
           break;\r
         case 'L':\r
-        case 'l': \r
-          Flags |= LONG_TYPE;    \r
+        case 'l':\r
+          Flags |= LONG_TYPE;\r
           break;\r
         case '*':\r
           if ((Flags & PRECISION) == 0) {\r
@@ -1691,11 +1685,11 @@ InternalPrintLibSPrintMarker (
             Precision = Count;\r
           }\r
           break;\r
-       \r
+\r
         case '\0':\r
           //\r
           // Make no output if Format string terminates unexpectedly when\r
-          // looking up for flag, width, precision and type. \r
+          // looking up for flag, width, precision and type.\r
           //\r
           Format   -= BytesPerFormatCharacter;\r
           Precision = 0;\r
@@ -1706,7 +1700,7 @@ InternalPrintLibSPrintMarker (
           Done = TRUE;\r
           break;\r
         }\r
-      } \r
+      }\r
 \r
       //\r
       // Handle each argument type\r
@@ -1746,9 +1740,9 @@ InternalPrintLibSPrintMarker (
           //\r
           // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
           // This assumption is made so the format string definition is compatible with the ANSI C\r
-          // Specification for formatted strings.  It is recommended that the Base Types be used \r
-          // everywhere, but in this one case, compliance with ANSI C is more important, and \r
-          // provides an implementation that is compatible with that largest possible set of CPU \r
+          // Specification for formatted strings.  It is recommended that the Base Types be used\r
+          // everywhere, but in this one case, compliance with ANSI C is more important, and\r
+          // provides an implementation that is compatible with that largest possible set of CPU\r
           // architectures.  This is why the type "int" is used in this one case.\r
           //\r
           if (BaseListMarker == NULL) {\r
@@ -1786,9 +1780,9 @@ InternalPrintLibSPrintMarker (
             //\r
             // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
             // This assumption is made so the format string definition is compatible with the ANSI C\r
-            // Specification for formatted strings.  It is recommended that the Base Types be used \r
-            // everywhere, but in this one case, compliance with ANSI C is more important, and \r
-            // provides an implementation that is compatible with that largest possible set of CPU \r
+            // Specification for formatted strings.  It is recommended that the Base Types be used\r
+            // everywhere, but in this one case, compliance with ANSI C is more important, and\r
+            // provides an implementation that is compatible with that largest possible set of CPU\r
             // architectures.  This is why the type "unsigned int" is used in this one case.\r
             //\r
             Value = (unsigned int)Value;\r
@@ -1800,9 +1794,9 @@ InternalPrintLibSPrintMarker (
             //\r
             // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
             // This assumption is made so the format string definition is compatible with the ANSI C\r
-            // Specification for formatted strings.  It is recommended that the Base Types be used \r
-            // everywhere, but in this one case, compliance with ANSI C is more important, and \r
-            // provides an implementation that is compatible with that largest possible set of CPU \r
+            // Specification for formatted strings.  It is recommended that the Base Types be used\r
+            // everywhere, but in this one case, compliance with ANSI C is more important, and\r
+            // provides an implementation that is compatible with that largest possible set of CPU\r
             // architectures.  This is why the type "unsigned int" is used in this one case.\r
             //\r
             Value = (unsigned int)Value;\r
@@ -1816,7 +1810,7 @@ InternalPrintLibSPrintMarker (
           Count = 0;\r
         }\r
         ArgumentString = (CHAR8 *)ValueBuffer + Count;\r
-        \r
+\r
         Digits = Count % 3;\r
         if (Digits != 0) {\r
           Digits = 3 - Digits;\r
@@ -1889,7 +1883,7 @@ InternalPrintLibSPrintMarker (
           GuidData3 = ReadUnaligned16 (&(TmpGuid->Data3));\r
           InternalPrintLibSPrint (\r
             ValueBuffer,\r
-            MAXIMUM_VALUE_CHARACTERS, \r
+            MAXIMUM_VALUE_CHARACTERS,\r
             0,\r
             "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
             GuidData1,\r
@@ -1910,9 +1904,9 @@ InternalPrintLibSPrintMarker (
 \r
       case 't':\r
         if (BaseListMarker == NULL) {\r
-          TmpTime = VA_ARG (VaListMarker, TIME *); \r
+          TmpTime = VA_ARG (VaListMarker, TIME *);\r
         } else {\r
-          TmpTime = BASE_ARG (BaseListMarker, TIME *); \r
+          TmpTime = BASE_ARG (BaseListMarker, TIME *);\r
         }\r
         if (TmpTime == NULL) {\r
           ArgumentString = "<null time>";\r
@@ -1997,7 +1991,7 @@ InternalPrintLibSPrintMarker (
         break;\r
       }\r
       break;\r
\r
+\r
     case '\r':\r
       Format += BytesPerFormatCharacter;\r
       FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;\r
@@ -2173,7 +2167,7 @@ InternalPrintLibSPrintMarker (
 }\r
 \r
 /**\r
-  Returns the number of characters that would be produced by if the formatted \r
+  Returns the number of characters that would be produced by if the formatted\r
   output were produced not including the Null-terminator.\r
 \r
   If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
@@ -2186,7 +2180,7 @@ InternalPrintLibSPrintMarker (
   @param[in]  FormatString    A Null-terminated Unicode format string.\r
   @param[in]  Marker          VA_LIST marker for the variable argument list.\r
 \r
-  @return The number of characters that would be produced, not including the \r
+  @return The number of characters that would be produced, not including the\r
           Null-terminator.\r
 **/\r
 UINTN\r
@@ -2201,7 +2195,7 @@ SPrintLength (
 }\r
 \r
 /**\r
-  Returns the number of characters that would be produced by if the formatted \r
+  Returns the number of characters that would be produced by if the formatted\r
   output were produced not including the Null-terminator.\r
 \r
   If FormatString is NULL, then ASSERT() and 0 is returned.\r
@@ -2212,7 +2206,7 @@ SPrintLength (
   @param[in]  FormatString    A Null-terminated ASCII format string.\r
   @param[in]  Marker          VA_LIST marker for the variable argument list.\r
 \r
-  @return The number of characters that would be produced, not including the \r
+  @return The number of characters that would be produced, not including the\r
           Null-terminator.\r
 **/\r
 UINTN\r