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
]);
125 gBS
->FreePool (Buffer
);
126 gBS
->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
);
208 IN EFI_HII_HANDLE Handle,
215 UINTN NumberOfHiiHandles;
216 EFI_HANDLE *HandleBuffer;
217 EFI_HII_PROTOCOL *Hii;
220 // There should only be one HII image
222 Status = gBS->LocateHandleBuffer (
224 &gEfiHiiProtocolGuid,
230 if (EFI_ERROR (Status)) {
235 // Retrieve the Hii protocol interface
237 Status = gBS->HandleProtocol (
239 &gEfiHiiProtocolGuid,
243 Hii->GetString (Hii, Handle, Token, FALSE, Language,
245 VA_START (args, fmt);
246 return _IPrint ((UINTN) -1, (UINTN) -1, gST->ConOut, fmt, args);
261 Prints a formatted unicode string to the default console, at
262 the supplied cursor position
266 Column, Row - The cursor position to print the string at
272 Length of string printed to the console
278 VA_START (args
, fmt
);
279 return _IPrint (Column
, Row
, gST
->ConOut
, fmt
, args
);
292 Prints a unicode string to the default console, at
293 the supplied cursor position, using L"%s" format.
297 Column, Row - The cursor position to print the string at
299 String - String pointer.
303 Length of string printed to the console
307 return PrintAt (Column
, Row
, (CHAR16
*) L
"%s", String
);
320 Prints a chracter to the default console, at
321 the supplied cursor position, using L"%c" format.
325 Column, Row - The cursor position to print the string at
327 Character - Character to print.
331 Length of string printed to the console.
335 return PrintAt (Column
, Row
, (CHAR16
*) L
"%c", Character
);