From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ml01.01.org (Postfix) with ESMTP id 4D9411A1DFB for ; Thu, 4 Aug 2016 19:13:50 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 04 Aug 2016 19:13:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,471,1464678000"; d="scan'208";a="1030069096" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 04 Aug 2016 19:13:49 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Liming Gao , Eric Dong Date: Fri, 5 Aug 2016 10:13:15 +0800 Message-Id: <1470363196-81536-2-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1470363196-81536-1-git-send-email-dandan.bi@intel.com> References: <1470363196-81536-1-git-send-email-dandan.bi@intel.com> Subject: [patch 1/2] MdeModulePkg/HiiDB: Share default if some default value are not specified X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2016 02:13:50 -0000 Add a new implementation policy of getting default in HiiDatabase. The new policy is only for the situation that a question has default value but doesn't have default value for all supported default type. In this case, we will choose the smallest default id from the existing defaults, and share its value to other default id which has no default value. Cc: Liming Gao Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Eric Dong --- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 115 ++++++++++++++++++--- .../Universal/HiiDatabaseDxe/HiiDatabase.h | 2 + 2 files changed, 101 insertions(+), 16 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 0578352..0a5ea83 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -1150,11 +1150,11 @@ InsertDefaultValue ( DefaultValueArray = BASE_CR (Link, IFR_DEFAULT_DATA, Entry); if (DefaultValueArray->DefaultId == DefaultValueData->DefaultId) { // // DEFAULT_VALUE_FROM_OPCODE has high priority, DEFAULT_VALUE_FROM_DEFAULT has low priority. // - if (DefaultValueData->Type > DefaultValueArray->Type) { + if (DefaultValueData->Type >= DefaultValueArray->Type) { // // Update the default value array in BlockData. // CopyMem (&DefaultValueArray->Value, &DefaultValueData->Value, sizeof (EFI_IFR_TYPE_VALUE)); DefaultValueArray->Type = DefaultValueData->Type; @@ -2099,19 +2099,22 @@ ParseIfrData ( LIST_ENTRY *LinkData; LIST_ENTRY *LinkDefault; EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore; EFI_HII_PACKAGE_HEADER *PackageHeader; EFI_VARSTORE_ID VarStoreId; + UINT16 SmallestDefaultId; + UINT16 SmallestIdFromFlag; Status = EFI_SUCCESS; BlockData = NULL; DefaultDataPtr = NULL; FirstOneOfOption = FALSE; VarStoreId = 0; FirstOrderedList = FALSE; VarStoreName = NULL; ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); + SmallestDefaultId = 0xFFFF; // // Go through the form package to parse OpCode one by one. // PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER); @@ -2473,10 +2476,12 @@ ParseIfrData ( // //when go to there,BlockData can't be NULLL. // ASSERT (BlockData != NULL); + SmallestIdFromFlag = FALSE; + // // Add default value for standard ID by CheckBox Flag // VarDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; // @@ -2487,21 +2492,20 @@ ParseIfrData ( // // When flag is set, defautl value is TRUE. // DefaultData.Type = DefaultValueFromFlag; DefaultData.Value.b = TRUE; - } else { - // - // When flag is not set, defautl value is FASLE. - // - DefaultData.Type = DefaultValueFromDefault; - DefaultData.Value.b = FALSE; + InsertDefaultValue (BlockData, &DefaultData); + + if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_STANDARD) { + // + // Record the SmallestDefaultId and update the SmallestIdFromFlag. + // + SmallestDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; + SmallestIdFromFlag = TRUE; + } } - // - // Add DefaultValue into current BlockData - // - InsertDefaultValue (BlockData, &DefaultData); // // Add default value for Manufacture ID by CheckBox Flag // VarDefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING; @@ -2513,21 +2517,49 @@ ParseIfrData ( // // When flag is set, defautl value is TRUE. // DefaultData.Type = DefaultValueFromFlag; DefaultData.Value.b = TRUE; + InsertDefaultValue (BlockData, &DefaultData); + + if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_MANUFACTURING) { + // + // Record the SmallestDefaultId and update the SmallestIdFromFlag. + // + SmallestDefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING; + SmallestIdFromFlag = TRUE; + } + } + if (SmallestIdFromFlag) { + // + // When smallest default Id is given by the flag of CheckBox, set defaut value with TRUE for other default Id in the DefaultId list. + // + DefaultData.Type = DefaultValueFromOtherDefault; + DefaultData.Value.b = TRUE; + // + // Set default value for all the default id in the DefaultId list. + // + for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) { + DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); + DefaultData.DefaultId = DefaultDataPtr->DefaultId; + InsertDefaultValue (BlockData, &DefaultData); + } } else { // // When flag is not set, defautl value is FASLE. // DefaultData.Type = DefaultValueFromDefault; DefaultData.Value.b = FALSE; + // + // Set default value for all the default id in the DefaultId list. + // + for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) { + DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); + DefaultData.DefaultId = DefaultDataPtr->DefaultId; + InsertDefaultValue (BlockData, &DefaultData); + } } - // - // Add DefaultValue into current BlockData - // - InsertDefaultValue (BlockData, &DefaultData); break; case EFI_IFR_DATE_OP: // // offset by question header @@ -2777,30 +2809,62 @@ ParseIfrData ( break; } // // 1. Set default value for OneOf option when flag field has default attribute. + // And set the default value with the smallest default id for other default id in the DefaultId list. // if (((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) || ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT_MFG) == EFI_IFR_OPTION_DEFAULT_MFG)) { // // This flag is used to specify whether this option is the first. Set it to FALSE for the following options. // The first oneof option value will be used as default value when no default value is specified. // FirstOneOfOption = FALSE; + + SmallestIdFromFlag = FALSE; // Prepare new DefaultValue // DefaultData.Type = DefaultValueFromFlag; CopyMem (&DefaultData.Value, &IfrOneOfOption->Value, IfrOneOfOption->Header.Length - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value)); if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) { DefaultData.DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; InsertDefaultValue (BlockData, &DefaultData); - } + if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_STANDARD) { + // + // Record the SmallestDefaultId and update the SmallestIdFromFlag. + // + SmallestDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; + SmallestIdFromFlag = TRUE; + } + } if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT_MFG) == EFI_IFR_OPTION_DEFAULT_MFG) { DefaultData.DefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING; InsertDefaultValue (BlockData, &DefaultData); + if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_MANUFACTURING) { + // + // Record the SmallestDefaultId and update the SmallestIdFromFlag. + // + SmallestDefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING; + SmallestIdFromFlag = TRUE; + } + } + + if (SmallestIdFromFlag) { + // + // When smallest default Id is given by the flag of oneofOption, set this option value for other default Id in the DefaultId list. + // + DefaultData.Type = DefaultValueFromOtherDefault; + // + // Set default value for other default id in the DefaultId list. + // + for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) { + DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); + DefaultData.DefaultId = DefaultDataPtr->DefaultId; + InsertDefaultValue (BlockData, &DefaultData); + } } } // // 2. Set as the default value when this is the first option. @@ -2854,10 +2918,25 @@ ParseIfrData ( // Add DefaultValue into current BlockData // InsertDefaultValue (BlockData, &DefaultData); // + // Set default value for other default id in the DefaultId list. + // + if (SmallestDefaultId >= VarDefaultId) { + SmallestDefaultId = VarDefaultId; + for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) { + DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); + if (DefaultDataPtr->DefaultId != DefaultData.DefaultId){ + DefaultData.Type = DefaultValueFromOtherDefault; + DefaultData.DefaultId = DefaultDataPtr->DefaultId; + InsertDefaultValue (BlockData, &DefaultData); + } + } + } + + // // After insert the default value, reset the cleaned value for next // time used. If not set here, need to set the value before everytime // use it. // DefaultData.Cleaned = FALSE; @@ -2871,10 +2950,14 @@ ParseIfrData ( if (BlockData->Scope > 0) { BlockData->Scope--; } if (BlockData->Scope == 0) { BlockData = NULL; + // + // when finishing parsing a question, clean the SmallestDefaultId of the question. + // + SmallestDefaultId = 0xFFFF; } } break; diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h index d90bc02..d85a804 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h @@ -85,10 +85,12 @@ typedef struct { // // Get default value from IFR data. // typedef enum { DefaultValueFromDefault = 0, // Get from the minimum or first one when not set default value. + DefaultValueFromOtherDefault, // Get default vale from other default when no default(When other + // defaults are more than one, use the default with smallest default id). DefaultValueFromFlag, // Get default value from the defalut flag. DefaultValueFromOpcode // Get default value from default opcode, highest priority. } DEFAULT_VALUE_TYPE; typedef struct { -- 1.9.5.msysgit.1