From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id 1F1821A1E13 for ; Sun, 7 Aug 2016 21:57:30 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 07 Aug 2016 21:57:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,488,1464678000"; d="scan'208";a="1031505937" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 07 Aug 2016 21:57:31 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 7 Aug 2016 21:57:29 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 7 Aug 2016 21:57:29 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.150]) with mapi id 14.03.0248.002; Mon, 8 Aug 2016 12:57:27 +0800 From: "Gao, Liming" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Dong, Eric" Thread-Topic: [patch 2/2] MdeModulePkg/Browser: Share default if some default value are not specified Thread-Index: AQHR7r8g60q+QdWWSUCO56cr9J+ZsqA+hEOw Date: Mon, 8 Aug 2016 04:57:26 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A1155E6204@shsmsx102.ccr.corp.intel.com> References: <1470363196-81536-1-git-send-email-dandan.bi@intel.com> <1470363196-81536-3-git-send-email-dandan.bi@intel.com> In-Reply-To: <1470363196-81536-3-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 2/2] MdeModulePkg/Browser: 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: Mon, 08 Aug 2016 04:57:30 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Dandan: I have two comments.=20 1) Why define EFI_HII_MAX_SUPPORT_DEFAULT_TYPE as 8? 2) Could we generate DefaultStoreListHead as ascending order? If so, don't = need call GetDefaultIdArray() function for each default retrieve.=20 Thanks Liming > -----Original Message----- > From: Bi, Dandan > Sent: Friday, August 05, 2016 10:13 AM > To: edk2-devel@lists.01.org > Cc: Gao, Liming ; Dong, Eric > Subject: [patch 2/2] MdeModulePkg/Browser: Share default if some default > value are not specified >=20 > Add a new implementation policy of getting default in SetupBrowser. > 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 > Cc: Liming Gao > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi > Reviewed-by: Eric Dong > --- > MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 66 > +++++++++++++++++++++++++- > MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 5 ++ > 2 files changed, 70 insertions(+), 1 deletion(-) >=20 > diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > index 6b38547..9473eb1 100644 > --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > @@ -4016,10 +4016,50 @@ ValueToOption ( > } >=20 > return NULL; > } >=20 > +/** > + This function is to get the default Id array, the default ids are in a= scending > order in the array. > + > + @param FormSet The form set. > + @param DefaultIdArray Point to the default Id Array. > + > + @retval DefaultIdCount Return the default Id number in the= array. > + > +**/ > +UINT16 > +GetDefaultIdArray ( > + IN FORM_BROWSER_FORMSET *FormSet, > + IN OUT UINT16 *DefaultIdArray > + ) > +{ > + FORMSET_DEFAULTSTORE *DefaultStore; > + LIST_ENTRY *DefaultLink; > + UINT16 DefaultIdCount; > + UINT16 Index; > + > + DefaultIdCount =3D 0; > + > + DefaultLink =3D GetFirstNode (&FormSet->DefaultStoreListHead); > + while (!IsNull (&FormSet->DefaultStoreListHead, DefaultLink)) { > + DefaultStore =3D FORMSET_DEFAULTSTORE_FROM_LINK(DefaultLink); > + Index =3D DefaultIdCount; > + // > + // Insert the DefaultId to the Array with ascending order. > + // > + while (Index > 0 && DefaultStore->DefaultId < DefaultIdArray[Index = - 1]) > { > + DefaultIdArray[Index] =3D DefaultIdArray[Index -1]; > + Index--; > + } > + DefaultIdArray[Index] =3D DefaultStore->DefaultId; > + DefaultLink =3D GetNextNode (&FormSet->DefaultStoreListHead, > DefaultLink); > + DefaultIdCount++; > + } > + > + return DefaultIdCount; > +} >=20 > /** > Reset Question to its default value. >=20 > @param FormSet The form set. > @@ -4048,29 +4088,38 @@ GetQuestionDefault ( > EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; > EFI_BROWSER_ACTION_REQUEST ActionRequest; > INTN Action; > CHAR16 *NewString; > EFI_IFR_TYPE_VALUE *TypeValue; > + UINT16 DefaultIdNumber; > + UINT16 > DefaultIdArray[EFI_HII_MAX_SUPPORT_DEFAULT_TYPE]; > + UINT16 ReGetCount; > + UINT16 OriginalDefaultId; >=20 > Status =3D EFI_NOT_FOUND; > StrValue =3D NULL; > + ReGetCount =3D 0; > + OriginalDefaultId =3D DefaultId; >=20 > // > // Statement don't have storage, skip them > // > if (Question->QuestionId =3D=3D 0) { > return Status; > } >=20 > + DefaultIdNumber =3D GetDefaultIdArray (FormSet, DefaultIdArray); > + > // > // There are Five ways to specify default value for a Question: > // 1, use call back function (highest priority) > // 2, use ExtractConfig function > // 3, use nested EFI_IFR_DEFAULT > // 4, set flags of EFI_ONE_OF_OPTION (provide Standard and > Manufacturing default) > // 5, set flags of EFI_IFR_CHECKBOX (provide Standard and Manufacturi= ng > default) (lowest priority) > // > +ReGetDefault: > HiiValue =3D &Question->HiiValue; > TypeValue =3D &HiiValue->Value; > if (HiiValue->Type =3D=3D EFI_IFR_TYPE_BUFFER) { > // > // For orderedlist, need to pass the BufferValue to Callback functio= n. > @@ -4233,11 +4282,26 @@ GetQuestionDefault ( > return EFI_SUCCESS; > } > } >=20 > // > - // For Questions without default > + // For question without default value for current default Id, we try t= o re- > get the default value form other default id in the DefaultIdArray. > + // If get, will exit the function, if not, will choose next default id= in the > DefaultIdArray. > + // The default id in DefaultIdArray are in ascending order to make sur= e > choose the smallest default id every time. > + // > + while (ReGetCount < DefaultIdNumber) { > + DefaultId =3D DefaultIdArray[ReGetCount]; > + if (DefaultId =3D=3D OriginalDefaultId) { > + ReGetCount ++; > + continue; > + } > + ReGetCount ++; > + goto ReGetDefault; > + } > + > + // > + // For Questions without default value for all the default id in the > DefaultIdArray. > // > Status =3D EFI_NOT_FOUND; > switch (Question->Operand) { > case EFI_IFR_NUMERIC_OP: > // > diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h > b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h > index cbc5401..21f392c 100644 > --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h > +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h > @@ -61,10 +61,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF > ANY KIND, EITHER EXPRESS OR IMPLIED. > #define UI_ACTION_REFRESH_FORM 1 > #define UI_ACTION_REFRESH_FORMSET 2 > #define UI_ACTION_EXIT 3 >=20 > // > +// The maximum number of default type > +// > +#define EFI_HII_MAX_SUPPORT_DEFAULT_TYPE 0x08 > + > +// > // > // Time definitions > // > #define ONE_SECOND 10000000 >=20 > -- > 1.9.5.msysgit.1