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 - 2012, 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.
155 UINTN LengthOfPrinted
;
157 VA_START (Args
, Fmt
);
158 LengthOfPrinted
= PrintInternal ((UINTN
) -1, (UINTN
) -1, gST
->ConOut
, Fmt
, Args
);
160 return LengthOfPrinted
;
165 Prints a unicode string to the default console,
168 @param String String pointer.
170 @return Length of string printed to the console
178 return ConsolePrint (L
"%s", String
);
183 Prints a chracter to the default console,
186 @param Character Character to print.
188 @return Length of string printed to the console.
196 return ConsolePrint (L
"%c", Character
);
201 Prints a formatted unicode string to the default console, at
202 the supplied cursor position.
204 @param Column The cursor position to print the string at.
205 @param Row The cursor position to print the string at.
206 @param Fmt Format string.
207 @param ... Variable argument list for format string.
209 @return Length of string printed to the console
222 UINTN LengthOfPrinted
;
224 VA_START (Args
, Fmt
);
225 LengthOfPrinted
= PrintInternal (Column
, Row
, gST
->ConOut
, Fmt
, Args
);
227 return LengthOfPrinted
;
232 Prints a unicode string to the default console, at
233 the supplied cursor position, using L"%s" format.
235 @param Column The cursor position to print the string at.
236 @param Row The cursor position to print the string at
237 @param String String pointer.
239 @return Length of string printed to the console
249 return PrintAt (Column
, Row
, L
"%s", String
);
254 Prints a chracter to the default console, at
255 the supplied cursor position, using L"%c" format.
257 @param Column The cursor position to print the string at.
258 @param Row The cursor position to print the string at.
259 @param Character Character to print.
261 @return Length of string printed to the console.
271 return PrintAt (Column
, Row
, L
"%c", Character
);