]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/UefiLib/UefiLibPrint.c
ECC clanup: Update the doxygen comment.
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiLibPrint.c
... / ...
CommitLineData
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
16\r
17#include "UefiLibInternal.h"\r
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
27 If Format is NULL, then ASSERT().\r
28 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
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
33 \r
34 @return The number of Unicode characters in the produced\r
35 output buffer not including the Null-terminator.\r
36**/\r
37UINTN\r
38EFIAPI\r
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
59 if (Console != NULL && Return > 0) {\r
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
80 If Format is NULL, then ASSERT().\r
81 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
82\r
83 @param Format Null-terminated Unicode format string.\r
84 @param ... Variable argument list whose contents are accessed based \r
85 on the format string specified by Format.\r
86 \r
87 @return The number of Unicode characters in the produced\r
88 output buffer not including the Null-terminator.\r
89\r
90**/\r
91UINTN\r
92EFIAPI\r
93Print (\r
94 IN CONST CHAR16 *Format,\r
95 ...\r
96 )\r
97{\r
98 VA_LIST Marker;\r
99 UINTN Return;\r
100\r
101 VA_START (Marker, Format);\r
102\r
103 Return = InternalPrint (Format, gST->ConOut, Marker);\r
104\r
105 VA_END (Marker);\r
106\r
107 return Return;\r
108}\r
109\r
110/**\r
111 Prints a formatted Unicode string to the console output device specified by\r
112 StdErr defined in the EFI_SYSTEM_TABLE.\r
113\r
114 This function prints a formatted Unicode string to the console output device\r
115 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode\r
116 characters that printed to StdErr. If the length of the formatted Unicode\r
117 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
118 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
119 If Format is NULL, then ASSERT().\r
120 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
121\r
122 @param Format Null-terminated Unicode format string.\r
123 @param ... Variable argument list whose contents are accessed based \r
124 on the format string specified by Format.\r
125\r
126 @return The number of Unicode characters in the produced\r
127 output buffer not including the Null-terminator.\r
128**/\r
129UINTN\r
130EFIAPI\r
131ErrorPrint (\r
132 IN CONST CHAR16 *Format,\r
133 ...\r
134 )\r
135{\r
136 VA_LIST Marker;\r
137 UINTN Return;\r
138\r
139 VA_START (Marker, Format);\r
140\r
141 Return = InternalPrint( Format, gST->StdErr, Marker);\r
142\r
143 VA_END (Marker);\r
144\r
145 return Return;\r
146}\r
147\r
148\r
149/**\r
150 Internal function which prints a formatted ASCII string to the console output device\r
151 specified by Console\r
152\r
153 This function prints a formatted ASCII string to the console output device\r
154 specified by Console and returns the number of ASCII characters that printed\r
155 to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,\r
156 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
157 If Format is NULL, then ASSERT().\r
158\r
159 If Format is NULL, then ASSERT().\r
160 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
161 \r
162\r
163 @param Format Null-terminated ASCII format string.\r
164 @param Console The output console.\r
165 @param Marker VA_LIST marker for the variable argument list.\r
166\r
167 @return The number of Unicode characters in the produced\r
168 output buffer not including the Null-terminator.\r
169\r
170**/\r
171UINTN\r
172EFIAPI\r
173AsciiInternalPrint (\r
174 IN CONST CHAR8 *Format,\r
175 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
176 IN VA_LIST Marker\r
177 )\r
178{\r
179 UINTN Return;\r
180 CHAR16 *Buffer;\r
181 UINTN BufferSize;\r
182\r
183 ASSERT (Format != NULL);\r
184\r
185 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
186\r
187 Buffer = (CHAR16 *) AllocatePool(BufferSize);\r
188 ASSERT (Buffer != NULL);\r
189\r
190 Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);\r
191\r
192 if (Console != NULL) {\r
193 //\r
194 // To be extra safe make sure Console has been initialized\r
195 //\r
196 Console->OutputString (Console, Buffer);\r
197 }\r
198\r
199 FreePool (Buffer);\r
200\r
201 return Return;\r
202}\r
203\r
204/**\r
205 Prints a formatted ASCII string to the console output device specified by\r
206 ConOut defined in the EFI_SYSTEM_TABLE.\r
207\r
208 This function prints a formatted ASCII string to the console output device\r
209 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII\r
210 characters that printed to ConOut. If the length of the formatted ASCII\r
211 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
212 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
213 If Format is NULL, then ASSERT().\r
214\r
215 @param Format Null-terminated ASCII format string.\r
216 @param ... Variable argument list whose contents are accessed based \r
217 on the format string specified by Format.\r
218 \r
219 @return The number of Ascii characters in the produced\r
220 output buffer not including the Null-terminator.\r
221\r
222**/\r
223UINTN\r
224EFIAPI\r
225AsciiPrint (\r
226 IN CONST CHAR8 *Format,\r
227 ...\r
228 )\r
229{\r
230 VA_LIST Marker;\r
231 UINTN Return;\r
232 ASSERT (Format != NULL);\r
233 \r
234 VA_START (Marker, Format);\r
235\r
236 Return = AsciiInternalPrint( Format, gST->ConOut, Marker);\r
237\r
238 VA_END (Marker);\r
239\r
240 return Return;\r
241}\r
242\r
243/**\r
244 Prints a formatted ASCII string to the console output device specified by\r
245 StdErr defined in the EFI_SYSTEM_TABLE.\r
246\r
247 This function prints a formatted ASCII string to the console output device\r
248 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII\r
249 characters that printed to StdErr. If the length of the formatted ASCII\r
250 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
251 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
252 If Format is NULL, then ASSERT().\r
253\r
254 @param Format Null-terminated ASCII format string.\r
255 @param ... Variable argument list whose contents are accessed based \r
256 on the format string specified by Format.\r
257 \r
258 @return The number of Ascii characters in the produced output\r
259 buffer not including the Null-terminator.\r
260\r
261**/\r
262UINTN\r
263EFIAPI\r
264AsciiErrorPrint (\r
265 IN CONST CHAR8 *Format,\r
266 ...\r
267 )\r
268{\r
269 VA_LIST Marker;\r
270 UINTN Return;\r
271\r
272 ASSERT (Format != NULL);\r
273 \r
274 VA_START (Marker, Format);\r
275\r
276 Return = AsciiInternalPrint( Format, gST->StdErr, Marker);\r
277\r
278 VA_END (Marker);\r
279\r
280 return Return;\r
281}\r
282\r