]>
Commit | Line | Data |
---|---|---|
a0afd019 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | PrintLib.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Print Library\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
a0afd019 | 22 | #include <PiDxe.h>\r |
ed7748fe | 23 | \r |
a0afd019 | 24 | #include <Protocol/Print.h>\r |
ed7748fe | 25 | \r |
a0afd019 | 26 | #include <Library/PrintLib.h>\r |
27 | #include <Library/UefiBootServicesTableLib.h>\r | |
28 | \r | |
29 | static EFI_PRINT_PROTOCOL *gPrintProtocol = NULL;\r | |
30 | \r | |
2ad4dad0 LG |
31 | EFI_STATUS\r |
32 | EFIAPI\r | |
33 | InternalLocatePrintProtocol (\r | |
a0afd019 | 34 | )\r |
a0afd019 | 35 | {\r |
2ad4dad0 | 36 | EFI_STATUS Status = EFI_SUCCESS;\r |
a0afd019 | 37 | \r |
38 | if (gPrintProtocol == NULL) {\r | |
39 | Status = gBS->LocateProtocol (\r | |
40 | &gEfiPrintProtocolGuid,\r | |
41 | NULL,\r | |
42 | (VOID **)&gPrintProtocol\r | |
43 | );\r | |
44 | if (EFI_ERROR (Status)) {\r | |
45 | gPrintProtocol = NULL;\r | |
2ad4dad0 | 46 | return Status;\r |
a0afd019 | 47 | }\r |
48 | }\r | |
2ad4dad0 LG |
49 | \r |
50 | return EFI_SUCCESS;\r | |
51 | }\r | |
52 | \r | |
53 | /**\r | |
54 | Produces a Null-terminated Unicode string in an output buffer based on \r | |
55 | a Null-terminated Unicode format string and a VA_LIST argument list\r | |
56 | \r | |
57 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
58 | and BufferSize. \r | |
59 | The Unicode string is produced by parsing the format string specified by FormatString. \r | |
60 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
61 | contents of the format string. \r | |
62 | The number of Unicode characters in the produced output buffer is returned not including\r | |
63 | the Null-terminator.\r | |
64 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
65 | \r | |
66 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
67 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
68 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
69 | If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
70 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
71 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
72 | ASSERT().\r | |
73 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
74 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
75 | Null-terminator, then ASSERT().\r | |
76 | \r | |
77 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
78 | Unicode string.\r | |
79 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
80 | @param FormatString Null-terminated Unicode format string.\r | |
81 | @param Marker VA_LIST marker for the variable argument list.\r | |
82 | \r | |
83 | @return The number of Unicode characters in the produced output buffer not including the\r | |
84 | Null-terminator.\r | |
85 | \r | |
86 | **/\r | |
87 | UINTN\r | |
88 | EFIAPI\r | |
89 | UnicodeVSPrint (\r | |
90 | OUT CHAR16 *StartOfBuffer,\r | |
91 | IN UINTN BufferSize,\r | |
92 | IN CONST CHAR16 *FormatString,\r | |
93 | IN VA_LIST Marker\r | |
94 | )\r | |
95 | {\r | |
96 | if (InternalLocatePrintProtocol() != EFI_SUCCESS) {\r | |
97 | return 0;\r | |
98 | }\r | |
99 | \r | |
a0afd019 | 100 | return gPrintProtocol->VSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r |
101 | }\r | |
102 | \r | |
2ad4dad0 LG |
103 | /**\r |
104 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
105 | Unicode format string and variable argument list.\r | |
106 | \r | |
107 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
108 | and BufferSize.\r | |
109 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
110 | Arguments are pulled from the variable argument list based on the contents of the format string.\r | |
111 | The number of Unicode characters in the produced output buffer is returned not including\r | |
112 | the Null-terminator.\r | |
113 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
114 | \r | |
115 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
116 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
117 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
118 | If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
119 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
120 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
121 | ASSERT().\r | |
122 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
123 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
124 | Null-terminator, then ASSERT().\r | |
125 | \r | |
126 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
127 | Unicode string.\r | |
128 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
129 | @param FormatString Null-terminated Unicode format string.\r | |
130 | \r | |
131 | @return The number of Unicode characters in the produced output buffer not including the\r | |
132 | Null-terminator.\r | |
133 | \r | |
134 | **/\r | |
a0afd019 | 135 | UINTN\r |
2ad4dad0 | 136 | EFIAPI\r |
a0afd019 | 137 | UnicodeSPrint (\r |
138 | OUT CHAR16 *StartOfBuffer,\r | |
139 | IN UINTN BufferSize,\r | |
2ad4dad0 | 140 | IN CONST CHAR16 *FormatString,\r |
a0afd019 | 141 | ...\r |
142 | )\r | |
a0afd019 | 143 | {\r |
2ad4dad0 | 144 | VA_LIST Marker;\r |
a0afd019 | 145 | \r |
146 | VA_START (Marker, FormatString);\r | |
2ad4dad0 | 147 | return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r |
a0afd019 | 148 | }\r |
149 | \r | |
2ad4dad0 LG |
150 | /**\r |
151 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r | |
152 | ASCII format string and a VA_LIST argument list\r | |
153 | \r | |
154 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
155 | and BufferSize.\r | |
156 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
157 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
158 | contents of the format string.\r | |
159 | The number of Unicode characters in the produced output buffer is returned not including\r | |
160 | the Null-terminator.\r | |
161 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
162 | \r | |
163 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
164 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
165 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
166 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
167 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
168 | ASSERT().\r | |
169 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
170 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
171 | Null-terminator, then ASSERT().\r | |
172 | \r | |
173 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
174 | Unicode string.\r | |
175 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
176 | @param FormatString Null-terminated Unicode format string.\r | |
177 | @param Marker VA_LIST marker for the variable argument list.\r | |
178 | \r | |
179 | @return The number of Unicode characters in the produced output buffer not including the\r | |
180 | Null-terminator.\r | |
181 | \r | |
182 | **/\r | |
a0afd019 | 183 | UINTN\r |
2ad4dad0 LG |
184 | EFIAPI\r |
185 | UnicodeVSPrintAsciiFormat (\r | |
186 | OUT CHAR16 *StartOfBuffer,\r | |
187 | IN UINTN BufferSize,\r | |
188 | IN CONST CHAR8 *FormatString,\r | |
189 | IN VA_LIST Marker\r | |
a0afd019 | 190 | )\r |
2ad4dad0 LG |
191 | {\r |
192 | if (InternalLocatePrintProtocol() != EFI_SUCCESS) {\r | |
193 | return 0;\r | |
194 | }\r | |
a0afd019 | 195 | \r |
2ad4dad0 LG |
196 | return gPrintProtocol->UniVSPrintAscii (StartOfBuffer, BufferSize, FormatString, Marker);\r |
197 | }\r | |
a0afd019 | 198 | \r |
2ad4dad0 LG |
199 | /**\r |
200 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
201 | ASCII format string and variable argument list.\r | |
202 | \r | |
203 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
204 | and BufferSize.\r | |
205 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
206 | Arguments are pulled from the variable argument list based on the contents of the \r | |
207 | format string.\r | |
208 | The number of Unicode characters in the produced output buffer is returned not including\r | |
209 | the Null-terminator.\r | |
210 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
211 | \r | |
212 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
213 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
214 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
215 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
216 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
217 | ASSERT().\r | |
218 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
219 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
220 | Null-terminator, then ASSERT().\r | |
221 | \r | |
222 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
223 | Unicode string.\r | |
224 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
225 | @param FormatString Null-terminated Unicode format string.\r | |
226 | \r | |
227 | @return The number of Unicode characters in the produced output buffer not including the\r | |
228 | Null-terminator.\r | |
229 | \r | |
230 | **/\r | |
231 | UINTN\r | |
232 | EFIAPI\r | |
233 | UnicodeSPrintAsciiFormat (\r | |
234 | OUT CHAR16 *StartOfBuffer,\r | |
235 | IN UINTN BufferSize,\r | |
236 | IN CONST CHAR8 *FormatString,\r | |
237 | ...\r | |
238 | )\r | |
239 | {\r | |
240 | VA_LIST Marker;\r | |
a0afd019 | 241 | \r |
2ad4dad0 LG |
242 | VA_START (Marker, FormatString);\r |
243 | return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
244 | }\r | |
a0afd019 | 245 | \r |
2ad4dad0 LG |
246 | /**\r |
247 | Converts a decimal value to a Null-terminated Unicode string.\r | |
248 | \r | |
249 | Converts the decimal number specified by Value to a Null-terminated Unicode \r | |
250 | string specified by Buffer containing at most Width characters. No padding of spaces \r | |
251 | is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
252 | The number of Unicode characters in Buffer is returned not including the Null-terminator.\r | |
253 | If the conversion contains more than Width characters, then only the first\r | |
254 | Width characters are returned, and the total number of characters \r | |
255 | required to perform the conversion is returned.\r | |
256 | Additional conversion parameters are specified in Flags. \r | |
257 | \r | |
258 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
259 | All conversions are left justified in Buffer.\r | |
260 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
261 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r | |
262 | are inserted every 3rd digit starting from the right.\r | |
263 | If HEX_RADIX is set in Flags, then the output buffer will be \r | |
264 | formatted in hexadecimal format.\r | |
265 | If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r | |
266 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r | |
267 | then Buffer is padded with '0' characters so the combination of the optional '-' \r | |
268 | sign character, '0' characters, digit characters for Value, and the Null-terminator\r | |
269 | add up to Width characters.\r | |
270 | If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r | |
271 | If Buffer is NULL, then ASSERT().\r | |
272 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
273 | If unsupported bits are set in Flags, then ASSERT().\r | |
274 | If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r | |
275 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
276 | \r | |
277 | @param Buffer Pointer to the output buffer for the produced Null-terminated\r | |
278 | Unicode string.\r | |
279 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
280 | @param Value The 64-bit signed value to convert to a string.\r | |
281 | @param Width The maximum number of Unicode characters to place in Buffer, not including\r | |
282 | the Null-terminator.\r | |
283 | \r | |
284 | @return The number of Unicode characters in Buffer not including the Null-terminator.\r | |
285 | \r | |
286 | **/\r | |
287 | UINTN\r | |
288 | EFIAPI\r | |
289 | UnicodeValueToString (\r | |
290 | IN OUT CHAR16 *Buffer,\r | |
291 | IN UINTN Flags,\r | |
292 | IN INT64 Value,\r | |
293 | IN UINTN Width\r | |
294 | )\r | |
295 | {\r | |
296 | if (InternalLocatePrintProtocol() != EFI_SUCCESS) {\r | |
297 | return 0;\r | |
298 | }\r | |
a0afd019 | 299 | \r |
2ad4dad0 LG |
300 | return gPrintProtocol->UniValueToString (Buffer, Flags, Value, Width);\r |
301 | }\r | |
a0afd019 | 302 | \r |
2ad4dad0 LG |
303 | /**\r |
304 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
305 | ASCII format string and a VA_LIST argument list.\r | |
306 | \r | |
307 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
308 | and BufferSize.\r | |
309 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
310 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
311 | the contents of the format string.\r | |
312 | The number of ASCII characters in the produced output buffer is returned not including\r | |
313 | the Null-terminator.\r | |
314 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
315 | \r | |
316 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
317 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
318 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
319 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
320 | ASSERT().\r | |
321 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
322 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
323 | Null-terminator, then ASSERT().\r | |
324 | \r | |
325 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
326 | ASCII string.\r | |
327 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
328 | @param FormatString Null-terminated Unicode format string.\r | |
329 | @param Marker VA_LIST marker for the variable argument list.\r | |
330 | \r | |
331 | @return The number of ASCII characters in the produced output buffer not including the\r | |
332 | Null-terminator.\r | |
333 | \r | |
334 | **/\r | |
335 | UINTN\r | |
336 | EFIAPI\r | |
337 | AsciiVSPrint (\r | |
338 | OUT CHAR8 *StartOfBuffer,\r | |
339 | IN UINTN BufferSize,\r | |
340 | IN CONST CHAR8 *FormatString,\r | |
341 | IN VA_LIST Marker\r | |
342 | )\r | |
a0afd019 | 343 | {\r |
2ad4dad0 LG |
344 | if (InternalLocatePrintProtocol() != EFI_SUCCESS) {\r |
345 | return 0;\r | |
346 | }\r | |
347 | \r | |
348 | return gPrintProtocol->AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
a0afd019 | 349 | }\r |
350 | \r | |
2ad4dad0 LG |
351 | /**\r |
352 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
353 | ASCII format string and variable argument list.\r | |
354 | \r | |
355 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
356 | and BufferSize.\r | |
357 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
358 | Arguments are pulled from the variable argument list based on the contents of the \r | |
359 | format string.\r | |
360 | The number of ASCII characters in the produced output buffer is returned not including\r | |
361 | the Null-terminator.\r | |
362 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
363 | \r | |
364 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
365 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
366 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
367 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
368 | ASSERT().\r | |
369 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
370 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
371 | Null-terminator, then ASSERT().\r | |
372 | \r | |
373 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
374 | ASCII string.\r | |
375 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
376 | @param FormatString Null-terminated Unicode format string.\r | |
377 | \r | |
378 | @return The number of ASCII characters in the produced output buffer not including the\r | |
379 | Null-terminator.\r | |
380 | \r | |
381 | **/\r | |
a0afd019 | 382 | UINTN\r |
2ad4dad0 | 383 | EFIAPI\r |
a0afd019 | 384 | AsciiSPrint (\r |
385 | OUT CHAR8 *StartOfBuffer,\r | |
386 | IN UINTN BufferSize,\r | |
2ad4dad0 | 387 | IN CONST CHAR8 *FormatString,\r |
a0afd019 | 388 | ...\r |
389 | )\r | |
2ad4dad0 LG |
390 | {\r |
391 | VA_LIST Marker;\r | |
392 | \r | |
393 | VA_START (Marker, FormatString);\r | |
394 | return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
395 | }\r | |
a0afd019 | 396 | \r |
2ad4dad0 LG |
397 | /**\r |
398 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
399 | ASCII format string and a VA_LIST argument list.\r | |
400 | \r | |
401 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
402 | and BufferSize.\r | |
403 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
404 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
405 | the contents of the format string.\r | |
406 | The number of ASCII characters in the produced output buffer is returned not including\r | |
407 | the Null-terminator.\r | |
408 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
409 | \r | |
410 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
411 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
412 | If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
413 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r | |
414 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
415 | ASSERT().\r | |
416 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
417 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
418 | Null-terminator, then ASSERT().\r | |
419 | \r | |
420 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
421 | ASCII string.\r | |
422 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
423 | @param FormatString Null-terminated Unicode format string.\r | |
424 | @param Marker VA_LIST marker for the variable argument list.\r | |
425 | \r | |
426 | @return The number of ASCII characters in the produced output buffer not including the\r | |
427 | Null-terminator.\r | |
428 | \r | |
429 | **/\r | |
430 | UINTN\r | |
431 | EFIAPI\r | |
432 | AsciiVSPrintUnicodeFormat (\r | |
433 | OUT CHAR8 *StartOfBuffer,\r | |
434 | IN UINTN BufferSize,\r | |
435 | IN CONST CHAR16 *FormatString,\r | |
436 | IN VA_LIST Marker\r | |
437 | )\r | |
a0afd019 | 438 | {\r |
2ad4dad0 LG |
439 | if (InternalLocatePrintProtocol() != EFI_SUCCESS) {\r |
440 | return 0;\r | |
441 | }\r | |
442 | \r | |
443 | return gPrintProtocol->AsciiVSPrintUni (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
444 | }\r | |
445 | \r | |
446 | /**\r | |
447 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
448 | ASCII format string and variable argument list.\r | |
449 | \r | |
450 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
451 | and BufferSize.\r | |
452 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
453 | Arguments are pulled from the variable argument list based on the contents of the \r | |
454 | format string.\r | |
455 | The number of ASCII characters in the produced output buffer is returned not including\r | |
456 | the Null-terminator.\r | |
457 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
458 | \r | |
459 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
460 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
461 | If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
462 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r | |
463 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
464 | ASSERT().\r | |
465 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
466 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
467 | Null-terminator, then ASSERT().\r | |
468 | \r | |
469 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
470 | ASCII string.\r | |
471 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
472 | @param FormatString Null-terminated Unicode format string.\r | |
473 | \r | |
474 | @return The number of ASCII characters in the produced output buffer not including the\r | |
475 | Null-terminator.\r | |
476 | \r | |
477 | **/\r | |
478 | UINTN\r | |
479 | EFIAPI\r | |
480 | AsciiSPrintUnicodeFormat (\r | |
481 | OUT CHAR8 *StartOfBuffer,\r | |
482 | IN UINTN BufferSize,\r | |
483 | IN CONST CHAR16 *FormatString,\r | |
484 | ...\r | |
485 | )\r | |
486 | {\r | |
487 | VA_LIST Marker;\r | |
a0afd019 | 488 | \r |
489 | VA_START (Marker, FormatString);\r | |
2ad4dad0 LG |
490 | return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r |
491 | }\r | |
492 | \r | |
493 | \r | |
494 | /**\r | |
495 | Converts a decimal value to a Null-terminated ASCII string.\r | |
496 | \r | |
497 | Converts the decimal number specified by Value to a Null-terminated ASCII string \r | |
498 | specified by Buffer containing at most Width characters. No padding of spaces \r | |
499 | is ever performed.\r | |
500 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
501 | The number of ASCII characters in Buffer is returned not including the Null-terminator.\r | |
502 | If the conversion contains more than Width characters, then only the first Width\r | |
503 | characters are returned, and the total number of characters required to perform\r | |
504 | the conversion is returned.\r | |
505 | Additional conversion parameters are specified in Flags. \r | |
506 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
507 | All conversions are left justified in Buffer.\r | |
508 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
509 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r | |
510 | are inserted every 3rd digit starting from the right.\r | |
511 | If HEX_RADIX is set in Flags, then the output buffer will be \r | |
512 | formatted in hexadecimal format.\r | |
513 | If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r | |
514 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r | |
515 | then Buffer is padded with '0' characters so the combination of the optional '-' \r | |
516 | sign character, '0' characters, digit characters for Value, and the Null-terminator\r | |
517 | add up to Width characters.\r | |
518 | \r | |
519 | If Buffer is NULL, then ASSERT().\r | |
520 | If unsupported bits are set in Flags, then ASSERT().\r | |
521 | If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r | |
522 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
523 | \r | |
524 | @param Buffer Pointer to the output buffer for the produced Null-terminated\r | |
525 | ASCII string.\r | |
526 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
527 | @param Value The 64-bit signed value to convert to a string.\r | |
528 | @param Width The maximum number of ASCII characters to place in Buffer, not including\r | |
529 | the Null-terminator.\r | |
530 | \r | |
531 | @return The number of ASCII characters in Buffer not including the Null-terminator.\r | |
532 | \r | |
533 | **/\r | |
534 | UINTN\r | |
535 | EFIAPI\r | |
536 | AsciiValueToString (\r | |
537 | IN OUT CHAR8 *Buffer,\r | |
538 | IN UINTN Flags,\r | |
539 | IN INT64 Value,\r | |
540 | IN UINTN Width\r | |
541 | )\r | |
542 | {\r | |
543 | if (InternalLocatePrintProtocol() != EFI_SUCCESS) {\r | |
544 | return 0;\r | |
545 | }\r | |
546 | \r | |
547 | return gPrintProtocol->AsciiValueToString (Buffer, Flags, Value, Width);\r | |
a0afd019 | 548 | }\r |