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.
42 IN CONST CHAR16
*Format
,
43 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Console
,
51 ASSERT (Format
!= NULL
);
52 ASSERT (((UINTN
) Format
& 0x01) == 0);
54 BufferSize
= (PcdGet32 (PcdUefiLibMaxPrintBufferSize
) + 1) * sizeof (CHAR16
);
56 Buffer
= (CHAR16
*) AllocatePool(BufferSize
);
57 ASSERT (Buffer
!= NULL
);
59 Return
= UnicodeVSPrint (Buffer
, BufferSize
, Format
, Marker
);
61 if (Console
!= NULL
&& Return
> 0) {
63 // To be extra safe make sure Console has been initialized
65 Console
->OutputString (Console
, Buffer
);
74 Prints a formatted Unicode string to the console output device specified by
75 ConOut defined in the EFI_SYSTEM_TABLE.
77 This function prints a formatted Unicode string to the console output device
78 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
79 characters that printed to ConOut. If the length of the formatted Unicode
80 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
81 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
82 If Format is NULL, then ASSERT().
83 If Format is not aligned on a 16-bit boundary, then ASSERT().
85 @param Format Null-terminated Unicode format string.
86 @param ... VARARG list consumed to process Format.
88 @return The number of Unicode characters in the produced
89 output buffer not including the Null-terminator.
95 IN CONST CHAR16
*Format
,
102 VA_START (Marker
, Format
);
104 Return
= InternalPrint (Format
, gST
->ConOut
, Marker
);
112 Prints a formatted Unicode string to the console output device specified by
113 StdErr defined in the EFI_SYSTEM_TABLE.
115 This function prints a formatted Unicode string to the console output device
116 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
117 characters that printed to StdErr. If the length of the formatted Unicode
118 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
119 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
120 If Format is NULL, then ASSERT().
121 If Format is not aligned on a 16-bit boundary, then ASSERT().
123 @param Format Null-terminated Unicode format string.
124 @param ... VARARG list consumed to process Format.
126 @return The number of Unicode characters in the produced
127 output buffer not including the Null-terminator.
133 IN CONST CHAR16
*Format
,
140 VA_START (Marker
, Format
);
142 Return
= InternalPrint( Format
, gST
->StdErr
, Marker
);
151 Internal function which prints a formatted ASCII string to the console output device
154 This function prints a formatted ASCII string to the console output device
155 specified by Console and returns the number of ASCII characters that printed
156 to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,
157 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.
158 If Format is NULL, then ASSERT().
160 If Format is NULL, then ASSERT().
161 If Format is not aligned on a 16-bit boundary, then ASSERT().
164 @param Format Null-terminated ASCII format string.
165 @param Console The output console.
166 @param Marker VA_LIST marker for the variable argument list.
168 @return The number of Unicode characters in the produced
169 output buffer not including the Null-terminator.
175 IN CONST CHAR8
*Format
,
176 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Console
,
184 ASSERT (Format
!= NULL
);
186 BufferSize
= (PcdGet32 (PcdUefiLibMaxPrintBufferSize
) + 1) * sizeof (CHAR16
);
188 Buffer
= (CHAR16
*) AllocatePool(BufferSize
);
189 ASSERT (Buffer
!= NULL
);
191 Return
= UnicodeVSPrintAsciiFormat (Buffer
, BufferSize
, Format
, Marker
);
193 if (Console
!= NULL
) {
195 // To be extra safe make sure Console has been initialized
197 Console
->OutputString (Console
, Buffer
);
206 Prints a formatted ASCII string to the console output device specified by
207 ConOut defined in the EFI_SYSTEM_TABLE.
209 This function prints a formatted ASCII string to the console output device
210 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
211 characters that printed to ConOut. If the length of the formatted ASCII
212 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
213 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
214 If Format is NULL, then ASSERT().
215 If Format is not aligned on a 16-bit boundary, then ASSERT().
217 @param Format Null-terminated ASCII format string.
218 @param ... VARARG list consumed to process Format.
220 @return The number of Ascii characters in the produced
221 output buffer not including the Null-terminator.
227 IN CONST CHAR8
*Format
,
234 VA_START (Marker
, Format
);
236 Return
= AsciiInternalPrint( Format
, gST
->ConOut
, Marker
);
244 Prints a formatted ASCII string to the console output device specified by
245 StdErr defined in the EFI_SYSTEM_TABLE.
247 This function prints a formatted ASCII string to the console output device
248 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
249 characters that printed to StdErr. If the length of the formatted ASCII
250 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
251 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
252 If Format is NULL, then ASSERT().
253 If Format is not aligned on a 16-bit boundary, then ASSERT().
255 @param Format Null-terminated ASCII format string.
256 @param ... VARARG list consumed to process Format.
258 @return The number of Ascii characters in the produced output
259 buffer not including the Null-terminator.
265 IN CONST CHAR8
*Format
,
272 VA_START (Marker
, Format
);
274 Return
= AsciiInternalPrint( Format
, gST
->StdErr
, Marker
);