3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
19 simple implemenation of SPrint() and Print() to support debug.
21 You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
22 time. This makes the implementation very simple.
24 VSPrint, Print, SPrint format specification has the follwoing form
29 'S','s' - argument is an Unicode string
30 'c' - argument is an ascii character
42 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*Out
,
47 // Display string worker for: Print, PrintAt, IPrint, IPrintAt
56 // For now, allocate an arbitrarily long buffer
58 Buffer
= AllocateZeroPool (0x10000);
59 BackupBuffer
= AllocateZeroPool (0x10000);
61 ASSERT (BackupBuffer
);
63 if (Column
!= (UINTN
) -1) {
64 Out
->SetCursorPosition (Out
, Column
, Row
);
67 UnicodeVSPrint (Buffer
, 0x10000, fmt
, args
);
69 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
71 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
77 for (; (Buffer
[Index
] != NARROW_CHAR
) && (Buffer
[Index
] != WIDE_CHAR
) && (Buffer
[Index
] != 0); Index
++) {
78 BackupBuffer
[Index
] = Buffer
[Index
];
81 if (Buffer
[Index
] == 0) {
85 // Null-terminate the temporary string
87 BackupBuffer
[Index
] = 0;
90 // Print this out, we are about to switch widths
92 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
95 // Preserve the current index + 1, since this is where we will start printing from next
97 PreviousIndex
= Index
+ 1;
100 // We are at a narrow or wide character directive. Set attributes and strip it and print it
102 if (Buffer
[Index
] == NARROW_CHAR
) {
104 // Preserve bits 0 - 6 and zero out the rest
106 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
107 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
110 // Must be wide, set bit 7 ON
112 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
| EFI_WIDE_ATTRIBUTE
;
113 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
118 } while (Buffer
[Index
] != 0);
121 // We hit the end of the string - print it
123 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
126 FreePool (BackupBuffer
);
139 Prints a formatted unicode string to the default console
147 Length of string printed to the console
153 VA_START (args
, fmt
);
154 return _IPrint ((UINTN
) -1, (UINTN
) -1, gST
->ConOut
, fmt
, args
);
165 Prints a unicode string to the default console,
170 String - String pointer.
174 Length of string printed to the console
178 return Print ((CHAR16
*) L
"%s", String
);
189 Prints a chracter to the default console,
194 Character - Character to print.
198 Length of string printed to the console.
202 return Print ((CHAR16
*) L
"%c", Character
);
216 Prints a formatted unicode string to the default console, at
217 the supplied cursor position
221 Column, Row - The cursor position to print the string at
227 Length of string printed to the console
233 VA_START (args
, fmt
);
234 return _IPrint (Column
, Row
, gST
->ConOut
, fmt
, args
);
247 Prints a unicode string to the default console, at
248 the supplied cursor position, using L"%s" format.
252 Column, Row - The cursor position to print the string at
254 String - String pointer.
258 Length of string printed to the console
262 return PrintAt (Column
, Row
, (CHAR16
*) L
"%s", String
);
275 Prints a chracter to the default console, at
276 the supplied cursor position, using L"%c" format.
280 Column, Row - The cursor position to print the string at
282 Character - Character to print.
286 Length of string printed to the console.
290 return PrintAt (Column
, Row
, (CHAR16
*) L
"%c", Character
);