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