]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/PrintLib.h
Move NEXT_MEMORY_DESCRIPTOR() from UefiSpec.h to UEFI Library
[mirror_edk2.git] / MdePkg / Include / Library / PrintLib.h
CommitLineData
488ee641 1/** @file\r
50a64e5b 2 Provides services to print a formatted string to a buffer. All combinations of\r
3 Unicode and ASCII strings are supported.\r
488ee641 4\r
50a64e5b 5Copyright (c) 2006 - 2008, Intel Corporation\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
488ee641 10\r
50a64e5b 11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
488ee641 13\r
14**/\r
15\r
16#ifndef __PRINT_LIB_H__\r
17#define __PRINT_LIB_H__\r
18\r
19///\r
20/// Define the maximum number of characters that are required to\r
21/// encode a decimal, hexidecimal, GUID, or TIME value with a NULL \r
22/// terminator.\r
23/// \r
24/// Maximum Length Decimal String = 28\r
25/// "-9,223,372,036,854,775,808"\r
26/// Maximum Length Hexidecimal String = 17\r
27/// "FFFFFFFFFFFFFFFF"\r
28/// Maximum Length GUID = 37\r
29/// "00000000-0000-0000-0000-000000000000"\r
30/// Maximum Length TIME = 18\r
31/// "12/12/2006 12:12"\r
32///\r
33#define MAXIMUM_VALUE_CHARACTERS 38\r
34\r
35///\r
36/// Flags bitmask values use in UnicodeValueToString() and \r
37/// AsciiValueToString()\r
38///\r
39#define LEFT_JUSTIFY 0x01\r
40#define COMMA_TYPE 0x08\r
41#define PREFIX_ZERO 0x20\r
42#define RADIX_HEX 0x80\r
43\r
44/**\r
45 Produces a Null-terminated Unicode string in an output buffer based on \r
46 a Null-terminated Unicode format string and a VA_LIST argument list\r
47 \r
48 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
49 and BufferSize. \r
50 The Unicode string is produced by parsing the format string specified by FormatString. \r
51 Arguments are pulled from the variable argument list specified by Marker based on the \r
52 contents of the format string. \r
53 The number of Unicode characters in the produced output buffer is returned not including\r
54 the Null-terminator.\r
55 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
56\r
57 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
58 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
59 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
60 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
61 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
62 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
63 ASSERT().\r
64 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
65 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
66 Null-terminator, then ASSERT().\r
67\r
68 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
69 Unicode string.\r
70 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
71 @param FormatString Null-terminated Unicode format string.\r
72 @param Marker VA_LIST marker for the variable argument list.\r
73 \r
74 @return The number of Unicode characters in the produced output buffer not including the\r
75 Null-terminator.\r
76\r
77**/\r
78UINTN\r
79EFIAPI\r
80UnicodeVSPrint (\r
81 OUT CHAR16 *StartOfBuffer,\r
82 IN UINTN BufferSize,\r
83 IN CONST CHAR16 *FormatString,\r
84 IN VA_LIST Marker\r
85 );\r
86\r
87/**\r
88 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
89 Unicode format string and variable argument list.\r
90 \r
91 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
92 and BufferSize.\r
93 The Unicode string is produced by parsing the format string specified by FormatString.\r
94 Arguments are pulled from the variable argument list based on the contents of the format string.\r
95 The number of Unicode characters in the produced output buffer is returned not including\r
96 the Null-terminator.\r
97 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
98\r
99 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
100 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
101 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
102 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
103 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
104 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
105 ASSERT().\r
106 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
107 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
108 Null-terminator, then ASSERT().\r
109\r
110 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
111 Unicode string.\r
112 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
113 @param FormatString Null-terminated Unicode format string.\r
285010e7 114 @param ... Variable argument list whose contents are accessed based on the \r
115 format string specified by FormatString.\r
488ee641 116 \r
117 @return The number of Unicode characters in the produced output buffer not including the\r
118 Null-terminator.\r
119\r
120**/\r
121UINTN\r
122EFIAPI\r
123UnicodeSPrint (\r
124 OUT CHAR16 *StartOfBuffer,\r
125 IN UINTN BufferSize,\r
126 IN CONST CHAR16 *FormatString,\r
127 ...\r
128 );\r
129\r
130/**\r
131 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
132 ASCII format string and a VA_LIST argument list\r
133 \r
134 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
135 and BufferSize.\r
136 The Unicode string is produced by parsing the format string specified by FormatString.\r
137 Arguments are pulled from the variable argument list specified by Marker based on the \r
138 contents of the format string.\r
139 The number of Unicode characters in the produced output buffer is returned not including\r
140 the Null-terminator.\r
141 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
142\r
143 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
144 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
145 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
146 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
147 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
148 ASSERT().\r
149 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
150 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
151 Null-terminator, then ASSERT().\r
152\r
153 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
154 Unicode string.\r
155 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
156 @param FormatString Null-terminated ASCII format string.\r
157 @param Marker VA_LIST marker for the variable argument list.\r
158 \r
159 @return The number of Unicode characters in the produced output buffer not including the\r
160 Null-terminator.\r
161\r
162**/\r
163UINTN\r
164EFIAPI\r
165UnicodeVSPrintAsciiFormat (\r
166 OUT CHAR16 *StartOfBuffer,\r
167 IN UINTN BufferSize,\r
168 IN CONST CHAR8 *FormatString,\r
169 IN VA_LIST Marker\r
170 );\r
171\r
172/**\r
173 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
174 ASCII format string and variable argument list.\r
175 \r
176 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
177 and BufferSize.\r
178 The Unicode string is produced by parsing the format string specified by FormatString.\r
179 Arguments are pulled from the variable argument list based on the contents of the \r
180 format string.\r
181 The number of Unicode characters in the produced output buffer is returned not including\r
182 the Null-terminator.\r
183 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
184\r
185 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
186 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
187 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
188 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
189 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
190 ASSERT().\r
191 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
192 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
193 Null-terminator, then ASSERT().\r
194\r
195 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
196 Unicode string.\r
197 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
198 @param FormatString Null-terminated ASCII format string.\r
285010e7 199 @param ... Variable argument list whose contents are accessed based on the \r
200 format string specified by FormatString.\r
488ee641 201 \r
202 @return The number of Unicode characters in the produced output buffer not including the\r
203 Null-terminator.\r
204\r
205**/\r
206UINTN\r
207EFIAPI\r
208UnicodeSPrintAsciiFormat (\r
209 OUT CHAR16 *StartOfBuffer,\r
210 IN UINTN BufferSize,\r
211 IN CONST CHAR8 *FormatString,\r
212 ...\r
213 );\r
214\r
215/**\r
216 Converts a decimal value to a Null-terminated Unicode string.\r
217 \r
218 Converts the decimal number specified by Value to a Null-terminated Unicode \r
219 string specified by Buffer containing at most Width characters. No padding of spaces \r
220 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
221 The number of Unicode characters in Buffer is returned not including the Null-terminator.\r
222 If the conversion contains more than Width characters, then only the first\r
223 Width characters are returned, and the total number of characters \r
224 required to perform the conversion is returned.\r
225 Additional conversion parameters are specified in Flags. \r
226 \r
227 The Flags bit LEFT_JUSTIFY is always ignored.\r
228 All conversions are left justified in Buffer.\r
229 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
230 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
231 are inserted every 3rd digit starting from the right.\r
232 If HEX_RADIX is set in Flags, then the output buffer will be \r
233 formatted in hexadecimal format.\r
234 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r
235 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
236 then Buffer is padded with '0' characters so the combination of the optional '-' \r
237 sign character, '0' characters, digit characters for Value, and the Null-terminator\r
238 add up to Width characters.\r
239 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
240 If Buffer is NULL, then ASSERT().\r
241 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
242 If unsupported bits are set in Flags, then ASSERT().\r
243 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
244 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
245\r
246 @param Buffer Pointer to the output buffer for the produced Null-terminated\r
247 Unicode string.\r
248 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
249 @param Value The 64-bit signed value to convert to a string.\r
250 @param Width The maximum number of Unicode characters to place in Buffer, not including\r
251 the Null-terminator.\r
252 \r
253 @return The number of Unicode characters in Buffer not including the Null-terminator.\r
254\r
255**/\r
256UINTN\r
257EFIAPI\r
258UnicodeValueToString (\r
259 IN OUT CHAR16 *Buffer,\r
260 IN UINTN Flags,\r
261 IN INT64 Value,\r
262 IN UINTN Width\r
263 );\r
264\r
265/**\r
266 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
267 ASCII format string and a VA_LIST argument list.\r
268 \r
269 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
270 and BufferSize.\r
271 The ASCII string is produced by parsing the format string specified by FormatString.\r
272 Arguments are pulled from the variable argument list specified by Marker based on \r
273 the contents of the format string.\r
274 The number of ASCII characters in the produced output buffer is returned not including\r
275 the Null-terminator.\r
276 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
277\r
278 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
279 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
280 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
281 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
282 ASSERT().\r
283 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
284 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
285 Null-terminator, then ASSERT().\r
286\r
287 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
288 ASCII string.\r
289 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
290 @param FormatString Null-terminated ASCII format string.\r
291 @param Marker VA_LIST marker for the variable argument list.\r
292 \r
293 @return The number of ASCII characters in the produced output buffer not including the\r
294 Null-terminator.\r
295\r
296**/\r
297UINTN\r
298EFIAPI\r
299AsciiVSPrint (\r
300 OUT CHAR8 *StartOfBuffer,\r
301 IN UINTN BufferSize,\r
302 IN CONST CHAR8 *FormatString,\r
303 IN VA_LIST Marker\r
304 );\r
305\r
306/**\r
307 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
308 ASCII format string and variable argument list.\r
309 \r
310 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
311 and BufferSize.\r
312 The ASCII string is produced by parsing the format string specified by FormatString.\r
313 Arguments are pulled from the variable argument list based on the contents of the \r
314 format string.\r
315 The number of ASCII characters in the produced output buffer is returned not including\r
316 the Null-terminator.\r
317 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
318\r
319 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
320 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
321 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
322 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
323 ASSERT().\r
324 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
325 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
326 Null-terminator, then ASSERT().\r
327\r
328 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
329 ASCII string.\r
330 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
331 @param FormatString Null-terminated ASCII format string.\r
285010e7 332 @param ... Variable argument list whose contents are accessed based on the \r
333 format string specified by FormatString.\r
488ee641 334 \r
335 @return The number of ASCII characters in the produced output buffer not including the\r
336 Null-terminator.\r
337\r
338**/\r
339UINTN\r
340EFIAPI\r
341AsciiSPrint (\r
342 OUT CHAR8 *StartOfBuffer,\r
343 IN UINTN BufferSize,\r
344 IN CONST CHAR8 *FormatString,\r
345 ...\r
346 );\r
347\r
348/**\r
349 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
350 Unicode format string and a VA_LIST argument list.\r
351 \r
352 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
353 and BufferSize.\r
354 The ASCII string is produced by parsing the format string specified by FormatString.\r
355 Arguments are pulled from the variable argument list specified by Marker based on \r
356 the contents of the format string.\r
357 The number of ASCII characters in the produced output buffer is returned not including\r
358 the Null-terminator.\r
359 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
360\r
361 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
362 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
363 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
364 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
365 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
366 ASSERT().\r
367 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
368 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
369 Null-terminator, then ASSERT().\r
370\r
371 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
372 ASCII string.\r
373 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
374 @param FormatString Null-terminated Unicode format string.\r
375 @param Marker VA_LIST marker for the variable argument list.\r
376 \r
377 @return The number of ASCII characters in the produced output buffer not including the\r
378 Null-terminator.\r
379\r
380**/\r
381UINTN\r
382EFIAPI\r
383AsciiVSPrintUnicodeFormat (\r
384 OUT CHAR8 *StartOfBuffer,\r
385 IN UINTN BufferSize,\r
386 IN CONST CHAR16 *FormatString,\r
387 IN VA_LIST Marker\r
388 );\r
389\r
390/**\r
391 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
392 Unicode format string and variable argument list.\r
393 \r
394 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
395 and BufferSize.\r
396 The ASCII string is produced by parsing the format string specified by FormatString.\r
397 Arguments are pulled from the variable argument list based on the contents of the \r
398 format string.\r
399 The number of ASCII characters in the produced output buffer is returned not including\r
400 the Null-terminator.\r
401 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
402\r
403 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
404 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
405 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
406 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
407 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
408 ASSERT().\r
409 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
410 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
411 Null-terminator, then ASSERT().\r
412\r
413 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
414 ASCII string.\r
415 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
416 @param FormatString Null-terminated Unicode format string.\r
285010e7 417 @param ... Variable argument list whose contents are accessed based on the \r
418 format string specified by FormatString.\r
488ee641 419 \r
420 @return The number of ASCII characters in the produced output buffer not including the\r
421 Null-terminator.\r
422\r
423**/\r
424UINTN\r
425EFIAPI\r
426AsciiSPrintUnicodeFormat (\r
427 OUT CHAR8 *StartOfBuffer,\r
428 IN UINTN BufferSize,\r
429 IN CONST CHAR16 *FormatString,\r
430 ...\r
431 );\r
432\r
433/**\r
434 Converts a decimal value to a Null-terminated ASCII string.\r
435 \r
436 Converts the decimal number specified by Value to a Null-terminated ASCII string \r
437 specified by Buffer containing at most Width characters. No padding of spaces \r
438 is ever performed.\r
439 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
440 The number of ASCII characters in Buffer is returned not including the Null-terminator.\r
441 If the conversion contains more than Width characters, then only the first Width\r
442 characters are returned, and the total number of characters required to perform\r
443 the conversion is returned.\r
444 Additional conversion parameters are specified in Flags. \r
445 The Flags bit LEFT_JUSTIFY is always ignored.\r
446 All conversions are left justified in Buffer.\r
447 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
448 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
449 are inserted every 3rd digit starting from the right.\r
450 If HEX_RADIX is set in Flags, then the output buffer will be \r
451 formatted in hexadecimal format.\r
452 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r
453 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
454 then Buffer is padded with '0' characters so the combination of the optional '-' \r
455 sign character, '0' characters, digit characters for Value, and the Null-terminator\r
456 add up to Width characters.\r
457 \r
458 If Buffer is NULL, then ASSERT().\r
459 If unsupported bits are set in Flags, then ASSERT().\r
460 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
461 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
462\r
463 @param Buffer Pointer to the output buffer for the produced Null-terminated\r
464 ASCII string.\r
465 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
466 @param Value The 64-bit signed value to convert to a string.\r
467 @param Width The maximum number of ASCII characters to place in Buffer, not including\r
468 the Null-terminator.\r
469 \r
470 @return The number of ASCII characters in Buffer not including the Null-terminator.\r
471\r
472**/\r
473UINTN\r
474EFIAPI\r
475AsciiValueToString (\r
58125b7a 476 OUT CHAR8 *Buffer,\r
477 IN UINTN Flags,\r
478 IN INT64 Value,\r
479 IN UINTN Width\r
488ee641 480 );\r
481\r
482#endif\r