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