]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/SetupBrowserDxe/Print.c
Correct all header files for doxygen format and correct the license issue for VgaClas...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / SetupBrowserDxe / Print.c
CommitLineData
3db51098 1/**@file\r
103b6520 2 Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
3 simple implemenation of SPrint() and Print() to support debug.\r
4\r
5 You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a\r
6 time. This makes the implementation very simple.\r
7\r
8 VSPrint, Print, SPrint format specification has the follwoing form\r
9\r
10 %type\r
11\r
12 type:\r
13 'S','s' - argument is an Unicode string\r
14 'c' - argument is an ascii character\r
15 '%' - Print a %\r
16\r
3db51098 17Copyright (c) 2006, Intel Corporation\r
18All rights reserved. This program and the accompanying materials\r
19are licensed and made available under the terms and conditions of the BSD License\r
20which accompanies this distribution. The full text of the license may be found at\r
21http://opensource.org/licenses/bsd-license.php\r
22\r
23THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
24WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
25\r
26**/\r
103b6520 27\r
103b6520 28#include "Print.h"\r
29\r
30STATIC\r
31UINTN\r
32_IPrint (\r
33 IN UINTN Column,\r
34 IN UINTN Row,\r
35fec2c4 35 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Out,\r
103b6520 36 IN CHAR16 *fmt,\r
37 IN VA_LIST args\r
38 )\r
39//\r
40// Display string worker for: Print, PrintAt, IPrint, IPrintAt\r
41//\r
42{\r
43 CHAR16 *Buffer;\r
44 CHAR16 *BackupBuffer;\r
45 UINTN Index;\r
46 UINTN PreviousIndex;\r
47\r
48 //\r
49 // For now, allocate an arbitrarily long buffer\r
50 //\r
51 Buffer = AllocateZeroPool (0x10000);\r
52 BackupBuffer = AllocateZeroPool (0x10000);\r
53 ASSERT (Buffer);\r
54 ASSERT (BackupBuffer);\r
55\r
56 if (Column != (UINTN) -1) {\r
57 Out->SetCursorPosition (Out, Column, Row);\r
58 }\r
59\r
60 UnicodeVSPrint (Buffer, 0x10000, fmt, args);\r
61\r
62 Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;\r
63\r
64 Out->SetAttribute (Out, Out->Mode->Attribute);\r
65\r
66 Index = 0;\r
67 PreviousIndex = 0;\r
68\r
69 do {\r
70 for (; (Buffer[Index] != NARROW_CHAR) && (Buffer[Index] != WIDE_CHAR) && (Buffer[Index] != 0); Index++) {\r
71 BackupBuffer[Index] = Buffer[Index];\r
72 }\r
73\r
74 if (Buffer[Index] == 0) {\r
75 break;\r
76 }\r
77 //\r
78 // Null-terminate the temporary string\r
79 //\r
80 BackupBuffer[Index] = 0;\r
81\r
82 //\r
83 // Print this out, we are about to switch widths\r
84 //\r
85 Out->OutputString (Out, &BackupBuffer[PreviousIndex]);\r
86\r
87 //\r
88 // Preserve the current index + 1, since this is where we will start printing from next\r
89 //\r
90 PreviousIndex = Index + 1;\r
91\r
92 //\r
93 // We are at a narrow or wide character directive. Set attributes and strip it and print it\r
94 //\r
95 if (Buffer[Index] == NARROW_CHAR) {\r
96 //\r
97 // Preserve bits 0 - 6 and zero out the rest\r
98 //\r
99 Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;\r
100 Out->SetAttribute (Out, Out->Mode->Attribute);\r
101 } else {\r
102 //\r
103 // Must be wide, set bit 7 ON\r
104 //\r
105 Out->Mode->Attribute = Out->Mode->Attribute | EFI_WIDE_ATTRIBUTE;\r
106 Out->SetAttribute (Out, Out->Mode->Attribute);\r
107 }\r
108\r
109 Index++;\r
110\r
111 } while (Buffer[Index] != 0);\r
112\r
113 //\r
114 // We hit the end of the string - print it\r
115 //\r
116 Out->OutputString (Out, &BackupBuffer[PreviousIndex]);\r
117\r
118 FreePool (Buffer);\r
119 FreePool (BackupBuffer);\r
120 return EFI_SUCCESS;\r
121}\r
122\r
123UINTN\r
124Print (\r
125 IN CHAR16 *fmt,\r
126 ...\r
127 )\r
128/*++\r
129\r
130Routine Description:\r
131\r
132 Prints a formatted unicode string to the default console\r
133\r
134Arguments:\r
135\r
136 fmt - Format string\r
137\r
138Returns:\r
139\r
140 Length of string printed to the console\r
141\r
142--*/\r
143{\r
144 VA_LIST args;\r
145\r
146 VA_START (args, fmt);\r
147 return _IPrint ((UINTN) -1, (UINTN) -1, gST->ConOut, fmt, args);\r
148}\r
149\r
150UINTN\r
151PrintString (\r
152 CHAR16 *String\r
153 )\r
154/*++\r
155\r
156Routine Description:\r
157\r
158 Prints a unicode string to the default console,\r
159 using L"%s" format.\r
160\r
161Arguments:\r
162\r
163 String - String pointer.\r
164\r
165Returns:\r
166\r
167 Length of string printed to the console\r
168\r
169--*/\r
170{\r
171 return Print ((CHAR16 *) L"%s", String);\r
172}\r
173\r
174UINTN\r
175PrintChar (\r
176 CHAR16 Character\r
177 )\r
178/*++\r
179\r
180Routine Description:\r
181\r
182 Prints a chracter to the default console,\r
183 using L"%c" format.\r
184\r
185Arguments:\r
186\r
187 Character - Character to print.\r
188\r
189Returns:\r
190\r
191 Length of string printed to the console.\r
192\r
193--*/\r
194{\r
195 return Print ((CHAR16 *) L"%c", Character);\r
196}\r
197\r
198UINTN\r
199PrintAt (\r
200 IN UINTN Column,\r
201 IN UINTN Row,\r
202 IN CHAR16 *fmt,\r
203 ...\r
204 )\r
205/*++\r
206\r
207Routine Description:\r
208\r
209 Prints a formatted unicode string to the default console, at\r
210 the supplied cursor position\r
211\r
212Arguments:\r
213\r
214 Column, Row - The cursor position to print the string at\r
215\r
216 fmt - Format string\r
217\r
218Returns:\r
219\r
220 Length of string printed to the console\r
221\r
222--*/\r
223{\r
224 VA_LIST args;\r
225\r
226 VA_START (args, fmt);\r
227 return _IPrint (Column, Row, gST->ConOut, fmt, args);\r
228}\r
229\r
230UINTN\r
231PrintStringAt (\r
232 IN UINTN Column,\r
233 IN UINTN Row,\r
234 CHAR16 *String\r
235 )\r
236/*++\r
237\r
238Routine Description:\r
239\r
240 Prints a unicode string to the default console, at\r
241 the supplied cursor position, using L"%s" format.\r
242\r
243Arguments:\r
244\r
245 Column, Row - The cursor position to print the string at\r
246\r
247 String - String pointer.\r
248\r
249Returns:\r
250\r
251 Length of string printed to the console\r
252\r
253--*/\r
254{\r
255 return PrintAt (Column, Row, (CHAR16 *) L"%s", String);\r
256}\r
257\r
258UINTN\r
259PrintCharAt (\r
260 IN UINTN Column,\r
261 IN UINTN Row,\r
262 CHAR16 Character\r
263 )\r
264/*++\r
265\r
266Routine Description:\r
267\r
268 Prints a chracter to the default console, at\r
269 the supplied cursor position, using L"%c" format.\r
270\r
271Arguments:\r
272\r
273 Column, Row - The cursor position to print the string at\r
274\r
275 Character - Character to print.\r
276\r
277Returns:\r
278\r
279 Length of string printed to the console.\r
280\r
281--*/\r
282{\r
283 return PrintAt (Column, Row, (CHAR16 *) L"%c", Character);\r
284}\r
285\r
286\r