3 This library class defines a set of interfaces to customize Display module
5 Copyright (c) 2013-2015, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "CustomizedDisplayLibInternal.h"
17 EFI_SCREEN_DESCRIPTOR gScreenDimensions
;
18 CHAR16
*mLibUnknownString
;
19 extern EFI_HII_HANDLE mCDLStringPackHandle
;
21 #define SPACE_BUFFER_SIZE 1000
24 // Browser Global Strings
27 CHAR16
*gEnterCommitString
;
28 CHAR16
*gEnterEscapeString
;
29 CHAR16
*gEscapeString
;
30 CHAR16
*gMoveHighlight
;
31 CHAR16
*gDecNumericInput
;
32 CHAR16
*gHexNumericInput
;
33 CHAR16
*gToggleCheckBox
;
34 CHAR16
*gLibEmptyString
;
40 CHAR16
*gAdjustNumber
;
42 CHAR16
*gNvUpdateMessage
;
43 CHAR16
*gInputErrorMessage
;
47 Print banner info for front page.
49 @param[in] FormData Form Data to be shown in Page
54 IN FORM_DISPLAY_ENGINE_FORM
*FormData
59 CHAR16
*StrFrontPageBanner
;
64 // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
67 gScreenDimensions
.LeftColumn
,
68 gScreenDimensions
.RightColumn
,
69 gScreenDimensions
.TopRow
,
70 FRONT_PAGE_HEADER_HEIGHT
- 1 + gScreenDimensions
.TopRow
,
71 BANNER_TEXT
| BANNER_BACKGROUND
75 // for (Line = 0; Line < BANNER_HEIGHT; Line++) {
77 for (Line
= (UINT8
) gScreenDimensions
.TopRow
; Line
< BANNER_HEIGHT
+ (UINT8
) gScreenDimensions
.TopRow
; Line
++) {
79 // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
81 for (Alignment
= (UINT8
) gScreenDimensions
.LeftColumn
;
82 Alignment
< BANNER_COLUMNS
+ (UINT8
) gScreenDimensions
.LeftColumn
;
85 RowIdx
= (UINT8
) (Line
- (UINT8
) gScreenDimensions
.TopRow
);
86 ColumnIdx
= (UINT8
) (Alignment
- (UINT8
) gScreenDimensions
.LeftColumn
);
88 ASSERT (RowIdx
< BANNER_HEIGHT
&& ColumnIdx
< BANNER_COLUMNS
);
90 if (gBannerData
!= NULL
&& gBannerData
->Banner
[RowIdx
][ColumnIdx
] != 0x0000) {
91 StrFrontPageBanner
= LibGetToken (gBannerData
->Banner
[RowIdx
][ColumnIdx
], FormData
->HiiHandle
);
96 switch (Alignment
- gScreenDimensions
.LeftColumn
) {
101 PrintStringAt (gScreenDimensions
.LeftColumn
+ BANNER_LEFT_COLUMN_INDENT
, Line
, StrFrontPageBanner
);
106 // Handle center column
109 gScreenDimensions
.LeftColumn
+ (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
) / 3,
117 // Handle right column
120 gScreenDimensions
.LeftColumn
+ (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
) * 2 / 3,
127 FreePool (StrFrontPageBanner
);
133 Print framework and form title for a page.
135 @param[in] FormData Form Data to be shown in Page
139 IN FORM_DISPLAY_ENGINE_FORM
*FormData
149 if (gClassOfVfr
!= FORMSET_CLASS_PLATFORM_SETUP
) {
151 // Only Setup page needs Framework
154 gScreenDimensions
.LeftColumn
,
155 gScreenDimensions
.RightColumn
,
156 gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
,
157 gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 1,
158 KEYHELP_TEXT
| KEYHELP_BACKGROUND
163 Buffer
= AllocateZeroPool (0x10000);
164 ASSERT (Buffer
!= NULL
);
165 Character
= BOXDRAW_HORIZONTAL
;
166 for (Index
= 0; Index
+ 2 < (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
); Index
++) {
167 Buffer
[Index
] = Character
;
171 // Print Top border line
172 // +------------------------------------------------------------------------------+
174 // +------------------------------------------------------------------------------+
176 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
177 Character
= BOXDRAW_DOWN_RIGHT
;
179 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.TopRow
, Character
);
180 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
182 Character
= BOXDRAW_DOWN_LEFT
;
183 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
185 Character
= BOXDRAW_VERTICAL
;
186 for (Row
= gScreenDimensions
.TopRow
+ 1; Row
<= gScreenDimensions
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 2; Row
++) {
187 PrintCharAt (gScreenDimensions
.LeftColumn
, Row
, Character
);
188 PrintCharAt (gScreenDimensions
.RightColumn
- 1, Row
, Character
);
194 TitleStr
= LibGetToken (FormData
->FormTitle
, FormData
->HiiHandle
);
195 ASSERT (TitleStr
!= NULL
);
196 TitleColumn
= (gScreenDimensions
.RightColumn
+ gScreenDimensions
.LeftColumn
- LibGetStringWidth (TitleStr
) / 2) / 2;
197 PrintStringAtWithWidth (gScreenDimensions
.LeftColumn
+ 1, gScreenDimensions
.TopRow
+ 1, gLibEmptyString
, TitleColumn
- gScreenDimensions
.LeftColumn
- 1);
198 PrintStringAtWithWidth (
200 gScreenDimensions
.TopRow
+ 1,
202 gScreenDimensions
.RightColumn
- 1 - TitleColumn
206 Character
= BOXDRAW_UP_RIGHT
;
207 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1, Character
);
208 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
210 Character
= BOXDRAW_UP_LEFT
;
211 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
214 // Print Bottom border line
215 // +------------------------------------------------------------------------------+
217 // +------------------------------------------------------------------------------+
219 Character
= BOXDRAW_DOWN_RIGHT
;
220 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
, Character
);
222 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
224 Character
= BOXDRAW_DOWN_LEFT
;
225 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
226 Character
= BOXDRAW_VERTICAL
;
227 for (Row
= gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
+ 1;
228 Row
<= gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
231 PrintCharAt (gScreenDimensions
.LeftColumn
, Row
, Character
);
232 PrintCharAt (gScreenDimensions
.RightColumn
- 1, Row
, Character
);
235 Character
= BOXDRAW_UP_RIGHT
;
236 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 1, Character
);
238 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
240 Character
= BOXDRAW_UP_LEFT
;
241 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
247 Process some op code which is not recognized by browser core.
249 @param OpCodeData The pointer to the op code buffer.
251 @return EFI_SUCCESS Pass the statement success.
256 IN EFI_IFR_OP_HEADER
*OpCodeData
259 EFI_GUID
* ClassGuid
;
265 switch (OpCodeData
->OpCode
) {
266 case EFI_IFR_FORM_SET_OP
:
268 // process the statement outside of form,if it is formset op, get its formsetguid or classguid and compared with gFrontPageFormSetGuid
270 if (CompareMem (PcdGetPtr (PcdFrontPageFormSetGuid
), &((EFI_IFR_FORM_SET
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
)) == 0){
271 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
273 ClassGuidNum
= (UINT8
)(((EFI_IFR_FORM_SET
*)OpCodeData
)->Flags
& 0x3);
274 ClassGuid
= (EFI_GUID
*)(VOID
*)((UINT8
*)OpCodeData
+ sizeof (EFI_IFR_FORM_SET
));
275 while (ClassGuidNum
-- > 0){
276 if (CompareGuid((EFI_GUID
*)PcdGetPtr (PcdFrontPageFormSetGuid
),ClassGuid
)){
277 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
285 case EFI_IFR_GUID_OP
:
286 if (CompareGuid (&gEfiIfrTianoGuid
, (EFI_GUID
*)((CHAR8
*) OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)))) {
288 // Tiano specific GUIDed opcodes
290 switch (((EFI_IFR_GUID_LABEL
*) OpCodeData
)->ExtendOpCode
) {
291 case EFI_IFR_EXTEND_OP_LABEL
:
297 case EFI_IFR_EXTEND_OP_BANNER
:
299 // Only in front page form set, we care about the banner data.
301 if (gClassOfVfr
== FORMSET_CLASS_FRONT_PAGE
) {
303 // Initialize Driver private data
305 if (gBannerData
== NULL
) {
306 gBannerData
= AllocateZeroPool (sizeof (BANNER_DATA
));
307 ASSERT (gBannerData
!= NULL
);
311 &gBannerData
->Banner
[((EFI_IFR_GUID_BANNER
*) OpCodeData
)->LineNumber
][
312 ((EFI_IFR_GUID_BANNER
*) OpCodeData
)->Alignment
],
313 &((EFI_IFR_GUID_BANNER
*) OpCodeData
)->Title
,
314 sizeof (EFI_STRING_ID
)
319 case EFI_IFR_EXTEND_OP_SUBCLASS
:
320 if (((EFI_IFR_GUID_SUBCLASS
*) OpCodeData
)->SubClass
== EFI_FRONT_PAGE_SUBCLASS
) {
321 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
337 Process some op codes which is out side of current form.
339 @param FormData Pointer to the form data.
341 @return EFI_SUCCESS Pass the statement success.
345 ProcessExternedOpcode (
346 IN FORM_DISPLAY_ENGINE_FORM
*FormData
350 LIST_ENTRY
*NestLink
;
351 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
352 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
354 Link
= GetFirstNode (&FormData
->StatementListOSF
);
355 while (!IsNull (&FormData
->StatementListOSF
, Link
)) {
356 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
357 Link
= GetNextNode (&FormData
->StatementListOSF
, Link
);
359 ProcessUserOpcode(Statement
->OpCode
);
362 Link
= GetFirstNode (&FormData
->StatementListHead
);
363 while (!IsNull (&FormData
->StatementListHead
, Link
)) {
364 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
365 Link
= GetNextNode (&FormData
->StatementListHead
, Link
);
367 ProcessUserOpcode(Statement
->OpCode
);
369 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
370 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
371 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
372 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
374 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);
415 ZeroMem (&gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
416 gST
->ConOut
->QueryMode (
418 gST
->ConOut
->Mode
->Mode
,
419 &gScreenDimensions
.RightColumn
,
420 &gScreenDimensions
.BottomRow
424 // Check local dimension vs. global dimension.
426 if (FormData
->ScreenDimensions
!= NULL
) {
427 if ((gScreenDimensions
.RightColumn
< FormData
->ScreenDimensions
->RightColumn
) ||
428 (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)) {
440 CopyMem (&gScreenDimensions
, (VOID
*) FormData
->ScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
442 return EFI_INVALID_PARAMETER
;
451 Get the string based on the StringId and HII Package List Handle.
453 @param Token The String's ID.
454 @param HiiHandle The package list in the HII database to search for
455 the specified string.
457 @return The output string.
462 IN EFI_STRING_ID Token
,
463 IN EFI_HII_HANDLE HiiHandle
468 String
= HiiGetString (HiiHandle
, Token
, NULL
);
469 if (String
== NULL
) {
470 String
= AllocateCopyPool (StrSize (mLibUnknownString
), mLibUnknownString
);
471 ASSERT (String
!= NULL
);
474 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
523 // We hit the null-terminator, we now have a count
525 if (String
[Index
] == 0) {
529 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
530 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
532 if (String
[Index
] == NARROW_CHAR
) {
534 // Skip to the next character
540 // Skip to the next character
545 } while (String
[Index
] != 0);
548 // Increment by one to include the null-terminator in the size
552 return Count
* sizeof (CHAR16
);
556 Show all registered HotKey help strings on bottom Rows.
558 @param FormData The curent input form data info.
559 @param SetState Set HotKey or Clear HotKey
563 PrintHotKeyHelpString (
564 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
570 UINTN BottomRowOfHotKeyHelp
;
571 UINTN ColumnIndexWidth
;
575 EFI_SCREEN_DESCRIPTOR LocalScreen
;
577 BROWSER_HOT_KEY
*HotKey
;
581 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
582 ColumnWidth
= (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
583 BottomRowOfHotKeyHelp
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 3;
584 ColumnStr
= gLibEmptyString
;
587 // Calculate total number of Register HotKeys.
590 Link
= GetFirstNode (&FormData
->HotKeyListHead
);
591 while (!IsNull (&FormData
->HotKeyListHead
, Link
)) {
592 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
594 // Calculate help information Column and Row.
596 ColumnIndex
= Index
% 3;
597 if (ColumnIndex
== 0) {
598 CurrentCol
= LocalScreen
.LeftColumn
+ 2 * ColumnWidth
;
599 ColumnIndexWidth
= ColumnWidth
- 1;
600 } else if (ColumnIndex
== 1) {
601 CurrentCol
= LocalScreen
.LeftColumn
+ ColumnWidth
;
602 ColumnIndexWidth
= ColumnWidth
;
604 CurrentCol
= LocalScreen
.LeftColumn
+ 2;
605 ColumnIndexWidth
= ColumnWidth
- 2;
607 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
610 // Help string can't exceed ColumnWidth. One Row will show three Help information.
613 if (StrLen (HotKey
->HelpString
) > ColumnIndexWidth
) {
614 BakChar
= HotKey
->HelpString
[ColumnIndexWidth
];
615 HotKey
->HelpString
[ColumnIndexWidth
] = L
'\0';
619 // Print HotKey help string on bottom Row.
622 ColumnStr
= HotKey
->HelpString
;
624 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, ColumnStr
, ColumnIndexWidth
);
626 if (BakChar
!= L
'\0') {
627 HotKey
->HelpString
[ColumnIndexWidth
] = BakChar
;
632 Link
= GetNextNode (&FormData
->HotKeyListHead
, Link
);
640 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
641 ColumnIndex
= Index
% 3;
642 if (ColumnIndex
== 0) {
643 CurrentCol
= LocalScreen
.LeftColumn
+ 2 * ColumnWidth
;
644 ColumnIndexWidth
= ColumnWidth
- 1;
646 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, gLibEmptyString
, ColumnIndexWidth
);
648 if (ColumnIndex
== 1) {
649 CurrentCol
= LocalScreen
.LeftColumn
+ ColumnWidth
;
650 ColumnIndexWidth
= ColumnWidth
;
651 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, gLibEmptyString
, ColumnIndexWidth
);
659 Get step info from numeric opcode.
661 @param[in] OpCode The input numeric op code.
663 @return step info for this opcode.
667 IN EFI_IFR_OP_HEADER
*OpCode
670 EFI_IFR_NUMERIC
*NumericOp
;
673 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
675 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
676 case EFI_IFR_NUMERIC_SIZE_1
:
677 Step
= NumericOp
->data
.u8
.Step
;
680 case EFI_IFR_NUMERIC_SIZE_2
:
681 Step
= NumericOp
->data
.u16
.Step
;
684 case EFI_IFR_NUMERIC_SIZE_4
:
685 Step
= NumericOp
->data
.u32
.Step
;
688 case EFI_IFR_NUMERIC_SIZE_8
:
689 Step
= NumericOp
->data
.u64
.Step
;
701 Initialize the HII String Token to the correct values.
705 InitializeLibStrings (
709 mLibUnknownString
= L
"!";
711 gEnterString
= LibGetToken (STRING_TOKEN (ENTER_STRING
), mCDLStringPackHandle
);
712 gEnterCommitString
= LibGetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), mCDLStringPackHandle
);
713 gEnterEscapeString
= LibGetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), mCDLStringPackHandle
);
714 gEscapeString
= LibGetToken (STRING_TOKEN (ESCAPE_STRING
), mCDLStringPackHandle
);
715 gMoveHighlight
= LibGetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), mCDLStringPackHandle
);
716 gDecNumericInput
= LibGetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), mCDLStringPackHandle
);
717 gHexNumericInput
= LibGetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), mCDLStringPackHandle
);
718 gToggleCheckBox
= LibGetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), mCDLStringPackHandle
);
720 gAreYouSure
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE
), mCDLStringPackHandle
);
721 gYesResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), mCDLStringPackHandle
);
722 gNoResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), mCDLStringPackHandle
);
723 gPlusString
= LibGetToken (STRING_TOKEN (PLUS_STRING
), mCDLStringPackHandle
);
724 gMinusString
= LibGetToken (STRING_TOKEN (MINUS_STRING
), mCDLStringPackHandle
);
725 gAdjustNumber
= LibGetToken (STRING_TOKEN (ADJUST_NUMBER
), mCDLStringPackHandle
);
726 gSaveChanges
= LibGetToken (STRING_TOKEN (SAVE_CHANGES
), mCDLStringPackHandle
);
728 gLibEmptyString
= LibGetToken (STRING_TOKEN (EMPTY_STRING
), mCDLStringPackHandle
);
730 gNvUpdateMessage
= LibGetToken (STRING_TOKEN (NV_UPDATE_MESSAGE
), mCDLStringPackHandle
);
731 gInputErrorMessage
= LibGetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE
), mCDLStringPackHandle
);
736 mSpaceBuffer
= AllocatePool ((SPACE_BUFFER_SIZE
+ 1) * sizeof (CHAR16
));
737 ASSERT (mSpaceBuffer
!= NULL
);
738 LibSetUnicodeMem (mSpaceBuffer
, SPACE_BUFFER_SIZE
, L
' ');
739 mSpaceBuffer
[SPACE_BUFFER_SIZE
] = L
'\0';
752 FreePool (gEnterString
);
753 FreePool (gEnterCommitString
);
754 FreePool (gEnterEscapeString
);
755 FreePool (gEscapeString
);
756 FreePool (gMoveHighlight
);
757 FreePool (gDecNumericInput
);
758 FreePool (gHexNumericInput
);
759 FreePool (gToggleCheckBox
);
761 FreePool (gAreYouSure
);
762 FreePool (gYesResponse
);
763 FreePool (gNoResponse
);
764 FreePool (gPlusString
);
765 FreePool (gMinusString
);
766 FreePool (gAdjustNumber
);
767 FreePool (gSaveChanges
);
769 FreePool (gLibEmptyString
);
771 FreePool (gNvUpdateMessage
);
772 FreePool (gInputErrorMessage
);
774 FreePool (mSpaceBuffer
);
778 Wait for a key to be pressed by user.
780 @param Key The key which is pressed by user.
782 @retval EFI_SUCCESS The function always completed successfully.
787 OUT EFI_INPUT_KEY
*Key
794 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, Key
);
795 if (!EFI_ERROR (Status
)) {
799 if (Status
!= EFI_NOT_READY
) {
803 gBS
->WaitForEvent (1, &gST
->ConIn
->WaitForKey
, &Index
);
810 Set Buffer to Value for Size bytes.
812 @param Buffer Memory to set.
813 @param Size Number of bytes to set
814 @param Value Value of the set operation.
827 while ((Size
--) != 0) {
833 The internal function prints to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
836 @param Width Width of string to be print.
837 @param Column The position of the output string.
838 @param Row The position of the output string.
839 @param Out The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
840 @param Fmt The format string.
841 @param Args The additional argument for the variables in the format string.
843 @return Number of Unicode character printed.
851 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Out
,
857 CHAR16
*BackupBuffer
;
866 // For now, allocate an arbitrarily long buffer
868 Buffer
= AllocateZeroPool (0x10000);
869 BackupBuffer
= AllocateZeroPool (0x10000);
871 ASSERT (BackupBuffer
);
873 if (Column
!= (UINTN
) -1) {
874 Out
->SetCursorPosition (Out
, Column
, Row
);
877 UnicodeVSPrint (Buffer
, 0x10000, Fmt
, Args
);
879 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
881 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
891 for (; (Buffer
[Index
] != NARROW_CHAR
) && (Buffer
[Index
] != WIDE_CHAR
) && (Buffer
[Index
] != 0); Index
++) {
892 BackupBuffer
[Index
] = Buffer
[Index
];
895 if (Buffer
[Index
] == 0) {
900 // Print this out, we are about to switch widths
902 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
903 Count
= StrLen (&BackupBuffer
[PreviousIndex
]);
904 PrintWidth
+= Count
* CharWidth
;
908 // Preserve the current index + 1, since this is where we will start printing from next
910 PreviousIndex
= Index
+ 1;
913 // We are at a narrow or wide character directive. Set attributes and strip it and print it
915 if (Buffer
[Index
] == NARROW_CHAR
) {
917 // Preserve bits 0 - 6 and zero out the rest
919 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
920 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
924 // Must be wide, set bit 7 ON
926 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
| EFI_WIDE_ATTRIBUTE
;
927 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
933 } while (Buffer
[Index
] != 0);
936 // We hit the end of the string - print it
938 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
939 Count
= StrLen (&BackupBuffer
[PreviousIndex
]);
940 PrintWidth
+= Count
* CharWidth
;
942 if (PrintWidth
< Width
) {
943 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
944 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
945 Out
->OutputString (Out
, &mSpaceBuffer
[SPACE_BUFFER_SIZE
- Width
+ PrintWidth
]);
949 FreePool (BackupBuffer
);
954 Prints a formatted unicode string to the default console, at
955 the supplied cursor position.
957 @param Width Width of String to be printed.
958 @param Column The cursor position to print the string at.
959 @param Row The cursor position to print the string at.
960 @param Fmt Format string.
961 @param ... Variable argument list for format string.
963 @return Length of string printed to the console
977 UINTN LengthOfPrinted
;
979 VA_START (Args
, Fmt
);
980 LengthOfPrinted
= PrintInternal (Width
, Column
, Row
, gST
->ConOut
, Fmt
, Args
);
982 return LengthOfPrinted
;