]>
Commit | Line | Data |
---|---|---|
22d9199f | 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 | Internal function which prints a formatted Unicode string to the console output device \r | |
18 | specified by Console\r | |
19 | \r | |
20 | This function prints a formatted Unicode string to the console output device \r | |
21 | specified by Console and returns the number of Unicode characters that printed \r | |
22 | to it. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize, \r | |
23 | then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r | |
24 | \r | |
25 | @param Format Null-terminated Unicode format string.\r | |
26 | @param Console The output console.\r | |
27 | @param Marker VA_LIST marker for the variable argument list.\r | |
28 | \r | |
29 | If Format is NULL, then ASSERT().\r | |
30 | If Format is not aligned on a 16-bit boundary, then ASSERT().\r | |
31 | \r | |
32 | **/\r | |
33 | \r | |
34 | STATIC\r | |
35 | UINTN\r | |
36 | InternalPrint (\r | |
37 | IN CONST CHAR16 *Format,\r | |
38 | IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *Console,\r | |
39 | IN VA_LIST Marker\r | |
40 | )\r | |
41 | {\r | |
42 | UINTN Return;\r | |
43 | CHAR16 *Buffer;\r | |
44 | UINTN BufferSize;\r | |
45 | \r | |
46 | ASSERT (Format != NULL);\r | |
47 | ASSERT (((UINTN) Format & 0x01) == 0);\r | |
48 | \r | |
49 | BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r | |
50 | \r | |
51 | Buffer = (CHAR16 *) AllocatePool(BufferSize);\r | |
52 | ASSERT (Buffer != NULL);\r | |
53 | \r | |
54 | Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r | |
55 | \r | |
56 | if (Console != NULL) {\r | |
57 | //\r | |
42721684 | 58 | // To be extra safe make sure Console has been initialized\r |
22d9199f | 59 | //\r |
60 | Console->OutputString (Console, Buffer);\r | |
61 | }\r | |
62 | \r | |
63 | FreePool (Buffer);\r | |
64 | \r | |
65 | return Return; \r | |
66 | }\r | |
67 | \r | |
68 | /** \r | |
69 | Prints a formatted Unicode string to the console output device specified by \r | |
70 | ConOut defined in the EFI_SYSTEM_TABLE.\r | |
71 | \r | |
72 | This function prints a formatted Unicode string to the console output device \r | |
73 | specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode \r | |
74 | characters that printed to ConOut. If the length of the formatted Unicode \r | |
75 | string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r | |
76 | PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r | |
77 | \r | |
78 | @param Format Null-terminated Unicode format string.\r | |
79 | @param ... VARARG list consumed to process Format.\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 | **/\r | |
84 | UINTN\r | |
85 | EFIAPI\r | |
86 | Print (\r | |
87 | IN CONST CHAR16 *Format,\r | |
88 | ...\r | |
89 | )\r | |
90 | {\r | |
91 | VA_LIST Marker;\r | |
92 | UINTN Return;\r | |
93 | \r | |
94 | VA_START (Marker, Format);\r | |
95 | \r | |
96 | Return = InternalPrint (Format, gST->ConOut, Marker);\r | |
97 | \r | |
98 | VA_END (Marker);\r | |
99 | \r | |
100 | return Return;\r | |
101 | }\r | |
102 | \r | |
103 | /** \r | |
104 | Prints a formatted Unicode string to the console output device specified by \r | |
105 | StdErr defined in the EFI_SYSTEM_TABLE.\r | |
106 | \r | |
107 | This function prints a formatted Unicode string to the console output device \r | |
108 | specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode \r | |
109 | characters that printed to StdErr. If the length of the formatted Unicode \r | |
110 | string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r | |
111 | PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r | |
112 | \r | |
113 | @param Format Null-terminated Unicode format string.\r | |
114 | @param ... VARARG list consumed to process Format.\r | |
115 | If Format is NULL, then ASSERT().\r | |
116 | If Format is not aligned on a 16-bit boundary, then ASSERT().\r | |
117 | \r | |
118 | **/\r | |
119 | \r | |
120 | UINTN\r | |
121 | EFIAPI\r | |
122 | ErrorPrint (\r | |
123 | IN CONST CHAR16 *Format,\r | |
124 | ...\r | |
125 | )\r | |
126 | {\r | |
127 | VA_LIST Marker;\r | |
128 | UINTN Return;\r | |
129 | \r | |
130 | VA_START (Marker, Format);\r | |
131 | \r | |
132 | Return = InternalPrint( Format, gST->StdErr, Marker);\r | |
133 | \r | |
134 | VA_END (Marker);\r | |
135 | \r | |
136 | return Return;\r | |
137 | }\r | |
138 | \r | |
139 | \r | |
140 | /** \r | |
141 | Internal function which prints a formatted ASCII string to the console output device \r | |
142 | specified by Console\r | |
143 | \r | |
144 | This function prints a formatted ASCII string to the console output device \r | |
145 | specified by Console and returns the number of ASCII characters that printed \r | |
146 | to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, \r | |
147 | then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r | |
148 | \r | |
149 | @param Format Null-terminated ASCII format string.\r | |
150 | @param Console The output console.\r | |
151 | @param Marker VA_LIST marker for the variable argument list.\r | |
152 | \r | |
153 | If Format is NULL, then ASSERT().\r | |
154 | \r | |
155 | **/\r | |
156 | \r | |
157 | STATIC\r | |
158 | UINTN\r | |
159 | AsciiInternalPrint (\r | |
160 | IN CONST CHAR8 *Format,\r | |
161 | IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *Console,\r | |
162 | IN VA_LIST Marker\r | |
163 | )\r | |
164 | {\r | |
165 | UINTN Return;\r | |
166 | CHAR16 *Buffer;\r | |
167 | UINTN BufferSize;\r | |
168 | \r | |
169 | ASSERT (Format != NULL);\r | |
170 | \r | |
171 | BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r | |
172 | \r | |
173 | Buffer = (CHAR16 *) AllocatePool(BufferSize);\r | |
174 | ASSERT (Buffer != NULL);\r | |
175 | \r | |
176 | Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);\r | |
177 | \r | |
178 | if (Console != NULL) {\r | |
179 | //\r | |
42721684 | 180 | // To be extra safe make sure Console has been initialized\r |
22d9199f | 181 | //\r |
182 | Console->OutputString (Console, Buffer);\r | |
183 | }\r | |
184 | \r | |
185 | FreePool (Buffer);\r | |
186 | \r | |
187 | return Return; \r | |
188 | }\r | |
189 | \r | |
190 | /** \r | |
191 | Prints a formatted ASCII string to the console output device specified by \r | |
192 | ConOut defined in the EFI_SYSTEM_TABLE.\r | |
193 | \r | |
194 | This function prints a formatted ASCII string to the console output device \r | |
195 | specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII \r | |
196 | characters that printed to ConOut. If the length of the formatted ASCII \r | |
197 | string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r | |
198 | PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r | |
199 | \r | |
200 | @param Format Null-terminated ASCII format string.\r | |
201 | @param ... VARARG list consumed to process Format.\r | |
202 | If Format is NULL, then ASSERT().\r | |
203 | If Format is not aligned on a 16-bit boundary, then ASSERT().\r | |
204 | \r | |
205 | **/\r | |
206 | UINTN\r | |
207 | EFIAPI\r | |
208 | AsciiPrint (\r | |
209 | IN CONST CHAR8 *Format,\r | |
210 | ...\r | |
211 | )\r | |
212 | {\r | |
213 | VA_LIST Marker;\r | |
214 | UINTN Return;\r | |
215 | \r | |
216 | VA_START (Marker, Format);\r | |
217 | \r | |
218 | Return = AsciiInternalPrint( Format, gST->ConOut, Marker);\r | |
219 | \r | |
220 | VA_END (Marker);\r | |
221 | \r | |
222 | return Return;\r | |
223 | }\r | |
224 | \r | |
225 | /** \r | |
226 | Prints a formatted ASCII string to the console output device specified by \r | |
227 | StdErr defined in the EFI_SYSTEM_TABLE.\r | |
228 | \r | |
229 | This function prints a formatted ASCII string to the console output device \r | |
230 | specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII \r | |
231 | characters that printed to StdErr. If the length of the formatted ASCII \r | |
232 | string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r | |
233 | PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r | |
234 | \r | |
235 | @param Format Null-terminated ASCII format string.\r | |
236 | @param ... VARARG list consumed to process Format.\r | |
237 | If Format is NULL, then ASSERT().\r | |
238 | If Format is not aligned on a 16-bit boundary, then ASSERT().\r | |
239 | \r | |
240 | **/\r | |
241 | UINTN\r | |
242 | EFIAPI\r | |
243 | AsciiErrorPrint (\r | |
244 | IN CONST CHAR8 *Format,\r | |
245 | ...\r | |
246 | )\r | |
247 | {\r | |
248 | VA_LIST Marker;\r | |
249 | UINTN Return;\r | |
250 | \r | |
251 | VA_START (Marker, Format);\r | |
252 | \r | |
253 | Return = AsciiInternalPrint( Format, gST->StdErr, Marker);\r | |
254 | \r | |
255 | VA_END (Marker);\r | |
256 | \r | |
257 | return Return;\r | |
258 | }\r | |
259 | \r |