]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkPkg/Library/UefiLibFramework/UefiLibPrint.c
1. Add PeiDxeDebugLibReportStatusCode.inf and UefiLibFramework/UefiLib.inf
[mirror_edk2.git] / IntelFrameworkPkg / Library / UefiLibFramework / 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
16#include "UefiLibFramework.h"\r
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
36STATIC\r
37UINTN\r
38InternalPrint (\r
b51e6bc4 39 IN CONST CHAR16 *Format,\r
40 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
41 IN VA_LIST Marker\r
79964ac8 42 )\r
43{\r
44 UINTN Return;\r
45 CHAR16 *Buffer;\r
46 UINTN BufferSize;\r
47\r
48 ASSERT (Format != NULL);\r
49 ASSERT (((UINTN) Format & 0x01) == 0);\r
50\r
51 BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
52\r
53 Buffer = (CHAR16 *) AllocatePool(BufferSize);\r
54 ASSERT (Buffer != NULL);\r
55\r
56 Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
57\r
58 if (Console != NULL) {\r
59 //\r
60 // To be extra safe make sure Console has been initialized\r
61 //\r
62 Console->OutputString (Console, Buffer);\r
63 }\r
64\r
65 FreePool (Buffer);\r
66\r
67 return Return;\r
68}\r
69\r
70/**\r
71 Prints a formatted Unicode string to the console output device specified by\r
72 ConOut defined in the EFI_SYSTEM_TABLE.\r
73\r
74 This function prints a formatted Unicode string to the console output device\r
75 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode\r
76 characters that printed to ConOut. If the length of the formatted Unicode\r
77 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
78 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
79\r
80 @param Format Null-terminated Unicode format string.\r
81 @param ... VARARG list consumed to process Format.\r
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
116 @param ... VARARG list consumed to process Format.\r
117 If Format is NULL, then ASSERT().\r
118 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
119\r
120**/\r
121\r
122UINTN\r
123EFIAPI\r
124ErrorPrint (\r
125 IN CONST CHAR16 *Format,\r
126 ...\r
127 )\r
128{\r
129 VA_LIST Marker;\r
130 UINTN Return;\r
131\r
132 VA_START (Marker, Format);\r
133\r
134 Return = InternalPrint( Format, gST->StdErr, Marker);\r
135\r
136 VA_END (Marker);\r
137\r
138 return Return;\r
139}\r
140\r
141\r
142/**\r
143 Internal function which prints a formatted ASCII string to the console output device\r
144 specified by Console\r
145\r
146 This function prints a formatted ASCII string to the console output device\r
147 specified by Console and returns the number of ASCII characters that printed\r
148 to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,\r
149 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
150\r
151 @param Format Null-terminated ASCII format string.\r
152 @param Console The output console.\r
153 @param Marker VA_LIST marker for the variable argument list.\r
154\r
155 If Format is NULL, then ASSERT().\r
156\r
157**/\r
158\r
159STATIC\r
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
203 @param ... VARARG list consumed to process Format.\r
204 If Format is NULL, then ASSERT().\r
205 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
206\r
207**/\r
208UINTN\r
209EFIAPI\r
210AsciiPrint (\r
211 IN CONST CHAR8 *Format,\r
212 ...\r
213 )\r
214{\r
215 VA_LIST Marker;\r
216 UINTN Return;\r
217\r
218 VA_START (Marker, Format);\r
219\r
220 Return = AsciiInternalPrint( Format, gST->ConOut, Marker);\r
221\r
222 VA_END (Marker);\r
223\r
224 return Return;\r
225}\r
226\r
227/**\r
228 Prints a formatted ASCII string to the console output device specified by\r
229 StdErr defined in the EFI_SYSTEM_TABLE.\r
230\r
231 This function prints a formatted ASCII string to the console output device\r
232 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII\r
233 characters that printed to StdErr. If the length of the formatted ASCII\r
234 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
235 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
236\r
237 @param Format Null-terminated ASCII format string.\r
238 @param ... VARARG list consumed to process Format.\r
239 If Format is NULL, then ASSERT().\r
240 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
241\r
242**/\r
243UINTN\r
244EFIAPI\r
245AsciiErrorPrint (\r
246 IN CONST CHAR8 *Format,\r
247 ...\r
248 )\r
249{\r
250 VA_LIST Marker;\r
251 UINTN Return;\r
252\r
253 VA_START (Marker, Format);\r
254\r
255 Return = AsciiInternalPrint( Format, gST->StdErr, Marker);\r
256\r
257 VA_END (Marker);\r
258\r
259 return Return;\r
260}\r
261\r