X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FSetupBrowserDxe%2FPresentation.c;h=863097d00540aa77fa7fa97c467f80be5e56380f;hb=41ff10dc06ae11f5e47094c67f1160a29dd8851c;hp=f41ac58feb6508f9152e72482ea1dff6eef93c83;hpb=e24adb18e330ff25dd35a278f0f8593378e14668;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index f41ac58feb..863097d005 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -1,7 +1,7 @@ /** @file Utility functions for UI presentation. -Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -182,10 +182,13 @@ GetStringWidth ( /** This function displays the page frame. + @param Selection Selection contains the information about + the Selection, form and formset to be displayed. + Selection action may be updated in retrieve callback. **/ VOID DisplayPageFrame ( - VOID + IN UI_MENU_SELECTION *Selection ) { UINTN Index; @@ -203,6 +206,10 @@ DisplayPageFrame ( gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &LocalScreen.RightColumn, &LocalScreen.BottomRow); ClearLines (0, LocalScreen.RightColumn, 0, LocalScreen.BottomRow, KEYHELP_BACKGROUND); + if (Selection->Form->ModalForm) { + return; + } + CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); // @@ -259,7 +266,7 @@ DisplayPageFrame ( // // Handle left column // - PrintStringAt (LocalScreen.LeftColumn, Line, StrFrontPageBanner); + PrintStringAt (LocalScreen.LeftColumn + BANNER_LEFT_COLUMN_INDENT, Line, StrFrontPageBanner); break; case 1: @@ -484,7 +491,11 @@ DisplayForm ( StringPtr = GetToken (Selection->Form->FormTitle, Handle); if ((gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) != FORMSET_CLASS_FRONT_PAGE) { - gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | TITLE_BACKGROUND); + if (Selection->Form->ModalForm) { + gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | EFI_BACKGROUND_BLACK); + } else { + gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | TITLE_BACKGROUND); + } PrintStringAt ( (LocalScreen.RightColumn + LocalScreen.LeftColumn - GetStringWidth (StringPtr) / 2) / 2, LocalScreen.TopRow + 1, @@ -673,6 +684,12 @@ UpdateKeyHelp ( EFI_SCREEN_DESCRIPTOR LocalScreen; FORM_BROWSER_STATEMENT *Statement; + gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND); + + if (Selection->Form->ModalForm) { + return; + } + CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); SecCol = LocalScreen.LeftColumn + (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3; @@ -684,8 +701,6 @@ UpdateKeyHelp ( TopRowOfHelp = LocalScreen.BottomRow - 4; BottomRowOfHelp = LocalScreen.BottomRow - 3; - gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND); - Statement = MenuOption->ThisTag; switch (Statement->Operand) { case EFI_IFR_ORDERED_LIST_OP: @@ -773,6 +788,7 @@ UpdateKeyHelp ( case EFI_IFR_TEXT_OP: case EFI_IFR_ACTION_OP: case EFI_IFR_RESET_BUTTON_OP: + case EFI_IFR_SUBTITLE_OP: ClearLines (LeftColumnOfHelp, RightColumnOfHelp, TopRowOfHelp, BottomRowOfHelp, KEYHELP_TEXT | KEYHELP_BACKGROUND); if (!Selected) { @@ -785,7 +801,7 @@ UpdateKeyHelp ( } PrintAt (StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); - if (Statement->Operand != EFI_IFR_TEXT_OP) { + if (Statement->Operand != EFI_IFR_TEXT_OP && Statement->Operand != EFI_IFR_SUBTITLE_OP) { PrintStringAt (SecCol, BottomRowOfHelp, gEnterString); } } else { @@ -846,6 +862,337 @@ FormUpdateNotify ( return EFI_SUCCESS; } +/** + check whether the formset need to update the NV. + + @param FormSet FormSet data structure. + + @retval TRUE Need to update the NV. + @retval FALSE No need to update the NV. +**/ +BOOLEAN +IsNvUpdateRequired ( + IN FORM_BROWSER_FORMSET *FormSet + ) +{ + LIST_ENTRY *Link; + FORM_BROWSER_FORM *Form; + + Link = GetFirstNode (&FormSet->FormListHead); + while (!IsNull (&FormSet->FormListHead, Link)) { + Form = FORM_BROWSER_FORM_FROM_LINK (Link); + + if (Form->NvUpdateRequired ) { + return TRUE; + } + + Link = GetNextNode (&FormSet->FormListHead, Link); + } + + return FALSE; +} + +/** + check whether the formset need to update the NV. + + @param FormSet FormSet data structure. + @param SetValue Whether set new value or clear old value. + +**/ +VOID +UpdateNvInfoInForm ( + IN FORM_BROWSER_FORMSET *FormSet, + IN BOOLEAN SetValue + ) +{ + LIST_ENTRY *Link; + FORM_BROWSER_FORM *Form; + + Link = GetFirstNode (&FormSet->FormListHead); + while (!IsNull (&FormSet->FormListHead, Link)) { + Form = FORM_BROWSER_FORM_FROM_LINK (Link); + + Form->NvUpdateRequired = SetValue; + + Link = GetNextNode (&FormSet->FormListHead, Link); + } +} +/** + Find menu which will show next time. + + @param Selection On input, Selection tell setup browser the information + about the Selection, form and formset to be displayed. + On output, Selection return the screen item that is selected + by user. + @param Repaint Whether need to repaint the menu. + @param NewLine Whether need to show at new line. + + @retval TRUE Need return. + @retval FALSE No need to return. +**/ +BOOLEAN +FindNextMenu ( + IN OUT UI_MENU_SELECTION *Selection, + IN BOOLEAN *Repaint, + IN BOOLEAN *NewLine + ) +{ + UI_MENU_LIST *CurrentMenu; + CHAR16 YesResponse; + CHAR16 NoResponse; + EFI_INPUT_KEY Key; + EFI_STATUS Status; + + CurrentMenu = Selection->CurrentMenu; + + if (CurrentMenu != NULL && CurrentMenu->Parent != NULL) { + // + // we have a parent, so go to the parent menu + // + if (CompareGuid (&CurrentMenu->FormSetGuid, &CurrentMenu->Parent->FormSetGuid)) { + // + // The parent menu and current menu are in the same formset + // + Selection->Action = UI_ACTION_REFRESH_FORM; + } else { + Selection->Action = UI_ACTION_REFRESH_FORMSET; + } + Selection->Statement = NULL; + + Selection->FormId = CurrentMenu->Parent->FormId; + Selection->QuestionId = CurrentMenu->Parent->QuestionId; + + // + // Clear highlight record for this menu + // + CurrentMenu->QuestionId = 0; + return FALSE; + } + + if ((gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) == FORMSET_CLASS_FRONT_PAGE) { + // + // We never exit FrontPage, so skip the ESC + // + Selection->Action = UI_ACTION_NONE; + return FALSE; + } + + // + // We are going to leave current FormSet, so check uncommited data in this FormSet + // + if (IsNvUpdateRequired(Selection->FormSet)) { + Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); + + YesResponse = gYesResponse[0]; + NoResponse = gNoResponse[0]; + + // + // If NV flag is up, prompt user + // + do { + CreateDialog (4, TRUE, 0, NULL, &Key, gEmptyString, gSaveChanges, gAreYouSure, gEmptyString); + } 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) { + // + // User hits the ESC key + // + if (Repaint != NULL) { + *Repaint = TRUE; + } + + if (NewLine != NULL) { + *NewLine = TRUE; + } + + Selection->Action = UI_ACTION_NONE; + return FALSE; + } + + // + // If the user hits the YesResponse key + // + if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) { + Status = SubmitForm (Selection->FormSet, Selection->Form, FALSE); + } + } + + Selection->Statement = NULL; + if (CurrentMenu != NULL) { + CurrentMenu->QuestionId = 0; + } + + Selection->Action = UI_ACTION_EXIT; + return TRUE; +} + +/** + Call the call back function for the question and process the return action. + + @param Selection On input, Selection tell setup browser the information + about the Selection, form and formset to be displayed. + On output, Selection return the screen item that is selected + by user. + @param Question The Question which need to call. + @param Action The action request. + @param SkipSaveOrDiscard Whether skip save or discard action. + + @retval EFI_SUCCESS The call back function excutes successfully. + @return Other value if the call back function failed to excute. +**/ +EFI_STATUS +ProcessCallBackFunction ( + IN OUT UI_MENU_SELECTION *Selection, + IN FORM_BROWSER_STATEMENT *Question, + IN EFI_BROWSER_ACTION Action, + IN BOOLEAN SkipSaveOrDiscard + ) +{ + EFI_STATUS Status; + EFI_BROWSER_ACTION_REQUEST ActionRequest; + EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; + EFI_HII_VALUE *HiiValue; + EFI_IFR_TYPE_VALUE *TypeValue; + FORM_BROWSER_STATEMENT *Statement; + BOOLEAN SubmitFormIsRequired; + BOOLEAN SingleForm; + BOOLEAN DiscardFormIsRequired; + BOOLEAN NeedExit; + LIST_ENTRY *Link; + + ConfigAccess = Selection->FormSet->ConfigAccess; + SubmitFormIsRequired = FALSE; + SingleForm = FALSE; + DiscardFormIsRequired = FALSE; + NeedExit = FALSE; + Status = EFI_SUCCESS; + ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; + + if (ConfigAccess == NULL) { + return EFI_SUCCESS; + } + + Link = GetFirstNode (&Selection->Form->StatementListHead); + while (!IsNull (&Selection->Form->StatementListHead, Link)) { + Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link); + Link = GetNextNode (&Selection->Form->StatementListHead, Link); + + // + // if Question != NULL, only process the question. Else, process all question in this form. + // + if ((Question != NULL) && (Statement != Question)) { + continue; + } + + if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) { + continue; + } + + // + // Check whether Statement is disabled. + // + if (Statement->DisableExpression != NULL) { + Status = EvaluateExpression (Selection->FormSet, Selection->Form, Statement->DisableExpression); + if (!EFI_ERROR (Status) && + (Statement->DisableExpression->Result.Type == EFI_IFR_TYPE_BOOLEAN) && + (Statement->DisableExpression->Result.Value.b)) { + continue; + } + } + + HiiValue = &Statement->HiiValue; + TypeValue = &HiiValue->Value; + if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) { + // + // For OrderedList, passing in the value buffer to Callback() + // + TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue; + } + + ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; + Status = ConfigAccess->Callback ( + ConfigAccess, + Action, + Statement->QuestionId, + HiiValue->Type, + TypeValue, + &ActionRequest + ); + if (!EFI_ERROR (Status)) { + switch (ActionRequest) { + case EFI_BROWSER_ACTION_REQUEST_RESET: + gResetRequired = TRUE; + break; + + case EFI_BROWSER_ACTION_REQUEST_SUBMIT: + SubmitFormIsRequired = TRUE; + break; + + case EFI_BROWSER_ACTION_REQUEST_EXIT: + Selection->Action = UI_ACTION_EXIT; + break; + + case EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT: + SubmitFormIsRequired = TRUE; + SingleForm = TRUE; + NeedExit = TRUE; + break; + + case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT: + DiscardFormIsRequired = TRUE; + SingleForm = TRUE; + NeedExit = TRUE; + break; + + case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY: + SubmitFormIsRequired = TRUE; + SingleForm = TRUE; + break; + + case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD: + DiscardFormIsRequired = TRUE; + SingleForm = TRUE; + break; + + default: + break; + } + + // + // According the spec, return value from call back of "changing" and + // "retrieve" should update to the question's temp buffer. + // + if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) { + SetQuestionValue(Selection->FormSet, Selection->Form, Statement, TRUE); + } + } else if (Status == EFI_UNSUPPORTED) { + // + // If return EFI_UNSUPPORTED, also consider Hii driver suceess deal with it. + // + Status = EFI_SUCCESS; + } + } + + if (SubmitFormIsRequired && !SkipSaveOrDiscard) { + SubmitForm (Selection->FormSet, Selection->Form, SingleForm); + } + + if (DiscardFormIsRequired && !SkipSaveOrDiscard) { + DiscardForm (Selection->FormSet, Selection->Form, SingleForm); + } + + if (NeedExit) { + FindNextMenu (Selection, NULL, NULL); + } + + return Status; +} + /** The worker function that send the displays to the screen. On output, the selection made by user is returned. @@ -866,15 +1213,11 @@ SetupBrowser ( { EFI_STATUS Status; LIST_ENTRY *Link; - EFI_BROWSER_ACTION_REQUEST ActionRequest; EFI_HANDLE NotifyHandle; - EFI_HII_VALUE *HiiValue; - EFI_IFR_TYPE_VALUE *TypeValue; FORM_BROWSER_STATEMENT *Statement; EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; FORM_BROWSER_FORMSET *FormSet; EFI_INPUT_KEY Key; - BOOLEAN SubmitFormIsRequired; gMenuRefreshHead = NULL; gResetRequired = FALSE; @@ -973,64 +1316,11 @@ SetupBrowser ( CopyGuid (&mCurrentFormSetGuid, &Selection->FormSetGuid); mCurrentFormId = Selection->FormId; - // - // Go through each statement in this form - // - SubmitFormIsRequired = FALSE; - Link = GetFirstNode (&Selection->Form->StatementListHead); - while (!IsNull (&Selection->Form->StatementListHead, Link)) { - Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link); - Link = GetNextNode (&Selection->Form->StatementListHead, Link); - - if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) { - continue; - } - - // - // Check whether Statement is disabled. - // - if (Statement->DisableExpression != NULL) { - Status = EvaluateExpression (Selection->FormSet, Selection->Form, Statement->DisableExpression); - if (!EFI_ERROR (Status) && - (Statement->DisableExpression->Result.Type == EFI_IFR_TYPE_BOOLEAN) && - (Statement->DisableExpression->Result.Value.b)) { - continue; - } - } - - ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; - Status = ConfigAccess->Callback ( - ConfigAccess, - EFI_BROWSER_ACTION_FORM_OPEN, - Statement->QuestionId, - EFI_IFR_TYPE_UNDEFINED, - NULL, - &ActionRequest - ); - - if (!EFI_ERROR (Status)) { - switch (ActionRequest) { - case EFI_BROWSER_ACTION_REQUEST_RESET: - gResetRequired = TRUE; - break; - - case EFI_BROWSER_ACTION_REQUEST_SUBMIT: - SubmitFormIsRequired = TRUE; - break; - - case EFI_BROWSER_ACTION_REQUEST_EXIT: - Selection->Action = UI_ACTION_EXIT; - gNvUpdateRequired = FALSE; - break; - - default: - break; - } - } - } - if (SubmitFormIsRequired) { - SubmitForm (Selection->FormSet, Selection->Form); + Status = ProcessCallBackFunction (Selection, NULL, EFI_BROWSER_ACTION_FORM_OPEN, FALSE); + if (EFI_ERROR (Status)) { + goto Done; } + // // EXIT requests to close form. // @@ -1043,7 +1333,7 @@ SetupBrowser ( if (mHiiPackageListUpdated) { Selection->Action = UI_ACTION_REFRESH_FORMSET; mHiiPackageListUpdated = FALSE; - goto Done; + break; } } @@ -1067,13 +1357,13 @@ SetupBrowser ( if (mHiiPackageListUpdated) { Selection->Action = UI_ACTION_REFRESH_FORMSET; mHiiPackageListUpdated = FALSE; - goto Done; + break; } // // Displays the Header and Footer borders // - DisplayPageFrame (); + DisplayPageFrame (Selection); // // Display form @@ -1101,49 +1391,19 @@ SetupBrowser ( ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) && (Statement->Operand != EFI_IFR_PASSWORD_OP)) { - ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; - - HiiValue = &Statement->HiiValue; - TypeValue = &HiiValue->Value; - if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) { + Status = ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGING, FALSE); + if (Statement->Operand == EFI_IFR_REF_OP && Selection->Action != UI_ACTION_EXIT) { // - // For OrderedList, passing in the value buffer to Callback() + // Process dynamic update ref opcode. // - TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue; - } - - Status = ConfigAccess->Callback ( - ConfigAccess, - EFI_BROWSER_ACTION_CHANGING, - Statement->QuestionId, - HiiValue->Type, - TypeValue, - &ActionRequest - ); - - if (!EFI_ERROR (Status)) { - switch (ActionRequest) { - case EFI_BROWSER_ACTION_REQUEST_RESET: - gResetRequired = TRUE; - break; - - case EFI_BROWSER_ACTION_REQUEST_SUBMIT: - SubmitForm (Selection->FormSet, Selection->Form); - break; - - case EFI_BROWSER_ACTION_REQUEST_EXIT: - Selection->Action = UI_ACTION_EXIT; - gNvUpdateRequired = FALSE; - break; - - default: - break; + if (!EFI_ERROR (Status)) { + Status = ProcessGotoOpCode(Statement, Selection, NULL, NULL); } - } else if (Status != EFI_UNSUPPORTED) { + // - // Callback return error status other than EFI_UNSUPPORTED + // Callback return error status or status return from process goto opcode. // - if (Statement->Operand == EFI_IFR_REF_OP) { + if (EFI_ERROR (Status)) { // // Cross reference will not be taken // @@ -1174,51 +1434,10 @@ SetupBrowser ( (Selection->Handle != mCurrentHiiHandle) || (!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid)) || (Selection->FormId != mCurrentFormId))) { - // - // Go through each statement in this form - // - SubmitFormIsRequired = FALSE; - Link = GetFirstNode (&Selection->Form->StatementListHead); - while (!IsNull (&Selection->Form->StatementListHead, Link)) { - Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link); - Link = GetNextNode (&Selection->Form->StatementListHead, Link); - - if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) { - continue; - } - ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; - Status = ConfigAccess->Callback ( - ConfigAccess, - EFI_BROWSER_ACTION_FORM_CLOSE, - Statement->QuestionId, - EFI_IFR_TYPE_UNDEFINED, - NULL, - &ActionRequest - ); - - if (!EFI_ERROR (Status)) { - switch (ActionRequest) { - case EFI_BROWSER_ACTION_REQUEST_RESET: - gResetRequired = TRUE; - break; - - case EFI_BROWSER_ACTION_REQUEST_SUBMIT: - SubmitFormIsRequired = TRUE; - break; - - case EFI_BROWSER_ACTION_REQUEST_EXIT: - Selection->Action = UI_ACTION_EXIT; - gNvUpdateRequired = FALSE; - break; - - default: - break; - } - } - } - if (SubmitFormIsRequired) { - SubmitForm (Selection->FormSet, Selection->Form); + Status = ProcessCallBackFunction (Selection, NULL, EFI_BROWSER_ACTION_FORM_CLOSE, FALSE); + if (EFI_ERROR (Status)) { + goto Done; } } } while (Selection->Action == UI_ACTION_REFRESH_FORM);