X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=EdkCompatibilityPkg%2FCompatibility%2FFrameworkHiiOnUefiHiiThunk%2FConfigAccess.c;h=c33a3f0b8e24a1754774da387631a2a4d1efe983;hb=b7cc5bf180e9deefc91a5e66e0b80fd222503608;hp=ac6f2ac24419fc7a70e001d570f387f9f6295e92;hpb=cb7d01c0c9fd199742d0fed6aa69dab0c79c3338;p=mirror_edk2.git diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c index ac6f2ac244..c33a3f0b8e 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c @@ -1,10 +1,10 @@ -/**@file +/** @file This file implements functions related to Config Access Protocols installed by by HII Thunk Modules. These Config access Protocols are used to thunk UEFI Config Access Callback to Framework HII Callback and EFI Variable Set/Get operations. -Copyright (c) 2008, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2008 - 2012, 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 http://opensource.org/licenses/bsd-license.php @@ -74,23 +74,27 @@ GetFirstStorageOfFormSet ( StorageList = GetFirstNode (&FormSet->StorageListHead); - if (!IsNull (&FormSet->StorageListHead, StorageList)) { + while (!IsNull (&FormSet->StorageListHead, StorageList)) { Storage = FORMSET_STORAGE_FROM_LINK (StorageList); - return Storage; + if (Storage->Type == EFI_HII_VARSTORE_BUFFER) { + return Storage; + } + StorageList = GetNextNode (&FormSet->StorageListHead, StorageList); } return NULL; } /** - Get the EFI_IFR_VARSTORE where the Question's value is stored. + Get the FORM_BROWSER_STATEMENT that matches the Question's value. @param FormSet The Form Set. + @param QuestionId QuestionId - @retval FORMSET_STORAGE * The EFI_IFR_VARSTORE where the Question's value is stored. - @retval NULL If the Form Set does not have EFI_IFR_VARSTORE. + @retval FORM_BROWSER_STATEMENT* FORM_BROWSER_STATEMENT that match Question's value. + @retval NULL If the Form Set does not have EFI_IFR_VARSTORE. **/ -FORMSET_STORAGE * +FORM_BROWSER_STATEMENT * GetStorageFromQuestionId ( IN CONST FORM_BROWSER_FORMSET * FormSet, IN EFI_QUESTION_ID QuestionId @@ -115,7 +119,7 @@ GetStorageFromQuestionId ( // UEFI Question ID is unique in a FormSet. // ASSERT (Statement->Storage->Type == EFI_HII_VARSTORE_BUFFER); - return Statement->Storage; + return Statement; } StatementList = GetNextNode (&Form->StatementListHead, StatementList); } @@ -126,38 +130,6 @@ GetStorageFromQuestionId ( return NULL; } -/** - Get the EFI_IFR_VARSTORE based the ID. - - @param FormSet The Form Set. - - @retval FORMSET_STORAGE * The EFI_IFR_VARSTORE with the ID. - @retval NULL If the Form Set does not have EFI_IFR_VARSTORE with such ID. -**/ -FORMSET_STORAGE * -GetStorageFromVarStoreId ( - IN CONST FORM_BROWSER_FORMSET * FormSet, - IN EFI_VARSTORE_ID VarStoreId - ) -{ - LIST_ENTRY *StorageList; - FORMSET_STORAGE *Storage; - - StorageList = GetFirstNode (&FormSet->StorageListHead); - - while (!IsNull (&FormSet->StorageListHead, StorageList)) { - Storage = FORMSET_STORAGE_FROM_LINK (StorageList); - - if (VarStoreId == Storage->VarStoreId) { - return Storage; - } - - StorageList = GetNextNode (&FormSet->StorageListHead, StorageList); - } - - return NULL; -} - /** Get the EFI_IFR_VARSTORE based the string in a or a string. @@ -178,10 +150,18 @@ GetStorageFromConfigString ( FORMSET_STORAGE *Storage; CHAR16 *Name; + if (ConfigString == NULL) { + return NULL; + } + StorageList = GetFirstNode (&FormSet->StorageListHead); while (!IsNull (&FormSet->StorageListHead, StorageList)) { Storage = FORMSET_STORAGE_FROM_LINK (StorageList); + StorageList = GetNextNode (&FormSet->StorageListHead, StorageList); + if (Storage->Type != EFI_HII_VARSTORE_BUFFER) { + continue; + } if ((Storage->VarStoreId == FormSet->DefaultVarStoreId) && (FormSet->OriginalDefaultVarStoreName != NULL)) { Name = FormSet->OriginalDefaultVarStoreName; @@ -189,14 +169,12 @@ GetStorageFromConfigString ( Name = Storage->Name; } - if (IsConfigHdrMatch (ConfigString, &Storage->Guid, Name)) { + if (HiiIsConfigHdrMatch (ConfigString, &Storage->Guid, Name)) { return Storage; } - - StorageList = GetNextNode (&FormSet->StorageListHead, StorageList); } - return NULL; + return NULL; } /** @@ -343,11 +321,11 @@ CallFormCallBack ( } *Data = AllocateZeroPool (*DataSize); - if (Data == NULL) { + if (*Data == NULL) { return EFI_OUT_OF_RESOURCES; } - FwFormCallBack->NvRead ( + Status = FwFormCallBack->NvRead ( FwFormCallBack, BufferStorage->Name, &BufferStorage->Guid, @@ -376,7 +354,6 @@ CallFormCallBack ( @retval EFI_INVALID_PARAMETER If the UEFI Variable Get Service return the size information of the data does not match what has been recorded early in he BUFFER_STORAGE_ENTRY. **/ - EFI_STATUS GetUefiVariable ( IN FORMSET_STORAGE *BufferStorage, @@ -403,7 +380,7 @@ GetUefiVariable ( } *Data = AllocateZeroPool (*DataSize); - if (Data == NULL) { + if (*Data == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -451,73 +428,200 @@ ThunkExtractConfig ( OUT EFI_STRING *Results ) { - EFI_STATUS Status; - CONFIG_ACCESS_PRIVATE *ConfigAccess; - FORMSET_STORAGE *BufferStorage; - VOID *Data; - UINTN DataSize; - - if (Request == NULL) { + EFI_STATUS Status; + CONFIG_ACCESS_PRIVATE *ConfigAccess; + FORMSET_STORAGE *BufferStorage; + VOID *Data; + UINTN DataSize; + FORM_BROWSER_FORMSET *FormSetContext; + CHAR16 *VarStoreName; + EFI_STRING ConfigRequestHdr; + EFI_STRING ConfigRequest; + UINTN Size; + BOOLEAN AllocatedRequest; + LIST_ENTRY *StorageList; + EFI_STRING SingleResult; + EFI_STRING FinalResults; + EFI_STRING StrPointer; + + if (Progress == NULL || Results == NULL) { + return EFI_INVALID_PARAMETER; + } + *Progress = Request; + + Status = EFI_SUCCESS; + Data = NULL; + StrPointer = NULL; + SingleResult = NULL; + FinalResults = NULL; + ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This); + FormSetContext = ConfigAccess->ThunkContext->FormSet; + if (IsListEmpty (&FormSetContext->StorageListHead)) { + // + // No VarStorage does exist in this form. + // return EFI_NOT_FOUND; } + StorageList = GetFirstNode (&FormSetContext->StorageListHead); - Data = NULL; - ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This); + do { + if (Request != NULL) { + BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request); + if (BufferStorage == NULL) { + return EFI_NOT_FOUND; + } + } else { + if (IsNull (&FormSetContext->StorageListHead, StorageList)) { + // + // No Storage to be extracted into the results. + // + break; + } + BufferStorage = FORMSET_STORAGE_FROM_LINK (StorageList); + StorageList = GetNextNode (&FormSetContext->StorageListHead, StorageList); + if (BufferStorage->Type != EFI_HII_VARSTORE_BUFFER) { + // + // BufferStorage type should be EFI_HII_VARSTORE_BUFFER + // + continue; + } + } + + VarStoreName = NULL; + ConfigRequestHdr = NULL; + ConfigRequest = NULL; + Size = 0; + AllocatedRequest = FALSE; - BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request); + if (ConfigAccess->ThunkContext->NvMapOverride == NULL) { + // + // NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback. + // + if (ConfigAccess->FormCallbackProtocol == NULL || + ConfigAccess->FormCallbackProtocol->NvRead == NULL) { + Status = GetUefiVariable ( + BufferStorage, + &Data, + &DataSize + ); + } else { + Status = CallFormCallBack ( + BufferStorage, + ConfigAccess->FormCallbackProtocol, + &Data, + &DataSize + ); + } + } else { + // + // Use the NvMapOverride. + // + DataSize = BufferStorage->Size; + Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride); + + if (Data != NULL) { + Status = EFI_SUCCESS; + } else { + Status = EFI_OUT_OF_RESOURCES; + } + } + + if (!EFI_ERROR (Status)) { + ConfigRequest = Request; + if (Request == NULL || (StrStr (Request, L"OFFSET") == NULL)) { + // + // Request is without any request element, construct full request string. + // - if (BufferStorage == NULL) { - *Progress = (EFI_STRING) Request; - return EFI_NOT_FOUND; - } + if ((BufferStorage->VarStoreId == FormSetContext->DefaultVarStoreId) && (FormSetContext->OriginalDefaultVarStoreName != NULL)) { + VarStoreName = FormSetContext->OriginalDefaultVarStoreName; + } else { + VarStoreName = BufferStorage->Name; + } - if (ConfigAccess->ThunkContext->NvMapOverride == NULL) { + // + // First Set ConfigRequestHdr string. + // + ConfigRequestHdr = HiiConstructConfigHdr (&BufferStorage->Guid, VarStoreName, ConfigAccess->ThunkContext->UefiHiiDriverHandle); + ASSERT (ConfigRequestHdr != NULL); + + // + // Allocate and fill a buffer large enough to hold the template + // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator + // + Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); + ConfigRequest = AllocateZeroPool (Size); + ASSERT (ConfigRequest != NULL); + AllocatedRequest = TRUE; + UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)DataSize); + FreePool (ConfigRequestHdr); + } + Status = mHiiConfigRoutingProtocol->BlockToConfig ( + mHiiConfigRoutingProtocol, + ConfigRequest, + Data, + DataSize, + &SingleResult, + Progress + ); + // + // Free the allocated config request string. + // + if (AllocatedRequest) { + FreePool (ConfigRequest); + ConfigRequest = NULL; + } + } // - // NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback. + // Free the allocated Data // - if (ConfigAccess->FormCallbackProtocol == NULL || - ConfigAccess->FormCallbackProtocol->NvRead == NULL) { - Status = GetUefiVariable ( - BufferStorage, - &Data, - &DataSize - ); - } else { - Status = CallFormCallBack ( - BufferStorage, - ConfigAccess->FormCallbackProtocol, - &Data, - &DataSize - ); + if (Data != NULL) { + FreePool (Data); } - } else { // - // Use the NvMapOverride. + // Directly return when meet with error // - DataSize = BufferStorage->Size; - Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride); - - if (Data != NULL) { - Status = EFI_SUCCESS; + if (EFI_ERROR (Status)) { + break; + } + // + // Merge result into the final results. + // + if (FinalResults == NULL) { + FinalResults = SingleResult; + SingleResult = NULL; } else { - Status = EFI_OUT_OF_RESOURCES; + Size = StrLen (FinalResults); + Size = Size + 1; + Size = Size + StrLen (SingleResult) + 1; + StrPointer = AllocateZeroPool (Size * sizeof (CHAR16)); + ASSERT (StrPointer != NULL); + StrCpy (StrPointer, FinalResults); + FreePool (FinalResults); + FinalResults = StrPointer; + StrPointer = StrPointer + StrLen (StrPointer); + *StrPointer = L'&'; + StrCpy (StrPointer + 1, SingleResult); + FreePool (SingleResult); } - } - + } while (Request == NULL); + if (!EFI_ERROR (Status)) { - Status = mHiiConfigRoutingProtocol->BlockToConfig ( - mHiiConfigRoutingProtocol, - Request, - Data, - DataSize, - Results, - Progress - ); + *Results = FinalResults; + } else { + if (FinalResults != NULL) { + FreePool (FinalResults); + } } - - if (Data != NULL) { - FreePool (Data); + // + // Set Progress string to the original request string. + // + if (Request == NULL) { + *Progress = NULL; + } else if (StrStr (Request, L"OFFSET") == NULL) { + *Progress = Request + StrLen (Request); } + return Status; } @@ -550,7 +654,6 @@ ThunkRouteConfig ( VOID *Data; UINTN DataSize; UINTN DataSize2; - UINTN LastModifiedByteIndex; BOOLEAN ResetRequired; BOOLEAN DataAllocated; @@ -601,17 +704,18 @@ ThunkRouteConfig ( } } + DataSize = DataSize2; Status = mHiiConfigRoutingProtocol->ConfigToBlock ( mHiiConfigRoutingProtocol, Configuration, Data, - &LastModifiedByteIndex, + &DataSize, Progress ); if (EFI_ERROR (Status)) { goto Done; } - + if (ConfigAccess->ThunkContext->NvMapOverride == NULL) { if (ConfigAccess->FormCallbackProtocol == NULL || ConfigAccess->FormCallbackProtocol->NvWrite == NULL) { @@ -632,7 +736,6 @@ ThunkRouteConfig ( Data, &ResetRequired ); - } } @@ -645,21 +748,21 @@ Done: } /** - Build the FRAMEWORK_EFI_IFR_DATA_ARRAY which will be used to pass to - EFI_FORM_CALLBACK_PROTOCOL.Callback. Check definition of FRAMEWORK_EFI_IFR_DATA_ARRAY + Build the EFI_IFR_DATA_ARRAY which will be used to pass to + EFI_FORM_CALLBACK_PROTOCOL.Callback. Check definition of EFI_IFR_DATA_ARRAY for details. ASSERT if the Question Type is not EFI_IFR_TYPE_NUM_SIZE_* or EFI_IFR_TYPE_STRING. - @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL + @param ConfigAccess Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL @param QuestionId The Question ID. @param Type The Question Type. @param Value The Question Value. @param NvMapAllocated On output indicates if a buffer is allocated for NvMap. - @return A pointer to FRAMEWORK_EFI_IFR_DATA_ARRAY. The caller must free this buffer allocated. + @return A pointer to EFI_IFR_DATA_ARRAY. The caller must free this buffer allocated. **/ -FRAMEWORK_EFI_IFR_DATA_ARRAY * +EFI_IFR_DATA_ARRAY * CreateIfrDataArray ( IN CONFIG_ACCESS_PRIVATE *ConfigAccess, IN EFI_QUESTION_ID QuestionId, @@ -668,13 +771,13 @@ CreateIfrDataArray ( OUT BOOLEAN *NvMapAllocated ) { - FRAMEWORK_EFI_IFR_DATA_ARRAY *IfrDataArray; - FRAMEWORK_EFI_IFR_DATA_ENTRY *IfrDataEntry; + EFI_IFR_DATA_ARRAY *IfrDataArray; + EFI_IFR_DATA_ENTRY *IfrDataEntry; UINTN BrowserDataSize; - FORMSET_STORAGE *BufferStorage; - EFI_STATUS Status; + FORMSET_STORAGE *BufferStorage; UINTN Size; EFI_STRING String; + FORM_BROWSER_STATEMENT *Statement; *NvMapAllocated = FALSE; @@ -690,10 +793,19 @@ CreateIfrDataArray ( break; case EFI_IFR_TYPE_STRING: - String = HiiGetString (ConfigAccess->ThunkContext->UefiHiiHandle, Value->string, NULL); - ASSERT (String != NULL); + if (Value->string == 0) { + Size = 0; + } else { + String = HiiGetString (ConfigAccess->ThunkContext->UefiHiiHandle, Value->string, NULL); + ASSERT (String != NULL); - Size = StrSize (String); + Size = StrSize (String); + } + break; + + case EFI_IFR_TYPE_ACTION: + case EFI_IFR_TYPE_UNDEFINED: + Size = 0; break; default: @@ -702,21 +814,27 @@ CreateIfrDataArray ( break; } - IfrDataArray = AllocateZeroPool (sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY) + sizeof (FRAMEWORK_EFI_IFR_DATA_ENTRY) + Size); + IfrDataArray = AllocateZeroPool (sizeof (EFI_IFR_DATA_ARRAY) + sizeof (EFI_IFR_DATA_ENTRY) + Size); ASSERT (IfrDataArray != NULL); + IfrDataArray->EntryCount = 1; + IfrDataEntry = (EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1); - BufferStorage = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId); + Statement = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId); - if (BufferStorage == NULL) { + if (Statement == NULL || Statement->Storage == NULL) { // // The QuestionId is not associated with a Buffer Storage. // Try to get the first Buffer Storage then. // BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet); + } else { + BufferStorage = Statement->Storage; + IfrDataEntry->OpCode = Statement->Operand; } if (BufferStorage != NULL) { - BrowserDataSize = BufferStorage->Size; + BrowserDataSize = BufferStorage->Size; + IfrDataEntry->Length = (UINT8) (sizeof (EFI_IFR_DATA_ENTRY) + Size); if (ConfigAccess->ThunkContext->NvMapOverride == NULL) { *NvMapAllocated = TRUE; @@ -726,10 +844,7 @@ CreateIfrDataArray ( IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride; } - Status = GetBrowserData (&BufferStorage->Guid, BufferStorage->Name, &BrowserDataSize, IfrDataArray->NvRamMap); - ASSERT_EFI_ERROR (Status); - - IfrDataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1); + ASSERT (HiiGetBrowserData (&BufferStorage->Guid, BufferStorage->Name, BrowserDataSize, (UINT8 *) IfrDataArray->NvRamMap)); switch (Type) { case EFI_IFR_TYPE_NUM_SIZE_8: @@ -741,21 +856,28 @@ CreateIfrDataArray ( break; case EFI_IFR_TYPE_STRING: - ASSERT (String != NULL); - StrCpy ((CHAR16 *) &IfrDataEntry->Data, String); - FreePool (String); + if (Size != 0) { + ASSERT (String != NULL); + StrCpy ((CHAR16 *) &IfrDataEntry->Data, String); + FreePool (String); + } break; + + case EFI_IFR_TYPE_ACTION: + case EFI_IFR_TYPE_UNDEFINED: + break; + default: ASSERT (FALSE); break; } // - // Need to fiil in the information for the rest of field for FRAMEWORK_EFI_IFR_DATA_ENTRY. + // Need to fiil in the information for the rest of field for EFI_IFR_DATA_ENTRY. // It seems that no implementation is found to use other fields. Leave them uninitialized for now. // //UINT8 OpCode; // Likely a string, numeric, or one-of - //UINT8 Length; // Length of the FRAMEWORK_EFI_IFR_DATA_ENTRY packet + //UINT8 Length; // Length of the EFI_IFR_DATA_ENTRY packet //UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback //VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value @@ -783,21 +905,24 @@ SyncBrowserDataForNvMapOverride ( IN EFI_QUESTION_ID QuestionId ) { - FORMSET_STORAGE *BufferStorage; - EFI_STATUS Status; - UINTN BrowserDataSize; + FORMSET_STORAGE *BufferStorage; + BOOLEAN CheckFlag; + UINTN BrowserDataSize; + FORM_BROWSER_STATEMENT *Statement; if (ConfigAccess->ThunkContext->NvMapOverride != NULL) { - BufferStorage = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId); + Statement = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId); - if (BufferStorage == NULL) { + if (Statement == NULL || Statement->Storage == NULL) { // // QuestionId is a statement without Storage. // 1) It is a Goto. // // BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet); + } else { + BufferStorage = Statement->Storage; } // @@ -807,22 +932,22 @@ SyncBrowserDataForNvMapOverride ( BrowserDataSize = BufferStorage->Size; - Status = SetBrowserData (&BufferStorage->Guid, BufferStorage->Name, BrowserDataSize, ConfigAccess->ThunkContext->NvMapOverride, NULL); - ASSERT_EFI_ERROR (Status); + CheckFlag = HiiSetBrowserData (&BufferStorage->Guid, BufferStorage->Name, BrowserDataSize, ConfigAccess->ThunkContext->NvMapOverride, NULL); + ASSERT (CheckFlag); } } /** - Free up resource allocated for a FRAMEWORK_EFI_IFR_DATA_ARRAY by CreateIfrDataArray (). + Free up resource allocated for a EFI_IFR_DATA_ARRAY by CreateIfrDataArray (). - @param Array The FRAMEWORK_EFI_IFR_DATA_ARRAY allocated. - @param NvMapAllocated If the NvRamMap is allocated for FRAMEWORK_EFI_IFR_DATA_ARRAY. + @param Array The EFI_IFR_DATA_ARRAY allocated. + @param NvMapAllocated If the NvRamMap is allocated for EFI_IFR_DATA_ARRAY. **/ VOID DestroyIfrDataArray ( - IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Array, + IN EFI_IFR_DATA_ARRAY *Array, IN BOOLEAN NvMapAllocated ) { @@ -985,133 +1110,139 @@ ThunkCallback ( CONFIG_ACCESS_PRIVATE *ConfigAccess; EFI_FORM_CALLBACK_PROTOCOL *FormCallbackProtocol; EFI_HII_CALLBACK_PACKET *Packet; - FRAMEWORK_EFI_IFR_DATA_ARRAY *Data; - FRAMEWORK_EFI_IFR_DATA_ENTRY *DataEntry; + EFI_IFR_DATA_ARRAY *Data; + EFI_IFR_DATA_ENTRY *DataEntry; UINT16 KeyValue; ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry; EFI_HANDLE NotifyHandle; EFI_INPUT_KEY Key; BOOLEAN NvMapAllocated; - ASSERT (This != NULL); - ASSERT (Value != NULL); - ASSERT (ActionRequest != NULL); + if (Action == EFI_BROWSER_ACTION_CHANGING) { + ASSERT (This != NULL); + ASSERT (Value != NULL); + ASSERT (ActionRequest != NULL); - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; - ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This); + ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This); - FormCallbackProtocol = ConfigAccess->FormCallbackProtocol; - if (FormCallbackProtocol == NULL) { - ASSERT (FALSE); - return EFI_UNSUPPORTED; - } + FormCallbackProtocol = ConfigAccess->FormCallbackProtocol; + if (FormCallbackProtocol == NULL) { + ASSERT (FALSE); + return EFI_UNSUPPORTED; + } - // - // Check if the QuestionId match a OneOfOption. - // - OneOfOptionMapEntry = GetOneOfOptionMapEntry (ConfigAccess->ThunkContext, QuestionId, Type, Value); + // + // Check if the QuestionId match a OneOfOption. + // + OneOfOptionMapEntry = GetOneOfOptionMapEntry (ConfigAccess->ThunkContext, QuestionId, Type, Value); + + if (OneOfOptionMapEntry == NULL) { + // + // This is not a One-Of-Option opcode. QuestionId is the KeyValue + // + KeyValue = QuestionId; + } else { + // + // Otherwise, use the original Key specified in One Of Option in the Framework VFR syntax. + // + KeyValue = OneOfOptionMapEntry->FwKey; + } - if (OneOfOptionMapEntry == NULL) { // - // This is not a One-Of-Option opcode. QuestionId is the KeyValue + // Build the EFI_IFR_DATA_ARRAY // - KeyValue = QuestionId; - } else { + Data = CreateIfrDataArray (ConfigAccess, QuestionId, Type, Value, &NvMapAllocated); + + Status = mHiiDatabase->RegisterPackageNotify ( + mHiiDatabase, + EFI_HII_PACKAGE_FORMS, + NULL, + FormUpdateNotify, + EFI_HII_DATABASE_NOTIFY_REMOVE_PACK, + &NotifyHandle + ); // - // Otherwise, use the original Key specified in One Of Option in the Framework VFR syntax. + //Call the Framework Callback function. // - KeyValue = OneOfOptionMapEntry->FwKey; - } - - // - // Build the FRAMEWORK_EFI_IFR_DATA_ARRAY - // - Data = CreateIfrDataArray (ConfigAccess, QuestionId, Type, Value, &NvMapAllocated); - - Status = mHiiDatabase->RegisterPackageNotify ( - mHiiDatabase, - EFI_HII_PACKAGE_FORMS, - NULL, - FormUpdateNotify, - EFI_HII_DATABASE_NOTIFY_REMOVE_PACK, - &NotifyHandle - ); - // - //Call the Framework Callback function. - // - Packet = NULL; - Status = FormCallbackProtocol->Callback ( - FormCallbackProtocol, - KeyValue, - Data, - &Packet - ); - SyncBrowserDataForNvMapOverride (ConfigAccess, QuestionId); + Packet = NULL; + Status = FormCallbackProtocol->Callback ( + FormCallbackProtocol, + KeyValue, + Data, + &Packet + ); + SyncBrowserDataForNvMapOverride (ConfigAccess, QuestionId); - // - // Callback require browser to perform action - // - if (EFI_ERROR (Status)) { - if (Packet != NULL) { - do { - IfrLibCreatePopUp (1, &Key, Packet->String); - } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); - } // - // Error Code in Status is discarded. + // Callback require browser to perform action // - } else { - if (Packet != NULL) { - if (Packet->DataArray.EntryCount == 1 && Packet->DataArray.NvRamMap == NULL) { - DataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) ((UINT8 *) Packet + sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY)); - if ((DataEntry->Flags & EXIT_REQUIRED) == EXIT_REQUIRED) { - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; - } - - if ((DataEntry->Flags & SAVE_REQUIRED) == SAVE_REQUIRED) { - Status = ConfigAccess->ConfigAccessProtocol.RouteConfig ( - &ConfigAccess->ConfigAccessProtocol, - NULL, - NULL - ); + if (EFI_ERROR (Status)) { + if (Packet != NULL) { + do { + CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, Packet->String, NULL); + } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); + } + // + // Error Code in Status is discarded. + // + } else { + if (Packet != NULL) { + if (Packet->DataArray.EntryCount == 1 && Packet->DataArray.NvRamMap == NULL) { + DataEntry = (EFI_IFR_DATA_ENTRY *) ((UINT8 *) Packet + sizeof (EFI_IFR_DATA_ARRAY)); + if ((DataEntry->Flags & EXIT_REQUIRED) == EXIT_REQUIRED) { + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + } + + if ((DataEntry->Flags & SAVE_REQUIRED) == SAVE_REQUIRED) { + Status = ConfigAccess->ConfigAccessProtocol.RouteConfig ( + &ConfigAccess->ConfigAccessProtocol, + NULL, + NULL + ); + } } - } - FreePool (Packet); + FreePool (Packet); + } } - } - // - // Unregister notify for Form package update - // - Status = mHiiDatabase->UnregisterPackageNotify ( - mHiiDatabase, - NotifyHandle - ); - // - // UEFI SetupBrowser behaves differently with Framework SetupBrowser when call back function - // update any forms in HII database. UEFI SetupBrowser will re-parse the displaying form package and load - // the values from variable storages. Framework SetupBrowser will only re-parse the displaying form packages. - // To make sure customer's previous changes is saved and the changing question behaves as expected, we - // issue a EFI_BROWSER_ACTION_REQUEST_SUBMIT to ask UEFI SetupBrowser to save the changes proceed to re-parse - // the form and load all the variable storages. - // - if (*ActionRequest == EFI_BROWSER_ACTION_REQUEST_NONE && mHiiPackageListUpdated) { - mHiiPackageListUpdated= FALSE; - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; - } else { - if (ConfigAccess->ThunkContext->FormSet->SubClass == EFI_FRONT_PAGE_SUBCLASS || - ConfigAccess->ThunkContext->FormSet->SubClass == EFI_SINGLE_USE_SUBCLASS) { - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + // + // Unregister notify for Form package update + // + Status = mHiiDatabase->UnregisterPackageNotify ( + mHiiDatabase, + NotifyHandle + ); + // + // UEFI SetupBrowser behaves differently with Framework SetupBrowser when call back function + // update any forms in HII database. UEFI SetupBrowser will re-parse the displaying form package and load + // the values from variable storages. Framework SetupBrowser will only re-parse the displaying form packages. + // To make sure customer's previous changes is saved and the changing question behaves as expected, we + // issue a EFI_BROWSER_ACTION_REQUEST_SUBMIT to ask UEFI SetupBrowser to save the changes proceed to re-parse + // the form and load all the variable storages. + // + if (*ActionRequest == EFI_BROWSER_ACTION_REQUEST_NONE && mHiiPackageListUpdated) { + mHiiPackageListUpdated= FALSE; + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; + } else { + if (ConfigAccess->ThunkContext->FormSet->SubClass == EFI_FRONT_PAGE_SUBCLASS || + ConfigAccess->ThunkContext->FormSet->SubClass == EFI_SINGLE_USE_SUBCLASS) { + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + } } - } + // + // Clean up. + // + DestroyIfrDataArray (Data, NvMapAllocated); + + return Status; + } // - // Clean up. + // All other action return unsupported. // - DestroyIfrDataArray (Data, NvMapAllocated); - - return Status; + return EFI_UNSUPPORTED; }