2 Mde UEFI library API implemention.
3 Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE
5 Copyright (c) 2007, Intel Corporation<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
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.
17 // Include common header file for this module.
19 #include "UefiLibInternal.h"
22 Internal function which prints a formatted Unicode string to the console output device
25 This function prints a formatted Unicode string to the console output device
26 specified by Console and returns the number of Unicode characters that printed
27 to it. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize,
28 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.
29 If Format is NULL, then ASSERT().
30 If Format is not aligned on a 16-bit boundary, then ASSERT().
32 @param Format Null-terminated Unicode format string.
33 @param Console The output console.
34 @param Marker VA_LIST marker for the variable argument list.
36 @return The number of Unicode characters in the produced
37 output buffer not including the Null-terminator.
43 IN CONST CHAR16
*Format
,
44 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Console
,
52 ASSERT (Format
!= NULL
);
53 ASSERT (((UINTN
) Format
& 0x01) == 0);
55 BufferSize
= (PcdGet32 (PcdUefiLibMaxPrintBufferSize
) + 1) * sizeof (CHAR16
);
57 Buffer
= (CHAR16
*) AllocatePool(BufferSize
);
58 ASSERT (Buffer
!= NULL
);
60 Return
= UnicodeVSPrint (Buffer
, BufferSize
, Format
, Marker
);
62 if (Console
!= NULL
&& Return
> 0) {
64 // To be extra safe make sure Console has been initialized
66 Console
->OutputString (Console
, Buffer
);
75 Prints a formatted Unicode string to the console output device specified by
76 ConOut defined in the EFI_SYSTEM_TABLE.
78 This function prints a formatted Unicode string to the console output device
79 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
80 characters that printed to ConOut. If the length of the formatted Unicode
81 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
82 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
83 If Format is NULL, then ASSERT().
84 If Format is not aligned on a 16-bit boundary, then ASSERT().
86 @param Format Null-terminated Unicode format string.
87 @param ... VARARG list consumed to process Format.
89 @return The number of Unicode characters in the produced
90 output buffer not including the Null-terminator.
96 IN CONST CHAR16
*Format
,
103 VA_START (Marker
, Format
);
105 Return
= InternalPrint (Format
, gST
->ConOut
, Marker
);
113 Prints a formatted Unicode string to the console output device specified by
114 StdErr defined in the EFI_SYSTEM_TABLE.
116 This function prints a formatted Unicode string to the console output device
117 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
118 characters that printed to StdErr. If the length of the formatted Unicode
119 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
120 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
121 If Format is NULL, then ASSERT().
122 If Format is not aligned on a 16-bit boundary, then ASSERT().
124 @param Format Null-terminated Unicode format string.
125 @param ... VARARG list consumed to process Format.
127 @return The number of Unicode characters in the produced
128 output buffer not including the Null-terminator.
134 IN CONST CHAR16
*Format
,
141 VA_START (Marker
, Format
);
143 Return
= InternalPrint( Format
, gST
->StdErr
, Marker
);
152 Internal function which prints a formatted ASCII string to the console output device
155 This function prints a formatted ASCII string to the console output device
156 specified by Console and returns the number of ASCII characters that printed
157 to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,
158 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.
159 If Format is NULL, then ASSERT().
161 If Format is NULL, then ASSERT().
162 If Format is not aligned on a 16-bit boundary, then ASSERT().
165 @param Format Null-terminated ASCII format string.
166 @param Console The output console.
167 @param Marker VA_LIST marker for the variable argument list.
169 @return The number of Unicode characters in the produced
170 output buffer not including the Null-terminator.
176 IN CONST CHAR8
*Format
,
177 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Console
,
185 ASSERT (Format
!= NULL
);
187 BufferSize
= (PcdGet32 (PcdUefiLibMaxPrintBufferSize
) + 1) * sizeof (CHAR16
);
189 Buffer
= (CHAR16
*) AllocatePool(BufferSize
);
190 ASSERT (Buffer
!= NULL
);
192 Return
= UnicodeVSPrintAsciiFormat (Buffer
, BufferSize
, Format
, Marker
);
194 if (Console
!= NULL
) {
196 // To be extra safe make sure Console has been initialized
198 Console
->OutputString (Console
, Buffer
);
207 Prints a formatted ASCII string to the console output device specified by
208 ConOut defined in the EFI_SYSTEM_TABLE.
210 This function prints a formatted ASCII string to the console output device
211 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
212 characters that printed to ConOut. If the length of the formatted ASCII
213 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
214 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
215 If Format is NULL, then ASSERT().
216 If Format is not aligned on a 16-bit boundary, then ASSERT().
218 @param Format Null-terminated ASCII format string.
219 @param ... VARARG list consumed to process Format.
221 @return The number of Ascii characters in the produced
222 output buffer not including the Null-terminator.
228 IN CONST CHAR8
*Format
,
235 VA_START (Marker
, Format
);
237 Return
= AsciiInternalPrint( Format
, gST
->ConOut
, Marker
);
245 Prints a formatted ASCII string to the console output device specified by
246 StdErr defined in the EFI_SYSTEM_TABLE.
248 This function prints a formatted ASCII string to the console output device
249 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
250 characters that printed to StdErr. If the length of the formatted ASCII
251 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
252 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
253 If Format is NULL, then ASSERT().
254 If Format is not aligned on a 16-bit boundary, then ASSERT().
256 @param Format Null-terminated ASCII format string.
257 @param ... VARARG list consumed to process Format.
259 @return The number of Ascii characters in the produced output
260 buffer not including the Null-terminator.
266 IN CONST CHAR8
*Format
,
273 VA_START (Marker
, Format
);
275 Return
= AsciiInternalPrint( Format
, gST
->StdErr
, Marker
);