]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePrintLib/PrintLib.c
Update function description to be consistent with code definition: HEX_RADIX => RADIX...
[mirror_edk2.git] / MdePkg / Library / BasePrintLib / PrintLib.c
1 /** @file
2 Base Print Library instance implementation.
3
4 Copyright (c) 2006 - 2009, Intel Corporation<BR>
5 Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "PrintLibInternal.h"
17
18 //
19 // Declare a VA_LIST global variable that is used in calls to BasePrintLibSPrintMarker()
20 // when the BASE_LIST parameter is valid and the VA_LIST parameter is ignored.
21 // A NULL VA_LIST can not be passed into BasePrintLibSPrintMarker() because some
22 // compilers define VA_LIST to be a structure.
23 //
24 VA_LIST gNullVaList;
25
26 #define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
27
28 /**
29 Produces a Null-terminated Unicode string in an output buffer based on
30 a Null-terminated Unicode format string and a VA_LIST argument list
31
32 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
33 and BufferSize.
34 The Unicode string is produced by parsing the format string specified by FormatString.
35 Arguments are pulled from the variable argument list specified by Marker based on the
36 contents of the format string.
37 The number of Unicode characters in the produced output buffer is returned not including
38 the Null-terminator.
39 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
40
41 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
42 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
43 If BufferSize > 1 and FormatString is NULL, then ASSERT().
44 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
45 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
46 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
47 ASSERT().
48 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
49 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
50 Null-terminator, then ASSERT().
51
52 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
53 Unicode string.
54 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
55 @param FormatString Null-terminated Unicode format string.
56 @param Marker VA_LIST marker for the variable argument list.
57
58 @return The number of Unicode characters in the produced output buffer not including the
59 Null-terminator.
60
61 **/
62 UINTN
63 EFIAPI
64 UnicodeVSPrint (
65 OUT CHAR16 *StartOfBuffer,
66 IN UINTN BufferSize,
67 IN CONST CHAR16 *FormatString,
68 IN VA_LIST Marker
69 )
70 {
71 ASSERT_UNICODE_BUFFER (StartOfBuffer);
72 ASSERT_UNICODE_BUFFER (FormatString);
73 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker, NULL);
74 }
75
76 /**
77 Produces a Null-terminated Unicode string in an output buffer based on
78 a Null-terminated Unicode format string and a BASE_LIST argument list
79
80 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
81 and BufferSize.
82 The Unicode string is produced by parsing the format string specified by FormatString.
83 Arguments are pulled from the variable argument list specified by Marker based on the
84 contents of the format string.
85 The number of Unicode characters in the produced output buffer is returned not including
86 the Null-terminator.
87 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
88
89 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
90 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
91 If BufferSize > 1 and FormatString is NULL, then ASSERT().
92 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
93 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
94 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
95 ASSERT().
96 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
97 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
98 Null-terminator, then ASSERT().
99
100 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
101 Unicode string.
102 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
103 @param FormatString Null-terminated Unicode format string.
104 @param Marker BASE_LIST marker for the variable argument list.
105
106 @return The number of Unicode characters in the produced output buffer not including the
107 Null-terminator.
108
109 **/
110 UINTN
111 EFIAPI
112 UnicodeBSPrint (
113 OUT CHAR16 *StartOfBuffer,
114 IN UINTN BufferSize,
115 IN CONST CHAR16 *FormatString,
116 IN BASE_LIST Marker
117 )
118 {
119 ASSERT_UNICODE_BUFFER (StartOfBuffer);
120 ASSERT_UNICODE_BUFFER (FormatString);
121 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, gNullVaList, Marker);
122 }
123
124 /**
125 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
126 Unicode format string and variable argument list.
127
128 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
129 and BufferSize.
130 The Unicode string is produced by parsing the format string specified by FormatString.
131 Arguments are pulled from the variable argument list based on the contents of the format string.
132 The number of Unicode characters in the produced output buffer is returned not including
133 the Null-terminator.
134 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
135
136 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
137 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
138 If BufferSize > 1 and FormatString is NULL, then ASSERT().
139 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
140 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
141 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
142 ASSERT().
143 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
144 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
145 Null-terminator, then ASSERT().
146
147 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
148 Unicode string.
149 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
150 @param FormatString Null-terminated Unicode format string.
151 @param ... Variable argument list whose contents are accessed based on the
152 format string specified by FormatString.
153
154 @return The number of Unicode characters in the produced output buffer not including the
155 Null-terminator.
156
157 **/
158 UINTN
159 EFIAPI
160 UnicodeSPrint (
161 OUT CHAR16 *StartOfBuffer,
162 IN UINTN BufferSize,
163 IN CONST CHAR16 *FormatString,
164 ...
165 )
166 {
167 VA_LIST Marker;
168
169 VA_START (Marker, FormatString);
170 return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
171 }
172
173 /**
174 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
175 ASCII format string and a VA_LIST argument list
176
177 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
178 and BufferSize.
179 The Unicode string is produced by parsing the format string specified by FormatString.
180 Arguments are pulled from the variable argument list specified by Marker based on the
181 contents of the format string.
182 The number of Unicode characters in the produced output buffer is returned not including
183 the Null-terminator.
184 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
185
186 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
187 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
188 If BufferSize > 1 and FormatString is NULL, then ASSERT().
189 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
190 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
191 ASSERT().
192 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
193 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
194 Null-terminator, then ASSERT().
195
196 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
197 Unicode string.
198 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
199 @param FormatString Null-terminated ASCII format string.
200 @param Marker VA_LIST marker for the variable argument list.
201
202 @return The number of Unicode characters in the produced output buffer not including the
203 Null-terminator.
204
205 **/
206 UINTN
207 EFIAPI
208 UnicodeVSPrintAsciiFormat (
209 OUT CHAR16 *StartOfBuffer,
210 IN UINTN BufferSize,
211 IN CONST CHAR8 *FormatString,
212 IN VA_LIST Marker
213 )
214 {
215 ASSERT_UNICODE_BUFFER (StartOfBuffer);
216 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, Marker, NULL);
217 }
218
219 /**
220 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
221 ASCII format string and a BASE_LIST argument list
222
223 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
224 and BufferSize.
225 The Unicode string is produced by parsing the format string specified by FormatString.
226 Arguments are pulled from the variable argument list specified by Marker based on the
227 contents of the format string.
228 The number of Unicode characters in the produced output buffer is returned not including
229 the Null-terminator.
230 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
231
232 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
233 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
234 If BufferSize > 1 and FormatString is NULL, then ASSERT().
235 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
236 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
237 ASSERT().
238 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
239 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
240 Null-terminator, then ASSERT().
241
242 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
243 Unicode string.
244 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
245 @param FormatString Null-terminated ASCII format string.
246 @param Marker BASE_LIST marker for the variable argument list.
247
248 @return The number of Unicode characters in the produced output buffer not including the
249 Null-terminator.
250
251 **/
252 UINTN
253 EFIAPI
254 UnicodeBSPrintAsciiFormat (
255 OUT CHAR16 *StartOfBuffer,
256 IN UINTN BufferSize,
257 IN CONST CHAR8 *FormatString,
258 IN BASE_LIST Marker
259 )
260 {
261 ASSERT_UNICODE_BUFFER (StartOfBuffer);
262 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, gNullVaList, Marker);
263 }
264
265 /**
266 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
267 ASCII format string and variable argument list.
268
269 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
270 and BufferSize.
271 The Unicode string is produced by parsing the format string specified by FormatString.
272 Arguments are pulled from the variable argument list based on the contents of the
273 format string.
274 The number of Unicode characters in the produced output buffer is returned not including
275 the Null-terminator.
276 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
277
278 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
279 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
280 If BufferSize > 1 and FormatString is NULL, then ASSERT().
281 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
282 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
283 ASSERT().
284 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
285 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
286 Null-terminator, then ASSERT().
287
288 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
289 Unicode string.
290 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
291 @param FormatString Null-terminated ASCII format string.
292 @param ... Variable argument list whose contents are accessed based on the
293 format string specified by FormatString.
294
295 @return The number of Unicode characters in the produced output buffer not including the
296 Null-terminator.
297
298 **/
299 UINTN
300 EFIAPI
301 UnicodeSPrintAsciiFormat (
302 OUT CHAR16 *StartOfBuffer,
303 IN UINTN BufferSize,
304 IN CONST CHAR8 *FormatString,
305 ...
306 )
307 {
308 VA_LIST Marker;
309
310 VA_START (Marker, FormatString);
311 return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);
312 }
313
314 /**
315 Converts a decimal value to a Null-terminated Unicode string.
316
317 Converts the decimal number specified by Value to a Null-terminated Unicode
318 string specified by Buffer containing at most Width characters. No padding of spaces
319 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
320 The number of Unicode characters in Buffer is returned not including the Null-terminator.
321 If the conversion contains more than Width characters, then only the first
322 Width characters are returned, and the total number of characters
323 required to perform the conversion is returned.
324 Additional conversion parameters are specified in Flags.
325
326 The Flags bit LEFT_JUSTIFY is always ignored.
327 All conversions are left justified in Buffer.
328 If Width is 0, PREFIX_ZERO is ignored in Flags.
329 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
330 are inserted every 3rd digit starting from the right.
331 If RADIX_HEX is set in Flags, then the output buffer will be
332 formatted in hexadecimal format.
333 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
334 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
335 then Buffer is padded with '0' characters so the combination of the optional '-'
336 sign character, '0' characters, digit characters for Value, and the Null-terminator
337 add up to Width characters.
338 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
339 If Buffer is NULL, then ASSERT().
340 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
341 If unsupported bits are set in Flags, then ASSERT().
342 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
343 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
344
345 @param Buffer Pointer to the output buffer for the produced Null-terminated
346 Unicode string.
347 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
348 @param Value The 64-bit signed value to convert to a string.
349 @param Width The maximum number of Unicode characters to place in Buffer, not including
350 the Null-terminator.
351
352 @return The number of Unicode characters in Buffer not including the Null-terminator.
353
354 **/
355 UINTN
356 EFIAPI
357 UnicodeValueToString (
358 IN OUT CHAR16 *Buffer,
359 IN UINTN Flags,
360 IN INT64 Value,
361 IN UINTN Width
362 )
363 {
364 ASSERT_UNICODE_BUFFER(Buffer);
365 return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);
366 }
367
368 /**
369 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
370 ASCII format string and a VA_LIST argument list.
371
372 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
373 and BufferSize.
374 The ASCII string is produced by parsing the format string specified by FormatString.
375 Arguments are pulled from the variable argument list specified by Marker based on
376 the contents of the format string.
377 The number of ASCII characters in the produced output buffer is returned not including
378 the Null-terminator.
379 If BufferSize is 0, then no output buffer is produced and 0 is returned.
380
381 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
382 If BufferSize > 0 and FormatString is NULL, then ASSERT().
383 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
384 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
385 ASSERT().
386 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
387 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
388 Null-terminator, then ASSERT().
389
390 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
391 ASCII string.
392 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
393 @param FormatString Null-terminated ASCII format string.
394 @param Marker VA_LIST marker for the variable argument list.
395
396 @return The number of ASCII characters in the produced output buffer not including the
397 Null-terminator.
398
399 **/
400 UINTN
401 EFIAPI
402 AsciiVSPrint (
403 OUT CHAR8 *StartOfBuffer,
404 IN UINTN BufferSize,
405 IN CONST CHAR8 *FormatString,
406 IN VA_LIST Marker
407 )
408 {
409 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, Marker, NULL);
410 }
411
412 /**
413 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
414 ASCII format string and a BASE_LIST argument list.
415
416 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
417 and BufferSize.
418 The ASCII string is produced by parsing the format string specified by FormatString.
419 Arguments are pulled from the variable argument list specified by Marker based on
420 the contents of the format string.
421 The number of ASCII characters in the produced output buffer is returned not including
422 the Null-terminator.
423 If BufferSize is 0, then no output buffer is produced and 0 is returned.
424
425 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
426 If BufferSize > 0 and FormatString is NULL, then ASSERT().
427 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
428 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
429 ASSERT().
430 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
431 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
432 Null-terminator, then ASSERT().
433
434 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
435 ASCII string.
436 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
437 @param FormatString Null-terminated ASCII format string.
438 @param Marker BASE_LIST marker for the variable argument list.
439
440 @return The number of ASCII characters in the produced output buffer not including the
441 Null-terminator.
442
443 **/
444 UINTN
445 EFIAPI
446 AsciiBSPrint (
447 OUT CHAR8 *StartOfBuffer,
448 IN UINTN BufferSize,
449 IN CONST CHAR8 *FormatString,
450 IN BASE_LIST Marker
451 )
452 {
453 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, gNullVaList, Marker);
454 }
455
456 /**
457 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
458 ASCII format string and variable argument list.
459
460 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
461 and BufferSize.
462 The ASCII string is produced by parsing the format string specified by FormatString.
463 Arguments are pulled from the variable argument list based on the contents of the
464 format string.
465 The number of ASCII characters in the produced output buffer is returned not including
466 the Null-terminator.
467 If BufferSize is 0, then no output buffer is produced and 0 is returned.
468
469 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
470 If BufferSize > 0 and FormatString is NULL, then ASSERT().
471 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
472 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
473 ASSERT().
474 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
475 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
476 Null-terminator, then ASSERT().
477
478 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
479 ASCII string.
480 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
481 @param FormatString Null-terminated ASCII format string.
482 @param ... Variable argument list whose contents are accessed based on the
483 format string specified by FormatString.
484
485 @return The number of ASCII characters in the produced output buffer not including the
486 Null-terminator.
487
488 **/
489 UINTN
490 EFIAPI
491 AsciiSPrint (
492 OUT CHAR8 *StartOfBuffer,
493 IN UINTN BufferSize,
494 IN CONST CHAR8 *FormatString,
495 ...
496 )
497 {
498 VA_LIST Marker;
499
500 VA_START (Marker, FormatString);
501 return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
502 }
503
504 /**
505 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
506 Unicode format string and a VA_LIST argument list.
507
508 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
509 and BufferSize.
510 The ASCII string is produced by parsing the format string specified by FormatString.
511 Arguments are pulled from the variable argument list specified by Marker based on
512 the contents of the format string.
513 The number of ASCII characters in the produced output buffer is returned not including
514 the Null-terminator.
515 If BufferSize is 0, then no output buffer is produced and 0 is returned.
516
517 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
518 If BufferSize > 0 and FormatString is NULL, then ASSERT().
519 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
520 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
521 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
522 ASSERT().
523 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
524 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
525 Null-terminator, then ASSERT().
526
527 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
528 ASCII string.
529 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
530 @param FormatString Null-terminated Unicode format string.
531 @param Marker VA_LIST marker for the variable argument list.
532
533 @return The number of ASCII characters in the produced output buffer not including the
534 Null-terminator.
535
536 **/
537 UINTN
538 EFIAPI
539 AsciiVSPrintUnicodeFormat (
540 OUT CHAR8 *StartOfBuffer,
541 IN UINTN BufferSize,
542 IN CONST CHAR16 *FormatString,
543 IN VA_LIST Marker
544 )
545 {
546 ASSERT_UNICODE_BUFFER (FormatString);
547 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker, NULL);
548 }
549
550 /**
551 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
552 Unicode format string and a BASE_LIST argument list.
553
554 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
555 and BufferSize.
556 The ASCII string is produced by parsing the format string specified by FormatString.
557 Arguments are pulled from the variable argument list specified by Marker based on
558 the contents of the format string.
559 The number of ASCII characters in the produced output buffer is returned not including
560 the Null-terminator.
561 If BufferSize is 0, then no output buffer is produced and 0 is returned.
562
563 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
564 If BufferSize > 0 and FormatString is NULL, then ASSERT().
565 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
566 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
567 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
568 ASSERT().
569 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
570 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
571 Null-terminator, then ASSERT().
572
573 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
574 ASCII string.
575 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
576 @param FormatString Null-terminated Unicode format string.
577 @param Marker BASE_LIST marker for the variable argument list.
578
579 @return The number of ASCII characters in the produced output buffer not including the
580 Null-terminator.
581
582 **/
583 UINTN
584 EFIAPI
585 AsciiBSPrintUnicodeFormat (
586 OUT CHAR8 *StartOfBuffer,
587 IN UINTN BufferSize,
588 IN CONST CHAR16 *FormatString,
589 IN BASE_LIST Marker
590 )
591 {
592 ASSERT_UNICODE_BUFFER (FormatString);
593 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, gNullVaList, Marker);
594 }
595
596 /**
597 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
598 Unicode format string and variable argument list.
599
600 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
601 and BufferSize.
602 The ASCII string is produced by parsing the format string specified by FormatString.
603 Arguments are pulled from the variable argument list based on the contents of the
604 format string.
605 The number of ASCII characters in the produced output buffer is returned not including
606 the Null-terminator.
607 If BufferSize is 0, then no output buffer is produced and 0 is returned.
608
609 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
610 If BufferSize > 0 and FormatString is NULL, then ASSERT().
611 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
612 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
613 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
614 ASSERT().
615 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
616 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
617 Null-terminator, then ASSERT().
618
619 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
620 ASCII string.
621 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
622 @param FormatString Null-terminated Unicode format string.
623 @param ... Variable argument list whose contents are accessed based on the
624 format string specified by FormatString.
625
626 @return The number of ASCII characters in the produced output buffer not including the
627 Null-terminator.
628
629 **/
630 UINTN
631 EFIAPI
632 AsciiSPrintUnicodeFormat (
633 OUT CHAR8 *StartOfBuffer,
634 IN UINTN BufferSize,
635 IN CONST CHAR16 *FormatString,
636 ...
637 )
638 {
639 VA_LIST Marker;
640
641 VA_START (Marker, FormatString);
642 return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);
643 }
644
645
646 /**
647 Converts a decimal value to a Null-terminated ASCII string.
648
649 Converts the decimal number specified by Value to a Null-terminated ASCII string
650 specified by Buffer containing at most Width characters. No padding of spaces
651 is ever performed.
652 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
653 The number of ASCII characters in Buffer is returned not including the Null-terminator.
654 If the conversion contains more than Width characters, then only the first Width
655 characters are returned, and the total number of characters required to perform
656 the conversion is returned.
657 Additional conversion parameters are specified in Flags.
658 The Flags bit LEFT_JUSTIFY is always ignored.
659 All conversions are left justified in Buffer.
660 If Width is 0, PREFIX_ZERO is ignored in Flags.
661 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
662 are inserted every 3rd digit starting from the right.
663 If RADIX_HEX is set in Flags, then the output buffer will be
664 formatted in hexadecimal format.
665 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
666 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
667 then Buffer is padded with '0' characters so the combination of the optional '-'
668 sign character, '0' characters, digit characters for Value, and the Null-terminator
669 add up to Width characters.
670
671 If Buffer is NULL, then ASSERT().
672 If unsupported bits are set in Flags, then ASSERT().
673 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
674 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
675
676 @param Buffer Pointer to the output buffer for the produced Null-terminated
677 ASCII string.
678 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
679 @param Value The 64-bit signed value to convert to a string.
680 @param Width The maximum number of ASCII characters to place in Buffer, not including
681 the Null-terminator.
682
683 @return The number of ASCII characters in Buffer not including the Null-terminator.
684
685 **/
686 UINTN
687 EFIAPI
688 AsciiValueToString (
689 OUT CHAR8 *Buffer,
690 IN UINTN Flags,
691 IN INT64 Value,
692 IN UINTN Width
693 )
694 {
695 return BasePrintLibConvertValueToString (Buffer, Flags, Value, Width, 1);
696 }