From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ml01.01.org (Postfix) with ESMTP id EA8B61A1E28 for ; Wed, 10 Aug 2016 03:02:28 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 10 Aug 2016 03:02:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,499,1464678000"; d="scan'208";a="1038526284" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 10 Aug 2016 03:02:28 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 10 Aug 2016 03:02:28 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.8]) with mapi id 14.03.0248.002; Wed, 10 Aug 2016 18:02:25 +0800 From: "Gao, Liming" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Dong, Eric" Thread-Topic: [PATCH v2 1/2] MdeModulePkg/HiiDB: Share default if some default value are not specified Thread-Index: AQHR8dzlGbt5sVS1MUWg80dQmfn5lqBB+NUA Date: Wed, 10 Aug 2016 10:02:25 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A1155E972A@shsmsx102.ccr.corp.intel.com> References: <1470705898-99100-1-git-send-email-dandan.bi@intel.com> <1470705898-99100-2-git-send-email-dandan.bi@intel.com> In-Reply-To: <1470705898-99100-2-git-send-email-dandan.bi@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 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: Wed, 10 Aug 2016 10:02:29 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Bi, Dandan > Sent: Tuesday, August 09, 2016 9:25 AM > To: edk2-devel@lists.01.org > Cc: Gao, Liming ; Dong, Eric > Subject: [PATCH v2 1/2] MdeModulePkg/HiiDB: Share default if some default > value are not specified >=20 > Add a new implementation policy of getting default value 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. >=20 > Notes: > v1->V2: > Clarify that when the type of DefaultValueData is > DefaultValueFromOtherDefault,it can be overrode by itself. >=20 > Cc: Liming Gao > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi > --- > .../Universal/HiiDatabaseDxe/ConfigRouting.c | 116 > ++++++++++++++++++--- > .../Universal/HiiDatabaseDxe/HiiDatabase.h | 2 + > 2 files changed, 102 insertions(+), 16 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > index 0578352..546e60c 100644 > --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > @@ -1149,12 +1149,13 @@ InsertDefaultValue ( > for (Link =3D DefaultLink->ForwardLink; Link !=3D DefaultLink; Link = =3D Link- > >ForwardLink) { > DefaultValueArray =3D BASE_CR (Link, IFR_DEFAULT_DATA, Entry); > if (DefaultValueArray->DefaultId =3D=3D DefaultValueData->DefaultId)= { > // > // DEFAULT_VALUE_FROM_OPCODE has high priority, > DEFAULT_VALUE_FROM_DEFAULT has low priority. > + // When the two default types are > DEFAULT_VALUE_FROM_OTHER_DEFAULT, the default value can be > overrode. > // > - if (DefaultValueData->Type > DefaultValueArray->Type) { > + if ((DefaultValueData->Type > DefaultValueArray->Type) || > (DefaultValueData->Type =3D=3D DefaultValueArray->Type && > DefaultValueData->Type =3D=3D DefaultValueFromOtherDefault)) { > // > // Update the default value array in BlockData. > // > CopyMem (&DefaultValueArray->Value, &DefaultValueData->Value, > sizeof (EFI_IFR_TYPE_VALUE)); > DefaultValueArray->Type =3D DefaultValueData->Type; > @@ -2099,19 +2100,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; >=20 > Status =3D EFI_SUCCESS; > BlockData =3D NULL; > DefaultDataPtr =3D NULL; > FirstOneOfOption =3D FALSE; > VarStoreId =3D 0; > FirstOrderedList =3D FALSE; > VarStoreName =3D NULL; > ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); > + SmallestDefaultId =3D 0xFFFF; >=20 > // > // Go through the form package to parse OpCode one by one. > // > PackageOffset =3D sizeof (EFI_HII_PACKAGE_HEADER); > @@ -2473,10 +2477,12 @@ ParseIfrData ( > // > //when go to there,BlockData can't be NULLL. > // > ASSERT (BlockData !=3D NULL); >=20 > + SmallestIdFromFlag =3D FALSE; > + > // > // Add default value for standard ID by CheckBox Flag > // > VarDefaultId =3D EFI_HII_DEFAULT_CLASS_STANDARD; > // > @@ -2487,21 +2493,20 @@ ParseIfrData ( > // > // When flag is set, defautl value is TRUE. > // > DefaultData.Type =3D DefaultValueFromFlag; > DefaultData.Value.b =3D TRUE; > - } else { > - // > - // When flag is not set, defautl value is FASLE. > - // > - DefaultData.Type =3D DefaultValueFromDefault; > - DefaultData.Value.b =3D FALSE; > + InsertDefaultValue (BlockData, &DefaultData); > + > + if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_STANDARD) { > + // > + // Record the SmallestDefaultId and update the SmallestIdFromF= lag. > + // > + SmallestDefaultId =3D EFI_HII_DEFAULT_CLASS_STANDARD; > + SmallestIdFromFlag =3D TRUE; > + } > } > - // > - // Add DefaultValue into current BlockData > - // > - InsertDefaultValue (BlockData, &DefaultData); >=20 > // > // Add default value for Manufacture ID by CheckBox Flag > // > VarDefaultId =3D EFI_HII_DEFAULT_CLASS_MANUFACTURING; > @@ -2513,21 +2518,49 @@ ParseIfrData ( > // > // When flag is set, defautl value is TRUE. > // > DefaultData.Type =3D DefaultValueFromFlag; > DefaultData.Value.b =3D TRUE; > + InsertDefaultValue (BlockData, &DefaultData); > + > + if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_MANUFACTURING) { > + // > + // Record the SmallestDefaultId and update the SmallestIdFromF= lag. > + // > + SmallestDefaultId =3D EFI_HII_DEFAULT_CLASS_MANUFACTURING; > + SmallestIdFromFlag =3D TRUE; > + } > + } > + if (SmallestIdFromFlag) { > + // > + // When smallest default Id is given by the flag of CheckBox, s= et defaut > value with TRUE for other default Id in the DefaultId list. > + // > + DefaultData.Type =3D DefaultValueFromOtherDefault; > + DefaultData.Value.b =3D TRUE; > + // > + // Set default value for all the default id in the DefaultId lis= t. > + // > + for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData != =3D > &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { > + DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry)= ; > + DefaultData.DefaultId =3D DefaultDataPtr->DefaultId; > + InsertDefaultValue (BlockData, &DefaultData); > + } > } else { > // > // When flag is not set, defautl value is FASLE. > // > DefaultData.Type =3D DefaultValueFromDefault; > DefaultData.Value.b =3D FALSE; > + // > + // Set default value for all the default id in the DefaultId lis= t. > + // > + for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData != =3D > &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { > + DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry)= ; > + DefaultData.DefaultId =3D DefaultDataPtr->DefaultId; > + InsertDefaultValue (BlockData, &DefaultData); > + } > } > - // > - // Add DefaultValue into current BlockData > - // > - InsertDefaultValue (BlockData, &DefaultData); > break; >=20 > case EFI_IFR_DATE_OP: > // > // offset by question header > @@ -2777,30 +2810,62 @@ ParseIfrData ( > break; > } >=20 > // > // 1. Set default value for OneOf option when flag field has defau= lt > attribute. > + // And set the default value with the smallest default id for o= ther > default id in the DefaultId list. > // > if (((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) =3D=3D > EFI_IFR_OPTION_DEFAULT) || > ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT_MFG) =3D=3D > 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 wh= en no > default value is specified. > // > FirstOneOfOption =3D FALSE; > + > + SmallestIdFromFlag =3D FALSE; >=20 > // Prepare new DefaultValue > // > DefaultData.Type =3D DefaultValueFromFlag; > CopyMem (&DefaultData.Value, &IfrOneOfOption->Value, > IfrOneOfOption->Header.Length - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, > Value)); > if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) =3D=3D > EFI_IFR_OPTION_DEFAULT) { > DefaultData.DefaultId =3D EFI_HII_DEFAULT_CLASS_STANDARD; > InsertDefaultValue (BlockData, &DefaultData); > - } > + if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_STANDARD) { > + // > + // Record the SmallestDefaultId and update the SmallestIdFro= mFlag. > + // > + SmallestDefaultId =3D EFI_HII_DEFAULT_CLASS_STANDARD; > + SmallestIdFromFlag =3D TRUE; > + } > + } > if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT_MFG) =3D=3D > EFI_IFR_OPTION_DEFAULT_MFG) { > DefaultData.DefaultId =3D EFI_HII_DEFAULT_CLASS_MANUFACTURING; > InsertDefaultValue (BlockData, &DefaultData); > + if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_MANUFACTURING) { > + // > + // Record the SmallestDefaultId and update the SmallestIdFro= mFlag. > + // > + SmallestDefaultId =3D EFI_HII_DEFAULT_CLASS_MANUFACTURING; > + SmallestIdFromFlag =3D TRUE; > + } > + } > + > + if (SmallestIdFromFlag) { > + // > + // When smallest default Id is given by the flag of oneofOptio= n, set this > option value for other default Id in the DefaultId list. > + // > + DefaultData.Type =3D DefaultValueFromOtherDefault; > + // > + // Set default value for other default id in the DefaultId lis= t. > + // > + for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData = !=3D > &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { > + DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA, Entr= y); > + DefaultData.DefaultId =3D DefaultDataPtr->DefaultId; > + InsertDefaultValue (BlockData, &DefaultData); > + } > } > } >=20 > // > // 2. Set as the default value when this is the first option. > @@ -2854,10 +2919,25 @@ ParseIfrData ( > // Add DefaultValue into current BlockData > // > InsertDefaultValue (BlockData, &DefaultData); >=20 > // > + // Set default value for other default id in the DefaultId list. > + // > + if (SmallestDefaultId >=3D VarDefaultId) { > + SmallestDefaultId =3D VarDefaultId; > + for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData != =3D > &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { > + DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry)= ; > + if (DefaultDataPtr->DefaultId !=3D DefaultData.DefaultId){ > + DefaultData.Type =3D DefaultValueFromOtherDefault; > + DefaultData.DefaultId =3D DefaultDataPtr->DefaultId; > + InsertDefaultValue (BlockData, &DefaultData); > + } > + } > + } > + > + // > // After insert the default value, reset the cleaned value for nex= t > // time used. If not set here, need to set the value before everyt= ime > // use it. > // > DefaultData.Cleaned =3D FALSE; > @@ -2871,10 +2951,14 @@ ParseIfrData ( > if (BlockData->Scope > 0) { > BlockData->Scope--; > } > if (BlockData->Scope =3D=3D 0) { > BlockData =3D NULL; > + // > + // when finishing parsing a question, clean the SmallestDefaul= tId of the > question. > + // > + SmallestDefaultId =3D 0xFFFF; > } > } >=20 > break; >=20 > diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h > b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h > index d90bc02..1b0f7f6 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 =3D 0, // Get from the minimum or first on= e when > not set default value. > + DefaultValueFromOtherDefault, // Get default vale from other defaul= t > when no default(When other > + // defaults are more than one, use th= e default with > smallest default id). > DefaultValueFromFlag, // Get default value from the defalut= flag. > DefaultValueFromOpcode // Get default value from default opc= ode, > highest priority. > } DEFAULT_VALUE_TYPE; >=20 > typedef struct { > -- > 1.9.5.msysgit.1