2 Instance of Print Library based on gEfiPrint2ProtocolGuid.
4 Implement the print library instance by wrap the interface
5 provided in the Print2 protocol. This protocol is defined as the internal
6 protocol related to this implementation, not in the public spec. So, this
7 library instance is only for this code base.
9 Copyright (c) 2009, Intel Corporation
10 All rights reserved. This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include <Protocol/Print2.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 #include <Library/DebugLib.h>
25 EFI_PRINT2_PROTOCOL
*mPrint2Protocol
= NULL
;
28 The constructor function caches the pointer to Print2 protocol.
30 The constructor function locates Print2 protocol from protocol database.
31 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
33 @param ImageHandle The firmware allocated handle for the EFI image.
34 @param SystemTable A pointer to the EFI System Table.
36 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
42 IN EFI_HANDLE ImageHandle
,
43 IN EFI_SYSTEM_TABLE
*SystemTable
48 Status
= gBS
->LocateProtocol (
49 &gEfiPrint2ProtocolGuid
,
51 (VOID
**) &mPrint2Protocol
53 ASSERT_EFI_ERROR (Status
);
54 ASSERT (mPrint2Protocol
!= NULL
);
61 Produces a Null-terminated Unicode string in an output buffer based on
62 a Null-terminated Unicode format string and a VA_LIST argument list
64 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
66 The Unicode string is produced by parsing the format string specified by FormatString.
67 Arguments are pulled from the variable argument list specified by Marker based on the
68 contents of the format string.
69 The number of Unicode characters in the produced output buffer is returned not including
71 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
73 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
74 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
75 If BufferSize > 1 and FormatString is NULL, then ASSERT().
76 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
77 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
78 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
80 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
81 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
82 Null-terminator, then ASSERT().
84 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
86 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
87 @param FormatString Null-terminated Unicode format string.
88 @param Marker VA_LIST marker for the variable argument list.
90 @return The number of Unicode characters in the produced output buffer not including the
97 OUT CHAR16
*StartOfBuffer
,
99 IN CONST CHAR16
*FormatString
,
103 return mPrint2Protocol
->UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
107 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
108 Unicode format string and variable argument list.
110 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
112 The Unicode string is produced by parsing the format string specified by FormatString.
113 Arguments are pulled from the variable argument list based on the contents of the format string.
114 The number of Unicode characters in the produced output buffer is returned not including
116 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
118 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
119 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
120 If BufferSize > 1 and FormatString is NULL, then ASSERT().
121 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
122 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
123 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
125 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
126 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
127 Null-terminator, then ASSERT().
129 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
131 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
132 @param FormatString Null-terminated Unicode format string.
133 @param ... Variable argument list whose contents are accessed based on the
134 format string specified by FormatString.
136 @return The number of Unicode characters in the produced output buffer not including the
143 OUT CHAR16
*StartOfBuffer
,
145 IN CONST CHAR16
*FormatString
,
151 VA_START (Marker
, FormatString
);
152 return UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
156 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
157 ASCII format string and a VA_LIST argument list
159 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
161 The Unicode string is produced by parsing the format string specified by FormatString.
162 Arguments are pulled from the variable argument list specified by Marker based on the
163 contents of the format string.
164 The number of Unicode characters in the produced output buffer is returned not including
166 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
168 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
169 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
170 If BufferSize > 1 and FormatString is NULL, then ASSERT().
171 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
172 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
174 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
175 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
176 Null-terminator, then ASSERT().
178 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
180 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
181 @param FormatString Null-terminated Unicode format string.
182 @param Marker VA_LIST marker for the variable argument list.
184 @return The number of Unicode characters in the produced output buffer not including the
190 UnicodeVSPrintAsciiFormat (
191 OUT CHAR16
*StartOfBuffer
,
193 IN CONST CHAR8
*FormatString
,
197 return mPrint2Protocol
->UnicodeSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
201 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
202 ASCII format string and variable argument list.
204 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
206 The Unicode string is produced by parsing the format string specified by FormatString.
207 Arguments are pulled from the variable argument list based on the contents of the
209 The number of Unicode characters in the produced output buffer is returned not including
211 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
213 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
214 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
215 If BufferSize > 1 and FormatString is NULL, then ASSERT().
216 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
217 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
219 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
220 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
221 Null-terminator, then ASSERT().
223 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
225 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
226 @param FormatString Null-terminated Unicode format string.
227 @param ... Variable argument list whose contents are accessed based on the
228 format string specified by FormatString.
230 @return The number of Unicode characters in the produced output buffer not including the
236 UnicodeSPrintAsciiFormat (
237 OUT CHAR16
*StartOfBuffer
,
239 IN CONST CHAR8
*FormatString
,
245 VA_START (Marker
, FormatString
);
246 return UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
250 Converts a decimal value to a Null-terminated Unicode string.
252 Converts the decimal number specified by Value to a Null-terminated Unicode
253 string specified by Buffer containing at most Width characters. No padding of spaces
254 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
255 The number of Unicode characters in Buffer is returned not including the Null-terminator.
256 If the conversion contains more than Width characters, then only the first
257 Width characters are returned, and the total number of characters
258 required to perform the conversion is returned.
259 Additional conversion parameters are specified in Flags.
261 The Flags bit LEFT_JUSTIFY is always ignored.
262 All conversions are left justified in Buffer.
263 If Width is 0, PREFIX_ZERO is ignored in Flags.
264 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
265 are inserted every 3rd digit starting from the right.
266 If HEX_RADIX is set in Flags, then the output buffer will be
267 formatted in hexadecimal format.
268 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
269 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
270 then Buffer is padded with '0' characters so the combination of the optional '-'
271 sign character, '0' characters, digit characters for Value, and the Null-terminator
272 add up to Width characters.
273 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
274 If Buffer is NULL, then ASSERT().
275 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
276 If unsupported bits are set in Flags, then ASSERT().
277 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
278 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
280 @param Buffer Pointer to the output buffer for the produced Null-terminated
282 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
283 @param Value The 64-bit signed value to convert to a string.
284 @param Width The maximum number of Unicode characters to place in Buffer, not including
287 @return The number of Unicode characters in Buffer not including the Null-terminator.
292 UnicodeValueToString (
293 IN OUT CHAR16
*Buffer
,
299 return mPrint2Protocol
->UnicodeValueToString (Buffer
, Flags
, Value
, Width
);
303 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
304 ASCII format string and a VA_LIST argument list.
306 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
308 The ASCII string is produced by parsing the format string specified by FormatString.
309 Arguments are pulled from the variable argument list specified by Marker based on
310 the contents of the format string.
311 The number of ASCII characters in the produced output buffer is returned not including
313 If BufferSize is 0, then no output buffer is produced and 0 is returned.
315 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
316 If BufferSize > 0 and FormatString is NULL, then ASSERT().
317 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
318 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
320 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
321 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
322 Null-terminator, then ASSERT().
324 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
326 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
327 @param FormatString Null-terminated Unicode format string.
328 @param Marker VA_LIST marker for the variable argument list.
330 @return The number of ASCII characters in the produced output buffer not including the
337 OUT CHAR8
*StartOfBuffer
,
339 IN CONST CHAR8
*FormatString
,
343 return mPrint2Protocol
->AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
347 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
348 ASCII format string and variable argument list.
350 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
352 The ASCII string is produced by parsing the format string specified by FormatString.
353 Arguments are pulled from the variable argument list based on the contents of the
355 The number of ASCII characters in the produced output buffer is returned not including
357 If BufferSize is 0, then no output buffer is produced and 0 is returned.
359 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
360 If BufferSize > 0 and FormatString is NULL, then ASSERT().
361 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
362 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
364 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
365 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
366 Null-terminator, then ASSERT().
368 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
370 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
371 @param FormatString Null-terminated Unicode format string.
372 @param ... Variable argument list whose contents are accessed based on the
373 format string specified by FormatString.
375 @return The number of ASCII characters in the produced output buffer not including the
382 OUT CHAR8
*StartOfBuffer
,
384 IN CONST CHAR8
*FormatString
,
390 VA_START (Marker
, FormatString
);
391 return AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
395 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
396 ASCII format string and a VA_LIST argument list.
398 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
400 The ASCII string is produced by parsing the format string specified by FormatString.
401 Arguments are pulled from the variable argument list specified by Marker based on
402 the contents of the format string.
403 The number of ASCII characters in the produced output buffer is returned not including
405 If BufferSize is 0, then no output buffer is produced and 0 is returned.
407 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
408 If BufferSize > 0 and FormatString is NULL, then ASSERT().
409 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
410 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
411 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
413 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
414 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
415 Null-terminator, then ASSERT().
417 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
419 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
420 @param FormatString Null-terminated Unicode format string.
421 @param Marker VA_LIST marker for the variable argument list.
423 @return The number of ASCII characters in the produced output buffer not including the
429 AsciiVSPrintUnicodeFormat (
430 OUT CHAR8
*StartOfBuffer
,
432 IN CONST CHAR16
*FormatString
,
436 return mPrint2Protocol
->AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
440 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
441 ASCII format string and variable argument list.
443 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
445 The ASCII string is produced by parsing the format string specified by FormatString.
446 Arguments are pulled from the variable argument list based on the contents of the
448 The number of ASCII characters in the produced output buffer is returned not including
450 If BufferSize is 0, then no output buffer is produced and 0 is returned.
452 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
453 If BufferSize > 0 and FormatString is NULL, then ASSERT().
454 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
455 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
456 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
458 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
459 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
460 Null-terminator, then ASSERT().
462 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
464 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
465 @param FormatString Null-terminated Unicode format string.
466 @param ... Variable argument list whose contents are accessed based on the
467 format string specified by FormatString.
469 @return The number of ASCII characters in the produced output buffer not including the
475 AsciiSPrintUnicodeFormat (
476 OUT CHAR8
*StartOfBuffer
,
478 IN CONST CHAR16
*FormatString
,
484 VA_START (Marker
, FormatString
);
485 return AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
490 Converts a decimal value to a Null-terminated ASCII string.
492 Converts the decimal number specified by Value to a Null-terminated ASCII string
493 specified by Buffer containing at most Width characters. No padding of spaces
495 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
496 The number of ASCII characters in Buffer is returned not including the Null-terminator.
497 If the conversion contains more than Width characters, then only the first Width
498 characters are returned, and the total number of characters required to perform
499 the conversion is returned.
500 Additional conversion parameters are specified in Flags.
501 The Flags bit LEFT_JUSTIFY is always ignored.
502 All conversions are left justified in Buffer.
503 If Width is 0, PREFIX_ZERO is ignored in Flags.
504 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
505 are inserted every 3rd digit starting from the right.
506 If HEX_RADIX is set in Flags, then the output buffer will be
507 formatted in hexadecimal format.
508 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
509 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
510 then Buffer is padded with '0' characters so the combination of the optional '-'
511 sign character, '0' characters, digit characters for Value, and the Null-terminator
512 add up to Width characters.
514 If Buffer is NULL, then ASSERT().
515 If unsupported bits are set in Flags, then ASSERT().
516 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
517 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
519 @param Buffer Pointer to the output buffer for the produced Null-terminated
521 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
522 @param Value The 64-bit signed value to convert to a string.
523 @param Width The maximum number of ASCII characters to place in Buffer, not including
526 @return The number of ASCII characters in Buffer not including the Null-terminator.
538 return mPrint2Protocol
->AsciiValueToString (Buffer
, Flags
, Value
, Width
);