]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiLib/UefiLibPrint.c
deleted an empty space.
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiLibPrint.c
CommitLineData
e386b444 1/** @file\r
2 Mde UEFI library API implemention.\r
3 Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE\r
4\r
5 Copyright (c) 2007, Intel Corporation<BR>\r
6 All rights reserved. This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
1efcc4ae 16\r
f734a10a 17#include "UefiLibInternal.h"\r
e386b444 18\r
19/**\r
20 Internal function which prints a formatted Unicode string to the console output device\r
21 specified by Console\r
22\r
23 This function prints a formatted Unicode string to the console output device\r
24 specified by Console and returns the number of Unicode characters that printed\r
25 to it. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize,\r
26 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
f80b0830 27 If Format is NULL, then ASSERT().\r
28 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
e386b444 29\r
30 @param Format Null-terminated Unicode format string.\r
31 @param Console The output console.\r
32 @param Marker VA_LIST marker for the variable argument list.\r
f80b0830 33 \r
34 @return The number of Unicode characters in the produced\r
35 output buffer not including the Null-terminator.\r
e386b444 36**/\r
e386b444 37UINTN\r
42eedea9 38EFIAPI\r
e386b444 39InternalPrint (\r
40 IN CONST CHAR16 *Format,\r
41 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
42 IN VA_LIST Marker\r
43 )\r
44{\r
45 UINTN Return;\r
46 CHAR16 *Buffer;\r
47 UINTN BufferSize;\r
48\r
49 ASSERT (Format != NULL);\r
50 ASSERT (((UINTN) Format & 0x01) == 0);\r
51\r
52 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
53\r
54 Buffer = (CHAR16 *) AllocatePool(BufferSize);\r
55 ASSERT (Buffer != NULL);\r
56\r
57 Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
58\r
2ad4dad0 59 if (Console != NULL && Return > 0) {\r
e386b444 60 //\r
61 // To be extra safe make sure Console has been initialized\r
62 //\r
63 Console->OutputString (Console, Buffer);\r
64 }\r
65\r
66 FreePool (Buffer);\r
67\r
68 return Return;\r
69}\r
70\r
71/**\r
72 Prints a formatted Unicode string to the console output device specified by\r
73 ConOut defined in the EFI_SYSTEM_TABLE.\r
74\r
75 This function prints a formatted Unicode string to the console output device\r
76 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode\r
77 characters that printed to ConOut. If the length of the formatted Unicode\r
78 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
79 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
f80b0830 80 If Format is NULL, then ASSERT().\r
81 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
e386b444 82\r
83 @param Format Null-terminated Unicode format string.\r
84 @param ... VARARG list consumed to process Format.\r
f80b0830 85 \r
86 @return The number of Unicode characters in the produced\r
87 output buffer not including the Null-terminator.\r
e386b444 88\r
89**/\r
90UINTN\r
91EFIAPI\r
92Print (\r
93 IN CONST CHAR16 *Format,\r
94 ...\r
95 )\r
96{\r
97 VA_LIST Marker;\r
98 UINTN Return;\r
99\r
100 VA_START (Marker, Format);\r
101\r
102 Return = InternalPrint (Format, gST->ConOut, Marker);\r
103\r
104 VA_END (Marker);\r
105\r
106 return Return;\r
107}\r
108\r
109/**\r
110 Prints a formatted Unicode string to the console output device specified by\r
111 StdErr defined in the EFI_SYSTEM_TABLE.\r
112\r
113 This function prints a formatted Unicode string to the console output device\r
114 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode\r
115 characters that printed to StdErr. If the length of the formatted Unicode\r
116 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
117 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
f80b0830 118 If Format is NULL, then ASSERT().\r
119 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
e386b444 120\r
121 @param Format Null-terminated Unicode format string.\r
122 @param ... VARARG list consumed to process Format.\r
e386b444 123\r
f80b0830 124 @return The number of Unicode characters in the produced\r
125 output buffer not including the Null-terminator.\r
e386b444 126**/\r
e386b444 127UINTN\r
128EFIAPI\r
129ErrorPrint (\r
130 IN CONST CHAR16 *Format,\r
131 ...\r
132 )\r
133{\r
134 VA_LIST Marker;\r
135 UINTN Return;\r
136\r
137 VA_START (Marker, Format);\r
138\r
139 Return = InternalPrint( Format, gST->StdErr, Marker);\r
140\r
141 VA_END (Marker);\r
142\r
143 return Return;\r
144}\r
145\r
146\r
147/**\r
148 Internal function which prints a formatted ASCII string to the console output device\r
149 specified by Console\r
150\r
151 This function prints a formatted ASCII string to the console output device\r
152 specified by Console and returns the number of ASCII characters that printed\r
153 to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,\r
154 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
f80b0830 155 If Format is NULL, then ASSERT().\r
156\r
157 If Format is NULL, then ASSERT().\r
158 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
159 \r
e386b444 160\r
161 @param Format Null-terminated ASCII format string.\r
162 @param Console The output console.\r
163 @param Marker VA_LIST marker for the variable argument list.\r
164\r
f80b0830 165 @return The number of Unicode characters in the produced\r
166 output buffer not including the Null-terminator.\r
e386b444 167\r
168**/\r
e386b444 169UINTN\r
42eedea9 170EFIAPI\r
e386b444 171AsciiInternalPrint (\r
172 IN CONST CHAR8 *Format,\r
173 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
174 IN VA_LIST Marker\r
175 )\r
176{\r
177 UINTN Return;\r
178 CHAR16 *Buffer;\r
179 UINTN BufferSize;\r
180\r
181 ASSERT (Format != NULL);\r
182\r
183 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
184\r
185 Buffer = (CHAR16 *) AllocatePool(BufferSize);\r
186 ASSERT (Buffer != NULL);\r
187\r
188 Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);\r
189\r
190 if (Console != NULL) {\r
191 //\r
192 // To be extra safe make sure Console has been initialized\r
193 //\r
194 Console->OutputString (Console, Buffer);\r
195 }\r
196\r
197 FreePool (Buffer);\r
198\r
199 return Return;\r
200}\r
201\r
202/**\r
203 Prints a formatted ASCII string to the console output device specified by\r
204 ConOut defined in the EFI_SYSTEM_TABLE.\r
205\r
206 This function prints a formatted ASCII string to the console output device\r
207 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII\r
208 characters that printed to ConOut. If the length of the formatted ASCII\r
209 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
210 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
f80b0830 211 If Format is NULL, then ASSERT().\r
e386b444 212\r
213 @param Format Null-terminated ASCII format string.\r
214 @param ... VARARG list consumed to process Format.\r
f80b0830 215 \r
216 @return The number of Ascii characters in the produced\r
217 output buffer not including the Null-terminator.\r
e386b444 218\r
219**/\r
220UINTN\r
221EFIAPI\r
222AsciiPrint (\r
223 IN CONST CHAR8 *Format,\r
224 ...\r
225 )\r
226{\r
227 VA_LIST Marker;\r
228 UINTN Return;\r
9edc73ad 229 ASSERT (Format != NULL);\r
230 \r
e386b444 231 VA_START (Marker, Format);\r
232\r
233 Return = AsciiInternalPrint( Format, gST->ConOut, Marker);\r
234\r
235 VA_END (Marker);\r
236\r
237 return Return;\r
238}\r
239\r
240/**\r
241 Prints a formatted ASCII string to the console output device specified by\r
242 StdErr defined in the EFI_SYSTEM_TABLE.\r
243\r
244 This function prints a formatted ASCII string to the console output device\r
245 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII\r
246 characters that printed to StdErr. If the length of the formatted ASCII\r
247 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
248 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
f80b0830 249 If Format is NULL, then ASSERT().\r
e386b444 250\r
251 @param Format Null-terminated ASCII format string.\r
252 @param ... VARARG list consumed to process Format.\r
f80b0830 253 \r
254 @return The number of Ascii characters in the produced output\r
255 buffer not including the Null-terminator.\r
e386b444 256\r
257**/\r
258UINTN\r
259EFIAPI\r
260AsciiErrorPrint (\r
261 IN CONST CHAR8 *Format,\r
262 ...\r
263 )\r
264{\r
265 VA_LIST Marker;\r
266 UINTN Return;\r
267\r
9edc73ad 268 ASSERT (Format != NULL);\r
269 \r
e386b444 270 VA_START (Marker, Format);\r
271\r
272 Return = AsciiInternalPrint( Format, gST->StdErr, Marker);\r
273\r
274 VA_END (Marker);\r
275\r
276 return Return;\r
277}\r
278\r