]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiLib/UefiLibPrint.c
remove unnecessary comments introduced by tools from MdePkg. The regular express...
[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
127\r
128UINTN\r
129EFIAPI\r
130ErrorPrint (\r
131 IN CONST CHAR16 *Format,\r
132 ...\r
133 )\r
134{\r
135 VA_LIST Marker;\r
136 UINTN Return;\r
137\r
138 VA_START (Marker, Format);\r
139\r
140 Return = InternalPrint( Format, gST->StdErr, Marker);\r
141\r
142 VA_END (Marker);\r
143\r
144 return Return;\r
145}\r
146\r
147\r
148/**\r
149 Internal function which prints a formatted ASCII string to the console output device\r
150 specified by Console\r
151\r
152 This function prints a formatted ASCII string to the console output device\r
153 specified by Console and returns the number of ASCII characters that printed\r
154 to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,\r
155 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
f80b0830 156 If Format is NULL, then ASSERT().\r
157\r
158 If Format is NULL, then ASSERT().\r
159 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
160 \r
e386b444 161\r
162 @param Format Null-terminated ASCII format string.\r
163 @param Console The output console.\r
164 @param Marker VA_LIST marker for the variable argument list.\r
165\r
f80b0830 166 @return The number of Unicode characters in the produced\r
167 output buffer not including the Null-terminator.\r
e386b444 168\r
169**/\r
e386b444 170UINTN\r
42eedea9 171EFIAPI\r
e386b444 172AsciiInternalPrint (\r
173 IN CONST CHAR8 *Format,\r
174 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
175 IN VA_LIST Marker\r
176 )\r
177{\r
178 UINTN Return;\r
179 CHAR16 *Buffer;\r
180 UINTN BufferSize;\r
181\r
182 ASSERT (Format != NULL);\r
183\r
184 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
185\r
186 Buffer = (CHAR16 *) AllocatePool(BufferSize);\r
187 ASSERT (Buffer != NULL);\r
188\r
189 Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);\r
190\r
191 if (Console != NULL) {\r
192 //\r
193 // To be extra safe make sure Console has been initialized\r
194 //\r
195 Console->OutputString (Console, Buffer);\r
196 }\r
197\r
198 FreePool (Buffer);\r
199\r
200 return Return;\r
201}\r
202\r
203/**\r
204 Prints a formatted ASCII string to the console output device specified by\r
205 ConOut defined in the EFI_SYSTEM_TABLE.\r
206\r
207 This function prints a formatted ASCII string to the console output device\r
208 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII\r
209 characters that printed to ConOut. If the length of the formatted ASCII\r
210 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
211 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
f80b0830 212 If Format is NULL, then ASSERT().\r
e386b444 213\r
214 @param Format Null-terminated ASCII format string.\r
215 @param ... VARARG list consumed to process Format.\r
f80b0830 216 \r
217 @return The number of Ascii characters in the produced\r
218 output buffer not including the Null-terminator.\r
e386b444 219\r
220**/\r
221UINTN\r
222EFIAPI\r
223AsciiPrint (\r
224 IN CONST CHAR8 *Format,\r
225 ...\r
226 )\r
227{\r
228 VA_LIST Marker;\r
229 UINTN Return;\r
9edc73ad 230 ASSERT (Format != NULL);\r
231 \r
e386b444 232 VA_START (Marker, Format);\r
233\r
234 Return = AsciiInternalPrint( Format, gST->ConOut, Marker);\r
235\r
236 VA_END (Marker);\r
237\r
238 return Return;\r
239}\r
240\r
241/**\r
242 Prints a formatted ASCII string to the console output device specified by\r
243 StdErr defined in the EFI_SYSTEM_TABLE.\r
244\r
245 This function prints a formatted ASCII string to the console output device\r
246 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII\r
247 characters that printed to StdErr. If the length of the formatted ASCII\r
248 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
249 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
f80b0830 250 If Format is NULL, then ASSERT().\r
e386b444 251\r
252 @param Format Null-terminated ASCII format string.\r
253 @param ... VARARG list consumed to process Format.\r
f80b0830 254 \r
255 @return The number of Ascii characters in the produced output\r
256 buffer not including the Null-terminator.\r
e386b444 257\r
258**/\r
259UINTN\r
260EFIAPI\r
261AsciiErrorPrint (\r
262 IN CONST CHAR8 *Format,\r
263 ...\r
264 )\r
265{\r
266 VA_LIST Marker;\r
267 UINTN Return;\r
268\r
9edc73ad 269 ASSERT (Format != NULL);\r
270 \r
e386b444 271 VA_START (Marker, Format);\r
272\r
273 Return = AsciiInternalPrint( Format, gST->StdErr, Marker);\r
274\r
275 VA_END (Marker);\r
276\r
277 return Return;\r
278}\r
279\r