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