diff options
Diffstat (limited to 'MdeModulePkg/Library/CustomizedDisplayLib')
7 files changed, 2420 insertions, 2420 deletions
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/Colors.h b/MdeModulePkg/Library/CustomizedDisplayLib/Colors.h index 487c6d4f2d..71a7d7f829 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/Colors.h +++ b/MdeModulePkg/Library/CustomizedDisplayLib/Colors.h @@ -1,38 +1,38 @@ -/** @file
-MACRO definitions for color used in Setup Browser.
-
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-//
-// Unicode collation protocol in
-
-#ifndef _COLORS_H_
-#define _COLORS_H_
-
-//
-// Screen Color Settings
-//
-#define PICKLIST_HIGHLIGHT_TEXT EFI_WHITE
-#define PICKLIST_HIGHLIGHT_BACKGROUND EFI_BACKGROUND_CYAN
-#define TITLE_TEXT EFI_WHITE
-#define TITLE_BACKGROUND EFI_BACKGROUND_BLUE
-#define KEYHELP_TEXT EFI_LIGHTGRAY
-#define KEYHELP_BACKGROUND EFI_BACKGROUND_BLACK
-#define SUBTITLE_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
-#define BANNER_TEXT EFI_BLUE
-#define BANNER_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
-#define FIELD_TEXT_GRAYED EFI_DARKGRAY
-#define FIELD_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
-#define POPUP_TEXT EFI_LIGHTGRAY
-#define POPUP_BACKGROUND EFI_BACKGROUND_BLUE
-#define POPUP_INVERSE_TEXT EFI_LIGHTGRAY
-#define POPUP_INVERSE_BACKGROUND EFI_BACKGROUND_BLACK
-#define HELP_TEXT EFI_BLUE
-#define ERROR_TEXT EFI_RED | EFI_BRIGHT
-#define INFO_TEXT EFI_YELLOW | EFI_BRIGHT
-#define ARROW_TEXT EFI_RED | EFI_BRIGHT
-#define ARROW_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
-
-#endif
+/** @file +MACRO definitions for color used in Setup Browser. + +Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR> +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +// +// Unicode collation protocol in + +#ifndef _COLORS_H_ +#define _COLORS_H_ + +// +// Screen Color Settings +// +#define PICKLIST_HIGHLIGHT_TEXT EFI_WHITE +#define PICKLIST_HIGHLIGHT_BACKGROUND EFI_BACKGROUND_CYAN +#define TITLE_TEXT EFI_WHITE +#define TITLE_BACKGROUND EFI_BACKGROUND_BLUE +#define KEYHELP_TEXT EFI_LIGHTGRAY +#define KEYHELP_BACKGROUND EFI_BACKGROUND_BLACK +#define SUBTITLE_BACKGROUND EFI_BACKGROUND_LIGHTGRAY +#define BANNER_TEXT EFI_BLUE +#define BANNER_BACKGROUND EFI_BACKGROUND_LIGHTGRAY +#define FIELD_TEXT_GRAYED EFI_DARKGRAY +#define FIELD_BACKGROUND EFI_BACKGROUND_LIGHTGRAY +#define POPUP_TEXT EFI_LIGHTGRAY +#define POPUP_BACKGROUND EFI_BACKGROUND_BLUE +#define POPUP_INVERSE_TEXT EFI_LIGHTGRAY +#define POPUP_INVERSE_BACKGROUND EFI_BACKGROUND_BLACK +#define HELP_TEXT EFI_BLUE +#define ERROR_TEXT EFI_RED | EFI_BRIGHT +#define INFO_TEXT EFI_YELLOW | EFI_BRIGHT +#define ARROW_TEXT EFI_RED | EFI_BRIGHT +#define ARROW_BACKGROUND EFI_BACKGROUND_LIGHTGRAY + +#endif diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c index b3da13d0a3..85b88a77a9 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c @@ -1,973 +1,973 @@ -/** @file
-
- This library class defines a set of interfaces to customize Display module
-
-Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-#include "CustomizedDisplayLibInternal.h"
-
-EFI_GUID gCustomizedDisplayLibGuid = {
- 0x99fdc8fd, 0x849b, 0x4eba, { 0xad, 0x13, 0xfb, 0x96, 0x99, 0xc9, 0xa, 0x4d }
-};
-
-EFI_HII_HANDLE mCDLStringPackHandle;
-UINT16 gClassOfVfr; // Formset class information
-BOOLEAN gLibIsFirstForm = TRUE;
-BANNER_DATA *gBannerData;
-
-UINTN gFooterHeight;
-
-/**
-+------------------------------------------------------------------------------+
-| Setup Page |
-+------------------------------------------------------------------------------+
-
-Statement
-Statement
-Statement
-
-
-
-
-
-+------------------------------------------------------------------------------+
-| F9=Reset to Defaults F10=Save |
-| ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Exit |
-+------------------------------------------------------------------------------+
- StatusBar
-**/
-
-/**
- This funtion defines Page Frame and Backgroud.
-
- Based on the above layout, it will be responsible for HeaderHeight, FooterHeight,
- StatusBarHeight and Backgroud. And, it will reserve Screen for Statement.
-
- @param[in] FormData Form Data to be shown in Page.
- @param[out] ScreenForStatement Screen to be used for Statement. (Prompt, Value and Help)
-
- @return Status
-**/
-EFI_STATUS
-EFIAPI
-DisplayPageFrame (
- IN FORM_DISPLAY_ENGINE_FORM *FormData,
- OUT EFI_SCREEN_DESCRIPTOR *ScreenForStatement
- )
-{
- EFI_STATUS Status;
-
- ASSERT (FormData != NULL && ScreenForStatement != NULL);
- if ((FormData == NULL) || (ScreenForStatement == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = ScreenDiemensionInfoValidate (FormData);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- gClassOfVfr = FORMSET_CLASS_PLATFORM_SETUP;
-
- ProcessExternedOpcode (FormData);
-
- //
- // Calculate the ScreenForStatement.
- //
- ScreenForStatement->BottomRow = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight;
- if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) {
- ScreenForStatement->TopRow = gScreenDimensions.TopRow + FRONT_PAGE_HEADER_HEIGHT;
- } else {
- ScreenForStatement->TopRow = gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT;
- }
-
- ScreenForStatement->LeftColumn = gScreenDimensions.LeftColumn;
- ScreenForStatement->RightColumn = gScreenDimensions.RightColumn;
-
- if ((gLibIsFirstForm) || ((FormData->Attribute & HII_DISPLAY_MODAL) != 0)) {
- //
- // Ensure we are in Text mode
- //
- gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
- ClearLines (0, gScreenDimensions.RightColumn, 0, gScreenDimensions.BottomRow, KEYHELP_BACKGROUND);
- gLibIsFirstForm = FALSE;
- }
-
- //
- // Don't print frame for modal form.
- //
- if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
- return EFI_SUCCESS;
- }
-
- if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) {
- PrintBannerInfo (FormData);
- }
-
- PrintFramework (FormData);
-
- UpdateStatusBar (NV_UPDATE_REQUIRED, FormData->SettingChangedFlag);
-
- return EFI_SUCCESS;
-}
-
-/**
- This function updates customized key panel's help information.
- The library will prepare those Strings for the basic key, ESC, Enter, Up/Down/Left/Right, +/-.
- and arrange them in Footer panel.
-
- @param[in] FormData Form Data to be shown in Page. FormData has the highlighted statement.
- @param[in] Statement The statement current selected.
- @param[in] Selected Whether or not a tag be selected. TRUE means Enter has hit this question.
-**/
-VOID
-EFIAPI
-RefreshKeyHelp (
- IN FORM_DISPLAY_ENGINE_FORM *FormData,
- IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
- IN BOOLEAN Selected
- )
-{
- UINTN SecCol;
- UINTN ThdCol;
- UINTN RightColumnOfHelp;
- UINTN TopRowOfHelp;
- UINTN BottomRowOfHelp;
- UINTN StartColumnOfHelp;
- EFI_IFR_NUMERIC *NumericOp;
- EFI_IFR_DATE *DateOp;
- EFI_IFR_TIME *TimeOp;
- BOOLEAN HexDisplay;
- UINTN ColumnWidth1;
- UINTN ColumnWidth2;
- UINTN ColumnWidth3;
- CHAR16 *ColumnStr1;
- CHAR16 *ColumnStr2;
- CHAR16 *ColumnStr3;
-
- ASSERT (FormData != NULL);
- if (FormData == NULL) {
- return;
- }
-
- gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND);
-
- if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
- return;
- }
-
- SecCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3;
- ThdCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3 * 2;
-
- //
- // + 2 means leave 1 space before the first hotkey info.
- //
- StartColumnOfHelp = gScreenDimensions.LeftColumn + 2;
- RightColumnOfHelp = gScreenDimensions.RightColumn - 1;
- TopRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1;
- BottomRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2;
-
- ColumnWidth1 = SecCol - StartColumnOfHelp;
- ColumnWidth2 = ThdCol - SecCol;
- ColumnWidth3 = RightColumnOfHelp - ThdCol;
- ColumnStr1 = gLibEmptyString;
- ColumnStr2 = gLibEmptyString;
- ColumnStr3 = gLibEmptyString;
-
- //
- // Clean the space at gScreenDimensions.LeftColumn + 1.
- //
- PrintStringAtWithWidth (StartColumnOfHelp - 1, BottomRowOfHelp, gLibEmptyString, 1);
- PrintStringAtWithWidth (StartColumnOfHelp - 1, TopRowOfHelp, gLibEmptyString, 1);
-
- if (Statement == NULL) {
- //
- // Print Key for Form without showable statement.
- //
- PrintHotKeyHelpString (FormData, TRUE);
- PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1);
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gLibEmptyString, ColumnWidth2);
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1);
- if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- ColumnStr3 = gEscapeString;
- }
-
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
-
- return;
- }
-
- HexDisplay = FALSE;
- NumericOp = NULL;
- DateOp = NULL;
- TimeOp = NULL;
- if (Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) {
- NumericOp = (EFI_IFR_NUMERIC *)Statement->OpCode;
- HexDisplay = (NumericOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
- } else if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) {
- DateOp = (EFI_IFR_DATE *)Statement->OpCode;
- HexDisplay = (DateOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
- } else if (Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
- TimeOp = (EFI_IFR_TIME *)Statement->OpCode;
- HexDisplay = (TimeOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
- }
-
- switch (Statement->OpCode->OpCode) {
- case EFI_IFR_ORDERED_LIST_OP:
- case EFI_IFR_ONE_OF_OP:
- case EFI_IFR_NUMERIC_OP:
- case EFI_IFR_TIME_OP:
- case EFI_IFR_DATE_OP:
- if (!Selected) {
- PrintHotKeyHelpString (FormData, TRUE);
-
- if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- ColumnStr3 = gEscapeString;
- }
-
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
-
- if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
- (Statement->OpCode->OpCode == EFI_IFR_TIME_OP))
- {
- PrintAt (
- ColumnWidth1,
- StartColumnOfHelp,
- BottomRowOfHelp,
- L"%c%c%c%c%s",
- ARROW_UP,
- ARROW_DOWN,
- ARROW_RIGHT,
- ARROW_LEFT,
- gMoveHighlight
- );
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber, ColumnWidth1);
- } else {
- PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
- if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) && (NumericOp != NULL) && (LibGetFieldFromNum (Statement->OpCode) != 0)) {
- ColumnStr1 = gAdjustNumber;
- }
-
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
- }
- } else {
- PrintHotKeyHelpString (FormData, FALSE);
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterCommitString, ColumnWidth2);
-
- //
- // If it is a selected numeric with manual input, display different message
- //
- if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) ||
- (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
- (Statement->OpCode->OpCode == EFI_IFR_TIME_OP))
- {
- ColumnStr2 = HexDisplay ? gHexNumericInput : gDecNumericInput;
- PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1);
- } else {
- PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
- }
-
- if (Statement->OpCode->OpCode == EFI_IFR_ORDERED_LIST_OP) {
- ColumnStr1 = gPlusString;
- ColumnStr3 = gMinusString;
- }
-
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
- PrintStringAtWithWidth (ThdCol, TopRowOfHelp, ColumnStr3, ColumnWidth3);
- PrintStringAtWithWidth (SecCol, TopRowOfHelp, ColumnStr2, ColumnWidth2);
-
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, gEnterEscapeString, ColumnWidth3);
- }
-
- break;
-
- case EFI_IFR_CHECKBOX_OP:
- PrintHotKeyHelpString (FormData, TRUE);
-
- if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- ColumnStr3 = gEscapeString;
- }
-
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
-
- PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gToggleCheckBox, ColumnWidth2);
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1);
- break;
-
- case EFI_IFR_REF_OP:
- case EFI_IFR_PASSWORD_OP:
- case EFI_IFR_STRING_OP:
- case EFI_IFR_TEXT_OP:
- case EFI_IFR_ACTION_OP:
- case EFI_IFR_RESET_BUTTON_OP:
- case EFI_IFR_SUBTITLE_OP:
- if (!Selected) {
- PrintHotKeyHelpString (FormData, TRUE);
-
- if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- ColumnStr3 = gEscapeString;
- }
-
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
-
- PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
- if ((Statement->OpCode->OpCode != EFI_IFR_TEXT_OP) && (Statement->OpCode->OpCode != EFI_IFR_SUBTITLE_OP)) {
- ColumnStr2 = gEnterString;
- }
-
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
- } else {
- PrintHotKeyHelpString (FormData, FALSE);
- if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) {
- ColumnStr2 = gEnterCommitString;
- ColumnStr3 = gEnterEscapeString;
- }
-
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
- PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, ColumnStr1, ColumnWidth1);
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
- }
-
- break;
-
- default:
- break;
- }
-}
-
-/**
- Update status bar.
-
- This function updates the status bar on the bottom of menu screen. It just shows StatusBar.
- Original logic in this function should be splitted out.
-
- @param[in] MessageType The type of message to be shown. InputError or Configuration Changed.
- @param[in] State Show or Clear Message.
-**/
-VOID
-EFIAPI
-UpdateStatusBar (
- IN UINTN MessageType,
- IN BOOLEAN State
- )
-{
- UINTN Index;
- CHAR16 OptionWidth;
-
- OptionWidth = (CHAR16)((gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3);
-
- switch (MessageType) {
- case INPUT_ERROR:
- if (State) {
- gST->ConOut->SetAttribute (gST->ConOut, ERROR_TEXT);
- PrintStringAt (
- gScreenDimensions.LeftColumn + OptionWidth,
- gScreenDimensions.BottomRow - 1,
- gInputErrorMessage
- );
- } else {
- gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
- for (Index = 0; Index < (LibGetStringWidth (gInputErrorMessage) - 2) / 2; Index++) {
- PrintStringAt (gScreenDimensions.LeftColumn + OptionWidth + Index, gScreenDimensions.BottomRow - 1, L" ");
- }
- }
-
- break;
-
- case NV_UPDATE_REQUIRED:
- //
- // Global setting support. Show configuration change on every form.
- //
- if (State) {
- gST->ConOut->SetAttribute (gST->ConOut, INFO_TEXT);
- PrintStringAt (
- gScreenDimensions.LeftColumn + OptionWidth * 2,
- gScreenDimensions.BottomRow - 1,
- gNvUpdateMessage
- );
- } else {
- gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
- for (Index = 0; Index < (LibGetStringWidth (gNvUpdateMessage) - 2) / 2; Index++) {
- PrintStringAt (
- (gScreenDimensions.LeftColumn + OptionWidth * 2 + Index),
- gScreenDimensions.BottomRow - 1,
- L" "
- );
- }
- }
-
- break;
-
- default:
- break;
- }
-}
-
-/**
- Create popup window. It will replace CreateDialog().
-
- This function draws OEM/Vendor specific pop up windows.
-
- @param[out] Key User Input Key
- @param ... String to be shown in Popup. The variable argument list is terminated by a NULL.
-
-**/
-VOID
-EFIAPI
-CreateDialog (
- OUT EFI_INPUT_KEY *Key OPTIONAL,
- ...
- )
-{
- VA_LIST Marker;
- EFI_INPUT_KEY KeyValue;
- EFI_STATUS Status;
- UINTN LargestString;
- UINTN LineNum;
- UINTN Index;
- UINTN Count;
- CHAR16 Character;
- UINTN Start;
- UINTN End;
- UINTN Top;
- UINTN Bottom;
- CHAR16 *String;
- UINTN DimensionsWidth;
- UINTN DimensionsHeight;
- UINTN CurrentAttribute;
- BOOLEAN CursorVisible;
-
- //
- // If screen dimension info is not ready, get it from console.
- //
- if ((gScreenDimensions.RightColumn == 0) || (gScreenDimensions.BottomRow == 0)) {
- ZeroMem (&gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
- gST->ConOut->QueryMode (
- gST->ConOut,
- gST->ConOut->Mode->Mode,
- &gScreenDimensions.RightColumn,
- &gScreenDimensions.BottomRow
- );
- }
-
- DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;
- DimensionsHeight = gScreenDimensions.BottomRow - gScreenDimensions.TopRow;
-
- LargestString = 0;
- LineNum = 0;
- VA_START (Marker, Key);
- while ((String = VA_ARG (Marker, CHAR16 *)) != NULL) {
- LineNum++;
-
- if ((LibGetStringWidth (String) / 2) > LargestString) {
- LargestString = (LibGetStringWidth (String) / 2);
- }
- }
-
- VA_END (Marker);
-
- if ((LargestString + 2) > DimensionsWidth) {
- LargestString = DimensionsWidth - 2;
- }
-
- CurrentAttribute = gST->ConOut->Mode->Attribute;
- CursorVisible = gST->ConOut->Mode->CursorVisible;
- gST->ConOut->EnableCursor (gST->ConOut, FALSE);
- gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());
-
- //
- // Subtract the PopUp width from total Columns, allow for one space extra on
- // each end plus a border.
- //
- Start = (DimensionsWidth - LargestString - 2) / 2 + gScreenDimensions.LeftColumn + 1;
- End = Start + LargestString + 1;
-
- Top = ((DimensionsHeight - LineNum - 2) / 2) + gScreenDimensions.TopRow - 1;
- Bottom = Top + LineNum + 2;
-
- Character = BOXDRAW_DOWN_RIGHT;
- PrintCharAt (Start, Top, Character);
- Character = BOXDRAW_HORIZONTAL;
- for (Index = Start; Index + 2 < End; Index++) {
- PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
- }
-
- Character = BOXDRAW_DOWN_LEFT;
- PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
- Character = BOXDRAW_VERTICAL;
-
- Count = 0;
- VA_START (Marker, Key);
- for (Index = Top; Index + 2 < Bottom; Index++, Count++) {
- String = VA_ARG (Marker, CHAR16 *);
-
- if (String[0] == CHAR_NULL) {
- //
- // Passing in a NULL results in a blank space
- //
- ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ());
- } else if (String[0] == L' ') {
- //
- // Passing in a space results in the assumption that this is where typing will occur
- //
- ClearLines (Start + 1, End - 1, Index + 1, Index + 1, POPUP_INVERSE_TEXT | POPUP_INVERSE_BACKGROUND);
- PrintStringAt (
- ((DimensionsWidth - LibGetStringWidth (String) / 2) / 2) + gScreenDimensions.LeftColumn + 1,
- Index + 1,
- String + 1
- );
- } else {
- //
- // This will clear the background of the line - we never know who might have been
- // here before us. This differs from the next clear in that it used the non-reverse
- // video for normal printing.
- //
- ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ());
- PrintStringAt (
- ((DimensionsWidth - LibGetStringWidth (String) / 2) / 2) + gScreenDimensions.LeftColumn + 1,
- Index + 1,
- String
- );
- }
-
- gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());
- PrintCharAt (Start, Index + 1, Character);
- PrintCharAt (End - 1, Index + 1, Character);
- }
-
- VA_END (Marker);
-
- Character = BOXDRAW_UP_RIGHT;
- PrintCharAt (Start, Bottom - 1, Character);
- Character = BOXDRAW_HORIZONTAL;
- for (Index = Start; Index + 2 < End; Index++) {
- PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
- }
-
- Character = BOXDRAW_UP_LEFT;
- PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
-
- if (Key != NULL) {
- Status = WaitForKeyStroke (&KeyValue);
- ASSERT_EFI_ERROR (Status);
- CopyMem (Key, &KeyValue, sizeof (EFI_INPUT_KEY));
- }
-
- gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);
- gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);
-}
-
-/**
- Confirm how to handle the changed data.
-
- @return Action BROWSER_ACTION_SUBMIT, BROWSER_ACTION_DISCARD or other values.
-**/
-UINTN
-EFIAPI
-ConfirmDataChange (
- VOID
- )
-{
- CHAR16 YesResponse;
- CHAR16 NoResponse;
- EFI_INPUT_KEY Key;
-
- gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
-
- YesResponse = gYesResponse[0];
- NoResponse = gNoResponse[0];
-
- //
- // If NV flag is up, prompt user
- //
- do {
- CreateDialog (&Key, gLibEmptyString, gSaveChanges, gAreYouSure, gLibEmptyString, NULL);
- } while
- (
- (Key.ScanCode != SCAN_ESC) &&
- ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (NoResponse | UPPER_LOWER_CASE_OFFSET)) &&
- ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (YesResponse | UPPER_LOWER_CASE_OFFSET))
- );
-
- if (Key.ScanCode == SCAN_ESC) {
- return BROWSER_ACTION_NONE;
- } else if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) {
- return BROWSER_ACTION_SUBMIT;
- } else {
- return BROWSER_ACTION_DISCARD;
- }
-}
-
-/**
- OEM specifies whether Setup exits Page by ESC key.
-
- This function customized the behavior that whether Setup exits Page so that
- system able to boot when configuration is not changed.
-
- @retval TRUE Exits FrontPage
- @retval FALSE Don't exit FrontPage.
-**/
-BOOLEAN
-EFIAPI
-FormExitPolicy (
- VOID
- )
-{
- return gClassOfVfr == FORMSET_CLASS_FRONT_PAGE ? FALSE : TRUE;
-}
-
-/**
- Set Timeout value for a ceratain Form to get user response.
-
- This function allows to set timeout value on a ceratain form if necessary.
- If timeout is not zero, the form will exit if user has no response in timeout.
-
- @param[in] FormData Form Data to be shown in Page
-
- @return 0 No timeout for this form.
- @return > 0 Timeout value in 100 ns units.
-**/
-UINT64
-EFIAPI
-FormExitTimeout (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
- )
-{
- return 0;
-}
-
-//
-// Print Functions
-//
-
-/**
- Prints a unicode string to the default console, at
- the supplied cursor position, using L"%s" format.
-
- @param Column The cursor position to print the string at. When it is -1, use current Position.
- @param Row The cursor position to print the string at. When it is -1, use current Position.
- @param String String pointer.
-
- @return Length of string printed to the console
-
-**/
-UINTN
-EFIAPI
-PrintStringAt (
- IN UINTN Column,
- IN UINTN Row,
- IN CHAR16 *String
- )
-{
- return PrintAt (0, Column, Row, L"%s", String);
-}
-
-/**
- Prints a unicode string to the default console, at
- the supplied cursor position, using L"%s" format.
-
- @param Column The cursor position to print the string at. When it is -1, use current Position.
- @param Row The cursor position to print the string at. When it is -1, use current Position.
- @param String String pointer.
- @param Width Width for String.
-
- @return Length of string printed to the console
-
-**/
-UINTN
-EFIAPI
-PrintStringAtWithWidth (
- IN UINTN Column,
- IN UINTN Row,
- IN CHAR16 *String,
- IN UINTN Width
- )
-{
- return PrintAt (Width, Column, Row, L"%s", String);
-}
-
-/**
- Prints a character to the default console, at
- the supplied cursor position, using L"%c" format.
-
- @param Column The cursor position to print the string at. When it is -1, use current Position.
- @param Row The cursor position to print the string at. When it is -1, use current Position.
- @param Character Character to print.
-
- @return Length of string printed to the console.
-
-**/
-UINTN
-EFIAPI
-PrintCharAt (
- IN UINTN Column,
- IN UINTN Row,
- CHAR16 Character
- )
-{
- return PrintAt (0, Column, Row, L"%c", Character);
-}
-
-/**
- Clear retangle with specified text attribute.
-
- @param LeftColumn Left column of retangle.
- @param RightColumn Right column of retangle.
- @param TopRow Start row of retangle.
- @param BottomRow End row of retangle.
- @param TextAttribute The character foreground and background.
-
-**/
-VOID
-EFIAPI
-ClearLines (
- IN UINTN LeftColumn,
- IN UINTN RightColumn,
- IN UINTN TopRow,
- IN UINTN BottomRow,
- IN UINTN TextAttribute
- )
-{
- CHAR16 *Buffer;
- UINTN Row;
-
- //
- // For now, allocate an arbitrarily long buffer
- //
- Buffer = AllocateZeroPool (0x10000);
- ASSERT (Buffer != NULL);
-
- //
- // Set foreground and background as defined
- //
- gST->ConOut->SetAttribute (gST->ConOut, TextAttribute);
-
- //
- // Much faster to buffer the long string instead of print it a character at a time
- //
- LibSetUnicodeMem (Buffer, RightColumn - LeftColumn, L' ');
-
- //
- // Clear the desired area with the appropriate foreground/background
- //
- for (Row = TopRow; Row <= BottomRow; Row++) {
- PrintStringAt (LeftColumn, Row, Buffer);
- }
-
- gST->ConOut->SetCursorPosition (gST->ConOut, LeftColumn, TopRow);
-
- FreePool (Buffer);
-}
-
-//
-// Color Setting Functions
-//
-
-/**
- Get OEM/Vendor specific popup attribute colors.
-
- @retval Byte code color setting for popup color.
-**/
-UINT8
-EFIAPI
-GetPopupColor (
- VOID
- )
-{
- return POPUP_TEXT | POPUP_BACKGROUND;
-}
-
-/**
- Get OEM/Vendor specific popup attribute colors.
-
- @retval Byte code color setting for popup inverse color.
-**/
-UINT8
-EFIAPI
-GetPopupInverseColor (
- VOID
- )
-{
- return POPUP_INVERSE_TEXT | POPUP_INVERSE_BACKGROUND;
-}
-
-/**
- Get OEM/Vendor specific PickList color attribute.
-
- @retval Byte code color setting for pick list color.
-**/
-UINT8
-EFIAPI
-GetPickListColor (
- VOID
- )
-{
- return PICKLIST_HIGHLIGHT_TEXT | PICKLIST_HIGHLIGHT_BACKGROUND;
-}
-
-/**
- Get OEM/Vendor specific arrow color attribute.
-
- @retval Byte code color setting for arrow color.
-**/
-UINT8
-EFIAPI
-GetArrowColor (
- VOID
- )
-{
- return ARROW_TEXT | ARROW_BACKGROUND;
-}
-
-/**
- Get OEM/Vendor specific info text color attribute.
-
- @retval Byte code color setting for info text color.
-**/
-UINT8
-EFIAPI
-GetInfoTextColor (
- VOID
- )
-{
- return INFO_TEXT | FIELD_BACKGROUND;
-}
-
-/**
- Get OEM/Vendor specific help text color attribute.
-
- @retval Byte code color setting for help text color.
-**/
-UINT8
-EFIAPI
-GetHelpTextColor (
- VOID
- )
-{
- return HELP_TEXT | FIELD_BACKGROUND;
-}
-
-/**
- Get OEM/Vendor specific grayed out text color attribute.
-
- @retval Byte code color setting for grayed out text color.
-**/
-UINT8
-EFIAPI
-GetGrayedTextColor (
- VOID
- )
-{
- return FIELD_TEXT_GRAYED | FIELD_BACKGROUND;
-}
-
-/**
- Get OEM/Vendor specific highlighted text color attribute.
-
- @retval Byte code color setting for highlight text color.
-**/
-UINT8
-EFIAPI
-GetHighlightTextColor (
- VOID
- )
-{
- return PcdGet8 (PcdBrowserFieldTextHighlightColor) | PcdGet8 (PcdBrowserFieldBackgroundHighlightColor);
-}
-
-/**
- Get OEM/Vendor specific field text color attribute.
-
- @retval Byte code color setting for field text color.
-**/
-UINT8
-EFIAPI
-GetFieldTextColor (
- VOID
- )
-{
- return PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND;
-}
-
-/**
- Get OEM/Vendor specific subtitle text color attribute.
-
- @retval Byte code color setting for subtitle text color.
-**/
-UINT8
-EFIAPI
-GetSubTitleTextColor (
- VOID
- )
-{
- return PcdGet8 (PcdBrowserSubtitleTextColor) | FIELD_BACKGROUND;
-}
-
-/**
- Clear Screen to the initial state.
-**/
-VOID
-EFIAPI
-ClearDisplayPage (
- VOID
- )
-{
- gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
- gST->ConOut->ClearScreen (gST->ConOut);
- gLibIsFirstForm = TRUE;
-}
-
-/**
- Constructor of Customized Display Library Instance.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
-
-**/
-EFI_STATUS
-EFIAPI
-CustomizedDisplayLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- mCDLStringPackHandle = HiiAddPackages (&gCustomizedDisplayLibGuid, ImageHandle, CustomizedDisplayLibStrings, NULL);
- ASSERT (mCDLStringPackHandle != NULL);
-
- InitializeLibStrings ();
-
- return EFI_SUCCESS;
-}
-
-/**
- Destructor of Customized Display Library Instance.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The destructor completed successfully.
- @retval Other value The destructor did not complete successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-CustomizedDisplayLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- HiiRemovePackages (mCDLStringPackHandle);
-
- FreeLibStrings ();
-
- return EFI_SUCCESS;
-}
+/** @file + + This library class defines a set of interfaces to customize Display module + +Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR> +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include "CustomizedDisplayLibInternal.h" + +EFI_GUID gCustomizedDisplayLibGuid = { + 0x99fdc8fd, 0x849b, 0x4eba, { 0xad, 0x13, 0xfb, 0x96, 0x99, 0xc9, 0xa, 0x4d } +}; + +EFI_HII_HANDLE mCDLStringPackHandle; +UINT16 gClassOfVfr; // Formset class information +BOOLEAN gLibIsFirstForm = TRUE; +BANNER_DATA *gBannerData; + +UINTN gFooterHeight; + +/** ++------------------------------------------------------------------------------+ +| Setup Page | ++------------------------------------------------------------------------------+ + +Statement +Statement +Statement + + + + + ++------------------------------------------------------------------------------+ +| F9=Reset to Defaults F10=Save | +| ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Exit | ++------------------------------------------------------------------------------+ + StatusBar +**/ + +/** + This funtion defines Page Frame and Backgroud. + + Based on the above layout, it will be responsible for HeaderHeight, FooterHeight, + StatusBarHeight and Backgroud. And, it will reserve Screen for Statement. + + @param[in] FormData Form Data to be shown in Page. + @param[out] ScreenForStatement Screen to be used for Statement. (Prompt, Value and Help) + + @return Status +**/ +EFI_STATUS +EFIAPI +DisplayPageFrame ( + IN FORM_DISPLAY_ENGINE_FORM *FormData, + OUT EFI_SCREEN_DESCRIPTOR *ScreenForStatement + ) +{ + EFI_STATUS Status; + + ASSERT (FormData != NULL && ScreenForStatement != NULL); + if ((FormData == NULL) || (ScreenForStatement == NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status = ScreenDiemensionInfoValidate (FormData); + if (EFI_ERROR (Status)) { + return Status; + } + + gClassOfVfr = FORMSET_CLASS_PLATFORM_SETUP; + + ProcessExternedOpcode (FormData); + + // + // Calculate the ScreenForStatement. + // + ScreenForStatement->BottomRow = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight; + if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) { + ScreenForStatement->TopRow = gScreenDimensions.TopRow + FRONT_PAGE_HEADER_HEIGHT; + } else { + ScreenForStatement->TopRow = gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT; + } + + ScreenForStatement->LeftColumn = gScreenDimensions.LeftColumn; + ScreenForStatement->RightColumn = gScreenDimensions.RightColumn; + + if ((gLibIsFirstForm) || ((FormData->Attribute & HII_DISPLAY_MODAL) != 0)) { + // + // Ensure we are in Text mode + // + gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); + ClearLines (0, gScreenDimensions.RightColumn, 0, gScreenDimensions.BottomRow, KEYHELP_BACKGROUND); + gLibIsFirstForm = FALSE; + } + + // + // Don't print frame for modal form. + // + if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) { + return EFI_SUCCESS; + } + + if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) { + PrintBannerInfo (FormData); + } + + PrintFramework (FormData); + + UpdateStatusBar (NV_UPDATE_REQUIRED, FormData->SettingChangedFlag); + + return EFI_SUCCESS; +} + +/** + This function updates customized key panel's help information. + The library will prepare those Strings for the basic key, ESC, Enter, Up/Down/Left/Right, +/-. + and arrange them in Footer panel. + + @param[in] FormData Form Data to be shown in Page. FormData has the highlighted statement. + @param[in] Statement The statement current selected. + @param[in] Selected Whether or not a tag be selected. TRUE means Enter has hit this question. +**/ +VOID +EFIAPI +RefreshKeyHelp ( + IN FORM_DISPLAY_ENGINE_FORM *FormData, + IN FORM_DISPLAY_ENGINE_STATEMENT *Statement, + IN BOOLEAN Selected + ) +{ + UINTN SecCol; + UINTN ThdCol; + UINTN RightColumnOfHelp; + UINTN TopRowOfHelp; + UINTN BottomRowOfHelp; + UINTN StartColumnOfHelp; + EFI_IFR_NUMERIC *NumericOp; + EFI_IFR_DATE *DateOp; + EFI_IFR_TIME *TimeOp; + BOOLEAN HexDisplay; + UINTN ColumnWidth1; + UINTN ColumnWidth2; + UINTN ColumnWidth3; + CHAR16 *ColumnStr1; + CHAR16 *ColumnStr2; + CHAR16 *ColumnStr3; + + ASSERT (FormData != NULL); + if (FormData == NULL) { + return; + } + + gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND); + + if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) { + return; + } + + SecCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3; + ThdCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3 * 2; + + // + // + 2 means leave 1 space before the first hotkey info. + // + StartColumnOfHelp = gScreenDimensions.LeftColumn + 2; + RightColumnOfHelp = gScreenDimensions.RightColumn - 1; + TopRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1; + BottomRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2; + + ColumnWidth1 = SecCol - StartColumnOfHelp; + ColumnWidth2 = ThdCol - SecCol; + ColumnWidth3 = RightColumnOfHelp - ThdCol; + ColumnStr1 = gLibEmptyString; + ColumnStr2 = gLibEmptyString; + ColumnStr3 = gLibEmptyString; + + // + // Clean the space at gScreenDimensions.LeftColumn + 1. + // + PrintStringAtWithWidth (StartColumnOfHelp - 1, BottomRowOfHelp, gLibEmptyString, 1); + PrintStringAtWithWidth (StartColumnOfHelp - 1, TopRowOfHelp, gLibEmptyString, 1); + + if (Statement == NULL) { + // + // Print Key for Form without showable statement. + // + PrintHotKeyHelpString (FormData, TRUE); + PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gLibEmptyString, ColumnWidth2); + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1); + if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { + ColumnStr3 = gEscapeString; + } + + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3); + + return; + } + + HexDisplay = FALSE; + NumericOp = NULL; + DateOp = NULL; + TimeOp = NULL; + if (Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) { + NumericOp = (EFI_IFR_NUMERIC *)Statement->OpCode; + HexDisplay = (NumericOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX; + } else if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) { + DateOp = (EFI_IFR_DATE *)Statement->OpCode; + HexDisplay = (DateOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX; + } else if (Statement->OpCode->OpCode == EFI_IFR_TIME_OP) { + TimeOp = (EFI_IFR_TIME *)Statement->OpCode; + HexDisplay = (TimeOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX; + } + + switch (Statement->OpCode->OpCode) { + case EFI_IFR_ORDERED_LIST_OP: + case EFI_IFR_ONE_OF_OP: + case EFI_IFR_NUMERIC_OP: + case EFI_IFR_TIME_OP: + case EFI_IFR_DATE_OP: + if (!Selected) { + PrintHotKeyHelpString (FormData, TRUE); + + if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { + ColumnStr3 = gEscapeString; + } + + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3); + + if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP) || + (Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) + { + PrintAt ( + ColumnWidth1, + StartColumnOfHelp, + BottomRowOfHelp, + L"%c%c%c%c%s", + ARROW_UP, + ARROW_DOWN, + ARROW_RIGHT, + ARROW_LEFT, + gMoveHighlight + ); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2); + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber, ColumnWidth1); + } else { + PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); + if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) && (NumericOp != NULL) && (LibGetFieldFromNum (Statement->OpCode) != 0)) { + ColumnStr1 = gAdjustNumber; + } + + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2); + } + } else { + PrintHotKeyHelpString (FormData, FALSE); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterCommitString, ColumnWidth2); + + // + // If it is a selected numeric with manual input, display different message + // + if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) || + (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) || + (Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) + { + ColumnStr2 = HexDisplay ? gHexNumericInput : gDecNumericInput; + PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1); + } else { + PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); + } + + if (Statement->OpCode->OpCode == EFI_IFR_ORDERED_LIST_OP) { + ColumnStr1 = gPlusString; + ColumnStr3 = gMinusString; + } + + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1); + PrintStringAtWithWidth (ThdCol, TopRowOfHelp, ColumnStr3, ColumnWidth3); + PrintStringAtWithWidth (SecCol, TopRowOfHelp, ColumnStr2, ColumnWidth2); + + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, gEnterEscapeString, ColumnWidth3); + } + + break; + + case EFI_IFR_CHECKBOX_OP: + PrintHotKeyHelpString (FormData, TRUE); + + if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { + ColumnStr3 = gEscapeString; + } + + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3); + + PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gToggleCheckBox, ColumnWidth2); + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1); + break; + + case EFI_IFR_REF_OP: + case EFI_IFR_PASSWORD_OP: + case EFI_IFR_STRING_OP: + case EFI_IFR_TEXT_OP: + case EFI_IFR_ACTION_OP: + case EFI_IFR_RESET_BUTTON_OP: + case EFI_IFR_SUBTITLE_OP: + if (!Selected) { + PrintHotKeyHelpString (FormData, TRUE); + + if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { + ColumnStr3 = gEscapeString; + } + + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3); + + PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); + if ((Statement->OpCode->OpCode != EFI_IFR_TEXT_OP) && (Statement->OpCode->OpCode != EFI_IFR_SUBTITLE_OP)) { + ColumnStr2 = gEnterString; + } + + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2); + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1); + } else { + PrintHotKeyHelpString (FormData, FALSE); + if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) { + ColumnStr2 = gEnterCommitString; + ColumnStr3 = gEnterEscapeString; + } + + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1); + PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, ColumnStr1, ColumnWidth1); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2); + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3); + } + + break; + + default: + break; + } +} + +/** + Update status bar. + + This function updates the status bar on the bottom of menu screen. It just shows StatusBar. + Original logic in this function should be splitted out. + + @param[in] MessageType The type of message to be shown. InputError or Configuration Changed. + @param[in] State Show or Clear Message. +**/ +VOID +EFIAPI +UpdateStatusBar ( + IN UINTN MessageType, + IN BOOLEAN State + ) +{ + UINTN Index; + CHAR16 OptionWidth; + + OptionWidth = (CHAR16)((gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3); + + switch (MessageType) { + case INPUT_ERROR: + if (State) { + gST->ConOut->SetAttribute (gST->ConOut, ERROR_TEXT); + PrintStringAt ( + gScreenDimensions.LeftColumn + OptionWidth, + gScreenDimensions.BottomRow - 1, + gInputErrorMessage + ); + } else { + gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND); + for (Index = 0; Index < (LibGetStringWidth (gInputErrorMessage) - 2) / 2; Index++) { + PrintStringAt (gScreenDimensions.LeftColumn + OptionWidth + Index, gScreenDimensions.BottomRow - 1, L" "); + } + } + + break; + + case NV_UPDATE_REQUIRED: + // + // Global setting support. Show configuration change on every form. + // + if (State) { + gST->ConOut->SetAttribute (gST->ConOut, INFO_TEXT); + PrintStringAt ( + gScreenDimensions.LeftColumn + OptionWidth * 2, + gScreenDimensions.BottomRow - 1, + gNvUpdateMessage + ); + } else { + gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND); + for (Index = 0; Index < (LibGetStringWidth (gNvUpdateMessage) - 2) / 2; Index++) { + PrintStringAt ( + (gScreenDimensions.LeftColumn + OptionWidth * 2 + Index), + gScreenDimensions.BottomRow - 1, + L" " + ); + } + } + + break; + + default: + break; + } +} + +/** + Create popup window. It will replace CreateDialog(). + + This function draws OEM/Vendor specific pop up windows. + + @param[out] Key User Input Key + @param ... String to be shown in Popup. The variable argument list is terminated by a NULL. + +**/ +VOID +EFIAPI +CreateDialog ( + OUT EFI_INPUT_KEY *Key OPTIONAL, + ... + ) +{ + VA_LIST Marker; + EFI_INPUT_KEY KeyValue; + EFI_STATUS Status; + UINTN LargestString; + UINTN LineNum; + UINTN Index; + UINTN Count; + CHAR16 Character; + UINTN Start; + UINTN End; + UINTN Top; + UINTN Bottom; + CHAR16 *String; + UINTN DimensionsWidth; + UINTN DimensionsHeight; + UINTN CurrentAttribute; + BOOLEAN CursorVisible; + + // + // If screen dimension info is not ready, get it from console. + // + if ((gScreenDimensions.RightColumn == 0) || (gScreenDimensions.BottomRow == 0)) { + ZeroMem (&gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); + gST->ConOut->QueryMode ( + gST->ConOut, + gST->ConOut->Mode->Mode, + &gScreenDimensions.RightColumn, + &gScreenDimensions.BottomRow + ); + } + + DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn; + DimensionsHeight = gScreenDimensions.BottomRow - gScreenDimensions.TopRow; + + LargestString = 0; + LineNum = 0; + VA_START (Marker, Key); + while ((String = VA_ARG (Marker, CHAR16 *)) != NULL) { + LineNum++; + + if ((LibGetStringWidth (String) / 2) > LargestString) { + LargestString = (LibGetStringWidth (String) / 2); + } + } + + VA_END (Marker); + + if ((LargestString + 2) > DimensionsWidth) { + LargestString = DimensionsWidth - 2; + } + + CurrentAttribute = gST->ConOut->Mode->Attribute; + CursorVisible = gST->ConOut->Mode->CursorVisible; + gST->ConOut->EnableCursor (gST->ConOut, FALSE); + gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ()); + + // + // Subtract the PopUp width from total Columns, allow for one space extra on + // each end plus a border. + // + Start = (DimensionsWidth - LargestString - 2) / 2 + gScreenDimensions.LeftColumn + 1; + End = Start + LargestString + 1; + + Top = ((DimensionsHeight - LineNum - 2) / 2) + gScreenDimensions.TopRow - 1; + Bottom = Top + LineNum + 2; + + Character = BOXDRAW_DOWN_RIGHT; + PrintCharAt (Start, Top, Character); + Character = BOXDRAW_HORIZONTAL; + for (Index = Start; Index + 2 < End; Index++) { + PrintCharAt ((UINTN)-1, (UINTN)-1, Character); + } + + Character = BOXDRAW_DOWN_LEFT; + PrintCharAt ((UINTN)-1, (UINTN)-1, Character); + Character = BOXDRAW_VERTICAL; + + Count = 0; + VA_START (Marker, Key); + for (Index = Top; Index + 2 < Bottom; Index++, Count++) { + String = VA_ARG (Marker, CHAR16 *); + + if (String[0] == CHAR_NULL) { + // + // Passing in a NULL results in a blank space + // + ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ()); + } else if (String[0] == L' ') { + // + // Passing in a space results in the assumption that this is where typing will occur + // + ClearLines (Start + 1, End - 1, Index + 1, Index + 1, POPUP_INVERSE_TEXT | POPUP_INVERSE_BACKGROUND); + PrintStringAt ( + ((DimensionsWidth - LibGetStringWidth (String) / 2) / 2) + gScreenDimensions.LeftColumn + 1, + Index + 1, + String + 1 + ); + } else { + // + // This will clear the background of the line - we never know who might have been + // here before us. This differs from the next clear in that it used the non-reverse + // video for normal printing. + // + ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ()); + PrintStringAt ( + ((DimensionsWidth - LibGetStringWidth (String) / 2) / 2) + gScreenDimensions.LeftColumn + 1, + Index + 1, + String + ); + } + + gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ()); + PrintCharAt (Start, Index + 1, Character); + PrintCharAt (End - 1, Index + 1, Character); + } + + VA_END (Marker); + + Character = BOXDRAW_UP_RIGHT; + PrintCharAt (Start, Bottom - 1, Character); + Character = BOXDRAW_HORIZONTAL; + for (Index = Start; Index + 2 < End; Index++) { + PrintCharAt ((UINTN)-1, (UINTN)-1, Character); + } + + Character = BOXDRAW_UP_LEFT; + PrintCharAt ((UINTN)-1, (UINTN)-1, Character); + + if (Key != NULL) { + Status = WaitForKeyStroke (&KeyValue); + ASSERT_EFI_ERROR (Status); + CopyMem (Key, &KeyValue, sizeof (EFI_INPUT_KEY)); + } + + gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute); + gST->ConOut->EnableCursor (gST->ConOut, CursorVisible); +} + +/** + Confirm how to handle the changed data. + + @return Action BROWSER_ACTION_SUBMIT, BROWSER_ACTION_DISCARD or other values. +**/ +UINTN +EFIAPI +ConfirmDataChange ( + VOID + ) +{ + CHAR16 YesResponse; + CHAR16 NoResponse; + EFI_INPUT_KEY Key; + + gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); + + YesResponse = gYesResponse[0]; + NoResponse = gNoResponse[0]; + + // + // If NV flag is up, prompt user + // + do { + CreateDialog (&Key, gLibEmptyString, gSaveChanges, gAreYouSure, gLibEmptyString, NULL); + } while + ( + (Key.ScanCode != SCAN_ESC) && + ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (NoResponse | UPPER_LOWER_CASE_OFFSET)) && + ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (YesResponse | UPPER_LOWER_CASE_OFFSET)) + ); + + if (Key.ScanCode == SCAN_ESC) { + return BROWSER_ACTION_NONE; + } else if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) { + return BROWSER_ACTION_SUBMIT; + } else { + return BROWSER_ACTION_DISCARD; + } +} + +/** + OEM specifies whether Setup exits Page by ESC key. + + This function customized the behavior that whether Setup exits Page so that + system able to boot when configuration is not changed. + + @retval TRUE Exits FrontPage + @retval FALSE Don't exit FrontPage. +**/ +BOOLEAN +EFIAPI +FormExitPolicy ( + VOID + ) +{ + return gClassOfVfr == FORMSET_CLASS_FRONT_PAGE ? FALSE : TRUE; +} + +/** + Set Timeout value for a ceratain Form to get user response. + + This function allows to set timeout value on a ceratain form if necessary. + If timeout is not zero, the form will exit if user has no response in timeout. + + @param[in] FormData Form Data to be shown in Page + + @return 0 No timeout for this form. + @return > 0 Timeout value in 100 ns units. +**/ +UINT64 +EFIAPI +FormExitTimeout ( + IN FORM_DISPLAY_ENGINE_FORM *FormData + ) +{ + return 0; +} + +// +// Print Functions +// + +/** + Prints a unicode string to the default console, at + the supplied cursor position, using L"%s" format. + + @param Column The cursor position to print the string at. When it is -1, use current Position. + @param Row The cursor position to print the string at. When it is -1, use current Position. + @param String String pointer. + + @return Length of string printed to the console + +**/ +UINTN +EFIAPI +PrintStringAt ( + IN UINTN Column, + IN UINTN Row, + IN CHAR16 *String + ) +{ + return PrintAt (0, Column, Row, L"%s", String); +} + +/** + Prints a unicode string to the default console, at + the supplied cursor position, using L"%s" format. + + @param Column The cursor position to print the string at. When it is -1, use current Position. + @param Row The cursor position to print the string at. When it is -1, use current Position. + @param String String pointer. + @param Width Width for String. + + @return Length of string printed to the console + +**/ +UINTN +EFIAPI +PrintStringAtWithWidth ( + IN UINTN Column, + IN UINTN Row, + IN CHAR16 *String, + IN UINTN Width + ) +{ + return PrintAt (Width, Column, Row, L"%s", String); +} + +/** + Prints a character to the default console, at + the supplied cursor position, using L"%c" format. + + @param Column The cursor position to print the string at. When it is -1, use current Position. + @param Row The cursor position to print the string at. When it is -1, use current Position. + @param Character Character to print. + + @return Length of string printed to the console. + +**/ +UINTN +EFIAPI +PrintCharAt ( + IN UINTN Column, + IN UINTN Row, + CHAR16 Character + ) +{ + return PrintAt (0, Column, Row, L"%c", Character); +} + +/** + Clear retangle with specified text attribute. + + @param LeftColumn Left column of retangle. + @param RightColumn Right column of retangle. + @param TopRow Start row of retangle. + @param BottomRow End row of retangle. + @param TextAttribute The character foreground and background. + +**/ +VOID +EFIAPI +ClearLines ( + IN UINTN LeftColumn, + IN UINTN RightColumn, + IN UINTN TopRow, + IN UINTN BottomRow, + IN UINTN TextAttribute + ) +{ + CHAR16 *Buffer; + UINTN Row; + + // + // For now, allocate an arbitrarily long buffer + // + Buffer = AllocateZeroPool (0x10000); + ASSERT (Buffer != NULL); + + // + // Set foreground and background as defined + // + gST->ConOut->SetAttribute (gST->ConOut, TextAttribute); + + // + // Much faster to buffer the long string instead of print it a character at a time + // + LibSetUnicodeMem (Buffer, RightColumn - LeftColumn, L' '); + + // + // Clear the desired area with the appropriate foreground/background + // + for (Row = TopRow; Row <= BottomRow; Row++) { + PrintStringAt (LeftColumn, Row, Buffer); + } + + gST->ConOut->SetCursorPosition (gST->ConOut, LeftColumn, TopRow); + + FreePool (Buffer); +} + +// +// Color Setting Functions +// + +/** + Get OEM/Vendor specific popup attribute colors. + + @retval Byte code color setting for popup color. +**/ +UINT8 +EFIAPI +GetPopupColor ( + VOID + ) +{ + return POPUP_TEXT | POPUP_BACKGROUND; +} + +/** + Get OEM/Vendor specific popup attribute colors. + + @retval Byte code color setting for popup inverse color. +**/ +UINT8 +EFIAPI +GetPopupInverseColor ( + VOID + ) +{ + return POPUP_INVERSE_TEXT | POPUP_INVERSE_BACKGROUND; +} + +/** + Get OEM/Vendor specific PickList color attribute. + + @retval Byte code color setting for pick list color. +**/ +UINT8 +EFIAPI +GetPickListColor ( + VOID + ) +{ + return PICKLIST_HIGHLIGHT_TEXT | PICKLIST_HIGHLIGHT_BACKGROUND; +} + +/** + Get OEM/Vendor specific arrow color attribute. + + @retval Byte code color setting for arrow color. +**/ +UINT8 +EFIAPI +GetArrowColor ( + VOID + ) +{ + return ARROW_TEXT | ARROW_BACKGROUND; +} + +/** + Get OEM/Vendor specific info text color attribute. + + @retval Byte code color setting for info text color. +**/ +UINT8 +EFIAPI +GetInfoTextColor ( + VOID + ) +{ + return INFO_TEXT | FIELD_BACKGROUND; +} + +/** + Get OEM/Vendor specific help text color attribute. + + @retval Byte code color setting for help text color. +**/ +UINT8 +EFIAPI +GetHelpTextColor ( + VOID + ) +{ + return HELP_TEXT | FIELD_BACKGROUND; +} + +/** + Get OEM/Vendor specific grayed out text color attribute. + + @retval Byte code color setting for grayed out text color. +**/ +UINT8 +EFIAPI +GetGrayedTextColor ( + VOID + ) +{ + return FIELD_TEXT_GRAYED | FIELD_BACKGROUND; +} + +/** + Get OEM/Vendor specific highlighted text color attribute. + + @retval Byte code color setting for highlight text color. +**/ +UINT8 +EFIAPI +GetHighlightTextColor ( + VOID + ) +{ + return PcdGet8 (PcdBrowserFieldTextHighlightColor) | PcdGet8 (PcdBrowserFieldBackgroundHighlightColor); +} + +/** + Get OEM/Vendor specific field text color attribute. + + @retval Byte code color setting for field text color. +**/ +UINT8 +EFIAPI +GetFieldTextColor ( + VOID + ) +{ + return PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND; +} + +/** + Get OEM/Vendor specific subtitle text color attribute. + + @retval Byte code color setting for subtitle text color. +**/ +UINT8 +EFIAPI +GetSubTitleTextColor ( + VOID + ) +{ + return PcdGet8 (PcdBrowserSubtitleTextColor) | FIELD_BACKGROUND; +} + +/** + Clear Screen to the initial state. +**/ +VOID +EFIAPI +ClearDisplayPage ( + VOID + ) +{ + gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); + gST->ConOut->ClearScreen (gST->ConOut); + gLibIsFirstForm = TRUE; +} + +/** + Constructor of Customized Display Library Instance. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +CustomizedDisplayLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + mCDLStringPackHandle = HiiAddPackages (&gCustomizedDisplayLibGuid, ImageHandle, CustomizedDisplayLibStrings, NULL); + ASSERT (mCDLStringPackHandle != NULL); + + InitializeLibStrings (); + + return EFI_SUCCESS; +} + +/** + Destructor of Customized Display Library Instance. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The destructor completed successfully. + @retval Other value The destructor did not complete successfully. + +**/ +EFI_STATUS +EFIAPI +CustomizedDisplayLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + HiiRemovePackages (mCDLStringPackHandle); + + FreeLibStrings (); + + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf index 45fbdaf864..456857c6b8 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf @@ -1,60 +1,60 @@ -## @file
-# Customize display library used by display engine.
-#
-# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = CustomizedDisplayLib
- MODULE_UNI_FILE = CustomizedDisplayLibModStrs.uni
- FILE_GUID = 80B92017-EC64-4923-938D-94FAEE85832E
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = CustomizedDisplayLib|DXE_DRIVER UEFI_APPLICATION
- CONSTRUCTOR = CustomizedDisplayLibConstructor
- DESTRUCTOR = CustomizedDisplayLibDestructor
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 EBC
-#
-
-[Sources]
- CustomizedDisplayLib.c
- Colors.h
- CustomizedDisplayLibInternal.h
- CustomizedDisplayLibInternal.c
- CustomizedDisplayLib.uni
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- UefiRuntimeServicesTableLib
- BaseMemoryLib
- DebugLib
- PrintLib
- HiiLib
- DevicePathLib
- PcdLib
-
-[Guids]
- gEfiIfrTianoGuid ## SOMETIMES_CONSUMES ## UNDEFINED
-
-[Protocols]
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdBrowserSubtitleTextColor ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdBrowserFieldTextColor ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdBrowserFieldTextHighlightColor ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdBrowserFieldBackgroundHighlightColor ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdFrontPageFormSetGuid ## CONSUMES
+## @file +# Customize display library used by display engine. +# +# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR> +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CustomizedDisplayLib + MODULE_UNI_FILE = CustomizedDisplayLibModStrs.uni + FILE_GUID = 80B92017-EC64-4923-938D-94FAEE85832E + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = CustomizedDisplayLib|DXE_DRIVER UEFI_APPLICATION + CONSTRUCTOR = CustomizedDisplayLibConstructor + DESTRUCTOR = CustomizedDisplayLibDestructor +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 EBC +# + +[Sources] + CustomizedDisplayLib.c + Colors.h + CustomizedDisplayLibInternal.h + CustomizedDisplayLibInternal.c + CustomizedDisplayLib.uni + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + MemoryAllocationLib + BaseLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiRuntimeServicesTableLib + BaseMemoryLib + DebugLib + PrintLib + HiiLib + DevicePathLib + PcdLib + +[Guids] + gEfiIfrTianoGuid ## SOMETIMES_CONSUMES ## UNDEFINED + +[Protocols] + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdBrowserSubtitleTextColor ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdBrowserFieldTextColor ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdBrowserFieldTextHighlightColor ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdBrowserFieldBackgroundHighlightColor ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFrontPageFormSetGuid ## CONSUMES diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.uni b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.uni index 3f2efa5626..9a2d7bd026 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.uni +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.uni @@ -1,57 +1,57 @@ -// *++
-//
-// Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// Module Name:
-//
-// SetupBrowserStr.uni
-//
-// Abstract:
-//
-// String definitions for Browser.
-//
-// --*/
-
-
-/=#
-
-#langdef en-US "English"
-#langdef fr-FR "Français"
-
-#string ENTER_STRING #language en-US "<Enter>=Select Entry"
- #language fr-FR "<Enter>=Choisir l'Entrée"
-#string ENTER_COMMIT_STRING #language en-US "<Enter>=Complete Entry"
- #language fr-FR "<Enter>=Compléter l'Entrée"
-#string ENTER_ESCAPE_STRING #language en-US "Esc=Exit Entry"
- #language fr-FR "Esc=Sortir l'Entrée"
-#string ESCAPE_STRING #language en-US "Esc=Exit"
- #language fr-FR "Esc=Sortir"
-#string ADJUST_NUMBER #language en-US "+/- =Adjust Value"
- #language fr-FR "+/- =Ajuster la valeur"
-#string PLUS_STRING #language en-US "+ =Move Selection Up"
- #language fr-FR "+ =Relever le choix"
-#string MINUS_STRING #language en-US "- =Move Selection Down"
- #language fr-FR "- =Abaisser le choix"
-#string MOVE_HIGHLIGHT #language en-US "=Move Highlight"
- #language fr-FR "=Essentiel de mouvement"
-#string DEC_NUMERIC_INPUT #language en-US "0123456789 are valid inputs"
- #language fr-FR "0123456789 sont des données valides"
-#string HEX_NUMERIC_INPUT #language en-US "0-9 a-f are valid inputs"
- #language fr-FR "0-9 a-f sont des données valides"
-#string TOGGLE_CHECK_BOX #language en-US "<Spacebar>Toggle Checkbox"
- #language fr-FR "<Spacebar>Bascule la Case de pointage"
-#string NV_UPDATE_MESSAGE #language en-US "Configuration changed"
- #language fr-FR "Configuration changed"
-#string INPUT_ERROR_MESSAGE #language en-US "!!"
- #language fr-FR "!!"
-#string EMPTY_STRING #language en-US ""
- #language fr-FR ""
-#string ARE_YOU_SURE_YES #language en-US "Y"
- #language fr-FR "Y"
-#string ARE_YOU_SURE_NO #language en-US "N"
- #language fr-FR "N"
-#string SAVE_CHANGES #language en-US "Changes have not saved. Save Changes and exit?"
- #language fr-FR "Enregistrer les modifications et quitter?"
-#string ARE_YOU_SURE #language en-US "Press 'Y' to save and exit, 'N' to discard and exit, 'ESC' to cancel."
- #language fr-FR "Pressez 'Y' pour sauvegarder et quitter, 'N' de se défaire et de sortie"
+// *++ +// +// Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR> +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// Module Name: +// +// SetupBrowserStr.uni +// +// Abstract: +// +// String definitions for Browser. +// +// --*/ + + +/=# + +#langdef en-US "English" +#langdef fr-FR "Français" + +#string ENTER_STRING #language en-US "<Enter>=Select Entry" + #language fr-FR "<Enter>=Choisir l'Entrée" +#string ENTER_COMMIT_STRING #language en-US "<Enter>=Complete Entry" + #language fr-FR "<Enter>=Compléter l'Entrée" +#string ENTER_ESCAPE_STRING #language en-US "Esc=Exit Entry" + #language fr-FR "Esc=Sortir l'Entrée" +#string ESCAPE_STRING #language en-US "Esc=Exit" + #language fr-FR "Esc=Sortir" +#string ADJUST_NUMBER #language en-US "+/- =Adjust Value" + #language fr-FR "+/- =Ajuster la valeur" +#string PLUS_STRING #language en-US "+ =Move Selection Up" + #language fr-FR "+ =Relever le choix" +#string MINUS_STRING #language en-US "- =Move Selection Down" + #language fr-FR "- =Abaisser le choix" +#string MOVE_HIGHLIGHT #language en-US "=Move Highlight" + #language fr-FR "=Essentiel de mouvement" +#string DEC_NUMERIC_INPUT #language en-US "0123456789 are valid inputs" + #language fr-FR "0123456789 sont des données valides" +#string HEX_NUMERIC_INPUT #language en-US "0-9 a-f are valid inputs" + #language fr-FR "0-9 a-f sont des données valides" +#string TOGGLE_CHECK_BOX #language en-US "<Spacebar>Toggle Checkbox" + #language fr-FR "<Spacebar>Bascule la Case de pointage" +#string NV_UPDATE_MESSAGE #language en-US "Configuration changed" + #language fr-FR "Configuration changed" +#string INPUT_ERROR_MESSAGE #language en-US "!!" + #language fr-FR "!!" +#string EMPTY_STRING #language en-US "" + #language fr-FR "" +#string ARE_YOU_SURE_YES #language en-US "Y" + #language fr-FR "Y" +#string ARE_YOU_SURE_NO #language en-US "N" + #language fr-FR "N" +#string SAVE_CHANGES #language en-US "Changes have not saved. Save Changes and exit?" + #language fr-FR "Enregistrer les modifications et quitter?" +#string ARE_YOU_SURE #language en-US "Press 'Y' to save and exit, 'N' to discard and exit, 'ESC' to cancel." + #language fr-FR "Pressez 'Y' pour sauvegarder et quitter, 'N' de se défaire et de sortie" diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c index 58130d9383..dfcf52b3ae 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c @@ -1,987 +1,987 @@ -/** @file
-
- This library class defines a set of interfaces to customize Display module
-
-Copyright (c) 2013-2018, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-#include "CustomizedDisplayLibInternal.h"
-
-EFI_SCREEN_DESCRIPTOR gScreenDimensions;
-CHAR16 *mLibUnknownString;
-extern EFI_HII_HANDLE mCDLStringPackHandle;
-CHAR16 *mSpaceBuffer;
-#define SPACE_BUFFER_SIZE 1000
-
-//
-// Browser Global Strings
-//
-CHAR16 *gEnterString;
-CHAR16 *gEnterCommitString;
-CHAR16 *gEnterEscapeString;
-CHAR16 *gEscapeString;
-CHAR16 *gMoveHighlight;
-CHAR16 *gDecNumericInput;
-CHAR16 *gHexNumericInput;
-CHAR16 *gToggleCheckBox;
-CHAR16 *gLibEmptyString;
-CHAR16 *gAreYouSure;
-CHAR16 *gYesResponse;
-CHAR16 *gNoResponse;
-CHAR16 *gPlusString;
-CHAR16 *gMinusString;
-CHAR16 *gAdjustNumber;
-CHAR16 *gSaveChanges;
-CHAR16 *gNvUpdateMessage;
-CHAR16 *gInputErrorMessage;
-
-/**
-
- Print banner info for front page.
-
- @param[in] FormData Form Data to be shown in Page
-
-**/
-VOID
-PrintBannerInfo (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
- )
-{
- UINT8 Line;
- UINT8 Alignment;
- CHAR16 *StrFrontPageBanner;
- UINT8 RowIdx;
- UINT8 ColumnIdx;
-
- //
- // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
- //
- ClearLines (
- gScreenDimensions.LeftColumn,
- gScreenDimensions.RightColumn,
- gScreenDimensions.TopRow,
- FRONT_PAGE_HEADER_HEIGHT - 1 + gScreenDimensions.TopRow,
- BANNER_TEXT | BANNER_BACKGROUND
- );
-
- //
- // for (Line = 0; Line < BANNER_HEIGHT; Line++) {
- //
- for (Line = (UINT8)gScreenDimensions.TopRow; Line < BANNER_HEIGHT + (UINT8)gScreenDimensions.TopRow; Line++) {
- //
- // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
- //
- for (Alignment = (UINT8)gScreenDimensions.LeftColumn;
- Alignment < BANNER_COLUMNS + (UINT8)gScreenDimensions.LeftColumn;
- Alignment++
- )
- {
- RowIdx = (UINT8)(Line - (UINT8)gScreenDimensions.TopRow);
- ColumnIdx = (UINT8)(Alignment - (UINT8)gScreenDimensions.LeftColumn);
-
- ASSERT (RowIdx < BANNER_HEIGHT && ColumnIdx < BANNER_COLUMNS);
-
- if ((gBannerData != NULL) && (gBannerData->Banner[RowIdx][ColumnIdx] != 0x0000)) {
- StrFrontPageBanner = LibGetToken (gBannerData->Banner[RowIdx][ColumnIdx], FormData->HiiHandle);
- } else {
- continue;
- }
-
- switch (Alignment - gScreenDimensions.LeftColumn) {
- case 0:
- //
- // Handle left column
- //
- PrintStringAt (gScreenDimensions.LeftColumn + BANNER_LEFT_COLUMN_INDENT, Line, StrFrontPageBanner);
- break;
-
- case 1:
- //
- // Handle center column
- //
- PrintStringAt (
- gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3,
- Line,
- StrFrontPageBanner
- );
- break;
-
- case 2:
- //
- // Handle right column
- //
- PrintStringAt (
- gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) * 2 / 3,
- Line,
- StrFrontPageBanner
- );
- break;
- }
-
- FreePool (StrFrontPageBanner);
- }
- }
-}
-
-/**
- Print framework and form title for a page.
-
- @param[in] FormData Form Data to be shown in Page
-**/
-VOID
-PrintFramework (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
- )
-{
- UINTN Index;
- CHAR16 Character;
- CHAR16 *Buffer;
- UINTN Row;
- CHAR16 *TitleStr;
- UINTN TitleColumn;
-
- if (gClassOfVfr != FORMSET_CLASS_PLATFORM_SETUP) {
- //
- // Only Setup page needs Framework
- //
- ClearLines (
- gScreenDimensions.LeftColumn,
- gScreenDimensions.RightColumn,
- gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight,
- gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 1,
- KEYHELP_TEXT | KEYHELP_BACKGROUND
- );
- return;
- }
-
- Buffer = AllocateZeroPool (0x10000);
- ASSERT (Buffer != NULL);
- Character = BOXDRAW_HORIZONTAL;
- for (Index = 0; Index + 2 < (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn); Index++) {
- Buffer[Index] = Character;
- }
-
- //
- // Print Top border line
- // +------------------------------------------------------------------------------+
- // ? ?
- // +------------------------------------------------------------------------------+
- //
- gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | TITLE_BACKGROUND);
- Character = BOXDRAW_DOWN_RIGHT;
-
- PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.TopRow, Character);
- PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer);
-
- Character = BOXDRAW_DOWN_LEFT;
- PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
-
- Character = BOXDRAW_VERTICAL;
- for (Row = gScreenDimensions.TopRow + 1; Row <= gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 2; Row++) {
- PrintCharAt (gScreenDimensions.LeftColumn, Row, Character);
- PrintCharAt (gScreenDimensions.RightColumn - 1, Row, Character);
- }
-
- //
- // Print Form Title
- //
- TitleStr = LibGetToken (FormData->FormTitle, FormData->HiiHandle);
- ASSERT (TitleStr != NULL);
- TitleColumn = (gScreenDimensions.RightColumn + gScreenDimensions.LeftColumn - LibGetStringWidth (TitleStr) / 2) / 2;
- PrintStringAtWithWidth (gScreenDimensions.LeftColumn + 1, gScreenDimensions.TopRow + 1, gLibEmptyString, TitleColumn - gScreenDimensions.LeftColumn - 1);
- PrintStringAtWithWidth (
- TitleColumn,
- gScreenDimensions.TopRow + 1,
- TitleStr,
- gScreenDimensions.RightColumn - 1 - TitleColumn
- );
- FreePool (TitleStr);
-
- Character = BOXDRAW_UP_RIGHT;
- PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 1, Character);
- PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer);
-
- Character = BOXDRAW_UP_LEFT;
- PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
-
- //
- // Print Bottom border line
- // +------------------------------------------------------------------------------+
- // ? ?
- // +------------------------------------------------------------------------------+
- //
- Character = BOXDRAW_DOWN_RIGHT;
- PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, Character);
-
- PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer);
-
- Character = BOXDRAW_DOWN_LEFT;
- PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
- Character = BOXDRAW_VERTICAL;
- for (Row = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1;
- Row <= gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2;
- Row++
- )
- {
- PrintCharAt (gScreenDimensions.LeftColumn, Row, Character);
- PrintCharAt (gScreenDimensions.RightColumn - 1, Row, Character);
- }
-
- Character = BOXDRAW_UP_RIGHT;
- PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 1, Character);
-
- PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer);
-
- Character = BOXDRAW_UP_LEFT;
- PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
-
- FreePool (Buffer);
-}
-
-/**
- Process some op code which is not recognized by browser core.
-
- @param OpCodeData The pointer to the op code buffer.
-
- @return EFI_SUCCESS Pass the statement success.
-
-**/
-VOID
-ProcessUserOpcode (
- IN EFI_IFR_OP_HEADER *OpCodeData
- )
-{
- EFI_GUID *ClassGuid;
- UINT8 ClassGuidNum;
-
- ClassGuid = NULL;
- ClassGuidNum = 0;
-
- switch (OpCodeData->OpCode) {
- case EFI_IFR_FORM_SET_OP:
- //
- // process the statement outside of form,if it is formset op, get its formsetguid or classguid and compared with gFrontPageFormSetGuid
- //
- if (CompareMem (PcdGetPtr (PcdFrontPageFormSetGuid), &((EFI_IFR_FORM_SET *)OpCodeData)->Guid, sizeof (EFI_GUID)) == 0) {
- gClassOfVfr = FORMSET_CLASS_FRONT_PAGE;
- } else {
- ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)OpCodeData)->Flags & 0x3);
- ClassGuid = (EFI_GUID *)(VOID *)((UINT8 *)OpCodeData + sizeof (EFI_IFR_FORM_SET));
- while (ClassGuidNum-- > 0) {
- if (CompareGuid ((EFI_GUID *)PcdGetPtr (PcdFrontPageFormSetGuid), ClassGuid)) {
- gClassOfVfr = FORMSET_CLASS_FRONT_PAGE;
- break;
- }
-
- ClassGuid++;
- }
- }
-
- break;
-
- case EFI_IFR_GUID_OP:
- if (CompareGuid (&gEfiIfrTianoGuid, (EFI_GUID *)((CHAR8 *)OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
- //
- // Tiano specific GUIDed opcodes
- //
- switch (((EFI_IFR_GUID_LABEL *)OpCodeData)->ExtendOpCode) {
- case EFI_IFR_EXTEND_OP_LABEL:
- //
- // just ignore label
- //
- break;
-
- case EFI_IFR_EXTEND_OP_BANNER:
- //
- // Only in front page form set, we care about the banner data.
- //
- if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) {
- //
- // Initialize Driver private data
- //
- if (gBannerData == NULL) {
- gBannerData = AllocateZeroPool (sizeof (BANNER_DATA));
- ASSERT (gBannerData != NULL);
- }
-
- CopyMem (
- &gBannerData->Banner[((EFI_IFR_GUID_BANNER *)OpCodeData)->LineNumber][
- ((EFI_IFR_GUID_BANNER *)OpCodeData)->Alignment],
- &((EFI_IFR_GUID_BANNER *)OpCodeData)->Title,
- sizeof (EFI_STRING_ID)
- );
- }
-
- break;
-
- case EFI_IFR_EXTEND_OP_SUBCLASS:
- if (((EFI_IFR_GUID_SUBCLASS *)OpCodeData)->SubClass == EFI_FRONT_PAGE_SUBCLASS) {
- gClassOfVfr = FORMSET_CLASS_FRONT_PAGE;
- }
-
- break;
-
- default:
- break;
- }
- }
-
- break;
-
- default:
- break;
- }
-}
-
-/**
- Process some op codes which is out side of current form.
-
- @param FormData Pointer to the form data.
-
- @return EFI_SUCCESS Pass the statement success.
-
-**/
-VOID
-ProcessExternedOpcode (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
- )
-{
- LIST_ENTRY *Link;
- LIST_ENTRY *NestLink;
- FORM_DISPLAY_ENGINE_STATEMENT *Statement;
- FORM_DISPLAY_ENGINE_STATEMENT *NestStatement;
-
- Link = GetFirstNode (&FormData->StatementListOSF);
- while (!IsNull (&FormData->StatementListOSF, Link)) {
- Statement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link);
- Link = GetNextNode (&FormData->StatementListOSF, Link);
-
- ProcessUserOpcode (Statement->OpCode);
- }
-
- Link = GetFirstNode (&FormData->StatementListHead);
- while (!IsNull (&FormData->StatementListHead, Link)) {
- Statement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link);
- Link = GetNextNode (&FormData->StatementListHead, Link);
-
- ProcessUserOpcode (Statement->OpCode);
-
- NestLink = GetFirstNode (&Statement->NestStatementList);
- while (!IsNull (&Statement->NestStatementList, NestLink)) {
- NestStatement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink);
- NestLink = GetNextNode (&Statement->NestStatementList, NestLink);
-
- ProcessUserOpcode (NestStatement->OpCode);
- }
- }
-}
-
-/**
- Validate the input screen diemenstion info.
-
- @param FormData The input form data info.
-
- @return EFI_SUCCESS The input screen info is acceptable.
- @return EFI_INVALID_PARAMETER The input screen info is not acceptable.
-
-**/
-EFI_STATUS
-ScreenDiemensionInfoValidate (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
- )
-{
- LIST_ENTRY *Link;
- UINTN Index;
-
- //
- // Calculate total number of Register HotKeys.
- //
- Index = 0;
- if (!IsListEmpty (&FormData->HotKeyListHead)) {
- Link = GetFirstNode (&FormData->HotKeyListHead);
- while (!IsNull (&FormData->HotKeyListHead, Link)) {
- Link = GetNextNode (&FormData->HotKeyListHead, Link);
- Index++;
- }
- }
-
- //
- // Show three HotKeys help information on one row.
- //
- gFooterHeight = FOOTER_HEIGHT + (Index / 3);
-
- ZeroMem (&gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
- gST->ConOut->QueryMode (
- gST->ConOut,
- gST->ConOut->Mode->Mode,
- &gScreenDimensions.RightColumn,
- &gScreenDimensions.BottomRow
- );
-
- //
- // Check local dimension vs. global dimension.
- //
- if (FormData->ScreenDimensions != NULL) {
- if ((gScreenDimensions.RightColumn < FormData->ScreenDimensions->RightColumn) ||
- (gScreenDimensions.BottomRow < FormData->ScreenDimensions->BottomRow)
- )
- {
- return EFI_INVALID_PARAMETER;
- } else {
- //
- // Local dimension validation.
- //
- if ((FormData->ScreenDimensions->RightColumn > FormData->ScreenDimensions->LeftColumn) &&
- (FormData->ScreenDimensions->BottomRow > FormData->ScreenDimensions->TopRow) &&
- ((FormData->ScreenDimensions->RightColumn - FormData->ScreenDimensions->LeftColumn) > 2) &&
- ((FormData->ScreenDimensions->BottomRow - FormData->ScreenDimensions->TopRow) > STATUS_BAR_HEIGHT +
- FRONT_PAGE_HEADER_HEIGHT + gFooterHeight + 3))
- {
- CopyMem (&gScreenDimensions, (VOID *)FormData->ScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
- } else {
- return EFI_INVALID_PARAMETER;
- }
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Get the string based on the StringId and HII Package List Handle.
-
- @param Token The String's ID.
- @param HiiHandle The package list in the HII database to search for
- the specified string.
-
- @return The output string.
-
-**/
-CHAR16 *
-LibGetToken (
- IN EFI_STRING_ID Token,
- IN EFI_HII_HANDLE HiiHandle
- )
-{
- EFI_STRING String;
-
- String = HiiGetString (HiiHandle, Token, NULL);
- if (String == NULL) {
- String = AllocateCopyPool (StrSize (mLibUnknownString), mLibUnknownString);
- ASSERT (String != NULL);
- }
-
- return (CHAR16 *)String;
-}
-
-/**
- Count the storage space of a Unicode string.
-
- This function handles the Unicode string with NARROW_CHAR
- and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
- does not count in the resultant output. If a WIDE_CHAR is
- hit, then 2 Unicode character will consume an output storage
- space with size of CHAR16 till a NARROW_CHAR is hit.
-
- If String is NULL, then ASSERT ().
-
- @param String The input string to be counted.
-
- @return Storage space for the input string.
-
-**/
-UINTN
-LibGetStringWidth (
- IN CHAR16 *String
- )
-{
- UINTN Index;
- UINTN Count;
- UINTN IncrementValue;
-
- ASSERT (String != NULL);
- if (String == NULL) {
- return 0;
- }
-
- Index = 0;
- Count = 0;
- IncrementValue = 1;
-
- do {
- //
- // Advance to the null-terminator or to the first width directive
- //
- for ( ;
- (String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0);
- Index++, Count = Count + IncrementValue
- )
- {
- }
-
- //
- // We hit the null-terminator, we now have a count
- //
- if (String[Index] == 0) {
- break;
- }
-
- //
- // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
- // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
- //
- if (String[Index] == NARROW_CHAR) {
- //
- // Skip to the next character
- //
- Index++;
- IncrementValue = 1;
- } else {
- //
- // Skip to the next character
- //
- Index++;
- IncrementValue = 2;
- }
- } while (String[Index] != 0);
-
- //
- // Increment by one to include the null-terminator in the size
- //
- Count++;
-
- return Count * sizeof (CHAR16);
-}
-
-/**
- Show all registered HotKey help strings on bottom Rows.
-
- @param FormData The curent input form data info.
- @param SetState Set HotKey or Clear HotKey
-
-**/
-VOID
-PrintHotKeyHelpString (
- IN FORM_DISPLAY_ENGINE_FORM *FormData,
- IN BOOLEAN SetState
- )
-{
- UINTN CurrentCol;
- UINTN CurrentRow;
- UINTN BottomRowOfHotKeyHelp;
- UINTN ColumnIndexWidth;
- UINTN ColumnWidth;
- UINTN ColumnIndex;
- UINTN Index;
- EFI_SCREEN_DESCRIPTOR LocalScreen;
- LIST_ENTRY *Link;
- BROWSER_HOT_KEY *HotKey;
- CHAR16 BakChar;
- CHAR16 *ColumnStr;
-
- CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
- ColumnWidth = (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3;
- BottomRowOfHotKeyHelp = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 3;
- ColumnStr = gLibEmptyString;
-
- //
- // Calculate total number of Register HotKeys.
- //
- Index = 0;
- Link = GetFirstNode (&FormData->HotKeyListHead);
- while (!IsNull (&FormData->HotKeyListHead, Link)) {
- HotKey = BROWSER_HOT_KEY_FROM_LINK (Link);
- //
- // Calculate help information Column and Row.
- //
- ColumnIndex = Index % 3;
- if (ColumnIndex == 0) {
- CurrentCol = LocalScreen.LeftColumn + 2 * ColumnWidth;
- ColumnIndexWidth = ColumnWidth - 1;
- } else if (ColumnIndex == 1) {
- CurrentCol = LocalScreen.LeftColumn + ColumnWidth;
- ColumnIndexWidth = ColumnWidth;
- } else {
- CurrentCol = LocalScreen.LeftColumn + 2;
- ColumnIndexWidth = ColumnWidth - 2;
- }
-
- CurrentRow = BottomRowOfHotKeyHelp - Index / 3;
-
- //
- // Help string can't exceed ColumnWidth. One Row will show three Help information.
- //
- BakChar = L'\0';
- if (StrLen (HotKey->HelpString) > ColumnIndexWidth) {
- BakChar = HotKey->HelpString[ColumnIndexWidth];
- HotKey->HelpString[ColumnIndexWidth] = L'\0';
- }
-
- //
- // Print HotKey help string on bottom Row.
- //
- if (SetState) {
- ColumnStr = HotKey->HelpString;
- }
-
- PrintStringAtWithWidth (CurrentCol, CurrentRow, ColumnStr, ColumnIndexWidth);
-
- if (BakChar != L'\0') {
- HotKey->HelpString[ColumnIndexWidth] = BakChar;
- }
-
- //
- // Get Next Hot Key.
- //
- Link = GetNextNode (&FormData->HotKeyListHead, Link);
- Index++;
- }
-
- if (SetState) {
- //
- // Clear KeyHelp
- //
- CurrentRow = BottomRowOfHotKeyHelp - Index / 3;
- ColumnIndex = Index % 3;
- if (ColumnIndex == 0) {
- CurrentCol = LocalScreen.LeftColumn + 2 * ColumnWidth;
- ColumnIndexWidth = ColumnWidth - 1;
- ColumnIndex++;
- PrintStringAtWithWidth (CurrentCol, CurrentRow, gLibEmptyString, ColumnIndexWidth);
- }
-
- if (ColumnIndex == 1) {
- CurrentCol = LocalScreen.LeftColumn + ColumnWidth;
- ColumnIndexWidth = ColumnWidth;
- PrintStringAtWithWidth (CurrentCol, CurrentRow, gLibEmptyString, ColumnIndexWidth);
- }
- }
-
- return;
-}
-
-/**
- Get step info from numeric opcode.
-
- @param[in] OpCode The input numeric op code.
-
- @return step info for this opcode.
-**/
-UINT64
-LibGetFieldFromNum (
- IN EFI_IFR_OP_HEADER *OpCode
- )
-{
- EFI_IFR_NUMERIC *NumericOp;
- UINT64 Step;
-
- NumericOp = (EFI_IFR_NUMERIC *)OpCode;
-
- switch (NumericOp->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- Step = NumericOp->data.u8.Step;
- break;
-
- case EFI_IFR_NUMERIC_SIZE_2:
- Step = NumericOp->data.u16.Step;
- break;
-
- case EFI_IFR_NUMERIC_SIZE_4:
- Step = NumericOp->data.u32.Step;
- break;
-
- case EFI_IFR_NUMERIC_SIZE_8:
- Step = NumericOp->data.u64.Step;
- break;
-
- default:
- Step = 0;
- break;
- }
-
- return Step;
-}
-
-/**
- Initialize the HII String Token to the correct values.
-
-**/
-VOID
-InitializeLibStrings (
- VOID
- )
-{
- mLibUnknownString = L"!";
-
- gEnterString = LibGetToken (STRING_TOKEN (ENTER_STRING), mCDLStringPackHandle);
- gEnterCommitString = LibGetToken (STRING_TOKEN (ENTER_COMMIT_STRING), mCDLStringPackHandle);
- gEnterEscapeString = LibGetToken (STRING_TOKEN (ENTER_ESCAPE_STRING), mCDLStringPackHandle);
- gEscapeString = LibGetToken (STRING_TOKEN (ESCAPE_STRING), mCDLStringPackHandle);
- gMoveHighlight = LibGetToken (STRING_TOKEN (MOVE_HIGHLIGHT), mCDLStringPackHandle);
- gDecNumericInput = LibGetToken (STRING_TOKEN (DEC_NUMERIC_INPUT), mCDLStringPackHandle);
- gHexNumericInput = LibGetToken (STRING_TOKEN (HEX_NUMERIC_INPUT), mCDLStringPackHandle);
- gToggleCheckBox = LibGetToken (STRING_TOKEN (TOGGLE_CHECK_BOX), mCDLStringPackHandle);
-
- gAreYouSure = LibGetToken (STRING_TOKEN (ARE_YOU_SURE), mCDLStringPackHandle);
- gYesResponse = LibGetToken (STRING_TOKEN (ARE_YOU_SURE_YES), mCDLStringPackHandle);
- gNoResponse = LibGetToken (STRING_TOKEN (ARE_YOU_SURE_NO), mCDLStringPackHandle);
- gPlusString = LibGetToken (STRING_TOKEN (PLUS_STRING), mCDLStringPackHandle);
- gMinusString = LibGetToken (STRING_TOKEN (MINUS_STRING), mCDLStringPackHandle);
- gAdjustNumber = LibGetToken (STRING_TOKEN (ADJUST_NUMBER), mCDLStringPackHandle);
- gSaveChanges = LibGetToken (STRING_TOKEN (SAVE_CHANGES), mCDLStringPackHandle);
-
- gLibEmptyString = LibGetToken (STRING_TOKEN (EMPTY_STRING), mCDLStringPackHandle);
-
- gNvUpdateMessage = LibGetToken (STRING_TOKEN (NV_UPDATE_MESSAGE), mCDLStringPackHandle);
- gInputErrorMessage = LibGetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE), mCDLStringPackHandle);
-
- //
- // SpaceBuffer;
- //
- mSpaceBuffer = AllocatePool ((SPACE_BUFFER_SIZE + 1) * sizeof (CHAR16));
- ASSERT (mSpaceBuffer != NULL);
- LibSetUnicodeMem (mSpaceBuffer, SPACE_BUFFER_SIZE, L' ');
- mSpaceBuffer[SPACE_BUFFER_SIZE] = L'\0';
-}
-
-/**
- Free the HII String.
-
-**/
-VOID
-FreeLibStrings (
- VOID
- )
-{
- FreePool (gEnterString);
- FreePool (gEnterCommitString);
- FreePool (gEnterEscapeString);
- FreePool (gEscapeString);
- FreePool (gMoveHighlight);
- FreePool (gDecNumericInput);
- FreePool (gHexNumericInput);
- FreePool (gToggleCheckBox);
-
- FreePool (gAreYouSure);
- FreePool (gYesResponse);
- FreePool (gNoResponse);
- FreePool (gPlusString);
- FreePool (gMinusString);
- FreePool (gAdjustNumber);
- FreePool (gSaveChanges);
-
- FreePool (gLibEmptyString);
-
- FreePool (gNvUpdateMessage);
- FreePool (gInputErrorMessage);
-
- FreePool (mSpaceBuffer);
-}
-
-/**
- Wait for a key to be pressed by user.
-
- @param Key The key which is pressed by user.
-
- @retval EFI_SUCCESS The function always completed successfully.
-
-**/
-EFI_STATUS
-WaitForKeyStroke (
- OUT EFI_INPUT_KEY *Key
- )
-{
- EFI_STATUS Status;
- UINTN Index;
-
- while (TRUE) {
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key);
- if (!EFI_ERROR (Status)) {
- break;
- }
-
- if (Status != EFI_NOT_READY) {
- continue;
- }
-
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
- }
-
- return Status;
-}
-
-/**
- Set Buffer to Value for Size bytes.
-
- @param Buffer Memory to set.
- @param Size Number of bytes to set
- @param Value Value of the set operation.
-
-**/
-VOID
-LibSetUnicodeMem (
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR16 Value
- )
-{
- CHAR16 *Ptr;
-
- Ptr = Buffer;
- while ((Size--) != 0) {
- *(Ptr++) = Value;
- }
-}
-
-/**
- The internal function prints to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
- protocol instance.
-
- @param Width Width of string to be print.
- @param Column The position of the output string.
- @param Row The position of the output string.
- @param Out The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
- @param Fmt The format string.
- @param Args The additional argument for the variables in the format string.
-
- @return Number of Unicode character printed.
-
-**/
-UINTN
-PrintInternal (
- IN UINTN Width,
- IN UINTN Column,
- IN UINTN Row,
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Out,
- IN CHAR16 *Fmt,
- IN VA_LIST Args
- )
-{
- CHAR16 *Buffer;
- CHAR16 *BackupBuffer;
- UINTN Index;
- UINTN PreviousIndex;
- UINTN Count;
- UINTN TotalCount;
- UINTN PrintWidth;
- UINTN CharWidth;
-
- //
- // For now, allocate an arbitrarily long buffer
- //
- Buffer = AllocateZeroPool (0x10000);
- BackupBuffer = AllocateZeroPool (0x10000);
- ASSERT (Buffer);
- ASSERT (BackupBuffer);
-
- if (Column != (UINTN)-1) {
- Out->SetCursorPosition (Out, Column, Row);
- }
-
- UnicodeVSPrint (Buffer, 0x10000, Fmt, Args);
-
- Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;
-
- Out->SetAttribute (Out, Out->Mode->Attribute);
-
- Index = 0;
- PreviousIndex = 0;
- Count = 0;
- TotalCount = 0;
- PrintWidth = 0;
- CharWidth = 1;
-
- do {
- for ( ; (Buffer[Index] != NARROW_CHAR) && (Buffer[Index] != WIDE_CHAR) && (Buffer[Index] != 0); Index++) {
- BackupBuffer[Index] = Buffer[Index];
- }
-
- if (Buffer[Index] == 0) {
- break;
- }
-
- //
- // Print this out, we are about to switch widths
- //
- Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
- Count = StrLen (&BackupBuffer[PreviousIndex]);
- PrintWidth += Count * CharWidth;
- TotalCount += Count;
-
- //
- // Preserve the current index + 1, since this is where we will start printing from next
- //
- PreviousIndex = Index + 1;
-
- //
- // We are at a narrow or wide character directive. Set attributes and strip it and print it
- //
- if (Buffer[Index] == NARROW_CHAR) {
- //
- // Preserve bits 0 - 6 and zero out the rest
- //
- Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;
- Out->SetAttribute (Out, Out->Mode->Attribute);
- CharWidth = 1;
- } else {
- //
- // Must be wide, set bit 7 ON
- //
- Out->Mode->Attribute = Out->Mode->Attribute | EFI_WIDE_ATTRIBUTE;
- Out->SetAttribute (Out, Out->Mode->Attribute);
- CharWidth = 2;
- }
-
- Index++;
- } while (Buffer[Index] != 0);
-
- //
- // We hit the end of the string - print it
- //
- Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
- Count = StrLen (&BackupBuffer[PreviousIndex]);
- PrintWidth += Count * CharWidth;
- TotalCount += Count;
- if (PrintWidth < Width) {
- Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;
- Out->SetAttribute (Out, Out->Mode->Attribute);
- Out->OutputString (Out, &mSpaceBuffer[SPACE_BUFFER_SIZE - Width + PrintWidth]);
- }
-
- FreePool (Buffer);
- FreePool (BackupBuffer);
- return TotalCount;
-}
-
-/**
- Prints a formatted unicode string to the default console, at
- the supplied cursor position.
-
- @param Width Width of String to be printed.
- @param Column The cursor position to print the string at.
- @param Row The cursor position to print the string at.
- @param Fmt Format string.
- @param ... Variable argument list for format string.
-
- @return Length of string printed to the console
-
-**/
-UINTN
-EFIAPI
-PrintAt (
- IN UINTN Width,
- IN UINTN Column,
- IN UINTN Row,
- IN CHAR16 *Fmt,
- ...
- )
-{
- VA_LIST Args;
- UINTN LengthOfPrinted;
-
- VA_START (Args, Fmt);
- LengthOfPrinted = PrintInternal (Width, Column, Row, gST->ConOut, Fmt, Args);
- VA_END (Args);
- return LengthOfPrinted;
-}
+/** @file + + This library class defines a set of interfaces to customize Display module + +Copyright (c) 2013-2018, Intel Corporation. All rights reserved.<BR> +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include "CustomizedDisplayLibInternal.h" + +EFI_SCREEN_DESCRIPTOR gScreenDimensions; +CHAR16 *mLibUnknownString; +extern EFI_HII_HANDLE mCDLStringPackHandle; +CHAR16 *mSpaceBuffer; +#define SPACE_BUFFER_SIZE 1000 + +// +// Browser Global Strings +// +CHAR16 *gEnterString; +CHAR16 *gEnterCommitString; +CHAR16 *gEnterEscapeString; +CHAR16 *gEscapeString; +CHAR16 *gMoveHighlight; +CHAR16 *gDecNumericInput; +CHAR16 *gHexNumericInput; +CHAR16 *gToggleCheckBox; +CHAR16 *gLibEmptyString; +CHAR16 *gAreYouSure; +CHAR16 *gYesResponse; +CHAR16 *gNoResponse; +CHAR16 *gPlusString; +CHAR16 *gMinusString; +CHAR16 *gAdjustNumber; +CHAR16 *gSaveChanges; +CHAR16 *gNvUpdateMessage; +CHAR16 *gInputErrorMessage; + +/** + + Print banner info for front page. + + @param[in] FormData Form Data to be shown in Page + +**/ +VOID +PrintBannerInfo ( + IN FORM_DISPLAY_ENGINE_FORM *FormData + ) +{ + UINT8 Line; + UINT8 Alignment; + CHAR16 *StrFrontPageBanner; + UINT8 RowIdx; + UINT8 ColumnIdx; + + // + // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND); + // + ClearLines ( + gScreenDimensions.LeftColumn, + gScreenDimensions.RightColumn, + gScreenDimensions.TopRow, + FRONT_PAGE_HEADER_HEIGHT - 1 + gScreenDimensions.TopRow, + BANNER_TEXT | BANNER_BACKGROUND + ); + + // + // for (Line = 0; Line < BANNER_HEIGHT; Line++) { + // + for (Line = (UINT8)gScreenDimensions.TopRow; Line < BANNER_HEIGHT + (UINT8)gScreenDimensions.TopRow; Line++) { + // + // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) { + // + for (Alignment = (UINT8)gScreenDimensions.LeftColumn; + Alignment < BANNER_COLUMNS + (UINT8)gScreenDimensions.LeftColumn; + Alignment++ + ) + { + RowIdx = (UINT8)(Line - (UINT8)gScreenDimensions.TopRow); + ColumnIdx = (UINT8)(Alignment - (UINT8)gScreenDimensions.LeftColumn); + + ASSERT (RowIdx < BANNER_HEIGHT && ColumnIdx < BANNER_COLUMNS); + + if ((gBannerData != NULL) && (gBannerData->Banner[RowIdx][ColumnIdx] != 0x0000)) { + StrFrontPageBanner = LibGetToken (gBannerData->Banner[RowIdx][ColumnIdx], FormData->HiiHandle); + } else { + continue; + } + + switch (Alignment - gScreenDimensions.LeftColumn) { + case 0: + // + // Handle left column + // + PrintStringAt (gScreenDimensions.LeftColumn + BANNER_LEFT_COLUMN_INDENT, Line, StrFrontPageBanner); + break; + + case 1: + // + // Handle center column + // + PrintStringAt ( + gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3, + Line, + StrFrontPageBanner + ); + break; + + case 2: + // + // Handle right column + // + PrintStringAt ( + gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) * 2 / 3, + Line, + StrFrontPageBanner + ); + break; + } + + FreePool (StrFrontPageBanner); + } + } +} + +/** + Print framework and form title for a page. + + @param[in] FormData Form Data to be shown in Page +**/ +VOID +PrintFramework ( + IN FORM_DISPLAY_ENGINE_FORM *FormData + ) +{ + UINTN Index; + CHAR16 Character; + CHAR16 *Buffer; + UINTN Row; + CHAR16 *TitleStr; + UINTN TitleColumn; + + if (gClassOfVfr != FORMSET_CLASS_PLATFORM_SETUP) { + // + // Only Setup page needs Framework + // + ClearLines ( + gScreenDimensions.LeftColumn, + gScreenDimensions.RightColumn, + gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, + gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 1, + KEYHELP_TEXT | KEYHELP_BACKGROUND + ); + return; + } + + Buffer = AllocateZeroPool (0x10000); + ASSERT (Buffer != NULL); + Character = BOXDRAW_HORIZONTAL; + for (Index = 0; Index + 2 < (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn); Index++) { + Buffer[Index] = Character; + } + + // + // Print Top border line + // +------------------------------------------------------------------------------+ + // ? ? + // +------------------------------------------------------------------------------+ + // + gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | TITLE_BACKGROUND); + Character = BOXDRAW_DOWN_RIGHT; + + PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.TopRow, Character); + PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer); + + Character = BOXDRAW_DOWN_LEFT; + PrintCharAt ((UINTN)-1, (UINTN)-1, Character); + + Character = BOXDRAW_VERTICAL; + for (Row = gScreenDimensions.TopRow + 1; Row <= gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 2; Row++) { + PrintCharAt (gScreenDimensions.LeftColumn, Row, Character); + PrintCharAt (gScreenDimensions.RightColumn - 1, Row, Character); + } + + // + // Print Form Title + // + TitleStr = LibGetToken (FormData->FormTitle, FormData->HiiHandle); + ASSERT (TitleStr != NULL); + TitleColumn = (gScreenDimensions.RightColumn + gScreenDimensions.LeftColumn - LibGetStringWidth (TitleStr) / 2) / 2; + PrintStringAtWithWidth (gScreenDimensions.LeftColumn + 1, gScreenDimensions.TopRow + 1, gLibEmptyString, TitleColumn - gScreenDimensions.LeftColumn - 1); + PrintStringAtWithWidth ( + TitleColumn, + gScreenDimensions.TopRow + 1, + TitleStr, + gScreenDimensions.RightColumn - 1 - TitleColumn + ); + FreePool (TitleStr); + + Character = BOXDRAW_UP_RIGHT; + PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 1, Character); + PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer); + + Character = BOXDRAW_UP_LEFT; + PrintCharAt ((UINTN)-1, (UINTN)-1, Character); + + // + // Print Bottom border line + // +------------------------------------------------------------------------------+ + // ? ? + // +------------------------------------------------------------------------------+ + // + Character = BOXDRAW_DOWN_RIGHT; + PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, Character); + + PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer); + + Character = BOXDRAW_DOWN_LEFT; + PrintCharAt ((UINTN)-1, (UINTN)-1, Character); + Character = BOXDRAW_VERTICAL; + for (Row = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1; + Row <= gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2; + Row++ + ) + { + PrintCharAt (gScreenDimensions.LeftColumn, Row, Character); + PrintCharAt (gScreenDimensions.RightColumn - 1, Row, Character); + } + + Character = BOXDRAW_UP_RIGHT; + PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 1, Character); + + PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer); + + Character = BOXDRAW_UP_LEFT; + PrintCharAt ((UINTN)-1, (UINTN)-1, Character); + + FreePool (Buffer); +} + +/** + Process some op code which is not recognized by browser core. + + @param OpCodeData The pointer to the op code buffer. + + @return EFI_SUCCESS Pass the statement success. + +**/ +VOID +ProcessUserOpcode ( + IN EFI_IFR_OP_HEADER *OpCodeData + ) +{ + EFI_GUID *ClassGuid; + UINT8 ClassGuidNum; + + ClassGuid = NULL; + ClassGuidNum = 0; + + switch (OpCodeData->OpCode) { + case EFI_IFR_FORM_SET_OP: + // + // process the statement outside of form,if it is formset op, get its formsetguid or classguid and compared with gFrontPageFormSetGuid + // + if (CompareMem (PcdGetPtr (PcdFrontPageFormSetGuid), &((EFI_IFR_FORM_SET *)OpCodeData)->Guid, sizeof (EFI_GUID)) == 0) { + gClassOfVfr = FORMSET_CLASS_FRONT_PAGE; + } else { + ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)OpCodeData)->Flags & 0x3); + ClassGuid = (EFI_GUID *)(VOID *)((UINT8 *)OpCodeData + sizeof (EFI_IFR_FORM_SET)); + while (ClassGuidNum-- > 0) { + if (CompareGuid ((EFI_GUID *)PcdGetPtr (PcdFrontPageFormSetGuid), ClassGuid)) { + gClassOfVfr = FORMSET_CLASS_FRONT_PAGE; + break; + } + + ClassGuid++; + } + } + + break; + + case EFI_IFR_GUID_OP: + if (CompareGuid (&gEfiIfrTianoGuid, (EFI_GUID *)((CHAR8 *)OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) { + // + // Tiano specific GUIDed opcodes + // + switch (((EFI_IFR_GUID_LABEL *)OpCodeData)->ExtendOpCode) { + case EFI_IFR_EXTEND_OP_LABEL: + // + // just ignore label + // + break; + + case EFI_IFR_EXTEND_OP_BANNER: + // + // Only in front page form set, we care about the banner data. + // + if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) { + // + // Initialize Driver private data + // + if (gBannerData == NULL) { + gBannerData = AllocateZeroPool (sizeof (BANNER_DATA)); + ASSERT (gBannerData != NULL); + } + + CopyMem ( + &gBannerData->Banner[((EFI_IFR_GUID_BANNER *)OpCodeData)->LineNumber][ + ((EFI_IFR_GUID_BANNER *)OpCodeData)->Alignment], + &((EFI_IFR_GUID_BANNER *)OpCodeData)->Title, + sizeof (EFI_STRING_ID) + ); + } + + break; + + case EFI_IFR_EXTEND_OP_SUBCLASS: + if (((EFI_IFR_GUID_SUBCLASS *)OpCodeData)->SubClass == EFI_FRONT_PAGE_SUBCLASS) { + gClassOfVfr = FORMSET_CLASS_FRONT_PAGE; + } + + break; + + default: + break; + } + } + + break; + + default: + break; + } +} + +/** + Process some op codes which is out side of current form. + + @param FormData Pointer to the form data. + + @return EFI_SUCCESS Pass the statement success. + +**/ +VOID +ProcessExternedOpcode ( + IN FORM_DISPLAY_ENGINE_FORM *FormData + ) +{ + LIST_ENTRY *Link; + LIST_ENTRY *NestLink; + FORM_DISPLAY_ENGINE_STATEMENT *Statement; + FORM_DISPLAY_ENGINE_STATEMENT *NestStatement; + + Link = GetFirstNode (&FormData->StatementListOSF); + while (!IsNull (&FormData->StatementListOSF, Link)) { + Statement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link); + Link = GetNextNode (&FormData->StatementListOSF, Link); + + ProcessUserOpcode (Statement->OpCode); + } + + Link = GetFirstNode (&FormData->StatementListHead); + while (!IsNull (&FormData->StatementListHead, Link)) { + Statement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link); + Link = GetNextNode (&FormData->StatementListHead, Link); + + ProcessUserOpcode (Statement->OpCode); + + NestLink = GetFirstNode (&Statement->NestStatementList); + while (!IsNull (&Statement->NestStatementList, NestLink)) { + NestStatement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink); + NestLink = GetNextNode (&Statement->NestStatementList, NestLink); + + ProcessUserOpcode (NestStatement->OpCode); + } + } +} + +/** + Validate the input screen diemenstion info. + + @param FormData The input form data info. + + @return EFI_SUCCESS The input screen info is acceptable. + @return EFI_INVALID_PARAMETER The input screen info is not acceptable. + +**/ +EFI_STATUS +ScreenDiemensionInfoValidate ( + IN FORM_DISPLAY_ENGINE_FORM *FormData + ) +{ + LIST_ENTRY *Link; + UINTN Index; + + // + // Calculate total number of Register HotKeys. + // + Index = 0; + if (!IsListEmpty (&FormData->HotKeyListHead)) { + Link = GetFirstNode (&FormData->HotKeyListHead); + while (!IsNull (&FormData->HotKeyListHead, Link)) { + Link = GetNextNode (&FormData->HotKeyListHead, Link); + Index++; + } + } + + // + // Show three HotKeys help information on one row. + // + gFooterHeight = FOOTER_HEIGHT + (Index / 3); + + ZeroMem (&gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); + gST->ConOut->QueryMode ( + gST->ConOut, + gST->ConOut->Mode->Mode, + &gScreenDimensions.RightColumn, + &gScreenDimensions.BottomRow + ); + + // + // Check local dimension vs. global dimension. + // + if (FormData->ScreenDimensions != NULL) { + if ((gScreenDimensions.RightColumn < FormData->ScreenDimensions->RightColumn) || + (gScreenDimensions.BottomRow < FormData->ScreenDimensions->BottomRow) + ) + { + return EFI_INVALID_PARAMETER; + } else { + // + // Local dimension validation. + // + if ((FormData->ScreenDimensions->RightColumn > FormData->ScreenDimensions->LeftColumn) && + (FormData->ScreenDimensions->BottomRow > FormData->ScreenDimensions->TopRow) && + ((FormData->ScreenDimensions->RightColumn - FormData->ScreenDimensions->LeftColumn) > 2) && + ((FormData->ScreenDimensions->BottomRow - FormData->ScreenDimensions->TopRow) > STATUS_BAR_HEIGHT + + FRONT_PAGE_HEADER_HEIGHT + gFooterHeight + 3)) + { + CopyMem (&gScreenDimensions, (VOID *)FormData->ScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); + } else { + return EFI_INVALID_PARAMETER; + } + } + } + + return EFI_SUCCESS; +} + +/** + Get the string based on the StringId and HII Package List Handle. + + @param Token The String's ID. + @param HiiHandle The package list in the HII database to search for + the specified string. + + @return The output string. + +**/ +CHAR16 * +LibGetToken ( + IN EFI_STRING_ID Token, + IN EFI_HII_HANDLE HiiHandle + ) +{ + EFI_STRING String; + + String = HiiGetString (HiiHandle, Token, NULL); + if (String == NULL) { + String = AllocateCopyPool (StrSize (mLibUnknownString), mLibUnknownString); + ASSERT (String != NULL); + } + + return (CHAR16 *)String; +} + +/** + Count the storage space of a Unicode string. + + This function handles the Unicode string with NARROW_CHAR + and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR + does not count in the resultant output. If a WIDE_CHAR is + hit, then 2 Unicode character will consume an output storage + space with size of CHAR16 till a NARROW_CHAR is hit. + + If String is NULL, then ASSERT (). + + @param String The input string to be counted. + + @return Storage space for the input string. + +**/ +UINTN +LibGetStringWidth ( + IN CHAR16 *String + ) +{ + UINTN Index; + UINTN Count; + UINTN IncrementValue; + + ASSERT (String != NULL); + if (String == NULL) { + return 0; + } + + Index = 0; + Count = 0; + IncrementValue = 1; + + do { + // + // Advance to the null-terminator or to the first width directive + // + for ( ; + (String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0); + Index++, Count = Count + IncrementValue + ) + { + } + + // + // We hit the null-terminator, we now have a count + // + if (String[Index] == 0) { + break; + } + + // + // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed + // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2) + // + if (String[Index] == NARROW_CHAR) { + // + // Skip to the next character + // + Index++; + IncrementValue = 1; + } else { + // + // Skip to the next character + // + Index++; + IncrementValue = 2; + } + } while (String[Index] != 0); + + // + // Increment by one to include the null-terminator in the size + // + Count++; + + return Count * sizeof (CHAR16); +} + +/** + Show all registered HotKey help strings on bottom Rows. + + @param FormData The curent input form data info. + @param SetState Set HotKey or Clear HotKey + +**/ +VOID +PrintHotKeyHelpString ( + IN FORM_DISPLAY_ENGINE_FORM *FormData, + IN BOOLEAN SetState + ) +{ + UINTN CurrentCol; + UINTN CurrentRow; + UINTN BottomRowOfHotKeyHelp; + UINTN ColumnIndexWidth; + UINTN ColumnWidth; + UINTN ColumnIndex; + UINTN Index; + EFI_SCREEN_DESCRIPTOR LocalScreen; + LIST_ENTRY *Link; + BROWSER_HOT_KEY *HotKey; + CHAR16 BakChar; + CHAR16 *ColumnStr; + + CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); + ColumnWidth = (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3; + BottomRowOfHotKeyHelp = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 3; + ColumnStr = gLibEmptyString; + + // + // Calculate total number of Register HotKeys. + // + Index = 0; + Link = GetFirstNode (&FormData->HotKeyListHead); + while (!IsNull (&FormData->HotKeyListHead, Link)) { + HotKey = BROWSER_HOT_KEY_FROM_LINK (Link); + // + // Calculate help information Column and Row. + // + ColumnIndex = Index % 3; + if (ColumnIndex == 0) { + CurrentCol = LocalScreen.LeftColumn + 2 * ColumnWidth; + ColumnIndexWidth = ColumnWidth - 1; + } else if (ColumnIndex == 1) { + CurrentCol = LocalScreen.LeftColumn + ColumnWidth; + ColumnIndexWidth = ColumnWidth; + } else { + CurrentCol = LocalScreen.LeftColumn + 2; + ColumnIndexWidth = ColumnWidth - 2; + } + + CurrentRow = BottomRowOfHotKeyHelp - Index / 3; + + // + // Help string can't exceed ColumnWidth. One Row will show three Help information. + // + BakChar = L'\0'; + if (StrLen (HotKey->HelpString) > ColumnIndexWidth) { + BakChar = HotKey->HelpString[ColumnIndexWidth]; + HotKey->HelpString[ColumnIndexWidth] = L'\0'; + } + + // + // Print HotKey help string on bottom Row. + // + if (SetState) { + ColumnStr = HotKey->HelpString; + } + + PrintStringAtWithWidth (CurrentCol, CurrentRow, ColumnStr, ColumnIndexWidth); + + if (BakChar != L'\0') { + HotKey->HelpString[ColumnIndexWidth] = BakChar; + } + + // + // Get Next Hot Key. + // + Link = GetNextNode (&FormData->HotKeyListHead, Link); + Index++; + } + + if (SetState) { + // + // Clear KeyHelp + // + CurrentRow = BottomRowOfHotKeyHelp - Index / 3; + ColumnIndex = Index % 3; + if (ColumnIndex == 0) { + CurrentCol = LocalScreen.LeftColumn + 2 * ColumnWidth; + ColumnIndexWidth = ColumnWidth - 1; + ColumnIndex++; + PrintStringAtWithWidth (CurrentCol, CurrentRow, gLibEmptyString, ColumnIndexWidth); + } + + if (ColumnIndex == 1) { + CurrentCol = LocalScreen.LeftColumn + ColumnWidth; + ColumnIndexWidth = ColumnWidth; + PrintStringAtWithWidth (CurrentCol, CurrentRow, gLibEmptyString, ColumnIndexWidth); + } + } + + return; +} + +/** + Get step info from numeric opcode. + + @param[in] OpCode The input numeric op code. + + @return step info for this opcode. +**/ +UINT64 +LibGetFieldFromNum ( + IN EFI_IFR_OP_HEADER *OpCode + ) +{ + EFI_IFR_NUMERIC *NumericOp; + UINT64 Step; + + NumericOp = (EFI_IFR_NUMERIC *)OpCode; + + switch (NumericOp->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + Step = NumericOp->data.u8.Step; + break; + + case EFI_IFR_NUMERIC_SIZE_2: + Step = NumericOp->data.u16.Step; + break; + + case EFI_IFR_NUMERIC_SIZE_4: + Step = NumericOp->data.u32.Step; + break; + + case EFI_IFR_NUMERIC_SIZE_8: + Step = NumericOp->data.u64.Step; + break; + + default: + Step = 0; + break; + } + + return Step; +} + +/** + Initialize the HII String Token to the correct values. + +**/ +VOID +InitializeLibStrings ( + VOID + ) +{ + mLibUnknownString = L"!"; + + gEnterString = LibGetToken (STRING_TOKEN (ENTER_STRING), mCDLStringPackHandle); + gEnterCommitString = LibGetToken (STRING_TOKEN (ENTER_COMMIT_STRING), mCDLStringPackHandle); + gEnterEscapeString = LibGetToken (STRING_TOKEN (ENTER_ESCAPE_STRING), mCDLStringPackHandle); + gEscapeString = LibGetToken (STRING_TOKEN (ESCAPE_STRING), mCDLStringPackHandle); + gMoveHighlight = LibGetToken (STRING_TOKEN (MOVE_HIGHLIGHT), mCDLStringPackHandle); + gDecNumericInput = LibGetToken (STRING_TOKEN (DEC_NUMERIC_INPUT), mCDLStringPackHandle); + gHexNumericInput = LibGetToken (STRING_TOKEN (HEX_NUMERIC_INPUT), mCDLStringPackHandle); + gToggleCheckBox = LibGetToken (STRING_TOKEN (TOGGLE_CHECK_BOX), mCDLStringPackHandle); + + gAreYouSure = LibGetToken (STRING_TOKEN (ARE_YOU_SURE), mCDLStringPackHandle); + gYesResponse = LibGetToken (STRING_TOKEN (ARE_YOU_SURE_YES), mCDLStringPackHandle); + gNoResponse = LibGetToken (STRING_TOKEN (ARE_YOU_SURE_NO), mCDLStringPackHandle); + gPlusString = LibGetToken (STRING_TOKEN (PLUS_STRING), mCDLStringPackHandle); + gMinusString = LibGetToken (STRING_TOKEN (MINUS_STRING), mCDLStringPackHandle); + gAdjustNumber = LibGetToken (STRING_TOKEN (ADJUST_NUMBER), mCDLStringPackHandle); + gSaveChanges = LibGetToken (STRING_TOKEN (SAVE_CHANGES), mCDLStringPackHandle); + + gLibEmptyString = LibGetToken (STRING_TOKEN (EMPTY_STRING), mCDLStringPackHandle); + + gNvUpdateMessage = LibGetToken (STRING_TOKEN (NV_UPDATE_MESSAGE), mCDLStringPackHandle); + gInputErrorMessage = LibGetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE), mCDLStringPackHandle); + + // + // SpaceBuffer; + // + mSpaceBuffer = AllocatePool ((SPACE_BUFFER_SIZE + 1) * sizeof (CHAR16)); + ASSERT (mSpaceBuffer != NULL); + LibSetUnicodeMem (mSpaceBuffer, SPACE_BUFFER_SIZE, L' '); + mSpaceBuffer[SPACE_BUFFER_SIZE] = L'\0'; +} + +/** + Free the HII String. + +**/ +VOID +FreeLibStrings ( + VOID + ) +{ + FreePool (gEnterString); + FreePool (gEnterCommitString); + FreePool (gEnterEscapeString); + FreePool (gEscapeString); + FreePool (gMoveHighlight); + FreePool (gDecNumericInput); + FreePool (gHexNumericInput); + FreePool (gToggleCheckBox); + + FreePool (gAreYouSure); + FreePool (gYesResponse); + FreePool (gNoResponse); + FreePool (gPlusString); + FreePool (gMinusString); + FreePool (gAdjustNumber); + FreePool (gSaveChanges); + + FreePool (gLibEmptyString); + + FreePool (gNvUpdateMessage); + FreePool (gInputErrorMessage); + + FreePool (mSpaceBuffer); +} + +/** + Wait for a key to be pressed by user. + + @param Key The key which is pressed by user. + + @retval EFI_SUCCESS The function always completed successfully. + +**/ +EFI_STATUS +WaitForKeyStroke ( + OUT EFI_INPUT_KEY *Key + ) +{ + EFI_STATUS Status; + UINTN Index; + + while (TRUE) { + Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key); + if (!EFI_ERROR (Status)) { + break; + } + + if (Status != EFI_NOT_READY) { + continue; + } + + gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index); + } + + return Status; +} + +/** + Set Buffer to Value for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + @param Value Value of the set operation. + +**/ +VOID +LibSetUnicodeMem ( + IN VOID *Buffer, + IN UINTN Size, + IN CHAR16 Value + ) +{ + CHAR16 *Ptr; + + Ptr = Buffer; + while ((Size--) != 0) { + *(Ptr++) = Value; + } +} + +/** + The internal function prints to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL + protocol instance. + + @param Width Width of string to be print. + @param Column The position of the output string. + @param Row The position of the output string. + @param Out The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance. + @param Fmt The format string. + @param Args The additional argument for the variables in the format string. + + @return Number of Unicode character printed. + +**/ +UINTN +PrintInternal ( + IN UINTN Width, + IN UINTN Column, + IN UINTN Row, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Out, + IN CHAR16 *Fmt, + IN VA_LIST Args + ) +{ + CHAR16 *Buffer; + CHAR16 *BackupBuffer; + UINTN Index; + UINTN PreviousIndex; + UINTN Count; + UINTN TotalCount; + UINTN PrintWidth; + UINTN CharWidth; + + // + // For now, allocate an arbitrarily long buffer + // + Buffer = AllocateZeroPool (0x10000); + BackupBuffer = AllocateZeroPool (0x10000); + ASSERT (Buffer); + ASSERT (BackupBuffer); + + if (Column != (UINTN)-1) { + Out->SetCursorPosition (Out, Column, Row); + } + + UnicodeVSPrint (Buffer, 0x10000, Fmt, Args); + + Out->Mode->Attribute = Out->Mode->Attribute & 0x7f; + + Out->SetAttribute (Out, Out->Mode->Attribute); + + Index = 0; + PreviousIndex = 0; + Count = 0; + TotalCount = 0; + PrintWidth = 0; + CharWidth = 1; + + do { + for ( ; (Buffer[Index] != NARROW_CHAR) && (Buffer[Index] != WIDE_CHAR) && (Buffer[Index] != 0); Index++) { + BackupBuffer[Index] = Buffer[Index]; + } + + if (Buffer[Index] == 0) { + break; + } + + // + // Print this out, we are about to switch widths + // + Out->OutputString (Out, &BackupBuffer[PreviousIndex]); + Count = StrLen (&BackupBuffer[PreviousIndex]); + PrintWidth += Count * CharWidth; + TotalCount += Count; + + // + // Preserve the current index + 1, since this is where we will start printing from next + // + PreviousIndex = Index + 1; + + // + // We are at a narrow or wide character directive. Set attributes and strip it and print it + // + if (Buffer[Index] == NARROW_CHAR) { + // + // Preserve bits 0 - 6 and zero out the rest + // + Out->Mode->Attribute = Out->Mode->Attribute & 0x7f; + Out->SetAttribute (Out, Out->Mode->Attribute); + CharWidth = 1; + } else { + // + // Must be wide, set bit 7 ON + // + Out->Mode->Attribute = Out->Mode->Attribute | EFI_WIDE_ATTRIBUTE; + Out->SetAttribute (Out, Out->Mode->Attribute); + CharWidth = 2; + } + + Index++; + } while (Buffer[Index] != 0); + + // + // We hit the end of the string - print it + // + Out->OutputString (Out, &BackupBuffer[PreviousIndex]); + Count = StrLen (&BackupBuffer[PreviousIndex]); + PrintWidth += Count * CharWidth; + TotalCount += Count; + if (PrintWidth < Width) { + Out->Mode->Attribute = Out->Mode->Attribute & 0x7f; + Out->SetAttribute (Out, Out->Mode->Attribute); + Out->OutputString (Out, &mSpaceBuffer[SPACE_BUFFER_SIZE - Width + PrintWidth]); + } + + FreePool (Buffer); + FreePool (BackupBuffer); + return TotalCount; +} + +/** + Prints a formatted unicode string to the default console, at + the supplied cursor position. + + @param Width Width of String to be printed. + @param Column The cursor position to print the string at. + @param Row The cursor position to print the string at. + @param Fmt Format string. + @param ... Variable argument list for format string. + + @return Length of string printed to the console + +**/ +UINTN +EFIAPI +PrintAt ( + IN UINTN Width, + IN UINTN Column, + IN UINTN Row, + IN CHAR16 *Fmt, + ... + ) +{ + VA_LIST Args; + UINTN LengthOfPrinted; + + VA_START (Args, Fmt); + LengthOfPrinted = PrintInternal (Width, Column, Row, gST->ConOut, Fmt, Args); + VA_END (Args); + return LengthOfPrinted; +} diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h index 01213cb059..7b8177a21d 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h @@ -1,287 +1,287 @@ -/** @file
-
- This library class defines a set of interfaces to customize Display module
-
-Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __CUSTOMIZED_DISPLAY_LIB_INTERNAL_H__
-#define __CUSTOMIZED_DISPLAY_LIB_INTERNAL_H__
-
-#include <PiDxe.h>
-
-#include <Protocol/SimpleTextOut.h>
-#include <Protocol/SimpleTextIn.h>
-#include <Protocol/FormBrowser2.h>
-#include <Protocol/FormBrowserEx2.h>
-#include <Protocol/DisplayProtocol.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/UnicodeCollation.h>
-#include <Protocol/HiiConfigAccess.h>
-#include <Protocol/HiiConfigRouting.h>
-#include <Protocol/HiiDatabase.h>
-#include <Protocol/HiiString.h>
-#include <Protocol/UserManager.h>
-#include <Protocol/DevicePathFromText.h>
-
-#include <Guid/MdeModuleHii.h>
-#include <Guid/HiiPlatformSetupFormset.h>
-#include <Guid/HiiFormMapMethodGuid.h>
-
-#include <Library/PrintLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/HiiLib.h>
-#include <Library/PcdLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/CustomizedDisplayLib.h>
-
-#include "Colors.h"
-
-#define FORMSET_CLASS_PLATFORM_SETUP 0x0001
-#define FORMSET_CLASS_FRONT_PAGE 0x0002
-
-#define FRONT_PAGE_HEADER_HEIGHT 6
-#define NONE_FRONT_PAGE_HEADER_HEIGHT 3
-#define FOOTER_HEIGHT 4
-#define STATUS_BAR_HEIGHT 1
-
-//
-// Screen definitions
-//
-#define BANNER_HEIGHT 6
-#define BANNER_COLUMNS 3
-#define BANNER_LEFT_COLUMN_INDENT 1
-
-//
-// Character definitions
-//
-#define UPPER_LOWER_CASE_OFFSET 0x20
-
-//
-// This is the Input Error Message
-//
-#define INPUT_ERROR 1
-
-//
-// This is the NV RAM update required Message
-//
-#define NV_UPDATE_REQUIRED 2
-
-typedef struct {
- EFI_STRING_ID Banner[BANNER_HEIGHT][BANNER_COLUMNS];
-} BANNER_DATA;
-
-extern UINT16 gClassOfVfr; // Formset class information
-extern BANNER_DATA *gBannerData;
-extern EFI_SCREEN_DESCRIPTOR gScreenDimensions;
-extern UINTN gFooterHeight;
-
-//
-// Browser Global Strings
-//
-extern CHAR16 *gEnterString;
-extern CHAR16 *gEnterCommitString;
-extern CHAR16 *gEnterEscapeString;
-extern CHAR16 *gEscapeString;
-extern CHAR16 *gMoveHighlight;
-extern CHAR16 *gDecNumericInput;
-extern CHAR16 *gHexNumericInput;
-extern CHAR16 *gToggleCheckBox;
-extern CHAR16 *gLibEmptyString;
-extern CHAR16 *gAreYouSure;
-extern CHAR16 *gYesResponse;
-extern CHAR16 *gNoResponse;
-extern CHAR16 *gPlusString;
-extern CHAR16 *gMinusString;
-extern CHAR16 *gAdjustNumber;
-extern CHAR16 *gSaveChanges;
-extern CHAR16 *gNvUpdateMessage;
-extern CHAR16 *gInputErrorMessage;
-
-/**
-
- Print banner info for front page.
-
- @param[in] FormData Form Data to be shown in Page
-
-**/
-VOID
-PrintBannerInfo (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
- );
-
-/**
- Print framework and form title for a page.
-
- @param[in] FormData Form Data to be shown in Page
-**/
-VOID
-PrintFramework (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
- );
-
-/**
- Validate the input screen diemenstion info.
-
- @param FormData The input form data info.
-
- @return EFI_SUCCESS The input screen info is acceptable.
- @return EFI_INVALID_PARAMETER The input screen info is not acceptable.
-
-**/
-EFI_STATUS
-ScreenDiemensionInfoValidate (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
- );
-
-/**
- Get the string based on the StringId and HII Package List Handle.
-
- @param Token The String's ID.
- @param HiiHandle The package list in the HII database to search for
- the specified string.
-
- @return The output string.
-
-**/
-CHAR16 *
-LibGetToken (
- IN EFI_STRING_ID Token,
- IN EFI_HII_HANDLE HiiHandle
- );
-
-/**
- Count the storage space of a Unicode string.
-
- This function handles the Unicode string with NARROW_CHAR
- and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
- does not count in the resultant output. If a WIDE_CHAR is
- hit, then 2 Unicode character will consume an output storage
- space with size of CHAR16 till a NARROW_CHAR is hit.
-
- If String is NULL, then ASSERT ().
-
- @param String The input string to be counted.
-
- @return Storage space for the input string.
-
-**/
-UINTN
-LibGetStringWidth (
- IN CHAR16 *String
- );
-
-/**
- Show all registered HotKey help strings on bottom Rows.
-
- @param FormData The curent input form data info.
- @param SetState Set HotKey or Clear HotKey
-
-**/
-VOID
-PrintHotKeyHelpString (
- IN FORM_DISPLAY_ENGINE_FORM *FormData,
- IN BOOLEAN SetState
- );
-
-/**
- Get step info from numeric opcode.
-
- @param[in] OpCode The input numeric op code.
-
- @return step info for this opcode.
-**/
-UINT64
-LibGetFieldFromNum (
- IN EFI_IFR_OP_HEADER *OpCode
- );
-
-/**
- Initialize the HII String Token to the correct values.
-
-**/
-VOID
-InitializeLibStrings (
- VOID
- );
-
-/**
- Free the HII String.
-
-**/
-VOID
-FreeLibStrings (
- VOID
- );
-
-/**
- Wait for a key to be pressed by user.
-
- @param Key The key which is pressed by user.
-
- @retval EFI_SUCCESS The function always completed successfully.
-
-**/
-EFI_STATUS
-WaitForKeyStroke (
- OUT EFI_INPUT_KEY *Key
- );
-
-/**
- Set Buffer to Value for Size bytes.
-
- @param Buffer Memory to set.
- @param Size Number of bytes to set
- @param Value Value of the set operation.
-
-**/
-VOID
-LibSetUnicodeMem (
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR16 Value
- );
-
-/**
- Prints a formatted unicode string to the default console, at
- the supplied cursor position.
-
- @param Width Width of String to be printed.
- @param Column The cursor position to print the string at.
- @param Row The cursor position to print the string at.
- @param Fmt Format string.
- @param ... Variable argument list for format string.
-
- @return Length of string printed to the console
-
-**/
-UINTN
-EFIAPI
-PrintAt (
- IN UINTN Width,
- IN UINTN Column,
- IN UINTN Row,
- IN CHAR16 *Fmt,
- ...
- );
-
-/**
- Process some op codes which is out side of current form.
-
- @param FormData Pointer to the form data.
-
-**/
-VOID
-ProcessExternedOpcode (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
- );
-
-#endif
+/** @file + + This library class defines a set of interfaces to customize Display module + +Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR> +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __CUSTOMIZED_DISPLAY_LIB_INTERNAL_H__ +#define __CUSTOMIZED_DISPLAY_LIB_INTERNAL_H__ + +#include <PiDxe.h> + +#include <Protocol/SimpleTextOut.h> +#include <Protocol/SimpleTextIn.h> +#include <Protocol/FormBrowser2.h> +#include <Protocol/FormBrowserEx2.h> +#include <Protocol/DisplayProtocol.h> +#include <Protocol/DevicePath.h> +#include <Protocol/UnicodeCollation.h> +#include <Protocol/HiiConfigAccess.h> +#include <Protocol/HiiConfigRouting.h> +#include <Protocol/HiiDatabase.h> +#include <Protocol/HiiString.h> +#include <Protocol/UserManager.h> +#include <Protocol/DevicePathFromText.h> + +#include <Guid/MdeModuleHii.h> +#include <Guid/HiiPlatformSetupFormset.h> +#include <Guid/HiiFormMapMethodGuid.h> + +#include <Library/PrintLib.h> +#include <Library/DebugLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/UefiRuntimeServicesTableLib.h> +#include <Library/UefiDriverEntryPoint.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/BaseLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/HiiLib.h> +#include <Library/PcdLib.h> +#include <Library/DevicePathLib.h> +#include <Library/CustomizedDisplayLib.h> + +#include "Colors.h" + +#define FORMSET_CLASS_PLATFORM_SETUP 0x0001 +#define FORMSET_CLASS_FRONT_PAGE 0x0002 + +#define FRONT_PAGE_HEADER_HEIGHT 6 +#define NONE_FRONT_PAGE_HEADER_HEIGHT 3 +#define FOOTER_HEIGHT 4 +#define STATUS_BAR_HEIGHT 1 + +// +// Screen definitions +// +#define BANNER_HEIGHT 6 +#define BANNER_COLUMNS 3 +#define BANNER_LEFT_COLUMN_INDENT 1 + +// +// Character definitions +// +#define UPPER_LOWER_CASE_OFFSET 0x20 + +// +// This is the Input Error Message +// +#define INPUT_ERROR 1 + +// +// This is the NV RAM update required Message +// +#define NV_UPDATE_REQUIRED 2 + +typedef struct { + EFI_STRING_ID Banner[BANNER_HEIGHT][BANNER_COLUMNS]; +} BANNER_DATA; + +extern UINT16 gClassOfVfr; // Formset class information +extern BANNER_DATA *gBannerData; +extern EFI_SCREEN_DESCRIPTOR gScreenDimensions; +extern UINTN gFooterHeight; + +// +// Browser Global Strings +// +extern CHAR16 *gEnterString; +extern CHAR16 *gEnterCommitString; +extern CHAR16 *gEnterEscapeString; +extern CHAR16 *gEscapeString; +extern CHAR16 *gMoveHighlight; +extern CHAR16 *gDecNumericInput; +extern CHAR16 *gHexNumericInput; +extern CHAR16 *gToggleCheckBox; +extern CHAR16 *gLibEmptyString; +extern CHAR16 *gAreYouSure; +extern CHAR16 *gYesResponse; +extern CHAR16 *gNoResponse; +extern CHAR16 *gPlusString; +extern CHAR16 *gMinusString; +extern CHAR16 *gAdjustNumber; +extern CHAR16 *gSaveChanges; +extern CHAR16 *gNvUpdateMessage; +extern CHAR16 *gInputErrorMessage; + +/** + + Print banner info for front page. + + @param[in] FormData Form Data to be shown in Page + +**/ +VOID +PrintBannerInfo ( + IN FORM_DISPLAY_ENGINE_FORM *FormData + ); + +/** + Print framework and form title for a page. + + @param[in] FormData Form Data to be shown in Page +**/ +VOID +PrintFramework ( + IN FORM_DISPLAY_ENGINE_FORM *FormData + ); + +/** + Validate the input screen diemenstion info. + + @param FormData The input form data info. + + @return EFI_SUCCESS The input screen info is acceptable. + @return EFI_INVALID_PARAMETER The input screen info is not acceptable. + +**/ +EFI_STATUS +ScreenDiemensionInfoValidate ( + IN FORM_DISPLAY_ENGINE_FORM *FormData + ); + +/** + Get the string based on the StringId and HII Package List Handle. + + @param Token The String's ID. + @param HiiHandle The package list in the HII database to search for + the specified string. + + @return The output string. + +**/ +CHAR16 * +LibGetToken ( + IN EFI_STRING_ID Token, + IN EFI_HII_HANDLE HiiHandle + ); + +/** + Count the storage space of a Unicode string. + + This function handles the Unicode string with NARROW_CHAR + and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR + does not count in the resultant output. If a WIDE_CHAR is + hit, then 2 Unicode character will consume an output storage + space with size of CHAR16 till a NARROW_CHAR is hit. + + If String is NULL, then ASSERT (). + + @param String The input string to be counted. + + @return Storage space for the input string. + +**/ +UINTN +LibGetStringWidth ( + IN CHAR16 *String + ); + +/** + Show all registered HotKey help strings on bottom Rows. + + @param FormData The curent input form data info. + @param SetState Set HotKey or Clear HotKey + +**/ +VOID +PrintHotKeyHelpString ( + IN FORM_DISPLAY_ENGINE_FORM *FormData, + IN BOOLEAN SetState + ); + +/** + Get step info from numeric opcode. + + @param[in] OpCode The input numeric op code. + + @return step info for this opcode. +**/ +UINT64 +LibGetFieldFromNum ( + IN EFI_IFR_OP_HEADER *OpCode + ); + +/** + Initialize the HII String Token to the correct values. + +**/ +VOID +InitializeLibStrings ( + VOID + ); + +/** + Free the HII String. + +**/ +VOID +FreeLibStrings ( + VOID + ); + +/** + Wait for a key to be pressed by user. + + @param Key The key which is pressed by user. + + @retval EFI_SUCCESS The function always completed successfully. + +**/ +EFI_STATUS +WaitForKeyStroke ( + OUT EFI_INPUT_KEY *Key + ); + +/** + Set Buffer to Value for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + @param Value Value of the set operation. + +**/ +VOID +LibSetUnicodeMem ( + IN VOID *Buffer, + IN UINTN Size, + IN CHAR16 Value + ); + +/** + Prints a formatted unicode string to the default console, at + the supplied cursor position. + + @param Width Width of String to be printed. + @param Column The cursor position to print the string at. + @param Row The cursor position to print the string at. + @param Fmt Format string. + @param ... Variable argument list for format string. + + @return Length of string printed to the console + +**/ +UINTN +EFIAPI +PrintAt ( + IN UINTN Width, + IN UINTN Column, + IN UINTN Row, + IN CHAR16 *Fmt, + ... + ); + +/** + Process some op codes which is out side of current form. + + @param FormData Pointer to the form data. + +**/ +VOID +ProcessExternedOpcode ( + IN FORM_DISPLAY_ENGINE_FORM *FormData + ); + +#endif diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibModStrs.uni b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibModStrs.uni index f73da2150a..1267c4cb76 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibModStrs.uni +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibModStrs.uni @@ -1,18 +1,18 @@ -// /** @file
-// CustomizedDisplayLib Module Localized Abstract and Description Content
-//
-// Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT
-#language en-US
-"Customize display library used by display engine."
-
-#string STR_MODULE_DESCRIPTION
-#language en-US
-"Customize display library used by display engine."
-
+// /** @file +// CustomizedDisplayLib Module Localized Abstract and Description Content +// +// Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR> +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + + +#string STR_MODULE_ABSTRACT +#language en-US +"Customize display library used by display engine." + +#string STR_MODULE_DESCRIPTION +#language en-US +"Customize display library used by display engine." + |
