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
36 // Include common header file for this module.
38 #include "CommonHeader.h"
47 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Out
,
52 // Display string worker for: Print, PrintAt, IPrint, IPrintAt
61 // For now, allocate an arbitrarily long buffer
63 Buffer
= AllocateZeroPool (0x10000);
64 BackupBuffer
= AllocateZeroPool (0x10000);
66 ASSERT (BackupBuffer
);
68 if (Column
!= (UINTN
) -1) {
69 Out
->SetCursorPosition (Out
, Column
, Row
);
72 UnicodeVSPrint (Buffer
, 0x10000, fmt
, args
);
74 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
76 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
]);
100 // Preserve the current index + 1, since this is where we will start printing from next
102 PreviousIndex
= Index
+ 1;
105 // We are at a narrow or wide character directive. Set attributes and strip it and print it
107 if (Buffer
[Index
] == NARROW_CHAR
) {
109 // Preserve bits 0 - 6 and zero out the rest
111 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
112 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
115 // Must be wide, set bit 7 ON
117 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
| EFI_WIDE_ATTRIBUTE
;
118 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
123 } while (Buffer
[Index
] != 0);
126 // We hit the end of the string - print it
128 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
131 FreePool (BackupBuffer
);
144 Prints a formatted unicode string to the default console
152 Length of string printed to the console
158 VA_START (args
, fmt
);
159 return _IPrint ((UINTN
) -1, (UINTN
) -1, gST
->ConOut
, fmt
, args
);
170 Prints a unicode string to the default console,
175 String - String pointer.
179 Length of string printed to the console
183 return Print ((CHAR16
*) L
"%s", String
);
194 Prints a chracter to the default console,
199 Character - Character to print.
203 Length of string printed to the console.
207 return Print ((CHAR16
*) L
"%c", Character
);
221 Prints a formatted unicode string to the default console, at
222 the supplied cursor position
226 Column, Row - The cursor position to print the string at
232 Length of string printed to the console
238 VA_START (args
, fmt
);
239 return _IPrint (Column
, Row
, gST
->ConOut
, fmt
, args
);
252 Prints a unicode string to the default console, at
253 the supplied cursor position, using L"%s" format.
257 Column, Row - The cursor position to print the string at
259 String - String pointer.
263 Length of string printed to the console
267 return PrintAt (Column
, Row
, (CHAR16
*) L
"%s", String
);
280 Prints a chracter to the default console, at
281 the supplied cursor position, using L"%c" format.
285 Column, Row - The cursor position to print the string at
287 Character - Character to print.
291 Length of string printed to the console.
295 return PrintAt (Column
, Row
, (CHAR16
*) L
"%c", Character
);