]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Library/PrintLib.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Include / Library / PrintLib.h
... / ...
CommitLineData
1/** @file\r
2 Provides services to print a formatted string to a buffer. All combinations of\r
3 Unicode and ASCII strings are supported.\r
4\r
5Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
6SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8 The Print Library functions provide a simple means to produce formatted output\r
9 strings. Many of the output functions use a format string to describe how to\r
10 format the output of variable arguments. The format string consists of normal\r
11 text and argument descriptors. There are no restrictions for how the normal\r
12 text and argument descriptors can be mixed. The following end of line(EOL)\r
13 translations must be performed on the contents of the format string:\r
14\r
15 - '\\r' is translated to '\\r'\r
16 - '\\r\\n' is translated to '\\r\\n'\r
17 - '\\n' is translated to '\\r\\n'\r
18 - '\\n\\r' is translated to '\\r\\n'\r
19\r
20 This does not follow the ANSI C standard for sprint(). The format of argument\r
21 descriptors is described below. The ANSI C standard for sprint() has been\r
22 followed for some of the format types, and has not been followed for others.\r
23 The exceptions are noted below.\r
24\r
25 %[flags][width][.precision]type\r
26\r
27 [flags]:\r
28 - -\r
29 - The field is left justified. If not flag is not specified, then the\r
30 field is right justified.\r
31 - space\r
32 - Prefix a space character to a number. Only valid for types X, x, and d.\r
33 - +\r
34 - Prefix a plus character to a number. Only valid for types X, x, and d.\r
35 If both space and + are specified, then space is ignored.\r
36 - 0\r
37 - Pad with 0 characters to the left of a number. Only valid for types\r
38 X, x, and d.\r
39 - ,\r
40 - Place a comma every 3rd digit of the number. Only valid for type d.\r
41 If 0 is also specified, then 0 is ignored.\r
42 - L, l\r
43 - The number being printed is size UINT64. Only valid for types X, x, and d.\r
44 If this flag is not specified, then the number being printed is size int.\r
45 - NOTE: All invalid flags are ignored.\r
46\r
47 [width]:\r
48\r
49 - *\r
50 - The width of the field is specified by a UINTN argument in the\r
51 argument list.\r
52 - number\r
53 - The number specified as a decimal value represents the width of\r
54 the field.\r
55 - NOTE: If [width] is not specified, then a field width of 0 is assumed.\r
56\r
57 [.precision]:\r
58\r
59 - *\r
60 - The precision of the field is specified by a UINTN argument in the\r
61 argument list.\r
62 - number\r
63 - The number specified as a decimal value represents the precision of\r
64 the field.\r
65 - NOTE: If [.precision] is not specified, then a precision of 0 is assumed.\r
66\r
67 type:\r
68\r
69 - %\r
70 - Print a %%.\r
71 - c\r
72 - The argument is a Unicode character. ASCII characters can be printed\r
73 using this type too by making sure bits 8..15 of the argument are set to 0.\r
74 - x\r
75 - The argument is an unsigned hexadecimal number. The characters used are 0..9 and\r
76 A..F. If the flag 'L' is not specified, then the argument is assumed\r
77 to be size int. This does not follow ANSI C.\r
78 - X\r
79 - The argument is an unsigned hexadecimal number and the number is padded with\r
80 zeros. This is equivalent to a format string of "0x". If the flag\r
81 'L' is not specified, then the argument is assumed to be size int.\r
82 This does not follow ANSI C.\r
83 - d\r
84 - The argument is a signed decimal number. If the flag 'L' is not specified,\r
85 then the argument is assumed to be size int.\r
86 - u\r
87 - The argument is a unsigned decimal number. If the flag 'L' is not specified,\r
88 then the argument is assumed to be size int.\r
89 - p\r
90 - The argument is a pointer that is a (VOID *), and it is printed as an\r
91 unsigned hexadecimal number The characters used are 0..9 and A..F.\r
92 - a\r
93 - The argument is a pointer to an ASCII string.\r
94 This does not follow ANSI C.\r
95 - S, s\r
96 - The argument is a pointer to a Unicode string.\r
97 This does not follow ANSI C.\r
98 - g\r
99 - The argument is a pointer to a GUID structure. The GUID is printed\r
100 in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.\r
101 This does not follow ANSI C.\r
102 - t\r
103 - The argument is a pointer to an EFI_TIME structure. The time and\r
104 date are printed in the format "mm/dd/yyyy hh:mm" where mm is the\r
105 month zero padded, dd is the day zero padded, yyyy is the year zero\r
106 padded, hh is the hour zero padded, and mm is minutes zero padded.\r
107 This does not follow ANSI C.\r
108 - r\r
109 - The argument is a RETURN_STATUS value. This value is converted to\r
110 a string following the table below. This does not follow ANSI C.\r
111 - RETURN_SUCCESS\r
112 - "Success"\r
113 - RETURN_LOAD_ERROR\r
114 - "Load Error"\r
115 - RETURN_INVALID_PARAMETER\r
116 - "Invalid Parameter"\r
117 - RETURN_UNSUPPORTED\r
118 - "Unsupported"\r
119 - RETURN_BAD_BUFFER_SIZE\r
120 - "Bad Buffer Size"\r
121 - RETURN_BUFFER_TOO_SMALL\r
122 - "Buffer Too Small"\r
123 - RETURN_NOT_READY\r
124 - "Not Ready"\r
125 - RETURN_DEVICE_ERROR\r
126 - "Device Error"\r
127 - RETURN_WRITE_PROTECTED\r
128 - "Write Protected"\r
129 - RETURN_OUT_OF_RESOURCES\r
130 - "Out of Resources"\r
131 - RETURN_VOLUME_CORRUPTED\r
132 - "Volume Corrupt"\r
133 - RETURN_VOLUME_FULL\r
134 - "Volume Full"\r
135 - RETURN_NO_MEDIA\r
136 - "No Media"\r
137 - RETURN_MEDIA_CHANGED\r
138 - "Media changed"\r
139 - RETURN_NOT_FOUND\r
140 - "Not Found"\r
141 - RETURN_ACCESS_DENIED\r
142 - "Access Denied"\r
143 - RETURN_NO_RESPONSE\r
144 - "No Response"\r
145 - RETURN_NO_MAPPING\r
146 - "No mapping"\r
147 - RETURN_TIMEOUT\r
148 - "Time out"\r
149 - RETURN_NOT_STARTED\r
150 - "Not started"\r
151 - RETURN_ALREADY_STARTED\r
152 - "Already started"\r
153 - RETURN_ABORTED\r
154 - "Aborted"\r
155 - RETURN_ICMP_ERROR\r
156 - "ICMP Error"\r
157 - RETURN_TFTP_ERROR\r
158 - "TFTP Error"\r
159 - RETURN_PROTOCOL_ERROR\r
160 - "Protocol Error"\r
161 - RETURN_WARN_UNKNOWN_GLYPH\r
162 - "Warning Unknown Glyph"\r
163 - RETURN_WARN_DELETE_FAILURE\r
164 - "Warning Delete Failure"\r
165 - RETURN_WARN_WRITE_FAILURE\r
166 - "Warning Write Failure"\r
167 - RETURN_WARN_BUFFER_TOO_SMALL\r
168 - "Warning Buffer Too Small"\r
169\r
170**/\r
171\r
172#ifndef __PRINT_LIB_H__\r
173#define __PRINT_LIB_H__\r
174\r
175///\r
176/// Define the maximum number of characters that are required to\r
177/// encode with a NULL terminator a decimal, hexadecimal, GUID,\r
178/// or TIME value.\r
179///\r
180/// Maximum Length Decimal String = 28\r
181/// "-9,223,372,036,854,775,808"\r
182/// Maximum Length Hexadecimal String = 17\r
183/// "FFFFFFFFFFFFFFFF"\r
184/// Maximum Length GUID = 37\r
185/// "00000000-0000-0000-0000-000000000000"\r
186/// Maximum Length TIME = 18\r
187/// "12/12/2006 12:12"\r
188///\r
189#define MAXIMUM_VALUE_CHARACTERS 38\r
190\r
191///\r
192/// Flags bitmask values use in UnicodeValueToString() and\r
193/// AsciiValueToString()\r
194///\r
195#define LEFT_JUSTIFY 0x01\r
196#define COMMA_TYPE 0x08\r
197#define PREFIX_ZERO 0x20\r
198#define RADIX_HEX 0x80\r
199\r
200/**\r
201 Produces a Null-terminated Unicode string in an output buffer based on\r
202 a Null-terminated Unicode format string and a VA_LIST argument list.\r
203\r
204 This function is similar as vsnprintf_s defined in C11.\r
205\r
206 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
207 and BufferSize.\r
208 The Unicode string is produced by parsing the format string specified by FormatString.\r
209 Arguments are pulled from the variable argument list specified by Marker based on the\r
210 contents of the format string.\r
211 The number of Unicode characters in the produced output buffer is returned not including\r
212 the Null-terminator.\r
213\r
214 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
215 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
216\r
217 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
218 unmodified and 0 is returned.\r
219 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
220 unmodified and 0 is returned.\r
221 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
222 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
223 buffer is unmodified and 0 is returned.\r
224 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
225 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
226 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
227\r
228 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.\r
229\r
230 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
231 Unicode string.\r
232 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
233 @param FormatString A Null-terminated Unicode format string.\r
234 @param Marker VA_LIST marker for the variable argument list.\r
235\r
236 @return The number of Unicode characters in the produced output buffer not including the\r
237 Null-terminator.\r
238\r
239**/\r
240UINTN\r
241EFIAPI\r
242UnicodeVSPrint (\r
243 OUT CHAR16 *StartOfBuffer,\r
244 IN UINTN BufferSize,\r
245 IN CONST CHAR16 *FormatString,\r
246 IN VA_LIST Marker\r
247 );\r
248\r
249/**\r
250 Produces a Null-terminated Unicode string in an output buffer based on\r
251 a Null-terminated Unicode format string and a BASE_LIST argument list.\r
252\r
253 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
254 and BufferSize.\r
255 The Unicode string is produced by parsing the format string specified by FormatString.\r
256 Arguments are pulled from the variable argument list specified by Marker based on the\r
257 contents of the format string.\r
258 The number of Unicode characters in the produced output buffer is returned not including\r
259 the Null-terminator.\r
260\r
261 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
262 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
263\r
264 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
265 unmodified and 0 is returned.\r
266 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
267 unmodified and 0 is returned.\r
268 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
269 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
270 buffer is unmodified and 0 is returned.\r
271 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
272 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
273 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
274\r
275 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.\r
276\r
277 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
278 Unicode string.\r
279 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
280 @param FormatString A Null-terminated Unicode format string.\r
281 @param Marker BASE_LIST marker for the variable argument list.\r
282\r
283 @return The number of Unicode characters in the produced output buffer not including the\r
284 Null-terminator.\r
285\r
286**/\r
287UINTN\r
288EFIAPI\r
289UnicodeBSPrint (\r
290 OUT CHAR16 *StartOfBuffer,\r
291 IN UINTN BufferSize,\r
292 IN CONST CHAR16 *FormatString,\r
293 IN BASE_LIST Marker\r
294 );\r
295\r
296/**\r
297 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
298 Unicode format string and variable argument list.\r
299\r
300 This function is similar as snprintf_s defined in C11.\r
301\r
302 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
303 and BufferSize.\r
304 The Unicode string is produced by parsing the format string specified by FormatString.\r
305 Arguments are pulled from the variable argument list based on the contents of the format string.\r
306 The number of Unicode characters in the produced output buffer is returned not including\r
307 the Null-terminator.\r
308\r
309 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
310 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
311\r
312 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
313 unmodified and 0 is returned.\r
314 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
315 unmodified and 0 is returned.\r
316 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
317 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
318 buffer is unmodified and 0 is returned.\r
319 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
320 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
321 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
322\r
323 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.\r
324\r
325 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
326 Unicode string.\r
327 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
328 @param FormatString A Null-terminated Unicode format string.\r
329 @param ... Variable argument list whose contents are accessed based on the\r
330 format string specified by FormatString.\r
331\r
332 @return The number of Unicode characters in the produced output buffer not including the\r
333 Null-terminator.\r
334\r
335**/\r
336UINTN\r
337EFIAPI\r
338UnicodeSPrint (\r
339 OUT CHAR16 *StartOfBuffer,\r
340 IN UINTN BufferSize,\r
341 IN CONST CHAR16 *FormatString,\r
342 ...\r
343 );\r
344\r
345/**\r
346 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
347 ASCII format string and a VA_LIST argument list.\r
348\r
349 This function is similar as vsnprintf_s defined in C11.\r
350\r
351 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
352 and BufferSize.\r
353 The Unicode string is produced by parsing the format string specified by FormatString.\r
354 Arguments are pulled from the variable argument list specified by Marker based on the\r
355 contents of the format string.\r
356 The number of Unicode characters in the produced output buffer is returned not including\r
357 the Null-terminator.\r
358\r
359 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
360\r
361 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
362 unmodified and 0 is returned.\r
363 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
364 unmodified and 0 is returned.\r
365 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
366 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
367 buffer is unmodified and 0 is returned.\r
368 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
369 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
370 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
371\r
372 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
373\r
374 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
375 Unicode string.\r
376 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
377 @param FormatString A Null-terminated ASCII format string.\r
378 @param Marker VA_LIST marker for the variable argument list.\r
379\r
380 @return The number of Unicode characters in the produced output buffer not including the\r
381 Null-terminator.\r
382\r
383**/\r
384UINTN\r
385EFIAPI\r
386UnicodeVSPrintAsciiFormat (\r
387 OUT CHAR16 *StartOfBuffer,\r
388 IN UINTN BufferSize,\r
389 IN CONST CHAR8 *FormatString,\r
390 IN VA_LIST Marker\r
391 );\r
392\r
393/**\r
394 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
395 ASCII format string and a BASE_LIST argument list.\r
396\r
397 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
398 and BufferSize.\r
399 The Unicode string is produced by parsing the format string specified by FormatString.\r
400 Arguments are pulled from the variable argument list specified by Marker based on the\r
401 contents of the format string.\r
402 The number of Unicode characters in the produced output buffer is returned not including\r
403 the Null-terminator.\r
404\r
405 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
406\r
407 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
408 unmodified and 0 is returned.\r
409 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
410 unmodified and 0 is returned.\r
411 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
412 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
413 buffer is unmodified and 0 is returned.\r
414 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
415 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
416 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
417\r
418 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
419\r
420 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
421 Unicode string.\r
422 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
423 @param FormatString A Null-terminated ASCII format string.\r
424 @param Marker BASE_LIST marker for the variable argument list.\r
425\r
426 @return The number of Unicode characters in the produced output buffer not including the\r
427 Null-terminator.\r
428\r
429**/\r
430UINTN\r
431EFIAPI\r
432UnicodeBSPrintAsciiFormat (\r
433 OUT CHAR16 *StartOfBuffer,\r
434 IN UINTN BufferSize,\r
435 IN CONST CHAR8 *FormatString,\r
436 IN BASE_LIST Marker\r
437 );\r
438\r
439/**\r
440 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
441 ASCII format string and variable argument list.\r
442\r
443 This function is similar as snprintf_s defined in C11.\r
444\r
445 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
446 and BufferSize.\r
447 The Unicode string is produced by parsing the format string specified by FormatString.\r
448 Arguments are pulled from the variable argument list based on the contents of the\r
449 format string.\r
450 The number of Unicode characters in the produced output buffer is returned not including\r
451 the Null-terminator.\r
452\r
453 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
454\r
455 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
456 unmodified and 0 is returned.\r
457 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
458 unmodified and 0 is returned.\r
459 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
460 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
461 buffer is unmodified and 0 is returned.\r
462 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
463 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
464 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
465\r
466 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
467\r
468 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
469 Unicode string.\r
470 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
471 @param FormatString A Null-terminated ASCII format string.\r
472 @param ... Variable argument list whose contents are accessed based on the\r
473 format string specified by FormatString.\r
474\r
475 @return The number of Unicode characters in the produced output buffer not including the\r
476 Null-terminator.\r
477\r
478**/\r
479UINTN\r
480EFIAPI\r
481UnicodeSPrintAsciiFormat (\r
482 OUT CHAR16 *StartOfBuffer,\r
483 IN UINTN BufferSize,\r
484 IN CONST CHAR8 *FormatString,\r
485 ...\r
486 );\r
487\r
488/**\r
489 Converts a decimal value to a Null-terminated Unicode string.\r
490\r
491 Converts the decimal number specified by Value to a Null-terminated Unicode\r
492 string specified by Buffer containing at most Width characters. No padding of\r
493 spaces is ever performed. If Width is 0 then a width of\r
494 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than\r
495 Width characters, then only the first Width characters are placed in Buffer.\r
496 Additional conversion parameters are specified in Flags.\r
497\r
498 The Flags bit LEFT_JUSTIFY is always ignored.\r
499 All conversions are left justified in Buffer.\r
500 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
501 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and\r
502 commas are inserted every 3rd digit starting from the right.\r
503 If RADIX_HEX is set in Flags, then the output buffer will be formatted in\r
504 hexadecimal format.\r
505 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in\r
506 Buffer is a '-'.\r
507 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then\r
508 Buffer is padded with '0' characters so the combination of the optional '-'\r
509 sign character, '0' characters, digit characters for Value, and the\r
510 Null-terminator add up to Width characters.\r
511\r
512 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
513 If an error would be returned, then the function will also ASSERT().\r
514\r
515 @param Buffer The pointer to the output buffer for the produced\r
516 Null-terminated Unicode string.\r
517 @param BufferSize The size of Buffer in bytes, including the\r
518 Null-terminator.\r
519 @param Flags The bitmask of flags that specify left justification,\r
520 zero pad, and commas.\r
521 @param Value The 64-bit signed value to convert to a string.\r
522 @param Width The maximum number of Unicode characters to place in\r
523 Buffer, not including the Null-terminator.\r
524\r
525 @retval RETURN_SUCCESS The decimal value is converted.\r
526 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted\r
527 value.\r
528 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.\r
529 If PcdMaximumUnicodeStringLength is not\r
530 zero, and BufferSize is greater than\r
531 (PcdMaximumUnicodeStringLength *\r
532 sizeof (CHAR16) + 1).\r
533 If unsupported bits are set in Flags.\r
534 If both COMMA_TYPE and RADIX_HEX are set in\r
535 Flags.\r
536 If Width >= MAXIMUM_VALUE_CHARACTERS.\r
537\r
538**/\r
539RETURN_STATUS\r
540EFIAPI\r
541UnicodeValueToStringS (\r
542 IN OUT CHAR16 *Buffer,\r
543 IN UINTN BufferSize,\r
544 IN UINTN Flags,\r
545 IN INT64 Value,\r
546 IN UINTN Width\r
547 );\r
548\r
549/**\r
550 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
551 ASCII format string and a VA_LIST argument list.\r
552\r
553 This function is similar as vsnprintf_s defined in C11.\r
554\r
555 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
556 and BufferSize.\r
557 The ASCII string is produced by parsing the format string specified by FormatString.\r
558 Arguments are pulled from the variable argument list specified by Marker based on\r
559 the contents of the format string.\r
560 The number of ASCII characters in the produced output buffer is returned not including\r
561 the Null-terminator.\r
562\r
563 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
564 unmodified and 0 is returned.\r
565 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
566 unmodified and 0 is returned.\r
567 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
568 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
569 is unmodified and 0 is returned.\r
570 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
571 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
572 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
573\r
574 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
575\r
576 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
577 ASCII string.\r
578 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
579 @param FormatString A Null-terminated ASCII format string.\r
580 @param Marker VA_LIST marker for the variable argument list.\r
581\r
582 @return The number of ASCII characters in the produced output buffer not including the\r
583 Null-terminator.\r
584\r
585**/\r
586UINTN\r
587EFIAPI\r
588AsciiVSPrint (\r
589 OUT CHAR8 *StartOfBuffer,\r
590 IN UINTN BufferSize,\r
591 IN CONST CHAR8 *FormatString,\r
592 IN VA_LIST Marker\r
593 );\r
594\r
595/**\r
596 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
597 ASCII format string and a BASE_LIST argument list.\r
598\r
599 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
600 and BufferSize.\r
601 The ASCII string is produced by parsing the format string specified by FormatString.\r
602 Arguments are pulled from the variable argument list specified by Marker based on\r
603 the contents of the format string.\r
604 The number of ASCII characters in the produced output buffer is returned not including\r
605 the Null-terminator.\r
606\r
607 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
608 unmodified and 0 is returned.\r
609 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
610 unmodified and 0 is returned.\r
611 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
612 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
613 is unmodified and 0 is returned.\r
614 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
615 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
616 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
617\r
618 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
619\r
620 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
621 ASCII string.\r
622 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
623 @param FormatString A Null-terminated ASCII format string.\r
624 @param Marker BASE_LIST marker for the variable argument list.\r
625\r
626 @return The number of ASCII characters in the produced output buffer not including the\r
627 Null-terminator.\r
628\r
629**/\r
630UINTN\r
631EFIAPI\r
632AsciiBSPrint (\r
633 OUT CHAR8 *StartOfBuffer,\r
634 IN UINTN BufferSize,\r
635 IN CONST CHAR8 *FormatString,\r
636 IN BASE_LIST Marker\r
637 );\r
638\r
639/**\r
640 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
641 ASCII format string and variable argument list.\r
642\r
643 This function is similar as snprintf_s defined in C11.\r
644\r
645 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
646 and BufferSize.\r
647 The ASCII string is produced by parsing the format string specified by FormatString.\r
648 Arguments are pulled from the variable argument list based on the contents of the\r
649 format string.\r
650 The number of ASCII characters in the produced output buffer is returned not including\r
651 the Null-terminator.\r
652\r
653 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
654 unmodified and 0 is returned.\r
655 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
656 unmodified and 0 is returned.\r
657 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
658 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
659 is unmodified and 0 is returned.\r
660 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
661 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
662 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
663\r
664 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
665\r
666 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
667 ASCII string.\r
668 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
669 @param FormatString A Null-terminated ASCII format string.\r
670 @param ... Variable argument list whose contents are accessed based on the\r
671 format string specified by FormatString.\r
672\r
673 @return The number of ASCII characters in the produced output buffer not including the\r
674 Null-terminator.\r
675\r
676**/\r
677UINTN\r
678EFIAPI\r
679AsciiSPrint (\r
680 OUT CHAR8 *StartOfBuffer,\r
681 IN UINTN BufferSize,\r
682 IN CONST CHAR8 *FormatString,\r
683 ...\r
684 );\r
685\r
686/**\r
687 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
688 Unicode format string and a VA_LIST argument list.\r
689\r
690 This function is similar as vsnprintf_s defined in C11.\r
691\r
692 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
693 and BufferSize.\r
694 The ASCII string is produced by parsing the format string specified by FormatString.\r
695 Arguments are pulled from the variable argument list specified by Marker based on\r
696 the contents of the format string.\r
697 The number of ASCII characters in the produced output buffer is returned not including\r
698 the Null-terminator.\r
699\r
700 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
701\r
702 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
703 unmodified and 0 is returned.\r
704 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
705 unmodified and 0 is returned.\r
706 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
707 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
708 is unmodified and 0 is returned.\r
709 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
710 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
711 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
712\r
713 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
714\r
715 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
716 ASCII string.\r
717 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
718 @param FormatString A Null-terminated Unicode format string.\r
719 @param Marker VA_LIST marker for the variable argument list.\r
720\r
721 @return The number of ASCII characters in the produced output buffer not including the\r
722 Null-terminator.\r
723\r
724**/\r
725UINTN\r
726EFIAPI\r
727AsciiVSPrintUnicodeFormat (\r
728 OUT CHAR8 *StartOfBuffer,\r
729 IN UINTN BufferSize,\r
730 IN CONST CHAR16 *FormatString,\r
731 IN VA_LIST Marker\r
732 );\r
733\r
734/**\r
735 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
736 Unicode format string and a BASE_LIST argument list.\r
737\r
738 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
739 and BufferSize.\r
740 The ASCII string is produced by parsing the format string specified by FormatString.\r
741 Arguments are pulled from the variable argument list specified by Marker based on\r
742 the contents of the format string.\r
743 The number of ASCII characters in the produced output buffer is returned not including\r
744 the Null-terminator.\r
745\r
746 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
747\r
748 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
749 unmodified and 0 is returned.\r
750 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
751 unmodified and 0 is returned.\r
752 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
753 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
754 is unmodified and 0 is returned.\r
755 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
756 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
757 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
758\r
759 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
760\r
761 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
762 ASCII string.\r
763 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
764 @param FormatString A Null-terminated Unicode format string.\r
765 @param Marker BASE_LIST marker for the variable argument list.\r
766\r
767 @return The number of ASCII characters in the produced output buffer not including the\r
768 Null-terminator.\r
769\r
770**/\r
771UINTN\r
772EFIAPI\r
773AsciiBSPrintUnicodeFormat (\r
774 OUT CHAR8 *StartOfBuffer,\r
775 IN UINTN BufferSize,\r
776 IN CONST CHAR16 *FormatString,\r
777 IN BASE_LIST Marker\r
778 );\r
779\r
780/**\r
781 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
782 Unicode format string and variable argument list.\r
783\r
784 This function is similar as snprintf_s defined in C11.\r
785\r
786 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
787 and BufferSize.\r
788 The ASCII string is produced by parsing the format string specified by FormatString.\r
789 Arguments are pulled from the variable argument list based on the contents of the\r
790 format string.\r
791 The number of ASCII characters in the produced output buffer is returned not including\r
792 the Null-terminator.\r
793\r
794 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
795\r
796 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
797 unmodified and 0 is returned.\r
798 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
799 unmodified and 0 is returned.\r
800 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
801 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
802 is unmodified and 0 is returned.\r
803 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
804 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
805 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
806\r
807 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
808\r
809 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
810 ASCII string.\r
811 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
812 @param FormatString A Null-terminated Unicode format string.\r
813 @param ... Variable argument list whose contents are accessed based on the\r
814 format string specified by FormatString.\r
815\r
816 @return The number of ASCII characters in the produced output buffer not including the\r
817 Null-terminator.\r
818\r
819**/\r
820UINTN\r
821EFIAPI\r
822AsciiSPrintUnicodeFormat (\r
823 OUT CHAR8 *StartOfBuffer,\r
824 IN UINTN BufferSize,\r
825 IN CONST CHAR16 *FormatString,\r
826 ...\r
827 );\r
828\r
829/**\r
830 Converts a decimal value to a Null-terminated Ascii string.\r
831\r
832 Converts the decimal number specified by Value to a Null-terminated Ascii\r
833 string specified by Buffer containing at most Width characters. No padding of\r
834 spaces is ever performed. If Width is 0 then a width of\r
835 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than\r
836 Width characters, then only the first Width characters are placed in Buffer.\r
837 Additional conversion parameters are specified in Flags.\r
838\r
839 The Flags bit LEFT_JUSTIFY is always ignored.\r
840 All conversions are left justified in Buffer.\r
841 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
842 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and\r
843 commas are inserted every 3rd digit starting from the right.\r
844 If RADIX_HEX is set in Flags, then the output buffer will be formatted in\r
845 hexadecimal format.\r
846 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in\r
847 Buffer is a '-'.\r
848 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then\r
849 Buffer is padded with '0' characters so the combination of the optional '-'\r
850 sign character, '0' characters, digit characters for Value, and the\r
851 Null-terminator add up to Width characters.\r
852\r
853 If an error would be returned, then the function will ASSERT().\r
854\r
855 @param Buffer The pointer to the output buffer for the produced\r
856 Null-terminated Ascii string.\r
857 @param BufferSize The size of Buffer in bytes, including the\r
858 Null-terminator.\r
859 @param Flags The bitmask of flags that specify left justification,\r
860 zero pad, and commas.\r
861 @param Value The 64-bit signed value to convert to a string.\r
862 @param Width The maximum number of Ascii characters to place in\r
863 Buffer, not including the Null-terminator.\r
864\r
865 @retval RETURN_SUCCESS The decimal value is converted.\r
866 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted\r
867 value.\r
868 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.\r
869 If PcdMaximumAsciiStringLength is not\r
870 zero, and BufferSize is greater than\r
871 PcdMaximumAsciiStringLength.\r
872 If unsupported bits are set in Flags.\r
873 If both COMMA_TYPE and RADIX_HEX are set in\r
874 Flags.\r
875 If Width >= MAXIMUM_VALUE_CHARACTERS.\r
876\r
877**/\r
878RETURN_STATUS\r
879EFIAPI\r
880AsciiValueToStringS (\r
881 IN OUT CHAR8 *Buffer,\r
882 IN UINTN BufferSize,\r
883 IN UINTN Flags,\r
884 IN INT64 Value,\r
885 IN UINTN Width\r
886 );\r
887\r
888/**\r
889 Returns the number of characters that would be produced by if the formatted\r
890 output were produced not including the Null-terminator.\r
891\r
892 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
893\r
894 If FormatString is NULL, then ASSERT() and 0 is returned.\r
895 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more\r
896 than PcdMaximumUnicodeStringLength Unicode characters not including the\r
897 Null-terminator, then ASSERT() and 0 is returned.\r
898\r
899 @param[in] FormatString A Null-terminated Unicode format string.\r
900 @param[in] Marker VA_LIST marker for the variable argument list.\r
901\r
902 @return The number of characters that would be produced, not including the\r
903 Null-terminator.\r
904**/\r
905UINTN\r
906EFIAPI\r
907SPrintLength (\r
908 IN CONST CHAR16 *FormatString,\r
909 IN VA_LIST Marker\r
910 );\r
911\r
912/**\r
913 Returns the number of characters that would be produced by if the formatted\r
914 output were produced not including the Null-terminator.\r
915\r
916 If FormatString is NULL, then ASSERT() and 0 is returned.\r
917 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more\r
918 than PcdMaximumAsciiStringLength Ascii characters not including the\r
919 Null-terminator, then ASSERT() and 0 is returned.\r
920\r
921 @param[in] FormatString A Null-terminated ASCII format string.\r
922 @param[in] Marker VA_LIST marker for the variable argument list.\r
923\r
924 @return The number of characters that would be produced, not including the\r
925 Null-terminator.\r
926**/\r
927UINTN\r
928EFIAPI\r
929SPrintLengthAsciiFormat (\r
930 IN CONST CHAR8 *FormatString,\r
931 IN VA_LIST Marker\r
932 );\r
933\r
934#endif\r