From 40ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5 Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Tue, 4 Aug 2015 09:09:10 +0000 Subject: MdeModulePkg:Fix the issue that refresh the question fail in DriverSample Once the question is refreshed,the processing should happen in the callback function of EFI_BROWSER_ACTION_RETRIEVE case,rather than EFI_BROWSER_ACTION_CHANGING in DriverSample. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Eric Dong git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18150 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/DriverSampleDxe/DriverSample.c | 165 ++++++++++----------- 1 file changed, 82 insertions(+), 83 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index a21f58a77d..2f77d39e52 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -1375,14 +1375,90 @@ DriverCallback ( case EFI_BROWSER_ACTION_RETRIEVE: { - if (QuestionId == 0x1248) { - { - if (Type != EFI_IFR_TYPE_REF) { - return EFI_INVALID_PARAMETER; + switch (QuestionId ) { + case 0x1248: + if (Type != EFI_IFR_TYPE_REF) { + return EFI_INVALID_PARAMETER; + } + Value->ref.FormId = 0x3; + break; + + case 0x5678: + case 0x1247: + // + // We will reach here once the Question is refreshed + // + + // + // Initialize the container for dynamic opcodes + // + StartOpCodeHandle = HiiAllocateOpCodeHandle (); + ASSERT (StartOpCodeHandle != NULL); + + // + // Create Hii Extend Label OpCode as the start opcode + // + StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; + if (QuestionId == 0x5678) { + StartLabel->Number = LABEL_UPDATE2; + FormId = 0x03; + PrivateData->Configuration.DynamicRefresh++; + } else if (QuestionId == 0x1247 ) { + StartLabel->Number = LABEL_UPDATE3; + FormId = 0x06; + PrivateData->Configuration.RefreshGuidCount++; + } + + HiiCreateActionOpCode ( + StartOpCodeHandle, // Container for dynamic created opcodes + 0x1237, // Question ID + STRING_TOKEN(STR_EXIT_TEXT), // Prompt text + STRING_TOKEN(STR_EXIT_TEXT), // Help text + EFI_IFR_FLAG_CALLBACK, // Question flag + 0 // Action String ID + ); + + HiiUpdateForm ( + PrivateData->HiiHandle[0], // HII handle + &gDriverSampleFormSetGuid, // Formset GUID + FormId, // Form ID + StartOpCodeHandle, // Label for where to insert opcodes + NULL // Insert data + ); + + HiiFreeOpCodeHandle (StartOpCodeHandle); + + // + // Refresh the Question value + // + Status = gRT->SetVariable( + VariableName, + &gDriverSampleFormSetGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof (DRIVER_SAMPLE_CONFIGURATION), + &PrivateData->Configuration + ); + + if (QuestionId == 0x5678) { + // + // Update uncommitted data of Browser + // + EfiData = AllocateZeroPool (sizeof (MY_EFI_VARSTORE_DATA)); + ASSERT (EfiData != NULL); + if (HiiGetBrowserData (&gDriverSampleFormSetGuid, MyEfiVar, sizeof (MY_EFI_VARSTORE_DATA), (UINT8 *) EfiData)) { + EfiData->Field8 = 111; + HiiSetBrowserData ( + &gDriverSampleFormSetGuid, + MyEfiVar, + sizeof (MY_EFI_VARSTORE_DATA), + (UINT8 *) EfiData, + NULL + ); } - - Value->ref.FormId = 0x3; + FreePool (EfiData); } + break; } } break; @@ -1596,83 +1672,6 @@ DriverCallback ( HiiFreeOpCodeHandle (EndOpCodeHandle); break; - case 0x5678: - case 0x1247: - // - // We will reach here once the Question is refreshed - // - - // - // Initialize the container for dynamic opcodes - // - StartOpCodeHandle = HiiAllocateOpCodeHandle (); - ASSERT (StartOpCodeHandle != NULL); - - // - // Create Hii Extend Label OpCode as the start opcode - // - StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); - StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; - if (QuestionId == 0x5678) { - StartLabel->Number = LABEL_UPDATE2; - FormId = 0x03; - PrivateData->Configuration.DynamicRefresh++; - } else if (QuestionId == 0x1247 ) { - StartLabel->Number = LABEL_UPDATE3; - FormId = 0x06; - PrivateData->Configuration.RefreshGuidCount++; - } - - HiiCreateActionOpCode ( - StartOpCodeHandle, // Container for dynamic created opcodes - 0x1237, // Question ID - STRING_TOKEN(STR_EXIT_TEXT), // Prompt text - STRING_TOKEN(STR_EXIT_TEXT), // Help text - EFI_IFR_FLAG_CALLBACK, // Question flag - 0 // Action String ID - ); - - HiiUpdateForm ( - PrivateData->HiiHandle[0], // HII handle - &gDriverSampleFormSetGuid, // Formset GUID - FormId, // Form ID - StartOpCodeHandle, // Label for where to insert opcodes - NULL // Insert data - ); - - HiiFreeOpCodeHandle (StartOpCodeHandle); - - // - // Refresh the Question value - // - Status = gRT->SetVariable( - VariableName, - &gDriverSampleFormSetGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, - sizeof (DRIVER_SAMPLE_CONFIGURATION), - &PrivateData->Configuration - ); - - if (QuestionId == 0x5678) { - // - // Update uncommitted data of Browser - // - EfiData = AllocateZeroPool (sizeof (MY_EFI_VARSTORE_DATA)); - ASSERT (EfiData != NULL); - if (HiiGetBrowserData (&gDriverSampleFormSetGuid, MyEfiVar, sizeof (MY_EFI_VARSTORE_DATA), (UINT8 *) EfiData)) { - EfiData->Field8 = 111; - HiiSetBrowserData ( - &gDriverSampleFormSetGuid, - MyEfiVar, - sizeof (MY_EFI_VARSTORE_DATA), - (UINT8 *) EfiData, - NULL - ); - } - FreePool (EfiData); - } - break; - case 0x2000: // // Only used to update the state. -- cgit v1.2.3