2 Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
3 simple implemenation of SPrint() and Print() to support debug.
5 You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
6 time. This makes the implementation very simple.
8 VSPrint, Print, SPrint format specification has the follwoing form
13 'S','s' - argument is an Unicode string
14 'c' - argument is an ascii character
18 Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
19 This program and the accompanying materials
20 are licensed and made available under the terms and conditions of the BSD License
21 which accompanies this distribution. The full text of the license may be found at
22 http://opensource.org/licenses/bsd-license.php
24 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
25 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
32 The internal function prints to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
35 @param Column The position of the output string.
36 @param Row The position of the output string.
37 @param Out The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
38 @param Fmt The format string.
39 @param Args The additional argument for the variables in the format string.
41 @return Number of Unicode character printed.
48 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Out
,
60 // For now, allocate an arbitrarily long buffer
62 Buffer
= AllocateZeroPool (0x10000);
63 BackupBuffer
= AllocateZeroPool (0x10000);
65 ASSERT (BackupBuffer
);
67 if (Column
!= (UINTN
) -1) {
68 Out
->SetCursorPosition (Out
, Column
, Row
);
71 UnicodeVSPrint (Buffer
, 0x10000, Fmt
, Args
);
73 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
75 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
82 for (; (Buffer
[Index
] != NARROW_CHAR
) && (Buffer
[Index
] != WIDE_CHAR
) && (Buffer
[Index
] != 0); Index
++) {
83 BackupBuffer
[Index
] = Buffer
[Index
];
86 if (Buffer
[Index
] == 0) {
90 // Null-terminate the temporary string
92 BackupBuffer
[Index
] = 0;
95 // Print this out, we are about to switch widths
97 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
98 Count
+= StrLen (&BackupBuffer
[PreviousIndex
]);
101 // Preserve the current index + 1, since this is where we will start printing from next
103 PreviousIndex
= Index
+ 1;
106 // We are at a narrow or wide character directive. Set attributes and strip it and print it
108 if (Buffer
[Index
] == NARROW_CHAR
) {
110 // Preserve bits 0 - 6 and zero out the rest
112 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
113 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
116 // Must be wide, set bit 7 ON
118 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
| EFI_WIDE_ATTRIBUTE
;
119 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
124 } while (Buffer
[Index
] != 0);
127 // We hit the end of the string - print it
129 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
130 Count
+= StrLen (&BackupBuffer
[PreviousIndex
]);
133 FreePool (BackupBuffer
);
139 Prints a formatted unicode string to the default console.
141 @param Fmt Format string
142 @param ... Variable argument list for format string.
144 @return Length of string printed to the console.
156 VA_START (Args
, Fmt
);
157 return PrintInternal ((UINTN
) -1, (UINTN
) -1, gST
->ConOut
, Fmt
, Args
);
162 Prints a unicode string to the default console,
165 @param String String pointer.
167 @return Length of string printed to the console
175 return ConsolePrint (L
"%s", String
);
180 Prints a chracter to the default console,
183 @param Character Character to print.
185 @return Length of string printed to the console.
193 return ConsolePrint (L
"%c", Character
);
198 Prints a formatted unicode string to the default console, at
199 the supplied cursor position.
201 @param Column The cursor position to print the string at.
202 @param Row The cursor position to print the string at.
203 @param Fmt Format string.
204 @param ... Variable argument list for format string.
206 @return Length of string printed to the console
220 VA_START (Args
, Fmt
);
221 return PrintInternal (Column
, Row
, gST
->ConOut
, Fmt
, Args
);
226 Prints a unicode string to the default console, at
227 the supplied cursor position, using L"%s" format.
229 @param Column The cursor position to print the string at.
230 @param Row The cursor position to print the string at
231 @param String String pointer.
233 @return Length of string printed to the console
243 return PrintAt (Column
, Row
, L
"%s", String
);
248 Prints a chracter to the default console, at
249 the supplied cursor position, using L"%c" format.
251 @param Column The cursor position to print the string at.
252 @param Row The cursor position to print the string at.
253 @param Character Character to print.
255 @return Length of string printed to the console.
265 return PrintAt (Column
, Row
, L
"%c", Character
);