X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FSetupBrowserDxe%2FSetup.c;h=0bc2d1b085cfaba4acdfc8caf349f78a55fb465d;hb=0c66bc762aa186a78b3c6ce6c691af31bedec5fd;hp=e617f2f367b12c39cc3ca2132b7b2a2ad7bb2de3;hpb=63d55bb98a5fa3018378d06c50784e463c6e999a;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index e617f2f367..0bc2d1b085 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1,7 +1,7 @@ /** @file Entry and initialization module for the browser. -Copyright (c) 2007 - 2008, Intel Corporation +Copyright (c) 2007 - 2009, 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 @@ -29,8 +29,11 @@ EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; EFI_HII_STRING_PROTOCOL *mHiiString; EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting; -BANNER_DATA *BannerData; -EFI_HII_HANDLE FrontPageHandle; +UINTN gBrowserContextCount = 0; +LIST_ENTRY gBrowserContextList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserContextList); + +BANNER_DATA *gBannerData; +EFI_HII_HANDLE gFrontPageHandle; UINTN gClassOfVfr; UINTN gFunctionKeySetting; BOOLEAN gResetRequired; @@ -38,14 +41,10 @@ BOOLEAN gNvUpdateRequired; EFI_HII_HANDLE gHiiHandle; UINT16 gDirection; EFI_SCREEN_DESCRIPTOR gScreenDimensions; -BOOLEAN gUpArrow; -BOOLEAN gDownArrow; // // Browser Global Strings // -CHAR16 *gFunctionOneString; -CHAR16 *gFunctionTwoString; CHAR16 *gFunctionNineString; CHAR16 *gFunctionTenString; CHAR16 *gEnterString; @@ -75,6 +74,9 @@ CHAR16 *gMinusString; CHAR16 *gAdjustNumber; CHAR16 *gSaveChanges; CHAR16 *gOptionMismatch; +CHAR16 *gFormSuppress; + +CHAR16 *mUnknownString = L"!"; CHAR16 gPromptBlockWidth; CHAR16 gOptionBlockWidth; @@ -85,6 +87,8 @@ EFI_GUID gSetupBrowserGuid = { 0xab368524, 0xb60c, 0x495b, {0xa0, 0x9, 0x12, 0xe8, 0x5b, 0x1a, 0xea, 0x32} }; +FORM_BROWSER_FORMSET *gOldFormSet; + FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = { // // Boot Manager @@ -188,7 +192,7 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = { @param FormId This field specifies which EFI_IFR_FORM to render as the first displayable page. If this field has a value of 0x0000, then the forms browser will render the specified forms in their encoded order. - @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in + @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in characters. @param ActionRequest Points to the action recommended by the form. @@ -214,6 +218,11 @@ SendForm ( UINTN Index; FORM_BROWSER_FORMSET *FormSet; + // + // Save globals used by SendForm() + // + SaveBrowserContext (); + Status = EFI_SUCCESS; ZeroMem (&gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); @@ -234,7 +243,8 @@ SendForm ( if ((gScreenDimensions.RightColumn < ScreenDimensions->RightColumn) || (gScreenDimensions.BottomRow < ScreenDimensions->BottomRow) ) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } else { // // Local dimension validation. @@ -253,7 +263,8 @@ SendForm ( ) { CopyMem (&gScreenDimensions, (VOID *) ScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); } else { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } } } @@ -268,7 +279,7 @@ SendForm ( InitializeBrowserStrings (); gFunctionKeySetting = DEFAULT_FUNCTION_KEY_SETTING; - gClassOfVfr = EFI_SETUP_APPLICATION_SUBCLASS; + gClassOfVfr = FORMSET_CLASS_PLATFORM_SETUP; // // Ensure we are in Text mode @@ -285,6 +296,9 @@ SendForm ( Selection->FormId = FormId; } + gOldFormSet = NULL; + gNvUpdateRequired = FALSE; + do { FormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET)); ASSERT (FormSet != NULL); @@ -299,15 +313,6 @@ SendForm ( } Selection->FormSet = FormSet; - // - // Initialize current settings of Questions in this FormSet - // - Status = InitializeCurrentSetting (FormSet); - if (EFI_ERROR (Status)) { - DestroyFormSet (FormSet); - break; - } - // // Display this formset // @@ -316,7 +321,6 @@ SendForm ( Status = SetupBrowser (Selection); gCurrentSelection = NULL; - DestroyFormSet (FormSet); if (EFI_ERROR (Status)) { break; @@ -324,6 +328,11 @@ SendForm ( } while (Selection->Action == UI_ACTION_REFRESH_FORMSET); + if (gOldFormSet != NULL) { + DestroyFormSet (gOldFormSet); + gOldFormSet = NULL; + } + FreePool (Selection); } @@ -339,6 +348,12 @@ SendForm ( gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->ClearScreen (gST->ConOut); +Done: + // + // Restore globals used by SendForm() + // + RestoreBrowserContext (); + return Status; } @@ -525,7 +540,6 @@ InitializeSetup ( ) { EFI_STATUS Status; - EFI_HII_PACKAGE_LIST_HEADER *PackageList; // // Locate required Hii relative protocols @@ -554,21 +568,19 @@ InitializeSetup ( // // Publish our HII data // - PackageList = HiiLibPreparePackageList (1, &gSetupBrowserGuid, SetupBrowserStrings); - ASSERT (PackageList != NULL); - Status = mHiiDatabase->NewPackageList ( - mHiiDatabase, - PackageList, - ImageHandle, - &gHiiHandle - ); - ASSERT_EFI_ERROR (Status); + gHiiHandle = HiiAddPackages ( + &gSetupBrowserGuid, + ImageHandle, + SetupBrowserStrings, + NULL + ); + ASSERT (gHiiHandle != NULL); // // Initialize Driver private data // - BannerData = AllocateZeroPool (sizeof (BANNER_DATA)); - ASSERT (BannerData != NULL); + gBannerData = AllocateZeroPool (sizeof (BANNER_DATA)); + ASSERT (gBannerData != NULL); // // Install FormBrowser2 protocol @@ -603,11 +615,9 @@ NewString ( ) { EFI_STRING_ID StringId; - EFI_STATUS Status; - StringId = 0; - Status = HiiLibNewString (HiiHandle, &StringId, String); - ASSERT_EFI_ERROR (Status); + StringId = HiiSetString (HiiHandle, 0, String, NULL); + ASSERT (StringId != 0); return StringId; } @@ -631,7 +641,8 @@ DeleteString ( CHAR16 NullChar; NullChar = CHAR_NULL; - return HiiLibSetString (HiiHandle, StringId, &NullChar); + HiiSetString (HiiHandle, StringId, &NullChar, NULL); + return EFI_SUCCESS; } @@ -651,29 +662,14 @@ GetToken ( IN EFI_HII_HANDLE HiiHandle ) { - EFI_STATUS Status; - CHAR16 *String; - UINTN BufferLength; - - // - // Set default string size assumption at no more than 256 bytes - // - BufferLength = 0x100; - String = AllocateZeroPool (BufferLength); - ASSERT (String != NULL); - - Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength); + EFI_STRING String; - if (Status == EFI_BUFFER_TOO_SMALL) { - FreePool (String); - String = AllocateZeroPool (BufferLength); + String = HiiGetString (HiiHandle, Token, NULL); + if (String == NULL) { + String = AllocateCopyPool (sizeof (mUnknownString), mUnknownString); ASSERT (String != NULL); - - Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength); } - ASSERT_EFI_ERROR (Status); - - return String; + return (CHAR16 *) String; } @@ -1145,7 +1141,7 @@ GetQuestionValue ( if (EFI_ERROR (Status)) { return Status; } - + LengthStr = StrLen (Value); Status = EFI_SUCCESS; if (IsString) { @@ -1179,7 +1175,7 @@ GetQuestionValue ( if ((Index & 1) == 0) { Dst [Index/2] = DigitUint8; } else { - Dst [Index/2] = (UINT8) ((Dst [Index/2] << 4) + DigitUint8); + Dst [Index/2] = (UINT8) ((DigitUint8 << 4) + Dst [Index/2]); } } } @@ -1288,7 +1284,7 @@ GetQuestionValue ( if ((Index & 1) == 0) { Dst [Index/2] = DigitUint8; } else { - Dst [Index/2] = (UINT8) ((Dst [Index/2] << 4) + DigitUint8); + Dst [Index/2] = (UINT8) ((DigitUint8 << 4) + Dst [Index/2]); } } } @@ -1546,7 +1542,7 @@ SetQuestionValue ( TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2); } } - + // // Convert to lower char. // @@ -1796,8 +1792,10 @@ GetQuestionDefault ( QUESTION_OPTION *Option; EFI_HII_VALUE *HiiValue; UINT8 Index; + EFI_STRING StrValue; - Status = EFI_SUCCESS; + Status = EFI_SUCCESS; + StrValue = NULL; // // Statement don't have storage, skip them @@ -1840,6 +1838,14 @@ GetQuestionDefault ( CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE)); } + if (HiiValue->Type == EFI_IFR_TYPE_STRING) { + StrValue = HiiGetString (FormSet->HiiHandle, HiiValue->Value.string, NULL); + if (StrValue == NULL) { + return EFI_NOT_FOUND; + } + Question->BufferValue = AllocateCopyPool (StrSize (StrValue), StrValue); + } + return EFI_SUCCESS; } @@ -1896,21 +1902,16 @@ GetQuestionDefault ( // For Questions without default // switch (Question->Operand) { - case EFI_IFR_NUMERIC_OP: - // - // Take minimal value as numeric's default value - // - HiiValue->Value.u64 = Question->Minimum; - break; - case EFI_IFR_ONE_OF_OP: // // Take first oneof option as oneof's default value // - Link = GetFirstNode (&Question->OptionListHead); - if (!IsNull (&Question->OptionListHead, Link)) { - Option = QUESTION_OPTION_FROM_LINK (Link); - CopyMem (HiiValue, &Option->Value, sizeof (EFI_HII_VALUE)); + if (ValueToOption (Question, HiiValue) == NULL) { + Link = GetFirstNode (&Question->OptionListHead); + if (!IsNull (&Question->OptionListHead, Link)) { + Option = QUESTION_OPTION_FROM_LINK (Link); + CopyMem (HiiValue, &Option->Value, sizeof (EFI_HII_VALUE)); + } } break; @@ -1923,7 +1924,7 @@ GetQuestionDefault ( while (!IsNull (&Question->OptionListHead, Link)) { Option = QUESTION_OPTION_FROM_LINK (Link); - Question->BufferValue[Index] = Option->Value.Value.u8; + SetArrayData (Question->BufferValue, Question->ValueType, Index, Option->Value.Value.u64); Index++; if (Index >= Question->MaxContainers) { @@ -1970,11 +1971,11 @@ ExtractFormDefault ( Link = GetNextNode (&Form->StatementListHead, Link); // - // If Question is suppressed, don't reset it to default + // If Question is disabled, don't reset it to default // - if (Question->SuppressExpression != NULL) { - Status = EvaluateExpression (FormSet, Form, Question->SuppressExpression); - if (!EFI_ERROR (Status) && Question->SuppressExpression->Result.Value.b) { + if (Question->DisableExpression != NULL) { + Status = EvaluateExpression (FormSet, Form, Question->DisableExpression); + if (!EFI_ERROR (Status) && Question->DisableExpression->Result.Value.b) { continue; } } @@ -2038,6 +2039,42 @@ LoadFormConfig ( } +/** + Initialize Question's Edit copy from Storage for the whole Formset. + + @param FormSet FormSet data structure. + + @retval EFI_SUCCESS The function completed successfully. + +**/ +EFI_STATUS +LoadFormSetConfig ( + IN FORM_BROWSER_FORMSET *FormSet + ) +{ + EFI_STATUS Status; + LIST_ENTRY *Link; + FORM_BROWSER_FORM *Form; + + Link = GetFirstNode (&FormSet->FormListHead); + while (!IsNull (&FormSet->FormListHead, Link)) { + Form = FORM_BROWSER_FORM_FROM_LINK (Link); + + // + // Initialize local copy of Value for each Form + // + Status = LoadFormConfig (FormSet, Form); + if (EFI_ERROR (Status)) { + return Status; + } + + Link = GetNextNode (&FormSet->FormListHead, Link); + } + + return EFI_SUCCESS; +} + + /** Fill storage's edit copy with settings requested from Configuration Driver. @@ -2100,6 +2137,54 @@ LoadStorage ( } +/** + Copy uncommitted data from source Storage to destination Storage. + + @param Dst Target Storage for uncommitted data. + @param Src Source Storage for uncommitted data. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Source and destination Storage is not the same type. + +**/ +EFI_STATUS +CopyStorage ( + IN OUT FORMSET_STORAGE *Dst, + IN FORMSET_STORAGE *Src + ) +{ + LIST_ENTRY *Link; + NAME_VALUE_NODE *Node; + + if ((Dst->Type != Src->Type) || (Dst->Size != Src->Size)) { + return EFI_INVALID_PARAMETER; + } + + switch (Src->Type) { + case EFI_HII_VARSTORE_BUFFER: + CopyMem (Dst->EditBuffer, Src->EditBuffer, Src->Size); + break; + + case EFI_HII_VARSTORE_NAME_VALUE: + Link = GetFirstNode (&Src->NameValueListHead); + while (!IsNull (&Src->NameValueListHead, Link)) { + Node = NAME_VALUE_NODE_FROM_LINK (Link); + + SetValueByName (Dst, Node->Name, Node->EditValue); + + Link = GetNextNode (&Src->NameValueListHead, Link); + } + break; + + case EFI_HII_VARSTORE_EFI_VARIABLE: + default: + break; + } + + return EFI_SUCCESS; +} + + /** Get current setting of Questions. @@ -2114,7 +2199,10 @@ InitializeCurrentSetting ( ) { LIST_ENTRY *Link; + LIST_ENTRY *Link2; FORMSET_STORAGE *Storage; + FORMSET_STORAGE *StorageSrc; + FORMSET_STORAGE *OldStorage; FORM_BROWSER_FORM *Form; EFI_STATUS Status; @@ -2137,7 +2225,35 @@ InitializeCurrentSetting ( while (!IsNull (&FormSet->StorageListHead, Link)) { Storage = FORMSET_STORAGE_FROM_LINK (Link); - Status = LoadStorage (FormSet, Storage); + OldStorage = NULL; + if (gOldFormSet != NULL) { + // + // Try to find the Storage in backup formset gOldFormSet + // + Link2 = GetFirstNode (&gOldFormSet->StorageListHead); + while (!IsNull (&gOldFormSet->StorageListHead, Link2)) { + StorageSrc = FORMSET_STORAGE_FROM_LINK (Link2); + + if (StorageSrc->VarStoreId == Storage->VarStoreId) { + OldStorage = StorageSrc; + break; + } + + Link2 = GetNextNode (&gOldFormSet->StorageListHead, Link2); + } + } + + if (OldStorage == NULL) { + // + // Storage is not found in backup formset, request it from ConfigDriver + // + Status = LoadStorage (FormSet, Storage); + } else { + // + // Storage found in backup formset, use it + // + Status = CopyStorage (Storage, OldStorage); + } // // Now Edit Buffer is filled with default values(lower priority) and current @@ -2158,9 +2274,11 @@ InitializeCurrentSetting ( Fetch the Ifr binary data of a FormSet. @param Handle PackageList Handle - @param FormSetGuid GUID of a formset. If not specified (NULL or zero - GUID), take the first FormSet found in package - list. + @param FormSetGuid On input, GUID or class GUID of a formset. If not + specified (NULL or zero GUID), take the first + FormSet with class GUID EFI_HII_PLATFORM_SETUP_FORMSET_GUID + found in package list. + On output, GUID of the formset found(if not NULL). @param BinaryLength The length of the FormSet IFR binary. @param BinaryData The buffer designed to receive the FormSet. @@ -2186,21 +2304,25 @@ GetIfrBinaryData ( UINT8 *OpCodeData; UINT32 Offset; UINT32 Offset2; - BOOLEAN ReturnDefault; UINT32 PackageListLength; EFI_HII_PACKAGE_HEADER PackageHeader; + UINT8 Index; + UINT8 NumberOfClassGuid; + BOOLEAN ClassGuidMatch; + EFI_GUID *ClassGuid; + EFI_GUID *ComparingGuid; OpCodeData = NULL; Package = NULL; - ZeroMem (&PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));; + ZeroMem (&PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER)); // - // if FormSetGuid is NULL or zero GUID, return first FormSet in the package list + // if FormSetGuid is NULL or zero GUID, return first Setup FormSet in the package list // if (FormSetGuid == NULL || CompareGuid (FormSetGuid, &gZeroGuid)) { - ReturnDefault = TRUE; + ComparingGuid = &gEfiHiiPlatformSetupFormsetGuid; } else { - ReturnDefault = FALSE; + ComparingGuid = FormSetGuid; } // @@ -2219,7 +2341,7 @@ GetIfrBinaryData ( return Status; } ASSERT (HiiPackageList != NULL); - + // // Get Form package from this HII package List // @@ -2227,6 +2349,7 @@ GetIfrBinaryData ( Offset2 = 0; CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32)); + ClassGuidMatch = FALSE; while (Offset < PackageListLength) { Package = ((UINT8 *) HiiPackageList) + Offset; CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER)); @@ -2241,16 +2364,24 @@ GetIfrBinaryData ( if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) { // - // Check whether return default FormSet + // Try to compare against formset GUID // - if (ReturnDefault) { + if (CompareGuid (ComparingGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) { break; } // - // FormSet GUID is specified, check it + // Try to compare against formset class GUID // - if (CompareGuid (FormSetGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) { + NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3); + ClassGuid = (EFI_GUID *) (OpCodeData + sizeof (EFI_IFR_FORM_SET)); + for (Index = 0; Index < NumberOfClassGuid; Index++) { + if (CompareGuid (ComparingGuid, ClassGuid + Index)) { + ClassGuidMatch = TRUE; + break; + } + } + if (ClassGuidMatch) { break; } } @@ -2277,9 +2408,9 @@ GetIfrBinaryData ( return EFI_NOT_FOUND; } - if (ReturnDefault && FormSetGuid != NULL) { + if (ClassGuidMatch && (FormSetGuid != NULL)) { // - // Return the default FormSet GUID + // Return the FormSet GUID // CopyMem (FormSetGuid, &((EFI_IFR_FORM_SET *) OpCodeData)->Guid, sizeof (EFI_GUID)); } @@ -2306,9 +2437,11 @@ GetIfrBinaryData ( Initialize the internal data structure of a FormSet. @param Handle PackageList Handle - @param FormSetGuid GUID of a formset. If not specified (NULL or zero - GUID), take the first FormSet found in package - list. + @param FormSetGuid On input, GUID or class GUID of a formset. If not + specified (NULL or zero GUID), take the first + FormSet with class GUID EFI_HII_PLATFORM_SETUP_FORMSET_GUID + found in package list. + On output, GUID of the formset found(if not NULL). @param FormSet FormSet data structure. @retval EFI_SUCCESS The function completed successfully. @@ -2363,9 +2496,10 @@ InitializeFormSet ( return Status; } - gClassOfVfr = FormSet->SubClass; - if (gClassOfVfr == EFI_FRONT_PAGE_SUBCLASS) { - FrontPageHandle = FormSet->HiiHandle; + gClassOfVfr = FORMSET_CLASS_PLATFORM_SETUP; + if (FormSet->SubClass == EFI_FRONT_PAGE_SUBCLASS) { + gClassOfVfr = FORMSET_CLASS_FRONT_PAGE; + gFrontPageHandle = FormSet->HiiHandle; } // @@ -2380,14 +2514,6 @@ InitializeFormSet ( // // Function key prompt can not be displayed if the function key has been disabled. // - if ((gFunctionKeySetting & FUNCTION_ONE) != FUNCTION_ONE) { - gFunctionOneString = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle); - } - - if ((gFunctionKeySetting & FUNCTION_TWO) != FUNCTION_TWO) { - gFunctionTwoString = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle); - } - if ((gFunctionKeySetting & FUNCTION_NINE) != FUNCTION_NINE) { gFunctionNineString = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle); } @@ -2400,3 +2526,164 @@ InitializeFormSet ( return Status; } + + +/** + Save globals used by previous call to SendForm(). SendForm() may be called from + HiiConfigAccess.Callback(), this will cause SendForm() be reentried. + So, save globals of previous call to SendForm() and restore them upon exit. + +**/ +VOID +SaveBrowserContext ( + VOID + ) +{ + BROWSER_CONTEXT *Context; + + gBrowserContextCount++; + if (gBrowserContextCount == 1) { + // + // This is not reentry of SendForm(), no context to save + // + return; + } + + Context = AllocatePool (sizeof (BROWSER_CONTEXT)); + ASSERT (Context != NULL); + + Context->Signature = BROWSER_CONTEXT_SIGNATURE; + + // + // Save FormBrowser context + // + Context->BannerData = gBannerData; + Context->ClassOfVfr = gClassOfVfr; + Context->FunctionKeySetting = gFunctionKeySetting; + Context->ResetRequired = gResetRequired; + Context->NvUpdateRequired = gNvUpdateRequired; + Context->Direction = gDirection; + Context->FunctionNineString = gFunctionNineString; + Context->FunctionTenString = gFunctionTenString; + Context->EnterString = gEnterString; + Context->EnterCommitString = gEnterCommitString; + Context->EnterEscapeString = gEnterEscapeString; + Context->EscapeString = gEscapeString; + Context->SaveFailed = gSaveFailed; + Context->MoveHighlight = gMoveHighlight; + Context->MakeSelection = gMakeSelection; + Context->DecNumericInput = gDecNumericInput; + Context->HexNumericInput = gHexNumericInput; + Context->ToggleCheckBox = gToggleCheckBox; + Context->PromptForData = gPromptForData; + Context->PromptForPassword = gPromptForPassword; + Context->PromptForNewPassword = gPromptForNewPassword; + Context->ConfirmPassword = gConfirmPassword; + Context->ConfirmError = gConfirmError; + Context->PassowordInvalid = gPassowordInvalid; + Context->PressEnter = gPressEnter; + Context->EmptyString = gEmptyString; + Context->AreYouSure = gAreYouSure; + Context->YesResponse = gYesResponse; + Context->NoResponse = gNoResponse; + Context->MiniString = gMiniString; + Context->PlusString = gPlusString; + Context->MinusString = gMinusString; + Context->AdjustNumber = gAdjustNumber; + Context->SaveChanges = gSaveChanges; + Context->OptionMismatch = gOptionMismatch; + Context->PromptBlockWidth = gPromptBlockWidth; + Context->OptionBlockWidth = gOptionBlockWidth; + Context->HelpBlockWidth = gHelpBlockWidth; + Context->OldFormSet = gOldFormSet; + Context->MenuRefreshHead = gMenuRefreshHead; + + CopyMem (&Context->ScreenDimensions, &gScreenDimensions, sizeof (gScreenDimensions)); + CopyMem (&Context->MenuOption, &gMenuOption, sizeof (gMenuOption)); + + // + // Insert to FormBrowser context list + // + InsertHeadList (&gBrowserContextList, &Context->Link); +} + + +/** + Restore globals used by previous call to SendForm(). + +**/ +VOID +RestoreBrowserContext ( + VOID + ) +{ + LIST_ENTRY *Link; + BROWSER_CONTEXT *Context; + + ASSERT (gBrowserContextCount != 0); + gBrowserContextCount--; + if (gBrowserContextCount == 0) { + // + // This is not reentry of SendForm(), no context to restore + // + return; + } + + ASSERT (!IsListEmpty (&gBrowserContextList)); + + Link = GetFirstNode (&gBrowserContextList); + Context = BROWSER_CONTEXT_FROM_LINK (Link); + + // + // Restore FormBrowser context + // + gBannerData = Context->BannerData; + gClassOfVfr = Context->ClassOfVfr; + gFunctionKeySetting = Context->FunctionKeySetting; + gResetRequired = Context->ResetRequired; + gNvUpdateRequired = Context->NvUpdateRequired; + gDirection = Context->Direction; + gFunctionNineString = Context->FunctionNineString; + gFunctionTenString = Context->FunctionTenString; + gEnterString = Context->EnterString; + gEnterCommitString = Context->EnterCommitString; + gEnterEscapeString = Context->EnterEscapeString; + gEscapeString = Context->EscapeString; + gSaveFailed = Context->SaveFailed; + gMoveHighlight = Context->MoveHighlight; + gMakeSelection = Context->MakeSelection; + gDecNumericInput = Context->DecNumericInput; + gHexNumericInput = Context->HexNumericInput; + gToggleCheckBox = Context->ToggleCheckBox; + gPromptForData = Context->PromptForData; + gPromptForPassword = Context->PromptForPassword; + gPromptForNewPassword = Context->PromptForNewPassword; + gConfirmPassword = Context->ConfirmPassword; + gConfirmError = Context->ConfirmError; + gPassowordInvalid = Context->PassowordInvalid; + gPressEnter = Context->PressEnter; + gEmptyString = Context->EmptyString; + gAreYouSure = Context->AreYouSure; + gYesResponse = Context->YesResponse; + gNoResponse = Context->NoResponse; + gMiniString = Context->MiniString; + gPlusString = Context->PlusString; + gMinusString = Context->MinusString; + gAdjustNumber = Context->AdjustNumber; + gSaveChanges = Context->SaveChanges; + gOptionMismatch = Context->OptionMismatch; + gPromptBlockWidth = Context->PromptBlockWidth; + gOptionBlockWidth = Context->OptionBlockWidth; + gHelpBlockWidth = Context->HelpBlockWidth; + gOldFormSet = Context->OldFormSet; + gMenuRefreshHead = Context->MenuRefreshHead; + + CopyMem (&gScreenDimensions, &Context->ScreenDimensions, sizeof (gScreenDimensions)); + CopyMem (&gMenuOption, &Context->MenuOption, sizeof (gMenuOption)); + + // + // Remove from FormBrowser context list + // + RemoveEntryList (&Context->Link); + gBS->FreePool (Context); +}