X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FSetupBrowserDxe%2FPresentation.c;h=4cd71e5d440d04e8653243361d9d1b705045c99d;hb=253616154506e17ebd02c076f240748f57e36ac2;hp=94ba2399507c9f3df520f4e46d98fc5474be6082;hpb=b18e7050464b0809e0c8366219447e87c9124551;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 94ba239950..4cd71e5d44 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 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2013, 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)); // @@ -293,7 +300,7 @@ DisplayPageFrame ( ClearLines ( LocalScreen.LeftColumn, LocalScreen.RightColumn, - LocalScreen.BottomRow - STATUS_BAR_HEIGHT - FOOTER_HEIGHT, + LocalScreen.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 1, KEYHELP_TEXT | KEYHELP_BACKGROUND ); @@ -341,14 +348,14 @@ DisplayPageFrame ( // +------------------------------------------------------------------------------+ // Character = BOXDRAW_DOWN_RIGHT; - PrintCharAt (LocalScreen.LeftColumn, LocalScreen.BottomRow - STATUS_BAR_HEIGHT - FOOTER_HEIGHT, Character); + PrintCharAt (LocalScreen.LeftColumn, LocalScreen.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, Character); PrintString (Buffer); Character = BOXDRAW_DOWN_LEFT; PrintChar (Character); Character = BOXDRAW_VERTICAL; - for (Row = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - FOOTER_HEIGHT + 1; + for (Row = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1; Row <= LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 2; Row++ ) { @@ -461,7 +468,6 @@ DisplayForm ( CHAR16 *StringPtr; UINT16 MenuItemCount; EFI_HII_HANDLE Handle; - BOOLEAN Suppress; EFI_SCREEN_DESCRIPTOR LocalScreen; UINT16 Width; UINTN ArrayEntry; @@ -471,6 +477,7 @@ DisplayForm ( UINT16 NumberOfLines; EFI_STATUS Status; UI_MENU_OPTION *MenuOption; + UINT16 GlyphWidth; Handle = Selection->Handle; MenuItemCount = 0; @@ -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, @@ -510,24 +521,16 @@ DisplayForm ( while (!IsNull (&Selection->Form->StatementListHead, Link)) { Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link); - if (Statement->SuppressExpression != NULL) { - Suppress = Statement->SuppressExpression->Result.Value.b; - } else { - Suppress = FALSE; - } - - if (Statement->DisableExpression != NULL) { - Suppress = (BOOLEAN) (Suppress || Statement->DisableExpression->Result.Value.b); - } - - if (!Suppress) { + if (EvaluateExpressionList(Statement->Expression, FALSE, NULL, NULL) <= ExpressGrayOut) { StringPtr = GetToken (Statement->Prompt, Handle); + ASSERT (StringPtr != NULL); Width = GetWidth (Statement, Handle); NumberOfLines = 1; ArrayEntry = 0; - for (; GetLineByWidth (StringPtr, Width, &ArrayEntry, &OutputString) != 0x0000;) { + GlyphWidth = 1; + for (; GetLineByWidth (StringPtr, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) { // // If there is more string to process print on the next row and increment the Skip value // @@ -542,7 +545,7 @@ DisplayForm ( // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do // it in UiFreeMenu. // - MenuOption = UiAddMenuOption (StringPtr, Selection->Handle, Statement, NumberOfLines, MenuItemCount); + MenuOption = UiAddMenuOption (StringPtr, Selection->Handle, Selection->Form, Statement, NumberOfLines, MenuItemCount); MenuItemCount++; if (MenuOption->IsQuestion && !MenuOption->ReadOnly) { @@ -572,13 +575,10 @@ InitializeBrowserStrings ( VOID ) { - gFunctionNineString = GetToken (STRING_TOKEN (FUNCTION_NINE_STRING), gHiiHandle); - gFunctionTenString = GetToken (STRING_TOKEN (FUNCTION_TEN_STRING), gHiiHandle); gEnterString = GetToken (STRING_TOKEN (ENTER_STRING), gHiiHandle); gEnterCommitString = GetToken (STRING_TOKEN (ENTER_COMMIT_STRING), gHiiHandle); gEnterEscapeString = GetToken (STRING_TOKEN (ENTER_ESCAPE_STRING), gHiiHandle); gEscapeString = GetToken (STRING_TOKEN (ESCAPE_STRING), gHiiHandle); - gSaveFailed = GetToken (STRING_TOKEN (SAVE_FAILED), gHiiHandle); gMoveHighlight = GetToken (STRING_TOKEN (MOVE_HIGHLIGHT), gHiiHandle); gMakeSelection = GetToken (STRING_TOKEN (MAKE_SELECTION), gHiiHandle); gDecNumericInput = GetToken (STRING_TOKEN (DEC_NUMERIC_INPUT), gHiiHandle); @@ -602,6 +602,7 @@ InitializeBrowserStrings ( gSaveChanges = GetToken (STRING_TOKEN (SAVE_CHANGES), gHiiHandle); gOptionMismatch = GetToken (STRING_TOKEN (OPTION_MISMATCH), gHiiHandle); gFormSuppress = GetToken (STRING_TOKEN (FORM_SUPPRESSED), gHiiHandle); + gProtocolNotFound = GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND), gHiiHandle); return ; } @@ -615,8 +616,6 @@ FreeBrowserStrings ( VOID ) { - FreePool (gFunctionNineString); - FreePool (gFunctionTenString); FreePool (gEnterString); FreePool (gEnterCommitString); FreePool (gEnterEscapeString); @@ -644,9 +643,68 @@ FreeBrowserStrings ( FreePool (gSaveChanges); FreePool (gOptionMismatch); FreePool (gFormSuppress); + FreePool (gProtocolNotFound); return ; } +/** + Show all registered HotKey help strings on bottom Rows. + +**/ +VOID +PrintHotKeyHelpString ( + VOID + ) +{ + UINTN CurrentCol; + UINTN CurrentRow; + UINTN BottomRowOfHotKeyHelp; + UINTN ColumnWidth; + UINTN Index; + EFI_SCREEN_DESCRIPTOR LocalScreen; + LIST_ENTRY *Link; + BROWSER_HOT_KEY *HotKey; + + CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); + ColumnWidth = (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3; + BottomRowOfHotKeyHelp = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 3; + + // + // Calculate total number of Register HotKeys. + // + Index = 0; + Link = GetFirstNode (&gBrowserHotKeyList); + while (!IsNull (&gBrowserHotKeyList, Link)) { + HotKey = BROWSER_HOT_KEY_FROM_LINK (Link); + // + // Help string can't exceed ColumnWidth. One Row will show three Help information. + // + if (StrLen (HotKey->HelpString) > ColumnWidth) { + HotKey->HelpString[ColumnWidth] = L'\0'; + } + // + // Calculate help information Column and Row. + // + if ((Index % 3) != 2) { + CurrentCol = LocalScreen.LeftColumn + (2 - Index % 3) * ColumnWidth; + } else { + CurrentCol = LocalScreen.LeftColumn + 2; + } + CurrentRow = BottomRowOfHotKeyHelp - Index / 3; + // + // Print HotKey help string on bottom Row. + // + PrintStringAt (CurrentCol, CurrentRow, HotKey->HelpString); + + // + // Get Next Hot Key. + // + Link = GetNextNode (&gBrowserHotKeyList, Link); + Index ++; + } + + return; +} /** Update key's help imformation. @@ -673,18 +731,22 @@ 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; - ThdCol = LocalScreen.LeftColumn + (LocalScreen.RightColumn - LocalScreen.LeftColumn) * 2 / 3; + ThdCol = LocalScreen.LeftColumn + (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3 * 2; StartColumnOfHelp = LocalScreen.LeftColumn + 2; LeftColumnOfHelp = LocalScreen.LeftColumn + 1; RightColumnOfHelp = LocalScreen.RightColumn - 2; - TopRowOfHelp = LocalScreen.BottomRow - 4; - BottomRowOfHelp = LocalScreen.BottomRow - 3; - - gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND); + TopRowOfHelp = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1; + BottomRowOfHelp = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 2; Statement = MenuOption->ThisTag; switch (Statement->Operand) { @@ -696,11 +758,15 @@ UpdateKeyHelp ( ClearLines (LeftColumnOfHelp, RightColumnOfHelp, TopRowOfHelp, BottomRowOfHelp, KEYHELP_TEXT | KEYHELP_BACKGROUND); if (!Selected) { + // + // On system setting, HotKey will show on every form. + // + if (gBrowserSettingScope == SystemLevel || + (Selection->FormEditable && gFunctionKeySetting != NONE_FUNCTION_KEY_SETTING)) { + PrintHotKeyHelpString (); + } + if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) { - if (Selection->FormEditable) { - PrintStringAt (SecCol, TopRowOfHelp, gFunctionNineString); - PrintStringAt (ThdCol, TopRowOfHelp, gFunctionTenString); - } PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); } @@ -755,11 +821,14 @@ UpdateKeyHelp ( case EFI_IFR_CHECKBOX_OP: ClearLines (LeftColumnOfHelp, RightColumnOfHelp, TopRowOfHelp, BottomRowOfHelp, KEYHELP_TEXT | KEYHELP_BACKGROUND); + // + // On system setting, HotKey will show on every form. + // + if (gBrowserSettingScope == SystemLevel || + (Selection->FormEditable && gFunctionKeySetting != NONE_FUNCTION_KEY_SETTING)) { + PrintHotKeyHelpString (); + } if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) { - if (Selection->FormEditable) { - PrintStringAt (SecCol, TopRowOfHelp, gFunctionNineString); - PrintStringAt (ThdCol, TopRowOfHelp, gFunctionTenString); - } PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); } @@ -777,11 +846,14 @@ UpdateKeyHelp ( ClearLines (LeftColumnOfHelp, RightColumnOfHelp, TopRowOfHelp, BottomRowOfHelp, KEYHELP_TEXT | KEYHELP_BACKGROUND); if (!Selected) { + // + // On system setting, HotKey will show on every form. + // + if (gBrowserSettingScope == SystemLevel || + (Selection->FormEditable && gFunctionKeySetting != NONE_FUNCTION_KEY_SETTING)) { + PrintHotKeyHelpString (); + } if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) { - if (Selection->FormEditable) { - PrintStringAt (SecCol, TopRowOfHelp, gFunctionNineString); - PrintStringAt (ThdCol, TopRowOfHelp, gFunctionTenString); - } PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); } @@ -926,7 +998,7 @@ FindNextMenu ( CHAR16 YesResponse; CHAR16 NoResponse; EFI_INPUT_KEY Key; - EFI_STATUS Status; + BROWSER_SETTING_SCOPE Scope; CurrentMenu = Selection->CurrentMenu; @@ -939,9 +1011,64 @@ FindNextMenu ( // The parent menu and current menu are in the same formset // Selection->Action = UI_ACTION_REFRESH_FORM; + Scope = FormLevel; } else { Selection->Action = UI_ACTION_REFRESH_FORMSET; + CopyMem (&Selection->FormSetGuid, &CurrentMenu->Parent->FormSetGuid, sizeof (EFI_GUID)); + Selection->Handle = CurrentMenu->Parent->HiiHandle; + Scope = FormSetLevel; } + + // + // Form Level Check whether the data is changed. + // + if ((gBrowserSettingScope == FormLevel && Selection->Form->NvUpdateRequired) || + (gBrowserSettingScope == FormSetLevel && IsNvUpdateRequired(Selection->FormSet) && Scope == FormSetLevel)) { + 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, Ingore. + // + if (Repaint != NULL) { + *Repaint = TRUE; + } + if (NewLine != NULL) { + *NewLine = TRUE; + } + + Selection->Action = UI_ACTION_NONE; + return FALSE; + } + + if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) { + // + // If the user hits the YesResponse key + // + SubmitForm (Selection->FormSet, Selection->Form, Scope); + } else { + // + // If the user hits the NoResponse key + // + DiscardForm (Selection->FormSet, Selection->Form, Scope); + } + } + Selection->Statement = NULL; Selection->FormId = CurrentMenu->Parent->FormId; @@ -965,8 +1092,8 @@ FindNextMenu ( // // 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); + if (gBrowserSettingScope != SystemLevel && IsNvUpdateRequired(Selection->FormSet)) { + gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); YesResponse = gYesResponse[0]; NoResponse = gNoResponse[0]; @@ -999,16 +1126,23 @@ FindNextMenu ( 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); + // + // If the user hits the YesResponse key + // + SubmitForm (Selection->FormSet, Selection->Form, FormSetLevel); + } else { + // + // If the user hits the NoResponse key + // + DiscardForm (Selection->FormSet, Selection->Form, FormSetLevel); } } Selection->Statement = NULL; - CurrentMenu->QuestionId = 0; + if (CurrentMenu != NULL) { + CurrentMenu->QuestionId = 0; + } Selection->Action = UI_ACTION_EXIT; return TRUE; @@ -1043,14 +1177,14 @@ ProcessCallBackFunction ( EFI_IFR_TYPE_VALUE *TypeValue; FORM_BROWSER_STATEMENT *Statement; BOOLEAN SubmitFormIsRequired; - BOOLEAN SingleForm; BOOLEAN DiscardFormIsRequired; BOOLEAN NeedExit; LIST_ENTRY *Link; + BROWSER_SETTING_SCOPE SettingLevel; ConfigAccess = Selection->FormSet->ConfigAccess; SubmitFormIsRequired = FALSE; - SingleForm = FALSE; + SettingLevel = FormSetLevel; DiscardFormIsRequired = FALSE; NeedExit = FALSE; Status = EFI_SUCCESS; @@ -1079,11 +1213,8 @@ ProcessCallBackFunction ( // // 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)) { + if (Statement->Expression != NULL) { + if (EvaluateExpressionList(Statement->Expression, TRUE, Selection->FormSet, Selection->Form) == ExpressDisable) { continue; } } @@ -1107,58 +1238,85 @@ ProcessCallBackFunction ( &ActionRequest ); if (!EFI_ERROR (Status)) { - switch (ActionRequest) { - case EFI_BROWSER_ACTION_REQUEST_RESET: - gResetRequired = TRUE; - break; + // + // Only for EFI_BROWSER_ACTION_CHANGED need to handle this ActionRequest. + // + if (Action == EFI_BROWSER_ACTION_CHANGED) { + switch (ActionRequest) { + case EFI_BROWSER_ACTION_REQUEST_RESET: + DiscardFormIsRequired = TRUE; + gResetRequired = TRUE; + Selection->Action = UI_ACTION_EXIT; + break; - case EFI_BROWSER_ACTION_REQUEST_SUBMIT: - SubmitFormIsRequired = TRUE; - break; + case EFI_BROWSER_ACTION_REQUEST_SUBMIT: + SubmitFormIsRequired = TRUE; + Selection->Action = UI_ACTION_EXIT; + break; - case EFI_BROWSER_ACTION_REQUEST_EXIT: - Selection->Action = UI_ACTION_EXIT; - break; + case EFI_BROWSER_ACTION_REQUEST_EXIT: + DiscardFormIsRequired = TRUE; + 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_SUBMIT_EXIT: + SubmitFormIsRequired = TRUE; + SettingLevel = FormLevel; + NeedExit = TRUE; + break; - case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT: - DiscardFormIsRequired = TRUE; - SingleForm = TRUE; - NeedExit = TRUE; - break; + case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT: + DiscardFormIsRequired = TRUE; + SettingLevel = FormLevel; + NeedExit = TRUE; + break; - case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY: - SubmitFormIsRequired = TRUE; - SingleForm = TRUE; - break; + case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY: + SubmitFormIsRequired = TRUE; + SettingLevel = FormLevel; + break; - case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD: - DiscardFormIsRequired = TRUE; - SingleForm = TRUE; - break; + case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD: + DiscardFormIsRequired = TRUE; + SettingLevel = FormLevel; + break; - default: - 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, GetSetValueWithEditBuffer); } - } else if (Status == EFI_UNSUPPORTED) { + } else { // - // If return EFI_UNSUPPORTED, also consider Hii driver suceess deal with it. + // According the spec, return fail from call back of "changing" and + // "retrieve", should restore the question's value. // - Status = EFI_SUCCESS; + if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) { + GetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer); + } + + 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); + SubmitForm (Selection->FormSet, Selection->Form, SettingLevel); } if (DiscardFormIsRequired && !SkipSaveOrDiscard) { - DiscardForm (Selection->FormSet, Selection->Form, SingleForm); + DiscardForm (Selection->FormSet, Selection->Form, SettingLevel); } if (NeedExit) { @@ -1168,6 +1326,57 @@ ProcessCallBackFunction ( return Status; } +/** + Call the retrieve type call back function for one question to get the initialize data. + + This function only used when in the initialize stage, because in this stage, the + Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead. + + @param ConfigAccess The config access protocol produced by the hii driver. + @param Statement The Question which need to call. + + @retval EFI_SUCCESS The call back function excutes successfully. + @return Other value if the call back function failed to excute. +**/ +EFI_STATUS +ProcessRetrieveForQuestion ( + IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess, + IN FORM_BROWSER_STATEMENT *Statement + ) +{ + EFI_STATUS Status; + EFI_BROWSER_ACTION_REQUEST ActionRequest; + EFI_HII_VALUE *HiiValue; + EFI_IFR_TYPE_VALUE *TypeValue; + + Status = EFI_SUCCESS; + ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; + + if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) { + return EFI_UNSUPPORTED; + } + + 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, + EFI_BROWSER_ACTION_RETRIEVE, + Statement->QuestionId, + HiiValue->Type, + TypeValue, + &ActionRequest + ); + return Status; +} + /** The worker function that send the displays to the screen. On output, the selection made by user is returned. @@ -1191,12 +1400,9 @@ SetupBrowser ( EFI_HANDLE NotifyHandle; FORM_BROWSER_STATEMENT *Statement; EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; - FORM_BROWSER_FORMSET *FormSet; EFI_INPUT_KEY Key; gMenuRefreshHead = NULL; - gResetRequired = FALSE; - FormSet = Selection->FormSet; ConfigAccess = Selection->FormSet->ConfigAccess; // @@ -1222,7 +1428,27 @@ SetupBrowser ( goto Done; } + // + // Update gOldFormSet on maintain back up FormSet list. + // And, make gOldFormSet point to current FormSet. + // + if (gOldFormSet != NULL) { + RemoveEntryList (&gOldFormSet->Link); + DestroyFormSet (gOldFormSet); + } + gOldFormSet = Selection->FormSet; + InsertTailList (&gBrowserFormSetList, &gOldFormSet->Link); + do { + // + // IFR is updated, force to reparse the IFR binary + // + if (mHiiPackageListUpdated) { + Selection->Action = UI_ACTION_REFRESH_FORMSET; + mHiiPackageListUpdated = FALSE; + break; + } + // // Initialize Selection->Form // @@ -1250,13 +1476,7 @@ SetupBrowser ( // Check Form is suppressed. // if (Selection->Form->SuppressExpression != NULL) { - Status = EvaluateExpression (Selection->FormSet, Selection->Form, Selection->Form->SuppressExpression); - if (EFI_ERROR (Status) || (Selection->Form->SuppressExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN)) { - Status = EFI_INVALID_PARAMETER; - goto Done; - } - - if (Selection->Form->SuppressExpression->Result.Value.b) { + if (EvaluateExpressionList(Selection->Form->SuppressExpression, TRUE, Selection->FormSet, Selection->Form) == ExpressSuppress) { // // Form is suppressed. // @@ -1269,11 +1489,6 @@ SetupBrowser ( } } - // - // Reset FormPackage update flag - // - mHiiPackageListUpdated = FALSE; - // // Before display new form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN // for each question with callback flag. @@ -1308,7 +1523,7 @@ SetupBrowser ( if (mHiiPackageListUpdated) { Selection->Action = UI_ACTION_REFRESH_FORMSET; mHiiPackageListUpdated = FALSE; - goto Done; + break; } } @@ -1332,13 +1547,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 @@ -1357,21 +1572,22 @@ SetupBrowser ( gResetRequired = TRUE; } - // - // Reset FormPackage update flag - // - mHiiPackageListUpdated = FALSE; - if ((ConfigAccess != NULL) && ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) && (Statement->Operand != EFI_IFR_PASSWORD_OP)) { - Status = ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGING, FALSE); - if ((EFI_ERROR (Status)) && (Status != EFI_UNSUPPORTED)) { + if (Statement->Operand == EFI_IFR_REF_OP && Selection->Action != UI_ACTION_EXIT) { + // + // Process dynamic update ref opcode. + // + if (!EFI_ERROR (Status)) { + Status = ProcessGotoOpCode(Statement, Selection, NULL, NULL); + } + // - // 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 // @@ -1379,17 +1595,10 @@ SetupBrowser ( Selection->QuestionId = 0; } } - } - // - // Check whether Form Package has been updated during Callback - // - if (mHiiPackageListUpdated && (Selection->Action == UI_ACTION_REFRESH_FORM)) { - // - // Force to reparse IFR binary of target Formset - // - mHiiPackageListUpdated = FALSE; - Selection->Action = UI_ACTION_REFRESH_FORMSET; + if (!EFI_ERROR (Status) && Statement->Operand != EFI_IFR_REF_OP) { + ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGED, FALSE); + } } } @@ -1410,14 +1619,6 @@ SetupBrowser ( } } while (Selection->Action == UI_ACTION_REFRESH_FORM); - // - // Record the old formset - // - if (gOldFormSet != NULL) { - DestroyFormSet (gOldFormSet); - } - gOldFormSet = FormSet; - Done: // // Reset current form information to the initial setting when error happens or form exit.