]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
eceb3a4c | 2 | Base Print Library instance Internal Functions definition.\r |
e1f414b6 | 3 | \r |
9b002aa4 | 4 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r |
19388d29 | 5 | This program and the accompanying materials\r |
e1f414b6 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
2fc59a00 | 8 | http://opensource.org/licenses/bsd-license.php.\r |
e1f414b6 | 9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
e1f414b6 | 13 | **/\r |
14 | \r | |
eceb3a4c LG |
15 | #ifndef __PRINT_LIB_INTERNAL_H__\r |
16 | #define __PRINT_LIB_INTERNAL_H__\r | |
e1f414b6 | 17 | \r |
f734a10a A |
18 | #include <Base.h>\r |
19 | #include <Library/PrintLib.h>\r | |
20 | #include <Library/BaseLib.h>\r | |
21 | #include <Library/DebugLib.h>\r | |
9b002aa4 | 22 | #include <Library/PcdLib.h>\r |
f734a10a | 23 | \r |
e1f414b6 | 24 | \r |
25 | //\r | |
26 | // Print primitives\r | |
27 | //\r | |
f405c067 | 28 | #define PREFIX_SIGN BIT1\r |
29 | #define PREFIX_BLANK BIT2\r | |
30 | #define LONG_TYPE BIT4\r | |
31 | #define OUTPUT_UNICODE BIT6\r | |
32 | #define FORMAT_UNICODE BIT8\r | |
33 | #define PAD_TO_WIDTH BIT9\r | |
34 | #define ARGUMENT_UNICODE BIT10\r | |
35 | #define PRECISION BIT11\r | |
36 | #define ARGUMENT_REVERSED BIT12\r | |
37 | #define COUNT_ONLY_NO_PRINT BIT13\r | |
9ade4339 | 38 | #define UNSIGNED_TYPE BIT14\r |
e1f414b6 | 39 | \r |
40 | //\r | |
41 | // Record date and time information\r | |
42 | //\r | |
43 | typedef struct {\r | |
44 | UINT16 Year;\r | |
45 | UINT8 Month;\r | |
46 | UINT8 Day;\r | |
47 | UINT8 Hour;\r | |
48 | UINT8 Minute;\r | |
49 | UINT8 Second;\r | |
50 | UINT8 Pad1;\r | |
51 | UINT32 Nanosecond;\r | |
52 | INT16 TimeZone;\r | |
53 | UINT8 Daylight;\r | |
54 | UINT8 Pad2;\r | |
55 | } TIME;\r | |
56 | \r | |
57 | /**\r | |
58 | Worker function that produces a Null-terminated string in an output buffer \r | |
59 | based on a Null-terminated format string and a VA_LIST argument list.\r | |
60 | \r | |
61 | VSPrint function to process format and place the results in Buffer. Since a \r | |
7c905091 | 62 | VA_LIST is used this routine allows the nesting of Vararg routines. Thus \r |
e1f414b6 | 63 | this is the main print working routine.\r |
64 | \r | |
f405c067 | 65 | If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.\r |
66 | \r | |
67 | @param[out] Buffer The character buffer to print the results of the \r | |
68 | parsing of Format into.\r | |
69 | @param[in] BufferSize The maximum number of characters to put into \r | |
70 | buffer.\r | |
71 | @param[in] Flags Initial flags value.\r | |
72 | Can only have FORMAT_UNICODE, OUTPUT_UNICODE, \r | |
73 | and COUNT_ONLY_NO_PRINT set.\r | |
74 | @param[in] Format A Null-terminated format string.\r | |
75 | @param[in] VaListMarker VA_LIST style variable argument list consumed by\r | |
76 | processing Format.\r | |
77 | @param[in] BaseListMarker BASE_LIST style variable argument list consumed\r | |
78 | by processing Format.\r | |
e1f414b6 | 79 | \r |
2fc59a00 | 80 | @return The number of characters printed not including the Null-terminator.\r |
f405c067 | 81 | If COUNT_ONLY_NO_PRINT was set returns the same, but without any\r |
82 | modification to Buffer.\r | |
e1f414b6 | 83 | \r |
84 | **/\r | |
85 | UINTN\r | |
2075236e | 86 | BasePrintLibSPrintMarker (\r |
e1f414b6 | 87 | OUT CHAR8 *Buffer,\r |
88 | IN UINTN BufferSize,\r | |
89 | IN UINTN Flags,\r | |
90 | IN CONST CHAR8 *Format,\r | |
2075236e | 91 | IN VA_LIST VaListMarker, OPTIONAL\r |
92 | IN BASE_LIST BaseListMarker OPTIONAL\r | |
e1f414b6 | 93 | );\r |
94 | \r | |
95 | /**\r | |
96 | Worker function that produces a Null-terminated string in an output buffer \r | |
97 | based on a Null-terminated format string and variable argument list.\r | |
98 | \r | |
99 | VSPrint function to process format and place the results in Buffer. Since a \r | |
7c905091 | 100 | VA_LIST is used this routine allows the nesting of Vararg routines. Thus \r |
e1f414b6 | 101 | this is the main print working routine\r |
102 | \r | |
2fc59a00 | 103 | @param StartOfBuffer The character buffer to print the results of the parsing\r |
e1f414b6 | 104 | of Format into.\r |
2fc59a00 | 105 | @param BufferSize The maximum number of characters to put into buffer.\r |
e1f414b6 | 106 | Zero means no limit.\r |
7c905091 | 107 | @param Flags Initial flags value.\r |
e1f414b6 | 108 | Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r |
109 | @param FormatString Null-terminated format string.\r | |
eceb3a4c | 110 | @param ... The variable argument list.\r |
e1f414b6 | 111 | \r |
2fc59a00 | 112 | @return The number of characters printed.\r |
e1f414b6 | 113 | \r |
114 | **/\r | |
115 | UINTN\r | |
932d66a9 | 116 | EFIAPI\r |
e1f414b6 | 117 | BasePrintLibSPrint (\r |
eceb3a4c | 118 | OUT CHAR8 *StartOfBuffer,\r |
e1f414b6 | 119 | IN UINTN BufferSize,\r |
120 | IN UINTN Flags,\r | |
121 | IN CONST CHAR8 *FormatString,\r | |
122 | ...\r | |
123 | );\r | |
124 | \r | |
125 | /**\r | |
126 | Internal function that places the character into the Buffer.\r | |
127 | \r | |
128 | Internal function that places ASCII or Unicode character into the Buffer.\r | |
129 | \r | |
130 | @param Buffer Buffer to place the Unicode or ASCII string.\r | |
131 | @param EndBuffer The end of the input Buffer. No characters will be\r | |
132 | placed after that. \r | |
2fc59a00 | 133 | @param Length The count of character to be placed into Buffer.\r |
a2bc29c4 | 134 | (Negative value indicates no buffer fill.)\r |
2fc59a00 | 135 | @param Character The character to be placed into Buffer.\r |
136 | @param Increment The character increment in Buffer.\r | |
e1f414b6 | 137 | \r |
eceb3a4c | 138 | @return Buffer Buffer filled with the input Character.\r |
e1f414b6 | 139 | \r |
140 | **/\r | |
141 | CHAR8 *\r | |
142 | BasePrintLibFillBuffer (\r | |
eceb3a4c LG |
143 | OUT CHAR8 *Buffer,\r |
144 | IN CHAR8 *EndBuffer,\r | |
145 | IN INTN Length,\r | |
146 | IN UINTN Character,\r | |
147 | IN INTN Increment\r | |
e1f414b6 | 148 | );\r |
149 | \r | |
150 | /**\r | |
7c905091 | 151 | Internal function that convert a number to a string in Buffer.\r |
e1f414b6 | 152 | \r |
7c905091 | 153 | Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer.\r |
e1f414b6 | 154 | \r |
7c905091 | 155 | @param Buffer Location to place the ASCII string of Value.\r |
2fc59a00 | 156 | @param Value The value to convert to a Decimal or Hexadecimal string in Buffer.\r |
e1f414b6 | 157 | @param Radix Radix of the value\r |
158 | \r | |
7c905091 | 159 | @return A pointer to the end of buffer filled with ASCII string.\r |
e1f414b6 | 160 | \r |
161 | **/\r | |
7c905091 | 162 | CHAR8 *\r |
e1f414b6 | 163 | BasePrintLibValueToString (\r |
164 | IN OUT CHAR8 *Buffer, \r | |
165 | IN INT64 Value, \r | |
166 | IN UINTN Radix\r | |
167 | );\r | |
168 | \r | |
169 | /**\r | |
170 | Internal function that converts a decimal value to a Null-terminated string.\r | |
171 | \r | |
172 | Converts the decimal number specified by Value to a Null-terminated \r | |
173 | string specified by Buffer containing at most Width characters.\r | |
174 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
175 | The total number of characters placed in Buffer is returned.\r | |
176 | If the conversion contains more than Width characters, then only the first\r | |
177 | Width characters are returned, and the total number of characters \r | |
178 | required to perform the conversion is returned.\r | |
179 | Additional conversion parameters are specified in Flags. \r | |
180 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
181 | All conversions are left justified in Buffer.\r | |
182 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
183 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r | |
184 | are inserted every 3rd digit starting from the right.\r | |
185 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
186 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r | |
187 | then Buffer is padded with '0' characters so the combination of the optional '-' \r | |
188 | sign character, '0' characters, digit characters for Value, and the Null-terminator\r | |
189 | add up to Width characters.\r | |
190 | \r | |
191 | If Buffer is NULL, then ASSERT().\r | |
192 | If unsupported bits are set in Flags, then ASSERT().\r | |
193 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
194 | \r | |
2fc59a00 | 195 | @param Buffer The pointer to the output buffer for the produced Null-terminated\r |
e1f414b6 | 196 | string.\r |
197 | @param Flags The bitmask of flags that specify left justification, zero pad,\r | |
198 | and commas.\r | |
199 | @param Value The 64-bit signed value to convert to a string.\r | |
200 | @param Width The maximum number of characters to place in Buffer, not including\r | |
201 | the Null-terminator.\r | |
202 | @param Increment Character increment in Buffer.\r | |
203 | \r | |
204 | @return Total number of characters required to perform the conversion.\r | |
205 | \r | |
206 | **/\r | |
207 | UINTN\r | |
208 | BasePrintLibConvertValueToString (\r | |
209 | IN OUT CHAR8 *Buffer,\r | |
210 | IN UINTN Flags,\r | |
211 | IN INT64 Value,\r | |
212 | IN UINTN Width,\r | |
213 | IN UINTN Increment\r | |
214 | );\r | |
215 | \r | |
51f0ceb4 HW |
216 | /**\r |
217 | Internal function that converts a decimal value to a Null-terminated string.\r | |
218 | \r | |
219 | Converts the decimal number specified by Value to a Null-terminated string\r | |
220 | specified by Buffer containing at most Width characters. If Width is 0 then a\r | |
221 | width of MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more\r | |
222 | than Width characters, then only the first Width characters are placed in\r | |
223 | Buffer. Additional conversion parameters are specified in Flags.\r | |
224 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
225 | All conversions are left justified in Buffer.\r | |
226 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
227 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and\r | |
228 | commas are inserted every 3rd digit starting from the right.\r | |
229 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
230 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,\r | |
231 | then Buffer is padded with '0' characters so the combination of the optional\r | |
232 | '-' sign character, '0' characters, digit characters for Value, and the\r | |
233 | Null-terminator add up to Width characters.\r | |
234 | \r | |
235 | If an error would be returned, the function will ASSERT().\r | |
236 | \r | |
237 | @param Buffer The pointer to the output buffer for the produced\r | |
238 | Null-terminated string.\r | |
239 | @param BufferSize The size of Buffer in bytes, including the\r | |
240 | Null-terminator.\r | |
241 | @param Flags The bitmask of flags that specify left justification,\r | |
242 | zero pad, and commas.\r | |
243 | @param Value The 64-bit signed value to convert to a string.\r | |
244 | @param Width The maximum number of characters to place in Buffer,\r | |
245 | not including the Null-terminator.\r | |
246 | @param Increment The character increment in Buffer.\r | |
247 | \r | |
248 | @retval RETURN_SUCCESS The decimal value is converted.\r | |
249 | @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted\r | |
250 | value.\r | |
251 | @retval RETURN_INVALID_PARAMETER If Buffer is NULL.\r | |
252 | If Increment is 1 and\r | |
253 | PcdMaximumAsciiStringLength is not zero,\r | |
254 | BufferSize is greater than\r | |
255 | PcdMaximumAsciiStringLength.\r | |
256 | If Increment is not 1 and\r | |
257 | PcdMaximumUnicodeStringLength is not zero,\r | |
258 | BufferSize is greater than\r | |
259 | (PcdMaximumUnicodeStringLength *\r | |
260 | sizeof (CHAR16) + 1).\r | |
261 | If unsupported bits are set in Flags.\r | |
262 | If both COMMA_TYPE and RADIX_HEX are set in\r | |
263 | Flags.\r | |
264 | If Width >= MAXIMUM_VALUE_CHARACTERS.\r | |
265 | \r | |
266 | **/\r | |
267 | RETURN_STATUS\r | |
268 | BasePrintLibConvertValueToStringS (\r | |
269 | IN OUT CHAR8 *Buffer,\r | |
270 | IN UINTN BufferSize,\r | |
271 | IN UINTN Flags,\r | |
272 | IN INT64 Value,\r | |
273 | IN UINTN Width,\r | |
274 | IN UINTN Increment\r | |
275 | );\r | |
276 | \r | |
e1f414b6 | 277 | #endif\r |