]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c
Add gEfiDriverConfiguration2ProtocolGuid GUID C Name in INF.
[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
80 @param ... VARARG list consumed to process Format.\r
81 If Format is NULL, then ASSERT().\r
82 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
83\r
84**/\r
85UINTN\r
86EFIAPI\r
87Print (\r
88 IN CONST CHAR16 *Format,\r
89 ...\r
90 )\r
91{\r
92 VA_LIST Marker;\r
93 UINTN Return;\r
94\r
95 VA_START (Marker, Format);\r
96\r
97 Return = InternalPrint (Format, gST->ConOut, Marker);\r
98\r
99 VA_END (Marker);\r
100\r
101 return Return;\r
102}\r
103\r
104/**\r
105 Prints a formatted Unicode string to the console output device specified by\r
106 StdErr defined in the EFI_SYSTEM_TABLE.\r
107\r
108 This function prints a formatted Unicode string to the console output device\r
109 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode\r
110 characters that printed to StdErr. If the length of the formatted Unicode\r
111 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
112 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
113\r
114 @param Format Null-terminated Unicode format string.\r
115 @param ... VARARG list consumed to process Format.\r
116 If Format is NULL, then ASSERT().\r
117 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
118\r
119**/\r
120\r
121UINTN\r
122EFIAPI\r
123ErrorPrint (\r
124 IN CONST CHAR16 *Format,\r
125 ...\r
126 )\r
127{\r
128 VA_LIST Marker;\r
129 UINTN Return;\r
130\r
131 VA_START (Marker, Format);\r
132\r
133 Return = InternalPrint( Format, gST->StdErr, Marker);\r
134\r
135 VA_END (Marker);\r
136\r
137 return Return;\r
138}\r
139\r
140\r
141/**\r
142 Internal function which prints a formatted ASCII string to the console output device\r
143 specified by Console\r
144\r
145 This function prints a formatted ASCII string to the console output device\r
146 specified by Console and returns the number of ASCII characters that printed\r
147 to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,\r
148 then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
149\r
150 @param Format Null-terminated ASCII format string.\r
151 @param Console The output console.\r
152 @param Marker VA_LIST marker for the variable argument list.\r
153\r
154 If Format is NULL, then ASSERT().\r
155\r
156**/\r
157\r
79964ac8 158UINTN\r
159AsciiInternalPrint (\r
b51e6bc4 160 IN CONST CHAR8 *Format,\r
161 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
162 IN VA_LIST Marker\r
79964ac8 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
180 // To be extra safe make sure Console has been initialized\r
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
206UINTN\r
207EFIAPI\r
208AsciiPrint (\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
241UINTN\r
242EFIAPI\r
243AsciiErrorPrint (\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