VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BasePrintLib/PrintLib.c@ 62180

最後變更 在這個檔案從62180是 58466,由 vboxsync 提交於 9 年 前

EFI/Firmware: Merged in the svn:eol-style, svn:mime-type and trailing whitespace cleanup that was done after the initial UDK2014.SP1 import: svn merge /vendor/edk2/UDK2014.SP1 /vendor/edk2/current .

  • 屬性 svn:eol-style 設為 native
檔案大小: 32.1 KB
 
1/** @file
2 Base Print Library instance implementation.
3
4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6 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//
24VA_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 A 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**/
62UINTN
63EFIAPI
64UnicodeVSPrint (
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 A 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**/
110UINTN
111EFIAPI
112UnicodeBSPrint (
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 A 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**/
158UINTN
159EFIAPI
160UnicodeSPrint (
161 OUT CHAR16 *StartOfBuffer,
162 IN UINTN BufferSize,
163 IN CONST CHAR16 *FormatString,
164 ...
165 )
166{
167 VA_LIST Marker;
168 UINTN NumberOfPrinted;
169
170 VA_START (Marker, FormatString);
171 NumberOfPrinted = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
172 VA_END (Marker);
173 return NumberOfPrinted;
174}
175
176/**
177 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
178 ASCII format string and a VA_LIST argument list
179
180 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
181 and BufferSize.
182 The Unicode string is produced by parsing the format string specified by FormatString.
183 Arguments are pulled from the variable argument list specified by Marker based on the
184 contents of the format string.
185 The number of Unicode characters in the produced output buffer is returned not including
186 the Null-terminator.
187 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
188
189 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
190 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
191 If BufferSize > 1 and FormatString is NULL, then ASSERT().
192 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
193 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
194 ASSERT().
195 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
196 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
197 Null-terminator, then ASSERT().
198
199 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
200 Unicode string.
201 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
202 @param FormatString A Null-terminated ASCII format string.
203 @param Marker VA_LIST marker for the variable argument list.
204
205 @return The number of Unicode characters in the produced output buffer not including the
206 Null-terminator.
207
208**/
209UINTN
210EFIAPI
211UnicodeVSPrintAsciiFormat (
212 OUT CHAR16 *StartOfBuffer,
213 IN UINTN BufferSize,
214 IN CONST CHAR8 *FormatString,
215 IN VA_LIST Marker
216 )
217{
218 ASSERT_UNICODE_BUFFER (StartOfBuffer);
219 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, Marker, NULL);
220}
221
222/**
223 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
224 ASCII format string and a BASE_LIST argument list
225
226 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
227 and BufferSize.
228 The Unicode string is produced by parsing the format string specified by FormatString.
229 Arguments are pulled from the variable argument list specified by Marker based on the
230 contents of the format string.
231 The number of Unicode characters in the produced output buffer is returned not including
232 the Null-terminator.
233 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
234
235 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
236 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
237 If BufferSize > 1 and FormatString is NULL, then ASSERT().
238 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
239 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
240 ASSERT().
241 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
242 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
243 Null-terminator, then ASSERT().
244
245 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
246 Unicode string.
247 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
248 @param FormatString A Null-terminated ASCII format string.
249 @param Marker BASE_LIST marker for the variable argument list.
250
251 @return The number of Unicode characters in the produced output buffer not including the
252 Null-terminator.
253
254**/
255UINTN
256EFIAPI
257UnicodeBSPrintAsciiFormat (
258 OUT CHAR16 *StartOfBuffer,
259 IN UINTN BufferSize,
260 IN CONST CHAR8 *FormatString,
261 IN BASE_LIST Marker
262 )
263{
264 ASSERT_UNICODE_BUFFER (StartOfBuffer);
265 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, gNullVaList, Marker);
266}
267
268/**
269 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
270 ASCII format string and variable argument list.
271
272 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
273 and BufferSize.
274 The Unicode string is produced by parsing the format string specified by FormatString.
275 Arguments are pulled from the variable argument list based on the contents of the
276 format string.
277 The number of Unicode characters in the produced output buffer is returned not including
278 the Null-terminator.
279 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
280
281 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
282 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
283 If BufferSize > 1 and FormatString is NULL, then ASSERT().
284 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
285 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
286 ASSERT().
287 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
288 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
289 Null-terminator, then ASSERT().
290
291 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
292 Unicode string.
293 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
294 @param FormatString A Null-terminated ASCII format string.
295 @param ... Variable argument list whose contents are accessed based on the
296 format string specified by FormatString.
297
298 @return The number of Unicode characters in the produced output buffer not including the
299 Null-terminator.
300
301**/
302UINTN
303EFIAPI
304UnicodeSPrintAsciiFormat (
305 OUT CHAR16 *StartOfBuffer,
306 IN UINTN BufferSize,
307 IN CONST CHAR8 *FormatString,
308 ...
309 )
310{
311 VA_LIST Marker;
312 UINTN NumberOfPrinted;
313
314 VA_START (Marker, FormatString);
315 NumberOfPrinted = UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);
316 VA_END (Marker);
317 return NumberOfPrinted;
318}
319
320/**
321 Converts a decimal value to a Null-terminated Unicode string.
322
323 Converts the decimal number specified by Value to a Null-terminated Unicode
324 string specified by Buffer containing at most Width characters. No padding of spaces
325 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
326 The number of Unicode characters in Buffer is returned not including the Null-terminator.
327 If the conversion contains more than Width characters, then only the first
328 Width characters are returned, and the total number of characters
329 required to perform the conversion is returned.
330 Additional conversion parameters are specified in Flags.
331
332 The Flags bit LEFT_JUSTIFY is always ignored.
333 All conversions are left justified in Buffer.
334 If Width is 0, PREFIX_ZERO is ignored in Flags.
335 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
336 are inserted every 3rd digit starting from the right.
337 If RADIX_HEX is set in Flags, then the output buffer will be
338 formatted in hexadecimal format.
339 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
340 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
341 then Buffer is padded with '0' characters so the combination of the optional '-'
342 sign character, '0' characters, digit characters for Value, and the Null-terminator
343 add up to Width characters.
344 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
345 If Buffer is NULL, then ASSERT().
346 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
347 If unsupported bits are set in Flags, then ASSERT().
348 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
349 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
350
351 @param Buffer The pointer to the output buffer for the produced Null-terminated
352 Unicode string.
353 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
354 @param Value The 64-bit signed value to convert to a string.
355 @param Width The maximum number of Unicode characters to place in Buffer, not including
356 the Null-terminator.
357
358 @return The number of Unicode characters in Buffer not including the Null-terminator.
359
360**/
361UINTN
362EFIAPI
363UnicodeValueToString (
364 IN OUT CHAR16 *Buffer,
365 IN UINTN Flags,
366 IN INT64 Value,
367 IN UINTN Width
368 )
369{
370 ASSERT_UNICODE_BUFFER(Buffer);
371 return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);
372}
373
374/**
375 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
376 ASCII format string and a VA_LIST argument list.
377
378 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
379 and BufferSize.
380 The ASCII string is produced by parsing the format string specified by FormatString.
381 Arguments are pulled from the variable argument list specified by Marker based on
382 the contents of the format string.
383 The number of ASCII characters in the produced output buffer is returned not including
384 the Null-terminator.
385 If BufferSize is 0, then no output buffer is produced and 0 is returned.
386
387 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
388 If BufferSize > 0 and FormatString is NULL, then ASSERT().
389 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
390 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
391 ASSERT().
392 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
393 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
394 Null-terminator, then ASSERT().
395
396 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
397 ASCII string.
398 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
399 @param FormatString A Null-terminated ASCII format string.
400 @param Marker VA_LIST marker for the variable argument list.
401
402 @return The number of ASCII characters in the produced output buffer not including the
403 Null-terminator.
404
405**/
406UINTN
407EFIAPI
408AsciiVSPrint (
409 OUT CHAR8 *StartOfBuffer,
410 IN UINTN BufferSize,
411 IN CONST CHAR8 *FormatString,
412 IN VA_LIST Marker
413 )
414{
415 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, Marker, NULL);
416}
417
418/**
419 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
420 ASCII format string and a BASE_LIST argument list.
421
422 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
423 and BufferSize.
424 The ASCII string is produced by parsing the format string specified by FormatString.
425 Arguments are pulled from the variable argument list specified by Marker based on
426 the contents of the format string.
427 The number of ASCII characters in the produced output buffer is returned not including
428 the Null-terminator.
429 If BufferSize is 0, then no output buffer is produced and 0 is returned.
430
431 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
432 If BufferSize > 0 and FormatString is NULL, then ASSERT().
433 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
434 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
435 ASSERT().
436 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
437 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
438 Null-terminator, then ASSERT().
439
440 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
441 ASCII string.
442 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
443 @param FormatString A Null-terminated ASCII format string.
444 @param Marker BASE_LIST marker for the variable argument list.
445
446 @return The number of ASCII characters in the produced output buffer not including the
447 Null-terminator.
448
449**/
450UINTN
451EFIAPI
452AsciiBSPrint (
453 OUT CHAR8 *StartOfBuffer,
454 IN UINTN BufferSize,
455 IN CONST CHAR8 *FormatString,
456 IN BASE_LIST Marker
457 )
458{
459 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, gNullVaList, Marker);
460}
461
462/**
463 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
464 ASCII format string and variable argument list.
465
466 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
467 and BufferSize.
468 The ASCII string is produced by parsing the format string specified by FormatString.
469 Arguments are pulled from the variable argument list based on the contents of the
470 format string.
471 The number of ASCII characters in the produced output buffer is returned not including
472 the Null-terminator.
473 If BufferSize is 0, then no output buffer is produced and 0 is returned.
474
475 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
476 If BufferSize > 0 and FormatString is NULL, then ASSERT().
477 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
478 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
479 ASSERT().
480 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
481 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
482 Null-terminator, then ASSERT().
483
484 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
485 ASCII string.
486 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
487 @param FormatString A Null-terminated ASCII format string.
488 @param ... Variable argument list whose contents are accessed based on the
489 format string specified by FormatString.
490
491 @return The number of ASCII characters in the produced output buffer not including the
492 Null-terminator.
493
494**/
495UINTN
496EFIAPI
497AsciiSPrint (
498 OUT CHAR8 *StartOfBuffer,
499 IN UINTN BufferSize,
500 IN CONST CHAR8 *FormatString,
501 ...
502 )
503{
504 VA_LIST Marker;
505 UINTN NumberOfPrinted;
506
507 VA_START (Marker, FormatString);
508 NumberOfPrinted = AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
509 VA_END (Marker);
510 return NumberOfPrinted;
511}
512
513/**
514 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
515 Unicode format string and a VA_LIST argument list.
516
517 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
518 and BufferSize.
519 The ASCII string is produced by parsing the format string specified by FormatString.
520 Arguments are pulled from the variable argument list specified by Marker based on
521 the contents of the format string.
522 The number of ASCII characters in the produced output buffer is returned not including
523 the Null-terminator.
524 If BufferSize is 0, then no output buffer is produced and 0 is returned.
525
526 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
527 If BufferSize > 0 and FormatString is NULL, then ASSERT().
528 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
529 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
530 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
531 ASSERT().
532 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
533 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
534 Null-terminator, then ASSERT().
535
536 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
537 ASCII string.
538 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
539 @param FormatString A Null-terminated Unicode format string.
540 @param Marker VA_LIST marker for the variable argument list.
541
542 @return The number of ASCII characters in the produced output buffer not including the
543 Null-terminator.
544
545**/
546UINTN
547EFIAPI
548AsciiVSPrintUnicodeFormat (
549 OUT CHAR8 *StartOfBuffer,
550 IN UINTN BufferSize,
551 IN CONST CHAR16 *FormatString,
552 IN VA_LIST Marker
553 )
554{
555 ASSERT_UNICODE_BUFFER (FormatString);
556 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker, NULL);
557}
558
559/**
560 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
561 Unicode format string and a BASE_LIST argument list.
562
563 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
564 and BufferSize.
565 The ASCII string is produced by parsing the format string specified by FormatString.
566 Arguments are pulled from the variable argument list specified by Marker based on
567 the contents of the format string.
568 The number of ASCII characters in the produced output buffer is returned not including
569 the Null-terminator.
570 If BufferSize is 0, then no output buffer is produced and 0 is returned.
571
572 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
573 If BufferSize > 0 and FormatString is NULL, then ASSERT().
574 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
575 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
576 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
577 ASSERT().
578 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
579 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
580 Null-terminator, then ASSERT().
581
582 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
583 ASCII string.
584 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
585 @param FormatString A Null-terminated Unicode format string.
586 @param Marker BASE_LIST marker for the variable argument list.
587
588 @return The number of ASCII characters in the produced output buffer not including the
589 Null-terminator.
590
591**/
592UINTN
593EFIAPI
594AsciiBSPrintUnicodeFormat (
595 OUT CHAR8 *StartOfBuffer,
596 IN UINTN BufferSize,
597 IN CONST CHAR16 *FormatString,
598 IN BASE_LIST Marker
599 )
600{
601 ASSERT_UNICODE_BUFFER (FormatString);
602 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, gNullVaList, Marker);
603}
604
605/**
606 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
607 Unicode format string and variable argument list.
608
609 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
610 and BufferSize.
611 The ASCII string is produced by parsing the format string specified by FormatString.
612 Arguments are pulled from the variable argument list based on the contents of the
613 format string.
614 The number of ASCII characters in the produced output buffer is returned not including
615 the Null-terminator.
616 If BufferSize is 0, then no output buffer is produced and 0 is returned.
617
618 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
619 If BufferSize > 0 and FormatString is NULL, then ASSERT().
620 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
621 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
622 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
623 ASSERT().
624 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
625 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
626 Null-terminator, then ASSERT().
627
628 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
629 ASCII string.
630 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
631 @param FormatString A Null-terminated Unicode format string.
632 @param ... Variable argument list whose contents are accessed based on the
633 format string specified by FormatString.
634
635 @return The number of ASCII characters in the produced output buffer not including the
636 Null-terminator.
637
638**/
639UINTN
640EFIAPI
641AsciiSPrintUnicodeFormat (
642 OUT CHAR8 *StartOfBuffer,
643 IN UINTN BufferSize,
644 IN CONST CHAR16 *FormatString,
645 ...
646 )
647{
648 VA_LIST Marker;
649 UINTN NumberOfPrinted;
650
651 VA_START (Marker, FormatString);
652 NumberOfPrinted = AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);
653 VA_END (Marker);
654 return NumberOfPrinted;
655}
656
657
658/**
659 Converts a decimal value to a Null-terminated ASCII string.
660
661 Converts the decimal number specified by Value to a Null-terminated ASCII string
662 specified by Buffer containing at most Width characters. No padding of spaces
663 is ever performed.
664 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
665 The number of ASCII characters in Buffer is returned not including the Null-terminator.
666 If the conversion contains more than Width characters, then only the first Width
667 characters are returned, and the total number of characters required to perform
668 the conversion is returned.
669 Additional conversion parameters are specified in Flags.
670 The Flags bit LEFT_JUSTIFY is always ignored.
671 All conversions are left justified in Buffer.
672 If Width is 0, PREFIX_ZERO is ignored in Flags.
673 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
674 are inserted every 3rd digit starting from the right.
675 If RADIX_HEX is set in Flags, then the output buffer will be
676 formatted in hexadecimal format.
677 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
678 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
679 then Buffer is padded with '0' characters so the combination of the optional '-'
680 sign character, '0' characters, digit characters for Value, and the Null-terminator
681 add up to Width characters.
682
683 If Buffer is NULL, then ASSERT().
684 If unsupported bits are set in Flags, then ASSERT().
685 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
686 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
687
688 @param Buffer The pointer to the output buffer for the produced Null-terminated
689 ASCII string.
690 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
691 @param Value The 64-bit signed value to convert to a string.
692 @param Width The maximum number of ASCII characters to place in Buffer, not including
693 the Null-terminator.
694
695 @return The number of ASCII characters in Buffer not including the Null-terminator.
696
697**/
698UINTN
699EFIAPI
700AsciiValueToString (
701 OUT CHAR8 *Buffer,
702 IN UINTN Flags,
703 IN INT64 Value,
704 IN UINTN Width
705 )
706{
707 return BasePrintLibConvertValueToString (Buffer, Flags, Value, Width, 1);
708}
709
710/**
711 Returns the number of characters that would be produced by if the formatted
712 output were produced not including the Null-terminator.
713
714 If FormatString is NULL, then ASSERT().
715 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
716
717 @param[in] FormatString A Null-terminated Unicode format string.
718 @param[in] Marker VA_LIST marker for the variable argument list.
719
720 @return The number of characters that would be produced, not including the
721 Null-terminator.
722**/
723UINTN
724EFIAPI
725SPrintLength (
726 IN CONST CHAR16 *FormatString,
727 IN VA_LIST Marker
728 )
729{
730 ASSERT(FormatString != NULL);
731 ASSERT_UNICODE_BUFFER (FormatString);
732 return BasePrintLibSPrintMarker (NULL, 0, FORMAT_UNICODE | OUTPUT_UNICODE | COUNT_ONLY_NO_PRINT, (CHAR8 *)FormatString, Marker, NULL);
733}
734
735/**
736 Returns the number of characters that would be produced by if the formatted
737 output were produced not including the Null-terminator.
738
739 If FormatString is NULL, then ASSERT().
740
741 @param[in] FormatString A Null-terminated ASCII format string.
742 @param[in] Marker VA_LIST marker for the variable argument list.
743
744 @return The number of characters that would be produced, not including the
745 Null-terminator.
746**/
747UINTN
748EFIAPI
749SPrintLengthAsciiFormat (
750 IN CONST CHAR8 *FormatString,
751 IN VA_LIST Marker
752 )
753{
754 ASSERT(FormatString != NULL);
755 return BasePrintLibSPrintMarker (NULL, 0, OUTPUT_UNICODE | COUNT_ONLY_NO_PRINT, (CHAR8 *)FormatString, Marker, NULL);
756}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette