3 This library class defines a set of interfaces to customize Display module
5 Copyright (c) 2013-2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "CustomizedDisplayLibInternal.h"
11 EFI_SCREEN_DESCRIPTOR gScreenDimensions
;
12 CHAR16
*mLibUnknownString
;
13 extern EFI_HII_HANDLE mCDLStringPackHandle
;
15 #define SPACE_BUFFER_SIZE 1000
18 // Browser Global Strings
21 CHAR16
*gEnterCommitString
;
22 CHAR16
*gEnterEscapeString
;
23 CHAR16
*gEscapeString
;
24 CHAR16
*gMoveHighlight
;
25 CHAR16
*gDecNumericInput
;
26 CHAR16
*gHexNumericInput
;
27 CHAR16
*gToggleCheckBox
;
28 CHAR16
*gLibEmptyString
;
34 CHAR16
*gAdjustNumber
;
36 CHAR16
*gNvUpdateMessage
;
37 CHAR16
*gInputErrorMessage
;
41 Print banner info for front page.
43 @param[in] FormData Form Data to be shown in Page
48 IN FORM_DISPLAY_ENGINE_FORM
*FormData
53 CHAR16
*StrFrontPageBanner
;
58 // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
61 gScreenDimensions
.LeftColumn
,
62 gScreenDimensions
.RightColumn
,
63 gScreenDimensions
.TopRow
,
64 FRONT_PAGE_HEADER_HEIGHT
- 1 + gScreenDimensions
.TopRow
,
65 BANNER_TEXT
| BANNER_BACKGROUND
69 // for (Line = 0; Line < BANNER_HEIGHT; Line++) {
71 for (Line
= (UINT8
) gScreenDimensions
.TopRow
; Line
< BANNER_HEIGHT
+ (UINT8
) gScreenDimensions
.TopRow
; Line
++) {
73 // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
75 for (Alignment
= (UINT8
) gScreenDimensions
.LeftColumn
;
76 Alignment
< BANNER_COLUMNS
+ (UINT8
) gScreenDimensions
.LeftColumn
;
79 RowIdx
= (UINT8
) (Line
- (UINT8
) gScreenDimensions
.TopRow
);
80 ColumnIdx
= (UINT8
) (Alignment
- (UINT8
) gScreenDimensions
.LeftColumn
);
82 ASSERT (RowIdx
< BANNER_HEIGHT
&& ColumnIdx
< BANNER_COLUMNS
);
84 if (gBannerData
!= NULL
&& gBannerData
->Banner
[RowIdx
][ColumnIdx
] != 0x0000) {
85 StrFrontPageBanner
= LibGetToken (gBannerData
->Banner
[RowIdx
][ColumnIdx
], FormData
->HiiHandle
);
90 switch (Alignment
- gScreenDimensions
.LeftColumn
) {
95 PrintStringAt (gScreenDimensions
.LeftColumn
+ BANNER_LEFT_COLUMN_INDENT
, Line
, StrFrontPageBanner
);
100 // Handle center column
103 gScreenDimensions
.LeftColumn
+ (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
) / 3,
111 // Handle right column
114 gScreenDimensions
.LeftColumn
+ (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
) * 2 / 3,
121 FreePool (StrFrontPageBanner
);
127 Print framework and form title for a page.
129 @param[in] FormData Form Data to be shown in Page
133 IN FORM_DISPLAY_ENGINE_FORM
*FormData
143 if (gClassOfVfr
!= FORMSET_CLASS_PLATFORM_SETUP
) {
145 // Only Setup page needs Framework
148 gScreenDimensions
.LeftColumn
,
149 gScreenDimensions
.RightColumn
,
150 gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
,
151 gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 1,
152 KEYHELP_TEXT
| KEYHELP_BACKGROUND
157 Buffer
= AllocateZeroPool (0x10000);
158 ASSERT (Buffer
!= NULL
);
159 Character
= BOXDRAW_HORIZONTAL
;
160 for (Index
= 0; Index
+ 2 < (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
); Index
++) {
161 Buffer
[Index
] = Character
;
165 // Print Top border line
166 // +------------------------------------------------------------------------------+
168 // +------------------------------------------------------------------------------+
170 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
171 Character
= BOXDRAW_DOWN_RIGHT
;
173 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.TopRow
, Character
);
174 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
176 Character
= BOXDRAW_DOWN_LEFT
;
177 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
179 Character
= BOXDRAW_VERTICAL
;
180 for (Row
= gScreenDimensions
.TopRow
+ 1; Row
<= gScreenDimensions
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 2; Row
++) {
181 PrintCharAt (gScreenDimensions
.LeftColumn
, Row
, Character
);
182 PrintCharAt (gScreenDimensions
.RightColumn
- 1, Row
, Character
);
188 TitleStr
= LibGetToken (FormData
->FormTitle
, FormData
->HiiHandle
);
189 ASSERT (TitleStr
!= NULL
);
190 TitleColumn
= (gScreenDimensions
.RightColumn
+ gScreenDimensions
.LeftColumn
- LibGetStringWidth (TitleStr
) / 2) / 2;
191 PrintStringAtWithWidth (gScreenDimensions
.LeftColumn
+ 1, gScreenDimensions
.TopRow
+ 1, gLibEmptyString
, TitleColumn
- gScreenDimensions
.LeftColumn
- 1);
192 PrintStringAtWithWidth (
194 gScreenDimensions
.TopRow
+ 1,
196 gScreenDimensions
.RightColumn
- 1 - TitleColumn
200 Character
= BOXDRAW_UP_RIGHT
;
201 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1, Character
);
202 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
204 Character
= BOXDRAW_UP_LEFT
;
205 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
208 // Print Bottom border line
209 // +------------------------------------------------------------------------------+
211 // +------------------------------------------------------------------------------+
213 Character
= BOXDRAW_DOWN_RIGHT
;
214 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
, Character
);
216 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
218 Character
= BOXDRAW_DOWN_LEFT
;
219 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
220 Character
= BOXDRAW_VERTICAL
;
221 for (Row
= gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
+ 1;
222 Row
<= gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
225 PrintCharAt (gScreenDimensions
.LeftColumn
, Row
, Character
);
226 PrintCharAt (gScreenDimensions
.RightColumn
- 1, Row
, Character
);
229 Character
= BOXDRAW_UP_RIGHT
;
230 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 1, Character
);
232 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
234 Character
= BOXDRAW_UP_LEFT
;
235 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
241 Process some op code which is not recognized by browser core.
243 @param OpCodeData The pointer to the op code buffer.
245 @return EFI_SUCCESS Pass the statement success.
250 IN EFI_IFR_OP_HEADER
*OpCodeData
253 EFI_GUID
* ClassGuid
;
259 switch (OpCodeData
->OpCode
) {
260 case EFI_IFR_FORM_SET_OP
:
262 // process the statement outside of form,if it is formset op, get its formsetguid or classguid and compared with gFrontPageFormSetGuid
264 if (CompareMem (PcdGetPtr (PcdFrontPageFormSetGuid
), &((EFI_IFR_FORM_SET
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
)) == 0){
265 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
267 ClassGuidNum
= (UINT8
)(((EFI_IFR_FORM_SET
*)OpCodeData
)->Flags
& 0x3);
268 ClassGuid
= (EFI_GUID
*)(VOID
*)((UINT8
*)OpCodeData
+ sizeof (EFI_IFR_FORM_SET
));
269 while (ClassGuidNum
-- > 0){
270 if (CompareGuid((EFI_GUID
*)PcdGetPtr (PcdFrontPageFormSetGuid
),ClassGuid
)){
271 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
279 case EFI_IFR_GUID_OP
:
280 if (CompareGuid (&gEfiIfrTianoGuid
, (EFI_GUID
*)((CHAR8
*) OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)))) {
282 // Tiano specific GUIDed opcodes
284 switch (((EFI_IFR_GUID_LABEL
*) OpCodeData
)->ExtendOpCode
) {
285 case EFI_IFR_EXTEND_OP_LABEL
:
291 case EFI_IFR_EXTEND_OP_BANNER
:
293 // Only in front page form set, we care about the banner data.
295 if (gClassOfVfr
== FORMSET_CLASS_FRONT_PAGE
) {
297 // Initialize Driver private data
299 if (gBannerData
== NULL
) {
300 gBannerData
= AllocateZeroPool (sizeof (BANNER_DATA
));
301 ASSERT (gBannerData
!= NULL
);
305 &gBannerData
->Banner
[((EFI_IFR_GUID_BANNER
*) OpCodeData
)->LineNumber
][
306 ((EFI_IFR_GUID_BANNER
*) OpCodeData
)->Alignment
],
307 &((EFI_IFR_GUID_BANNER
*) OpCodeData
)->Title
,
308 sizeof (EFI_STRING_ID
)
313 case EFI_IFR_EXTEND_OP_SUBCLASS
:
314 if (((EFI_IFR_GUID_SUBCLASS
*) OpCodeData
)->SubClass
== EFI_FRONT_PAGE_SUBCLASS
) {
315 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
331 Process some op codes which is out side of current form.
333 @param FormData Pointer to the form data.
335 @return EFI_SUCCESS Pass the statement success.
339 ProcessExternedOpcode (
340 IN FORM_DISPLAY_ENGINE_FORM
*FormData
344 LIST_ENTRY
*NestLink
;
345 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
346 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
348 Link
= GetFirstNode (&FormData
->StatementListOSF
);
349 while (!IsNull (&FormData
->StatementListOSF
, Link
)) {
350 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
351 Link
= GetNextNode (&FormData
->StatementListOSF
, Link
);
353 ProcessUserOpcode(Statement
->OpCode
);
356 Link
= GetFirstNode (&FormData
->StatementListHead
);
357 while (!IsNull (&FormData
->StatementListHead
, Link
)) {
358 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
359 Link
= GetNextNode (&FormData
->StatementListHead
, Link
);
361 ProcessUserOpcode(Statement
->OpCode
);
363 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
364 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
365 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
366 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
368 ProcessUserOpcode(NestStatement
->OpCode
);
375 Validate the input screen diemenstion info.
377 @param FormData The input form data info.
379 @return EFI_SUCCESS The input screen info is acceptable.
380 @return EFI_INVALID_PARAMETER The input screen info is not acceptable.
384 ScreenDiemensionInfoValidate (
385 IN FORM_DISPLAY_ENGINE_FORM
*FormData
392 // Calculate total number of Register HotKeys.
395 if (!IsListEmpty (&FormData
->HotKeyListHead
)){
396 Link
= GetFirstNode (&FormData
->HotKeyListHead
);
397 while (!IsNull (&FormData
->HotKeyListHead
, Link
)) {
398 Link
= GetNextNode (&FormData
->HotKeyListHead
, Link
);
404 // Show three HotKeys help information on one row.
406 gFooterHeight
= FOOTER_HEIGHT
+ (Index
/ 3);
409 ZeroMem (&gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
410 gST
->ConOut
->QueryMode (
412 gST
->ConOut
->Mode
->Mode
,
413 &gScreenDimensions
.RightColumn
,
414 &gScreenDimensions
.BottomRow
418 // Check local dimension vs. global dimension.
420 if (FormData
->ScreenDimensions
!= NULL
) {
421 if ((gScreenDimensions
.RightColumn
< FormData
->ScreenDimensions
->RightColumn
) ||
422 (gScreenDimensions
.BottomRow
< FormData
->ScreenDimensions
->BottomRow
)
424 return EFI_INVALID_PARAMETER
;
427 // Local dimension validation.
429 if ((FormData
->ScreenDimensions
->RightColumn
> FormData
->ScreenDimensions
->LeftColumn
) &&
430 (FormData
->ScreenDimensions
->BottomRow
> FormData
->ScreenDimensions
->TopRow
) &&
431 ((FormData
->ScreenDimensions
->RightColumn
- FormData
->ScreenDimensions
->LeftColumn
) > 2) &&
432 ((FormData
->ScreenDimensions
->BottomRow
- FormData
->ScreenDimensions
->TopRow
) > STATUS_BAR_HEIGHT
+
433 FRONT_PAGE_HEADER_HEIGHT
+ gFooterHeight
+ 3)) {
434 CopyMem (&gScreenDimensions
, (VOID
*) FormData
->ScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
436 return EFI_INVALID_PARAMETER
;
445 Get the string based on the StringId and HII Package List Handle.
447 @param Token The String's ID.
448 @param HiiHandle The package list in the HII database to search for
449 the specified string.
451 @return The output string.
456 IN EFI_STRING_ID Token
,
457 IN EFI_HII_HANDLE HiiHandle
462 String
= HiiGetString (HiiHandle
, Token
, NULL
);
463 if (String
== NULL
) {
464 String
= AllocateCopyPool (StrSize (mLibUnknownString
), mLibUnknownString
);
465 ASSERT (String
!= NULL
);
468 return (CHAR16
*) String
;
473 Count the storage space of a Unicode string.
475 This function handles the Unicode string with NARROW_CHAR
476 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
477 does not count in the resultant output. If a WIDE_CHAR is
478 hit, then 2 Unicode character will consume an output storage
479 space with size of CHAR16 till a NARROW_CHAR is hit.
481 If String is NULL, then ASSERT ().
483 @param String The input string to be counted.
485 @return Storage space for the input string.
495 UINTN IncrementValue
;
497 ASSERT (String
!= NULL
);
498 if (String
== NULL
) {
508 // Advance to the null-terminator or to the first width directive
511 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
512 Index
++, Count
= Count
+ IncrementValue
517 // We hit the null-terminator, we now have a count
519 if (String
[Index
] == 0) {
523 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
524 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
526 if (String
[Index
] == NARROW_CHAR
) {
528 // Skip to the next character
534 // Skip to the next character
539 } while (String
[Index
] != 0);
542 // Increment by one to include the null-terminator in the size
546 return Count
* sizeof (CHAR16
);
550 Show all registered HotKey help strings on bottom Rows.
552 @param FormData The curent input form data info.
553 @param SetState Set HotKey or Clear HotKey
557 PrintHotKeyHelpString (
558 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
564 UINTN BottomRowOfHotKeyHelp
;
565 UINTN ColumnIndexWidth
;
569 EFI_SCREEN_DESCRIPTOR LocalScreen
;
571 BROWSER_HOT_KEY
*HotKey
;
575 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
576 ColumnWidth
= (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
577 BottomRowOfHotKeyHelp
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 3;
578 ColumnStr
= gLibEmptyString
;
581 // Calculate total number of Register HotKeys.
584 Link
= GetFirstNode (&FormData
->HotKeyListHead
);
585 while (!IsNull (&FormData
->HotKeyListHead
, Link
)) {
586 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
588 // Calculate help information Column and Row.
590 ColumnIndex
= Index
% 3;
591 if (ColumnIndex
== 0) {
592 CurrentCol
= LocalScreen
.LeftColumn
+ 2 * ColumnWidth
;
593 ColumnIndexWidth
= ColumnWidth
- 1;
594 } else if (ColumnIndex
== 1) {
595 CurrentCol
= LocalScreen
.LeftColumn
+ ColumnWidth
;
596 ColumnIndexWidth
= ColumnWidth
;
598 CurrentCol
= LocalScreen
.LeftColumn
+ 2;
599 ColumnIndexWidth
= ColumnWidth
- 2;
601 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
604 // Help string can't exceed ColumnWidth. One Row will show three Help information.
607 if (StrLen (HotKey
->HelpString
) > ColumnIndexWidth
) {
608 BakChar
= HotKey
->HelpString
[ColumnIndexWidth
];
609 HotKey
->HelpString
[ColumnIndexWidth
] = L
'\0';
613 // Print HotKey help string on bottom Row.
616 ColumnStr
= HotKey
->HelpString
;
618 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, ColumnStr
, ColumnIndexWidth
);
620 if (BakChar
!= L
'\0') {
621 HotKey
->HelpString
[ColumnIndexWidth
] = BakChar
;
626 Link
= GetNextNode (&FormData
->HotKeyListHead
, Link
);
634 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
635 ColumnIndex
= Index
% 3;
636 if (ColumnIndex
== 0) {
637 CurrentCol
= LocalScreen
.LeftColumn
+ 2 * ColumnWidth
;
638 ColumnIndexWidth
= ColumnWidth
- 1;
640 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, gLibEmptyString
, ColumnIndexWidth
);
642 if (ColumnIndex
== 1) {
643 CurrentCol
= LocalScreen
.LeftColumn
+ ColumnWidth
;
644 ColumnIndexWidth
= ColumnWidth
;
645 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, gLibEmptyString
, ColumnIndexWidth
);
653 Get step info from numeric opcode.
655 @param[in] OpCode The input numeric op code.
657 @return step info for this opcode.
661 IN EFI_IFR_OP_HEADER
*OpCode
664 EFI_IFR_NUMERIC
*NumericOp
;
667 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
669 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
670 case EFI_IFR_NUMERIC_SIZE_1
:
671 Step
= NumericOp
->data
.u8
.Step
;
674 case EFI_IFR_NUMERIC_SIZE_2
:
675 Step
= NumericOp
->data
.u16
.Step
;
678 case EFI_IFR_NUMERIC_SIZE_4
:
679 Step
= NumericOp
->data
.u32
.Step
;
682 case EFI_IFR_NUMERIC_SIZE_8
:
683 Step
= NumericOp
->data
.u64
.Step
;
695 Initialize the HII String Token to the correct values.
699 InitializeLibStrings (
703 mLibUnknownString
= L
"!";
705 gEnterString
= LibGetToken (STRING_TOKEN (ENTER_STRING
), mCDLStringPackHandle
);
706 gEnterCommitString
= LibGetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), mCDLStringPackHandle
);
707 gEnterEscapeString
= LibGetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), mCDLStringPackHandle
);
708 gEscapeString
= LibGetToken (STRING_TOKEN (ESCAPE_STRING
), mCDLStringPackHandle
);
709 gMoveHighlight
= LibGetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), mCDLStringPackHandle
);
710 gDecNumericInput
= LibGetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), mCDLStringPackHandle
);
711 gHexNumericInput
= LibGetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), mCDLStringPackHandle
);
712 gToggleCheckBox
= LibGetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), mCDLStringPackHandle
);
714 gAreYouSure
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE
), mCDLStringPackHandle
);
715 gYesResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), mCDLStringPackHandle
);
716 gNoResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), mCDLStringPackHandle
);
717 gPlusString
= LibGetToken (STRING_TOKEN (PLUS_STRING
), mCDLStringPackHandle
);
718 gMinusString
= LibGetToken (STRING_TOKEN (MINUS_STRING
), mCDLStringPackHandle
);
719 gAdjustNumber
= LibGetToken (STRING_TOKEN (ADJUST_NUMBER
), mCDLStringPackHandle
);
720 gSaveChanges
= LibGetToken (STRING_TOKEN (SAVE_CHANGES
), mCDLStringPackHandle
);
722 gLibEmptyString
= LibGetToken (STRING_TOKEN (EMPTY_STRING
), mCDLStringPackHandle
);
724 gNvUpdateMessage
= LibGetToken (STRING_TOKEN (NV_UPDATE_MESSAGE
), mCDLStringPackHandle
);
725 gInputErrorMessage
= LibGetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE
), mCDLStringPackHandle
);
730 mSpaceBuffer
= AllocatePool ((SPACE_BUFFER_SIZE
+ 1) * sizeof (CHAR16
));
731 ASSERT (mSpaceBuffer
!= NULL
);
732 LibSetUnicodeMem (mSpaceBuffer
, SPACE_BUFFER_SIZE
, L
' ');
733 mSpaceBuffer
[SPACE_BUFFER_SIZE
] = L
'\0';
746 FreePool (gEnterString
);
747 FreePool (gEnterCommitString
);
748 FreePool (gEnterEscapeString
);
749 FreePool (gEscapeString
);
750 FreePool (gMoveHighlight
);
751 FreePool (gDecNumericInput
);
752 FreePool (gHexNumericInput
);
753 FreePool (gToggleCheckBox
);
755 FreePool (gAreYouSure
);
756 FreePool (gYesResponse
);
757 FreePool (gNoResponse
);
758 FreePool (gPlusString
);
759 FreePool (gMinusString
);
760 FreePool (gAdjustNumber
);
761 FreePool (gSaveChanges
);
763 FreePool (gLibEmptyString
);
765 FreePool (gNvUpdateMessage
);
766 FreePool (gInputErrorMessage
);
768 FreePool (mSpaceBuffer
);
772 Wait for a key to be pressed by user.
774 @param Key The key which is pressed by user.
776 @retval EFI_SUCCESS The function always completed successfully.
781 OUT EFI_INPUT_KEY
*Key
788 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, Key
);
789 if (!EFI_ERROR (Status
)) {
793 if (Status
!= EFI_NOT_READY
) {
797 gBS
->WaitForEvent (1, &gST
->ConIn
->WaitForKey
, &Index
);
804 Set Buffer to Value for Size bytes.
806 @param Buffer Memory to set.
807 @param Size Number of bytes to set
808 @param Value Value of the set operation.
821 while ((Size
--) != 0) {
827 The internal function prints to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
830 @param Width Width of string to be print.
831 @param Column The position of the output string.
832 @param Row The position of the output string.
833 @param Out The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
834 @param Fmt The format string.
835 @param Args The additional argument for the variables in the format string.
837 @return Number of Unicode character printed.
845 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Out
,
851 CHAR16
*BackupBuffer
;
860 // For now, allocate an arbitrarily long buffer
862 Buffer
= AllocateZeroPool (0x10000);
863 BackupBuffer
= AllocateZeroPool (0x10000);
865 ASSERT (BackupBuffer
);
867 if (Column
!= (UINTN
) -1) {
868 Out
->SetCursorPosition (Out
, Column
, Row
);
871 UnicodeVSPrint (Buffer
, 0x10000, Fmt
, Args
);
873 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
875 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
885 for (; (Buffer
[Index
] != NARROW_CHAR
) && (Buffer
[Index
] != WIDE_CHAR
) && (Buffer
[Index
] != 0); Index
++) {
886 BackupBuffer
[Index
] = Buffer
[Index
];
889 if (Buffer
[Index
] == 0) {
894 // Print this out, we are about to switch widths
896 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
897 Count
= StrLen (&BackupBuffer
[PreviousIndex
]);
898 PrintWidth
+= Count
* CharWidth
;
902 // Preserve the current index + 1, since this is where we will start printing from next
904 PreviousIndex
= Index
+ 1;
907 // We are at a narrow or wide character directive. Set attributes and strip it and print it
909 if (Buffer
[Index
] == NARROW_CHAR
) {
911 // Preserve bits 0 - 6 and zero out the rest
913 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
914 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
918 // Must be wide, set bit 7 ON
920 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
| EFI_WIDE_ATTRIBUTE
;
921 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
927 } while (Buffer
[Index
] != 0);
930 // We hit the end of the string - print it
932 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
933 Count
= StrLen (&BackupBuffer
[PreviousIndex
]);
934 PrintWidth
+= Count
* CharWidth
;
936 if (PrintWidth
< Width
) {
937 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
938 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
939 Out
->OutputString (Out
, &mSpaceBuffer
[SPACE_BUFFER_SIZE
- Width
+ PrintWidth
]);
943 FreePool (BackupBuffer
);
948 Prints a formatted unicode string to the default console, at
949 the supplied cursor position.
951 @param Width Width of String to be printed.
952 @param Column The cursor position to print the string at.
953 @param Row The cursor position to print the string at.
954 @param Fmt Format string.
955 @param ... Variable argument list for format string.
957 @return Length of string printed to the console
971 UINTN LengthOfPrinted
;
973 VA_START (Args
, Fmt
);
974 LengthOfPrinted
= PrintInternal (Width
, Column
, Row
, gST
->ConOut
, Fmt
, Args
);
976 return LengthOfPrinted
;