]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Base Print Library instance Internal Functions definition.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #ifndef __PRINT_LIB_INTERNAL_H__\r | |
10 | #define __PRINT_LIB_INTERNAL_H__\r | |
11 | \r | |
12 | #include <Base.h>\r | |
13 | #include <Library/PrintLib.h>\r | |
14 | #include <Library/BaseLib.h>\r | |
15 | #include <Library/DebugLib.h>\r | |
16 | #include <Library/PcdLib.h>\r | |
17 | \r | |
18 | \r | |
19 | //\r | |
20 | // Print primitives\r | |
21 | //\r | |
22 | #define PREFIX_SIGN BIT1\r | |
23 | #define PREFIX_BLANK BIT2\r | |
24 | #define LONG_TYPE BIT4\r | |
25 | #define OUTPUT_UNICODE BIT6\r | |
26 | #define FORMAT_UNICODE BIT8\r | |
27 | #define PAD_TO_WIDTH BIT9\r | |
28 | #define ARGUMENT_UNICODE BIT10\r | |
29 | #define PRECISION BIT11\r | |
30 | #define ARGUMENT_REVERSED BIT12\r | |
31 | #define COUNT_ONLY_NO_PRINT BIT13\r | |
32 | #define UNSIGNED_TYPE BIT14\r | |
33 | \r | |
34 | //\r | |
35 | // Record date and time information\r | |
36 | //\r | |
37 | typedef struct {\r | |
38 | UINT16 Year;\r | |
39 | UINT8 Month;\r | |
40 | UINT8 Day;\r | |
41 | UINT8 Hour;\r | |
42 | UINT8 Minute;\r | |
43 | UINT8 Second;\r | |
44 | UINT8 Pad1;\r | |
45 | UINT32 Nanosecond;\r | |
46 | INT16 TimeZone;\r | |
47 | UINT8 Daylight;\r | |
48 | UINT8 Pad2;\r | |
49 | } TIME;\r | |
50 | \r | |
51 | /**\r | |
52 | Worker function that produces a Null-terminated string in an output buffer\r | |
53 | based on a Null-terminated format string and a VA_LIST argument list.\r | |
54 | \r | |
55 | VSPrint function to process format and place the results in Buffer. Since a\r | |
56 | VA_LIST is used this routine allows the nesting of Vararg routines. Thus\r | |
57 | this is the main print working routine.\r | |
58 | \r | |
59 | If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.\r | |
60 | \r | |
61 | @param[out] Buffer The character buffer to print the results of the\r | |
62 | parsing of Format into.\r | |
63 | @param[in] BufferSize The maximum number of characters to put into\r | |
64 | buffer.\r | |
65 | @param[in] Flags Initial flags value.\r | |
66 | Can only have FORMAT_UNICODE, OUTPUT_UNICODE,\r | |
67 | and COUNT_ONLY_NO_PRINT set.\r | |
68 | @param[in] Format A Null-terminated format string.\r | |
69 | @param[in] VaListMarker VA_LIST style variable argument list consumed by\r | |
70 | processing Format.\r | |
71 | @param[in] BaseListMarker BASE_LIST style variable argument list consumed\r | |
72 | by processing Format.\r | |
73 | \r | |
74 | @return The number of characters printed not including the Null-terminator.\r | |
75 | If COUNT_ONLY_NO_PRINT was set returns the same, but without any\r | |
76 | modification to Buffer.\r | |
77 | \r | |
78 | **/\r | |
79 | UINTN\r | |
80 | BasePrintLibSPrintMarker (\r | |
81 | OUT CHAR8 *Buffer,\r | |
82 | IN UINTN BufferSize,\r | |
83 | IN UINTN Flags,\r | |
84 | IN CONST CHAR8 *Format,\r | |
85 | IN VA_LIST VaListMarker, OPTIONAL\r | |
86 | IN BASE_LIST BaseListMarker OPTIONAL\r | |
87 | );\r | |
88 | \r | |
89 | /**\r | |
90 | Worker function that produces a Null-terminated string in an output buffer\r | |
91 | based on a Null-terminated format string and variable argument list.\r | |
92 | \r | |
93 | VSPrint function to process format and place the results in Buffer. Since a\r | |
94 | VA_LIST is used this routine allows the nesting of Vararg routines. Thus\r | |
95 | this is the main print working routine\r | |
96 | \r | |
97 | @param StartOfBuffer The character buffer to print the results of the parsing\r | |
98 | of Format into.\r | |
99 | @param BufferSize The maximum number of characters to put into buffer.\r | |
100 | Zero means no limit.\r | |
101 | @param Flags Initial flags value.\r | |
102 | Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r | |
103 | @param FormatString Null-terminated format string.\r | |
104 | @param ... The variable argument list.\r | |
105 | \r | |
106 | @return The number of characters printed.\r | |
107 | \r | |
108 | **/\r | |
109 | UINTN\r | |
110 | EFIAPI\r | |
111 | BasePrintLibSPrint (\r | |
112 | OUT CHAR8 *StartOfBuffer,\r | |
113 | IN UINTN BufferSize,\r | |
114 | IN UINTN Flags,\r | |
115 | IN CONST CHAR8 *FormatString,\r | |
116 | ...\r | |
117 | );\r | |
118 | \r | |
119 | /**\r | |
120 | Internal function that places the character into the Buffer.\r | |
121 | \r | |
122 | Internal function that places ASCII or Unicode character into the Buffer.\r | |
123 | \r | |
124 | @param Buffer Buffer to place the Unicode or ASCII string.\r | |
125 | @param EndBuffer The end of the input Buffer. No characters will be\r | |
126 | placed after that.\r | |
127 | @param Length The count of character to be placed into Buffer.\r | |
128 | (Negative value indicates no buffer fill.)\r | |
129 | @param Character The character to be placed into Buffer.\r | |
130 | @param Increment The character increment in Buffer.\r | |
131 | \r | |
132 | @return Buffer Buffer filled with the input Character.\r | |
133 | \r | |
134 | **/\r | |
135 | CHAR8 *\r | |
136 | BasePrintLibFillBuffer (\r | |
137 | OUT CHAR8 *Buffer,\r | |
138 | IN CHAR8 *EndBuffer,\r | |
139 | IN INTN Length,\r | |
140 | IN UINTN Character,\r | |
141 | IN INTN Increment\r | |
142 | );\r | |
143 | \r | |
144 | /**\r | |
145 | Internal function that convert a number to a string in Buffer.\r | |
146 | \r | |
147 | Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer.\r | |
148 | \r | |
149 | @param Buffer Location to place the ASCII string of Value.\r | |
150 | @param Value The value to convert to a Decimal or Hexadecimal string in Buffer.\r | |
151 | @param Radix Radix of the value\r | |
152 | \r | |
153 | @return A pointer to the end of buffer filled with ASCII string.\r | |
154 | \r | |
155 | **/\r | |
156 | CHAR8 *\r | |
157 | BasePrintLibValueToString (\r | |
158 | IN OUT CHAR8 *Buffer,\r | |
159 | IN INT64 Value,\r | |
160 | IN UINTN Radix\r | |
161 | );\r | |
162 | \r | |
163 | /**\r | |
164 | Internal function that converts a decimal value to a Null-terminated string.\r | |
165 | \r | |
166 | Converts the decimal number specified by Value to a Null-terminated\r | |
167 | string specified by Buffer containing at most Width characters.\r | |
168 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
169 | The total number of characters placed in Buffer is returned.\r | |
170 | If the conversion contains more than Width characters, then only the first\r | |
171 | Width characters are returned, and the total number of characters\r | |
172 | required to perform the conversion is returned.\r | |
173 | Additional conversion parameters are specified in Flags.\r | |
174 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
175 | All conversions are left justified in Buffer.\r | |
176 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
177 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r | |
178 | are inserted every 3rd digit starting from the right.\r | |
179 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
180 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,\r | |
181 | then Buffer is padded with '0' characters so the combination of the optional '-'\r | |
182 | sign character, '0' characters, digit characters for Value, and the Null-terminator\r | |
183 | add up to Width characters.\r | |
184 | \r | |
185 | If Buffer is NULL, then ASSERT().\r | |
186 | If unsupported bits are set in Flags, then ASSERT().\r | |
187 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
188 | \r | |
189 | @param Buffer The pointer to the output buffer for the produced Null-terminated\r | |
190 | string.\r | |
191 | @param Flags The bitmask of flags that specify left justification, zero pad,\r | |
192 | and commas.\r | |
193 | @param Value The 64-bit signed value to convert to a string.\r | |
194 | @param Width The maximum number of characters to place in Buffer, not including\r | |
195 | the Null-terminator.\r | |
196 | @param Increment Character increment in Buffer.\r | |
197 | \r | |
198 | @return Total number of characters required to perform the conversion.\r | |
199 | \r | |
200 | **/\r | |
201 | UINTN\r | |
202 | BasePrintLibConvertValueToString (\r | |
203 | IN OUT CHAR8 *Buffer,\r | |
204 | IN UINTN Flags,\r | |
205 | IN INT64 Value,\r | |
206 | IN UINTN Width,\r | |
207 | IN UINTN Increment\r | |
208 | );\r | |
209 | \r | |
210 | /**\r | |
211 | Internal function that converts a decimal value to a Null-terminated string.\r | |
212 | \r | |
213 | Converts the decimal number specified by Value to a Null-terminated string\r | |
214 | specified by Buffer containing at most Width characters. If Width is 0 then a\r | |
215 | width of MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more\r | |
216 | than Width characters, then only the first Width characters are placed in\r | |
217 | Buffer. Additional conversion parameters are specified in Flags.\r | |
218 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
219 | All conversions are left justified in Buffer.\r | |
220 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
221 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and\r | |
222 | commas are inserted every 3rd digit starting from the right.\r | |
223 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
224 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,\r | |
225 | then Buffer is padded with '0' characters so the combination of the optional\r | |
226 | '-' sign character, '0' characters, digit characters for Value, and the\r | |
227 | Null-terminator add up to Width characters.\r | |
228 | \r | |
229 | If an error would be returned, the function will ASSERT().\r | |
230 | \r | |
231 | @param Buffer The pointer to the output buffer for the produced\r | |
232 | Null-terminated string.\r | |
233 | @param BufferSize The size of Buffer in bytes, including the\r | |
234 | Null-terminator.\r | |
235 | @param Flags The bitmask of flags that specify left justification,\r | |
236 | zero pad, and commas.\r | |
237 | @param Value The 64-bit signed value to convert to a string.\r | |
238 | @param Width The maximum number of characters to place in Buffer,\r | |
239 | not including the Null-terminator.\r | |
240 | @param Increment The character increment in Buffer.\r | |
241 | \r | |
242 | @retval RETURN_SUCCESS The decimal value is converted.\r | |
243 | @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted\r | |
244 | value.\r | |
245 | @retval RETURN_INVALID_PARAMETER If Buffer is NULL.\r | |
246 | If Increment is 1 and\r | |
247 | PcdMaximumAsciiStringLength is not zero,\r | |
248 | BufferSize is greater than\r | |
249 | PcdMaximumAsciiStringLength.\r | |
250 | If Increment is not 1 and\r | |
251 | PcdMaximumUnicodeStringLength is not zero,\r | |
252 | BufferSize is greater than\r | |
253 | (PcdMaximumUnicodeStringLength *\r | |
254 | sizeof (CHAR16) + 1).\r | |
255 | If unsupported bits are set in Flags.\r | |
256 | If both COMMA_TYPE and RADIX_HEX are set in\r | |
257 | Flags.\r | |
258 | If Width >= MAXIMUM_VALUE_CHARACTERS.\r | |
259 | \r | |
260 | **/\r | |
261 | RETURN_STATUS\r | |
262 | BasePrintLibConvertValueToStringS (\r | |
263 | IN OUT CHAR8 *Buffer,\r | |
264 | IN UINTN BufferSize,\r | |
265 | IN UINTN Flags,\r | |
266 | IN INT64 Value,\r | |
267 | IN UINTN Width,\r | |
268 | IN UINTN Increment\r | |
269 | );\r | |
270 | \r | |
271 | #endif\r |