3 This library class defines a set of interfaces to customize Display module
5 Copyright (c) 2013, 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 switch (OpCodeData
->OpCode
) {
260 case EFI_IFR_GUID_OP
:
261 if (CompareGuid (&gEfiIfrTianoGuid
, (EFI_GUID
*)((CHAR8
*) OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)))) {
263 // Tiano specific GUIDed opcodes
265 switch (((EFI_IFR_GUID_LABEL
*) OpCodeData
)->ExtendOpCode
) {
266 case EFI_IFR_EXTEND_OP_LABEL
:
272 case EFI_IFR_EXTEND_OP_BANNER
:
274 // Only in front page form set, we care about the banner data.
276 if (gClassOfVfr
== FORMSET_CLASS_FRONT_PAGE
) {
278 // Initialize Driver private data
280 if (gBannerData
== NULL
) {
281 gBannerData
= AllocateZeroPool (sizeof (BANNER_DATA
));
282 ASSERT (gBannerData
!= NULL
);
286 &gBannerData
->Banner
[((EFI_IFR_GUID_BANNER
*) OpCodeData
)->LineNumber
][
287 ((EFI_IFR_GUID_BANNER
*) OpCodeData
)->Alignment
],
288 &((EFI_IFR_GUID_BANNER
*) OpCodeData
)->Title
,
289 sizeof (EFI_STRING_ID
)
294 case EFI_IFR_EXTEND_OP_SUBCLASS
:
295 if (((EFI_IFR_GUID_SUBCLASS
*) OpCodeData
)->SubClass
== EFI_FRONT_PAGE_SUBCLASS
) {
296 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
312 Process some op codes which is out side of current form.
314 @param FormData Pointer to the form data.
316 @return EFI_SUCCESS Pass the statement success.
320 ProcessExternedOpcode (
321 IN FORM_DISPLAY_ENGINE_FORM
*FormData
325 LIST_ENTRY
*NestLink
;
326 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
327 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
329 Link
= GetFirstNode (&FormData
->StatementListOSF
);
330 while (!IsNull (&FormData
->StatementListOSF
, Link
)) {
331 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
332 Link
= GetNextNode (&FormData
->StatementListOSF
, Link
);
334 ProcessUserOpcode(Statement
->OpCode
);
337 Link
= GetFirstNode (&FormData
->StatementListHead
);
338 while (!IsNull (&FormData
->StatementListHead
, Link
)) {
339 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
340 Link
= GetNextNode (&FormData
->StatementListHead
, Link
);
342 ProcessUserOpcode(Statement
->OpCode
);
344 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
345 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
346 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
347 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
349 ProcessUserOpcode(NestStatement
->OpCode
);
356 Validate the input screen diemenstion info.
358 @param FormData The input form data info.
360 @return EFI_SUCCESS The input screen info is acceptable.
361 @return EFI_INVALID_PARAMETER The input screen info is not acceptable.
365 ScreenDiemensionInfoValidate (
366 IN FORM_DISPLAY_ENGINE_FORM
*FormData
373 // Calculate total number of Register HotKeys.
376 if (!IsListEmpty (&FormData
->HotKeyListHead
)){
377 Link
= GetFirstNode (&FormData
->HotKeyListHead
);
378 while (!IsNull (&FormData
->HotKeyListHead
, Link
)) {
379 Link
= GetNextNode (&FormData
->HotKeyListHead
, Link
);
385 // Show three HotKeys help information on one row.
387 gFooterHeight
= FOOTER_HEIGHT
+ (Index
/ 3);
390 ZeroMem (&gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
391 gST
->ConOut
->QueryMode (
393 gST
->ConOut
->Mode
->Mode
,
394 &gScreenDimensions
.RightColumn
,
395 &gScreenDimensions
.BottomRow
399 // Check local dimension vs. global dimension.
401 if (FormData
->ScreenDimensions
!= NULL
) {
402 if ((gScreenDimensions
.RightColumn
< FormData
->ScreenDimensions
->RightColumn
) ||
403 (gScreenDimensions
.BottomRow
< FormData
->ScreenDimensions
->BottomRow
)
405 return EFI_INVALID_PARAMETER
;
408 // Local dimension validation.
410 if ((FormData
->ScreenDimensions
->RightColumn
> FormData
->ScreenDimensions
->LeftColumn
) &&
411 (FormData
->ScreenDimensions
->BottomRow
> FormData
->ScreenDimensions
->TopRow
) &&
412 ((FormData
->ScreenDimensions
->RightColumn
- FormData
->ScreenDimensions
->LeftColumn
) > 2) &&
413 ((FormData
->ScreenDimensions
->BottomRow
- FormData
->ScreenDimensions
->TopRow
) > STATUS_BAR_HEIGHT
+
414 FRONT_PAGE_HEADER_HEIGHT
+ gFooterHeight
+ 3)) {
415 CopyMem (&gScreenDimensions
, (VOID
*) FormData
->ScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
417 return EFI_INVALID_PARAMETER
;
426 Get the string based on the StringId and HII Package List Handle.
428 @param Token The String's ID.
429 @param HiiHandle The package list in the HII database to search for
430 the specified string.
432 @return The output string.
437 IN EFI_STRING_ID Token
,
438 IN EFI_HII_HANDLE HiiHandle
443 String
= HiiGetString (HiiHandle
, Token
, NULL
);
444 if (String
== NULL
) {
445 String
= AllocateCopyPool (StrSize (mLibUnknownString
), mLibUnknownString
);
446 ASSERT (String
!= NULL
);
449 return (CHAR16
*) String
;
454 Count the storage space of a Unicode string.
456 This function handles the Unicode string with NARROW_CHAR
457 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
458 does not count in the resultant output. If a WIDE_CHAR is
459 hit, then 2 Unicode character will consume an output storage
460 space with size of CHAR16 till a NARROW_CHAR is hit.
462 If String is NULL, then ASSERT ().
464 @param String The input string to be counted.
466 @return Storage space for the input string.
476 UINTN IncrementValue
;
478 ASSERT (String
!= NULL
);
479 if (String
== NULL
) {
489 // Advance to the null-terminator or to the first width directive
492 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
493 Index
++, Count
= Count
+ IncrementValue
498 // We hit the null-terminator, we now have a count
500 if (String
[Index
] == 0) {
504 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
505 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
507 if (String
[Index
] == NARROW_CHAR
) {
509 // Skip to the next character
515 // Skip to the next character
520 } while (String
[Index
] != 0);
523 // Increment by one to include the null-terminator in the size
527 return Count
* sizeof (CHAR16
);
531 Show all registered HotKey help strings on bottom Rows.
533 @param FormData The curent input form data info.
534 @param SetState Set HotKey or Clear HotKey
538 PrintHotKeyHelpString (
539 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
545 UINTN BottomRowOfHotKeyHelp
;
546 UINTN ColumnIndexWidth
;
550 EFI_SCREEN_DESCRIPTOR LocalScreen
;
552 BROWSER_HOT_KEY
*HotKey
;
556 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
557 ColumnWidth
= (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
558 BottomRowOfHotKeyHelp
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 3;
559 ColumnStr
= gLibEmptyString
;
562 // Calculate total number of Register HotKeys.
565 Link
= GetFirstNode (&FormData
->HotKeyListHead
);
566 while (!IsNull (&FormData
->HotKeyListHead
, Link
)) {
567 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
569 // Calculate help information Column and Row.
571 ColumnIndex
= Index
% 3;
572 if (ColumnIndex
== 0) {
573 CurrentCol
= LocalScreen
.LeftColumn
+ 2 * ColumnWidth
;
574 ColumnIndexWidth
= ColumnWidth
- 1;
575 } else if (ColumnIndex
== 1) {
576 CurrentCol
= LocalScreen
.LeftColumn
+ ColumnWidth
;
577 ColumnIndexWidth
= ColumnWidth
;
579 CurrentCol
= LocalScreen
.LeftColumn
+ 2;
580 ColumnIndexWidth
= ColumnWidth
- 2;
582 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
585 // Help string can't exceed ColumnWidth. One Row will show three Help information.
588 if (StrLen (HotKey
->HelpString
) > ColumnIndexWidth
) {
589 BakChar
= HotKey
->HelpString
[ColumnIndexWidth
];
590 HotKey
->HelpString
[ColumnIndexWidth
] = L
'\0';
594 // Print HotKey help string on bottom Row.
597 ColumnStr
= HotKey
->HelpString
;
599 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, ColumnStr
, ColumnIndexWidth
);
601 if (BakChar
!= L
'\0') {
602 HotKey
->HelpString
[ColumnIndexWidth
] = BakChar
;
607 Link
= GetNextNode (&FormData
->HotKeyListHead
, Link
);
615 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
616 ColumnIndex
= Index
% 3;
617 if (ColumnIndex
== 0) {
618 CurrentCol
= LocalScreen
.LeftColumn
+ 2 * ColumnWidth
;
619 ColumnIndexWidth
= ColumnWidth
- 1;
621 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, gLibEmptyString
, ColumnIndexWidth
);
623 if (ColumnIndex
== 1) {
624 CurrentCol
= LocalScreen
.LeftColumn
+ ColumnWidth
;
625 ColumnIndexWidth
= ColumnWidth
;
626 PrintStringAtWithWidth (CurrentCol
, CurrentRow
, gLibEmptyString
, ColumnIndexWidth
);
634 Get step info from numeric opcode.
636 @param[in] OpCode The input numeric op code.
638 @return step info for this opcode.
642 IN EFI_IFR_OP_HEADER
*OpCode
645 EFI_IFR_NUMERIC
*NumericOp
;
648 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
650 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
651 case EFI_IFR_NUMERIC_SIZE_1
:
652 Step
= NumericOp
->data
.u8
.Step
;
655 case EFI_IFR_NUMERIC_SIZE_2
:
656 Step
= NumericOp
->data
.u16
.Step
;
659 case EFI_IFR_NUMERIC_SIZE_4
:
660 Step
= NumericOp
->data
.u32
.Step
;
663 case EFI_IFR_NUMERIC_SIZE_8
:
664 Step
= NumericOp
->data
.u64
.Step
;
676 Initialize the HII String Token to the correct values.
680 InitializeLibStrings (
684 mLibUnknownString
= L
"!";
686 gEnterString
= LibGetToken (STRING_TOKEN (ENTER_STRING
), mCDLStringPackHandle
);
687 gEnterCommitString
= LibGetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), mCDLStringPackHandle
);
688 gEnterEscapeString
= LibGetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), mCDLStringPackHandle
);
689 gEscapeString
= LibGetToken (STRING_TOKEN (ESCAPE_STRING
), mCDLStringPackHandle
);
690 gMoveHighlight
= LibGetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), mCDLStringPackHandle
);
691 gDecNumericInput
= LibGetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), mCDLStringPackHandle
);
692 gHexNumericInput
= LibGetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), mCDLStringPackHandle
);
693 gToggleCheckBox
= LibGetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), mCDLStringPackHandle
);
695 gAreYouSure
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE
), mCDLStringPackHandle
);
696 gYesResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), mCDLStringPackHandle
);
697 gNoResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), mCDLStringPackHandle
);
698 gPlusString
= LibGetToken (STRING_TOKEN (PLUS_STRING
), mCDLStringPackHandle
);
699 gMinusString
= LibGetToken (STRING_TOKEN (MINUS_STRING
), mCDLStringPackHandle
);
700 gAdjustNumber
= LibGetToken (STRING_TOKEN (ADJUST_NUMBER
), mCDLStringPackHandle
);
701 gSaveChanges
= LibGetToken (STRING_TOKEN (SAVE_CHANGES
), mCDLStringPackHandle
);
703 gLibEmptyString
= LibGetToken (STRING_TOKEN (EMPTY_STRING
), mCDLStringPackHandle
);
705 gNvUpdateMessage
= LibGetToken (STRING_TOKEN (NV_UPDATE_MESSAGE
), mCDLStringPackHandle
);
706 gInputErrorMessage
= LibGetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE
), mCDLStringPackHandle
);
711 mSpaceBuffer
= AllocatePool ((SPACE_BUFFER_SIZE
+ 1) * sizeof (CHAR16
));
712 ASSERT (mSpaceBuffer
!= NULL
);
713 LibSetUnicodeMem (mSpaceBuffer
, SPACE_BUFFER_SIZE
, L
' ');
714 mSpaceBuffer
[SPACE_BUFFER_SIZE
] = L
'\0';
727 FreePool (gEnterString
);
728 FreePool (gEnterCommitString
);
729 FreePool (gEnterEscapeString
);
730 FreePool (gEscapeString
);
731 FreePool (gMoveHighlight
);
732 FreePool (gDecNumericInput
);
733 FreePool (gHexNumericInput
);
734 FreePool (gToggleCheckBox
);
736 FreePool (gAreYouSure
);
737 FreePool (gYesResponse
);
738 FreePool (gNoResponse
);
739 FreePool (gPlusString
);
740 FreePool (gMinusString
);
741 FreePool (gAdjustNumber
);
742 FreePool (gSaveChanges
);
744 FreePool (gLibEmptyString
);
746 FreePool (gNvUpdateMessage
);
747 FreePool (gInputErrorMessage
);
749 FreePool (mSpaceBuffer
);
753 Wait for a key to be pressed by user.
755 @param Key The key which is pressed by user.
757 @retval EFI_SUCCESS The function always completed successfully.
762 OUT EFI_INPUT_KEY
*Key
769 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, Key
);
770 if (!EFI_ERROR (Status
)) {
774 if (Status
!= EFI_NOT_READY
) {
778 gBS
->WaitForEvent (1, &gST
->ConIn
->WaitForKey
, &Index
);
785 Set Buffer to Value for Size bytes.
787 @param Buffer Memory to set.
788 @param Size Number of bytes to set
789 @param Value Value of the set operation.
802 while ((Size
--) != 0) {
808 The internal function prints to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
811 @param Width Width of string to be print.
812 @param Column The position of the output string.
813 @param Row The position of the output string.
814 @param Out The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
815 @param Fmt The format string.
816 @param Args The additional argument for the variables in the format string.
818 @return Number of Unicode character printed.
826 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Out
,
832 CHAR16
*BackupBuffer
;
841 // For now, allocate an arbitrarily long buffer
843 Buffer
= AllocateZeroPool (0x10000);
844 BackupBuffer
= AllocateZeroPool (0x10000);
846 ASSERT (BackupBuffer
);
848 if (Column
!= (UINTN
) -1) {
849 Out
->SetCursorPosition (Out
, Column
, Row
);
852 UnicodeVSPrint (Buffer
, 0x10000, Fmt
, Args
);
854 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
856 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
866 for (; (Buffer
[Index
] != NARROW_CHAR
) && (Buffer
[Index
] != WIDE_CHAR
) && (Buffer
[Index
] != 0); Index
++) {
867 BackupBuffer
[Index
] = Buffer
[Index
];
870 if (Buffer
[Index
] == 0) {
875 // Print this out, we are about to switch widths
877 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
878 Count
= StrLen (&BackupBuffer
[PreviousIndex
]);
879 PrintWidth
+= Count
* CharWidth
;
883 // Preserve the current index + 1, since this is where we will start printing from next
885 PreviousIndex
= Index
+ 1;
888 // We are at a narrow or wide character directive. Set attributes and strip it and print it
890 if (Buffer
[Index
] == NARROW_CHAR
) {
892 // Preserve bits 0 - 6 and zero out the rest
894 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
895 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
899 // Must be wide, set bit 7 ON
901 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
| EFI_WIDE_ATTRIBUTE
;
902 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
908 } while (Buffer
[Index
] != 0);
911 // We hit the end of the string - print it
913 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
914 Count
= StrLen (&BackupBuffer
[PreviousIndex
]);
915 PrintWidth
+= Count
* CharWidth
;
917 if (PrintWidth
< Width
) {
918 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
919 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
920 Out
->OutputString (Out
, &mSpaceBuffer
[SPACE_BUFFER_SIZE
- Width
+ PrintWidth
]);
924 FreePool (BackupBuffer
);
929 Prints a formatted unicode string to the default console, at
930 the supplied cursor position.
932 @param Width Width of String to be printed.
933 @param Column The cursor position to print the string at.
934 @param Row The cursor position to print the string at.
935 @param Fmt Format string.
936 @param ... Variable argument list for format string.
938 @return Length of string printed to the console
952 UINTN LengthOfPrinted
;
954 VA_START (Args
, Fmt
);
955 LengthOfPrinted
= PrintInternal (Width
, Column
, Row
, gST
->ConOut
, Fmt
, Args
);
957 return LengthOfPrinted
;