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
;
80 RowIdx
= (UINT8
)(Line
- (UINT8
)gScreenDimensions
.TopRow
);
81 ColumnIdx
= (UINT8
)(Alignment
- (UINT8
)gScreenDimensions
.LeftColumn
);
83 ASSERT (RowIdx
< BANNER_HEIGHT
&& ColumnIdx
< BANNER_COLUMNS
);
85 if ((gBannerData
!= NULL
) && (gBannerData
->Banner
[RowIdx
][ColumnIdx
] != 0x0000)) {
86 StrFrontPageBanner
= LibGetToken (gBannerData
->Banner
[RowIdx
][ColumnIdx
], FormData
->HiiHandle
);
91 switch (Alignment
- gScreenDimensions
.LeftColumn
) {
96 PrintStringAt (gScreenDimensions
.LeftColumn
+ BANNER_LEFT_COLUMN_INDENT
, Line
, StrFrontPageBanner
);
101 // Handle center column
104 gScreenDimensions
.LeftColumn
+ (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
) / 3,
112 // Handle right column
115 gScreenDimensions
.LeftColumn
+ (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
) * 2 / 3,
122 FreePool (StrFrontPageBanner
);
128 Print framework and form title for a page.
130 @param[in] FormData Form Data to be shown in Page
134 IN FORM_DISPLAY_ENGINE_FORM
*FormData
144 if (gClassOfVfr
!= FORMSET_CLASS_PLATFORM_SETUP
) {
146 // Only Setup page needs Framework
149 gScreenDimensions
.LeftColumn
,
150 gScreenDimensions
.RightColumn
,
151 gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
,
152 gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 1,
153 KEYHELP_TEXT
| KEYHELP_BACKGROUND
158 Buffer
= AllocateZeroPool (0x10000);
159 ASSERT (Buffer
!= NULL
);
160 Character
= BOXDRAW_HORIZONTAL
;
161 for (Index
= 0; Index
+ 2 < (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
); Index
++) {
162 Buffer
[Index
] = Character
;
166 // Print Top border line
167 // +------------------------------------------------------------------------------+
169 // +------------------------------------------------------------------------------+
171 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
172 Character
= BOXDRAW_DOWN_RIGHT
;
174 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.TopRow
, Character
);
175 PrintStringAt ((UINTN
)-1, (UINTN
)-1, Buffer
);
177 Character
= BOXDRAW_DOWN_LEFT
;
178 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
180 Character
= BOXDRAW_VERTICAL
;
181 for (Row
= gScreenDimensions
.TopRow
+ 1; Row
<= gScreenDimensions
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 2; Row
++) {
182 PrintCharAt (gScreenDimensions
.LeftColumn
, Row
, Character
);
183 PrintCharAt (gScreenDimensions
.RightColumn
- 1, Row
, Character
);
189 TitleStr
= LibGetToken (FormData
->FormTitle
, FormData
->HiiHandle
);
190 ASSERT (TitleStr
!= NULL
);
191 TitleColumn
= (gScreenDimensions
.RightColumn
+ gScreenDimensions
.LeftColumn
- LibGetStringWidth (TitleStr
) / 2) / 2;
192 PrintStringAtWithWidth (gScreenDimensions
.LeftColumn
+ 1, gScreenDimensions
.TopRow
+ 1, gLibEmptyString
, TitleColumn
- gScreenDimensions
.LeftColumn
- 1);
193 PrintStringAtWithWidth (
195 gScreenDimensions
.TopRow
+ 1,
197 gScreenDimensions
.RightColumn
- 1 - TitleColumn
201 Character
= BOXDRAW_UP_RIGHT
;
202 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1, Character
);
203 PrintStringAt ((UINTN
)-1, (UINTN
)-1, Buffer
);
205 Character
= BOXDRAW_UP_LEFT
;
206 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
209 // Print Bottom border line
210 // +------------------------------------------------------------------------------+
212 // +------------------------------------------------------------------------------+
214 Character
= BOXDRAW_DOWN_RIGHT
;
215 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
, Character
);
217 PrintStringAt ((UINTN
)-1, (UINTN
)-1, Buffer
);
219 Character
= BOXDRAW_DOWN_LEFT
;
220 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
221 Character
= BOXDRAW_VERTICAL
;
222 for (Row
= gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
+ 1;
223 Row
<= gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
227 PrintCharAt (gScreenDimensions
.LeftColumn
, Row
, Character
);
228 PrintCharAt (gScreenDimensions
.RightColumn
- 1, Row
, Character
);
231 Character
= BOXDRAW_UP_RIGHT
;
232 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 1, Character
);
234 PrintStringAt ((UINTN
)-1, (UINTN
)-1, Buffer
);
236 Character
= BOXDRAW_UP_LEFT
;
237 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
243 Process some op code which is not recognized by browser core.
245 @param OpCodeData The pointer to the op code buffer.
247 @return EFI_SUCCESS Pass the statement success.
252 IN EFI_IFR_OP_HEADER
*OpCodeData
261 switch (OpCodeData
->OpCode
) {
262 case EFI_IFR_FORM_SET_OP
:
264 // process the statement outside of form,if it is formset op, get its formsetguid or classguid and compared with gFrontPageFormSetGuid
266 if (CompareMem (PcdGetPtr (PcdFrontPageFormSetGuid
), &((EFI_IFR_FORM_SET
*)OpCodeData
)->Guid
, sizeof (EFI_GUID
)) == 0) {
267 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
269 ClassGuidNum
= (UINT8
)(((EFI_IFR_FORM_SET
*)OpCodeData
)->Flags
& 0x3);
270 ClassGuid
= (EFI_GUID
*)(VOID
*)((UINT8
*)OpCodeData
+ sizeof (EFI_IFR_FORM_SET
));
271 while (ClassGuidNum
-- > 0) {
272 if (CompareGuid ((EFI_GUID
*)PcdGetPtr (PcdFrontPageFormSetGuid
), ClassGuid
)) {
273 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
283 case EFI_IFR_GUID_OP
:
284 if (CompareGuid (&gEfiIfrTianoGuid
, (EFI_GUID
*)((CHAR8
*)OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)))) {
286 // Tiano specific GUIDed opcodes
288 switch (((EFI_IFR_GUID_LABEL
*)OpCodeData
)->ExtendOpCode
) {
289 case EFI_IFR_EXTEND_OP_LABEL
:
295 case EFI_IFR_EXTEND_OP_BANNER
:
297 // Only in front page form set, we care about the banner data.
299 if (gClassOfVfr
== FORMSET_CLASS_FRONT_PAGE
) {
301 // Initialize Driver private data
303 if (gBannerData
== NULL
) {
304 gBannerData
= AllocateZeroPool (sizeof (BANNER_DATA
));
305 ASSERT (gBannerData
!= NULL
);
309 &gBannerData
->Banner
[((EFI_IFR_GUID_BANNER
*)OpCodeData
)->LineNumber
][
310 ((EFI_IFR_GUID_BANNER
*)OpCodeData
)->Alignment
],
311 &((EFI_IFR_GUID_BANNER
*)OpCodeData
)->Title
,
312 sizeof (EFI_STRING_ID
)
318 case EFI_IFR_EXTEND_OP_SUBCLASS
:
319 if (((EFI_IFR_GUID_SUBCLASS
*)OpCodeData
)->SubClass
== EFI_FRONT_PAGE_SUBCLASS
) {
320 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
338 Process some op codes which is out side of current form.
340 @param FormData Pointer to the form data.
342 @return EFI_SUCCESS Pass the statement success.
346 ProcessExternedOpcode (
347 IN FORM_DISPLAY_ENGINE_FORM
*FormData
351 LIST_ENTRY
*NestLink
;
352 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
353 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
355 Link
= GetFirstNode (&FormData
->StatementListOSF
);
356 while (!IsNull (&FormData
->StatementListOSF
, Link
)) {
357 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
358 Link
= GetNextNode (&FormData
->StatementListOSF
, Link
);
360 ProcessUserOpcode (Statement
->OpCode
);
363 Link
= GetFirstNode (&FormData
->StatementListHead
);
364 while (!IsNull (&FormData
->StatementListHead
, Link
)) {
365 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
366 Link
= GetNextNode (&FormData
->StatementListHead
, Link
);
368 ProcessUserOpcode (Statement
->OpCode
);
370 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
371 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
372 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
373 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
375 ProcessUserOpcode (NestStatement
->OpCode
);
381 Validate the input screen diemenstion info.
383 @param FormData The input form data info.
385 @return EFI_SUCCESS The input screen info is acceptable.
386 @return EFI_INVALID_PARAMETER The input screen info is not acceptable.
390 ScreenDiemensionInfoValidate (
391 IN FORM_DISPLAY_ENGINE_FORM
*FormData
398 // Calculate total number of Register HotKeys.
401 if (!IsListEmpty (&FormData
->HotKeyListHead
)) {
402 Link
= GetFirstNode (&FormData
->HotKeyListHead
);
403 while (!IsNull (&FormData
->HotKeyListHead
, Link
)) {
404 Link
= GetNextNode (&FormData
->HotKeyListHead
, Link
);
410 // Show three HotKeys help information on one row.
412 gFooterHeight
= FOOTER_HEIGHT
+ (Index
/ 3);
414 ZeroMem (&gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
415 gST
->ConOut
->QueryMode (
417 gST
->ConOut
->Mode
->Mode
,
418 &gScreenDimensions
.RightColumn
,
419 &gScreenDimensions
.BottomRow
423 // Check local dimension vs. global dimension.
425 if (FormData
->ScreenDimensions
!= NULL
) {
426 if ((gScreenDimensions
.RightColumn
< FormData
->ScreenDimensions
->RightColumn
) ||
427 (gScreenDimensions
.BottomRow
< FormData
->ScreenDimensions
->BottomRow
)
430 return EFI_INVALID_PARAMETER
;
433 // Local dimension validation.
435 if ((FormData
->ScreenDimensions
->RightColumn
> FormData
->ScreenDimensions
->LeftColumn
) &&
436 (FormData
->ScreenDimensions
->BottomRow
> FormData
->ScreenDimensions
->TopRow
) &&
437 ((FormData
->ScreenDimensions
->RightColumn
- FormData
->ScreenDimensions
->LeftColumn
) > 2) &&
438 ((FormData
->ScreenDimensions
->BottomRow
- FormData
->ScreenDimensions
->TopRow
) > STATUS_BAR_HEIGHT
+
439 FRONT_PAGE_HEADER_HEIGHT
+ gFooterHeight
+ 3))
441 CopyMem (&gScreenDimensions
, (VOID
*)FormData
->ScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
443 return EFI_INVALID_PARAMETER
;
452 Get the string based on the StringId and HII Package List Handle.
454 @param Token The String's ID.
455 @param HiiHandle The package list in the HII database to search for
456 the specified string.
458 @return The output string.
463 IN EFI_STRING_ID Token
,
464 IN EFI_HII_HANDLE HiiHandle
469 String
= HiiGetString (HiiHandle
, Token
, NULL
);
470 if (String
== NULL
) {
471 String
= AllocateCopyPool (StrSize (mLibUnknownString
), mLibUnknownString
);
472 ASSERT (String
!= NULL
);
475 return (CHAR16
*)String
;
479 Count the storage space of a Unicode string.
481 This function handles the Unicode string with NARROW_CHAR
482 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
483 does not count in the resultant output. If a WIDE_CHAR is
484 hit, then 2 Unicode character will consume an output storage
485 space with size of CHAR16 till a NARROW_CHAR is hit.
487 If String is NULL, then ASSERT ().
489 @param String The input string to be counted.
491 @return Storage space for the input string.
501 UINTN IncrementValue
;
503 ASSERT (String
!= NULL
);
504 if (String
== NULL
) {
514 // Advance to the null-terminator or to the first width directive
517 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
518 Index
++, Count
= Count
+ IncrementValue
524 // We hit the null-terminator, we now have a count
526 if (String
[Index
] == 0) {
531 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
532 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
534 if (String
[Index
] == NARROW_CHAR
) {
536 // Skip to the next character
542 // Skip to the next character
547 } while (String
[Index
] != 0);
550 // Increment by one to include the null-terminator in the size
554 return Count
* sizeof (CHAR16
);
558 Show all registered HotKey help strings on bottom Rows.
560 @param FormData The curent input form data info.
561 @param SetState Set HotKey or Clear HotKey
565 PrintHotKeyHelpString (
566 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
572 UINTN BottomRowOfHotKeyHelp
;
573 UINTN ColumnIndexWidth
;
577 EFI_SCREEN_DESCRIPTOR LocalScreen
;
579 BROWSER_HOT_KEY
*HotKey
;
583 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
584 ColumnWidth
= (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
585 BottomRowOfHotKeyHelp
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 3;
586 ColumnStr
= gLibEmptyString
;
589 // Calculate total number of Register HotKeys.
592 Link
= GetFirstNode (&FormData
->HotKeyListHead
);
593 while (!IsNull (&FormData
->HotKeyListHead
, Link
)) {
594 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
596 // Calculate help information Column and Row.
598 ColumnIndex
= Index
% 3;
599 if (ColumnIndex
== 0) {
600 CurrentCol
= LocalScreen
.LeftColumn
+ 2 * ColumnWidth
;
601 ColumnIndexWidth
= ColumnWidth
- 1;
602 } else if (ColumnIndex
== 1) {
603 CurrentCol
= LocalScreen
.LeftColumn
+ ColumnWidth
;
604 ColumnIndexWidth
= ColumnWidth
;
606 CurrentCol
= LocalScreen
.LeftColumn
+ 2;
607 ColumnIndexWidth
= ColumnWidth
- 2;
610 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
613 // Help string can't exceed ColumnWidth. One Row will show three Help information.
616 if (StrLen (HotKey
->HelpString
) > ColumnIndexWidth
) {
617 BakChar
= HotKey
->HelpString
[ColumnIndexWidth
];
618 HotKey
->HelpString
[ColumnIndexWidth
] = L
'\0';
622 // Print HotKey help string on bottom Row.
625 ColumnStr
= HotKey
->HelpString
;
628 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, ColumnStr
, ColumnIndexWidth
);
630 if (BakChar
!= L
'\0') {
631 HotKey
->HelpString
[ColumnIndexWidth
] = BakChar
;
637 Link
= GetNextNode (&FormData
->HotKeyListHead
, Link
);
645 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
646 ColumnIndex
= Index
% 3;
647 if (ColumnIndex
== 0) {
648 CurrentCol
= LocalScreen
.LeftColumn
+ 2 * ColumnWidth
;
649 ColumnIndexWidth
= ColumnWidth
- 1;
651 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, gLibEmptyString
, ColumnIndexWidth
);
654 if (ColumnIndex
== 1) {
655 CurrentCol
= LocalScreen
.LeftColumn
+ ColumnWidth
;
656 ColumnIndexWidth
= ColumnWidth
;
657 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, gLibEmptyString
, ColumnIndexWidth
);
665 Get step info from numeric opcode.
667 @param[in] OpCode The input numeric op code.
669 @return step info for this opcode.
673 IN EFI_IFR_OP_HEADER
*OpCode
676 EFI_IFR_NUMERIC
*NumericOp
;
679 NumericOp
= (EFI_IFR_NUMERIC
*)OpCode
;
681 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
682 case EFI_IFR_NUMERIC_SIZE_1
:
683 Step
= NumericOp
->data
.u8
.Step
;
686 case EFI_IFR_NUMERIC_SIZE_2
:
687 Step
= NumericOp
->data
.u16
.Step
;
690 case EFI_IFR_NUMERIC_SIZE_4
:
691 Step
= NumericOp
->data
.u32
.Step
;
694 case EFI_IFR_NUMERIC_SIZE_8
:
695 Step
= NumericOp
->data
.u64
.Step
;
707 Initialize the HII String Token to the correct values.
711 InitializeLibStrings (
715 mLibUnknownString
= L
"!";
717 gEnterString
= LibGetToken (STRING_TOKEN (ENTER_STRING
), mCDLStringPackHandle
);
718 gEnterCommitString
= LibGetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), mCDLStringPackHandle
);
719 gEnterEscapeString
= LibGetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), mCDLStringPackHandle
);
720 gEscapeString
= LibGetToken (STRING_TOKEN (ESCAPE_STRING
), mCDLStringPackHandle
);
721 gMoveHighlight
= LibGetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), mCDLStringPackHandle
);
722 gDecNumericInput
= LibGetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), mCDLStringPackHandle
);
723 gHexNumericInput
= LibGetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), mCDLStringPackHandle
);
724 gToggleCheckBox
= LibGetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), mCDLStringPackHandle
);
726 gAreYouSure
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE
), mCDLStringPackHandle
);
727 gYesResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), mCDLStringPackHandle
);
728 gNoResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), mCDLStringPackHandle
);
729 gPlusString
= LibGetToken (STRING_TOKEN (PLUS_STRING
), mCDLStringPackHandle
);
730 gMinusString
= LibGetToken (STRING_TOKEN (MINUS_STRING
), mCDLStringPackHandle
);
731 gAdjustNumber
= LibGetToken (STRING_TOKEN (ADJUST_NUMBER
), mCDLStringPackHandle
);
732 gSaveChanges
= LibGetToken (STRING_TOKEN (SAVE_CHANGES
), mCDLStringPackHandle
);
734 gLibEmptyString
= LibGetToken (STRING_TOKEN (EMPTY_STRING
), mCDLStringPackHandle
);
736 gNvUpdateMessage
= LibGetToken (STRING_TOKEN (NV_UPDATE_MESSAGE
), mCDLStringPackHandle
);
737 gInputErrorMessage
= LibGetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE
), mCDLStringPackHandle
);
742 mSpaceBuffer
= AllocatePool ((SPACE_BUFFER_SIZE
+ 1) * sizeof (CHAR16
));
743 ASSERT (mSpaceBuffer
!= NULL
);
744 LibSetUnicodeMem (mSpaceBuffer
, SPACE_BUFFER_SIZE
, L
' ');
745 mSpaceBuffer
[SPACE_BUFFER_SIZE
] = L
'\0';
757 FreePool (gEnterString
);
758 FreePool (gEnterCommitString
);
759 FreePool (gEnterEscapeString
);
760 FreePool (gEscapeString
);
761 FreePool (gMoveHighlight
);
762 FreePool (gDecNumericInput
);
763 FreePool (gHexNumericInput
);
764 FreePool (gToggleCheckBox
);
766 FreePool (gAreYouSure
);
767 FreePool (gYesResponse
);
768 FreePool (gNoResponse
);
769 FreePool (gPlusString
);
770 FreePool (gMinusString
);
771 FreePool (gAdjustNumber
);
772 FreePool (gSaveChanges
);
774 FreePool (gLibEmptyString
);
776 FreePool (gNvUpdateMessage
);
777 FreePool (gInputErrorMessage
);
779 FreePool (mSpaceBuffer
);
783 Wait for a key to be pressed by user.
785 @param Key The key which is pressed by user.
787 @retval EFI_SUCCESS The function always completed successfully.
792 OUT EFI_INPUT_KEY
*Key
799 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, Key
);
800 if (!EFI_ERROR (Status
)) {
804 if (Status
!= EFI_NOT_READY
) {
808 gBS
->WaitForEvent (1, &gST
->ConIn
->WaitForKey
, &Index
);
815 Set Buffer to Value for Size bytes.
817 @param Buffer Memory to set.
818 @param Size Number of bytes to set
819 @param Value Value of the set operation.
832 while ((Size
--) != 0) {
838 The internal function prints to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
841 @param Width Width of string to be print.
842 @param Column The position of the output string.
843 @param Row The position of the output string.
844 @param Out The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
845 @param Fmt The format string.
846 @param Args The additional argument for the variables in the format string.
848 @return Number of Unicode character printed.
856 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Out
,
862 CHAR16
*BackupBuffer
;
871 // For now, allocate an arbitrarily long buffer
873 Buffer
= AllocateZeroPool (0x10000);
874 BackupBuffer
= AllocateZeroPool (0x10000);
876 ASSERT (BackupBuffer
);
878 if (Column
!= (UINTN
)-1) {
879 Out
->SetCursorPosition (Out
, Column
, Row
);
882 UnicodeVSPrint (Buffer
, 0x10000, Fmt
, Args
);
884 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
886 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
896 for ( ; (Buffer
[Index
] != NARROW_CHAR
) && (Buffer
[Index
] != WIDE_CHAR
) && (Buffer
[Index
] != 0); Index
++) {
897 BackupBuffer
[Index
] = Buffer
[Index
];
900 if (Buffer
[Index
] == 0) {
905 // Print this out, we are about to switch widths
907 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
908 Count
= StrLen (&BackupBuffer
[PreviousIndex
]);
909 PrintWidth
+= Count
* CharWidth
;
913 // Preserve the current index + 1, since this is where we will start printing from next
915 PreviousIndex
= Index
+ 1;
918 // We are at a narrow or wide character directive. Set attributes and strip it and print it
920 if (Buffer
[Index
] == NARROW_CHAR
) {
922 // Preserve bits 0 - 6 and zero out the rest
924 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
925 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
929 // Must be wide, set bit 7 ON
931 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
| EFI_WIDE_ATTRIBUTE
;
932 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
937 } while (Buffer
[Index
] != 0);
940 // We hit the end of the string - print it
942 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
943 Count
= StrLen (&BackupBuffer
[PreviousIndex
]);
944 PrintWidth
+= Count
* CharWidth
;
946 if (PrintWidth
< Width
) {
947 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
948 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
949 Out
->OutputString (Out
, &mSpaceBuffer
[SPACE_BUFFER_SIZE
- Width
+ PrintWidth
]);
953 FreePool (BackupBuffer
);
958 Prints a formatted unicode string to the default console, at
959 the supplied cursor position.
961 @param Width Width of String to be printed.
962 @param Column The cursor position to print the string at.
963 @param Row The cursor position to print the string at.
964 @param Fmt Format string.
965 @param ... Variable argument list for format string.
967 @return Length of string printed to the console
981 UINTN LengthOfPrinted
;
983 VA_START (Args
, Fmt
);
984 LengthOfPrinted
= PrintInternal (Width
, Column
, Row
, gST
->ConOut
, Fmt
, Args
);
986 return LengthOfPrinted
;