From nobody Thu Dec 26 12:07:01 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1505896773494812.9217760514697; Wed, 20 Sep 2017 01:39:33 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 11D9621ECCB2D; Wed, 20 Sep 2017 01:36:23 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BF7E621ECCB08 for ; Wed, 20 Sep 2017 01:36:21 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 01:39:27 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 20 Sep 2017 01:39:26 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,420,1500966000"; d="scan'208";a="153434366" From: Dandan Bi To: edk2-devel@lists.01.org Date: Wed, 20 Sep 2017 16:39:06 +0800 Message-Id: <1505896748-436688-5-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1505896748-436688-1-git-send-email-dandan.bi@intel.com> References: <1505896748-436688-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [PATCH V5 4/6] MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Dong , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" V5: Update the EDKII extension GUID name with EDKII/Edkii prefix. REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D545 For oneof/numeric/checkbox, their storage may be bit field. When generating string to get default value for these questions, we need to parse the Ifr data to get the bit Varstore info,and then generating the correct string. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 346 +++++++++++++++++= ++-- .../Universal/HiiDatabaseDxe/HiiDatabase.h | 6 +- .../Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf | 3 +- 3 files changed, 319 insertions(+), 36 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeMod= ulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index c9ff1cf..a87f31e 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -1223,19 +1223,19 @@ InsertBlockData ( // Insert block data in its Offset and Width order. // for (Link =3D BlockLink->ForwardLink; Link !=3D BlockLink; Link =3D Link= ->ForwardLink) { BlockArray =3D BASE_CR (Link, IFR_BLOCK_DATA, Entry); if (BlockArray->Offset =3D=3D BlockSingleData->Offset) { - if (BlockArray->Width > BlockSingleData->Width) { + if ((BlockArray->Width > BlockSingleData->Width) || (BlockSingleData= ->IsBitVar && BlockArray->Width =3D=3D BlockSingleData->Width)) { // // Insert this block data in the front of block array // InsertTailList (Link, &BlockSingleData->Entry); return; } =20 - if (BlockArray->Width =3D=3D BlockSingleData->Width) { + if ((!BlockSingleData->IsBitVar) && BlockArray->Width =3D=3D BlockSi= ngleData->Width) { // // The same block array has been added. // if (BlockSingleData !=3D BlockArray) { FreePool (BlockSingleData); @@ -1978,10 +1978,11 @@ Done: @param HiiHandle The hii handle for this form package. @param VarStorageData The varstore data structure. @param IfrOpHdr Ifr opcode header for this opcode. @param VarWidth The buffer width for this opcode. @param ReturnData The data block added for this opcode. + @param IsBitVar Whether the the opcode refers to bit stor= age. =20 @retval EFI_SUCCESS This opcode is required. @retval EFI_NOT_FOUND This opcode is not required. @retval Others Contain some error. =20 @@ -1991,20 +1992,26 @@ IsThisOpcodeRequired ( IN IFR_BLOCK_DATA *RequestBlockArray, IN EFI_HII_HANDLE HiiHandle, IN OUT IFR_VARSTORAGE_DATA *VarStorageData, IN EFI_IFR_OP_HEADER *IfrOpHdr, IN UINT16 VarWidth, - OUT IFR_BLOCK_DATA **ReturnData + OUT IFR_BLOCK_DATA **ReturnData, + IN BOOLEAN IsBitVar ) { IFR_BLOCK_DATA *BlockData; UINT16 VarOffset; EFI_STRING_ID NameId; EFI_IFR_QUESTION_HEADER *IfrQuestionHdr; + UINT16 BitOffset; + UINT16 BitWidth; + UINT16 TotalBits; =20 NameId =3D 0; VarOffset =3D 0; + BitOffset =3D 0; + BitWidth =3D 0; IfrQuestionHdr =3D (EFI_IFR_QUESTION_HEADER *)((CHAR8 *) IfrOpHdr + siz= eof (EFI_IFR_OP_HEADER)); =20 if (VarStorageData->Type =3D=3D EFI_HII_VARSTORE_NAME_VALUE) { NameId =3D IfrQuestionHdr->VarStoreInfo.VarName; =20 @@ -2016,11 +2023,27 @@ IsThisOpcodeRequired ( // This question is not in the requested string. Skip it. // return EFI_NOT_FOUND; } } else { - VarOffset =3D IfrQuestionHdr->VarStoreInfo.VarOffset; + // + // Get the byte offset/with and bit offset/width + // + if (IsBitVar) { + BitOffset =3D IfrQuestionHdr->VarStoreInfo.VarOffset; + BitWidth =3D VarWidth; + VarOffset =3D BitOffset / 8; + // + // Use current bit width and the bit width before current bit (with = same byte offset) to calculate the byte width. + // + TotalBits =3D BitOffset % 8 + BitWidth; + VarWidth =3D (TotalBits % 8 =3D=3D 0 ? TotalBits / 8: TotalBits / 8 = + 1); + } else { + VarOffset =3D IfrQuestionHdr->VarStoreInfo.VarOffset; + BitWidth =3D VarWidth; + BitOffset =3D VarOffset * 8; + } =20 // // Check whether this question is in requested block array. // if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth, FALSE, H= iiHandle)) { @@ -2051,10 +2074,13 @@ IsThisOpcodeRequired ( =20 BlockData->Width =3D VarWidth; BlockData->QuestionId =3D IfrQuestionHdr->QuestionId; BlockData->OpCode =3D IfrOpHdr->OpCode; BlockData->Scope =3D IfrOpHdr->Scope; + BlockData->IsBitVar =3D IsBitVar; + BlockData->BitOffset =3D BitOffset; + BlockData->BitWidth =3D BitWidth; InitializeListHead (&BlockData->DefaultValueEntry); // // Add Block Data into VarStorageData BlockEntry // InsertBlockData (&VarStorageData->BlockEntry, &BlockData); @@ -2124,10 +2150,11 @@ ParseIfrData ( EFI_HII_PACKAGE_HEADER *PackageHeader; EFI_VARSTORE_ID VarStoreId; UINT16 SmallestDefaultId; BOOLEAN SmallestIdFromFlag; BOOLEAN FromOtherDefaultOpcode; + BOOLEAN QuestionReferBitField; =20 Status =3D EFI_SUCCESS; BlockData =3D NULL; DefaultDataPtr =3D NULL; FirstOneOfOption =3D FALSE; @@ -2135,10 +2162,11 @@ ParseIfrData ( FirstOrderedList =3D FALSE; VarStoreName =3D NULL; ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); SmallestDefaultId =3D 0xFFFF; FromOtherDefaultOpcode =3D FALSE; + QuestionReferBitField =3D FALSE; =20 // // Go through the form package to parse OpCode one by one. // PackageOffset =3D sizeof (EFI_HII_PACKAGE_HEADER); @@ -2309,11 +2337,11 @@ ParseIfrData ( // if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2341,20 +2369,25 @@ ParseIfrData ( // IfrOneOf =3D (EFI_IFR_ONE_OF *) IfrOpHdr; if (IfrOneOf->Question.VarStoreId !=3D VarStoreId) { break; } - VarWidth =3D (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE= )); + + if (QuestionReferBitField) { + VarWidth =3D IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE_BIT; + } else { + VarWidth =3D (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SI= ZE)); + } =20 // // The BlockData may allocate by other opcode,need to clean. // if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, QuestionReferBitField); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2376,30 +2409,37 @@ ParseIfrData ( } else if (IfrOpHdr->OpCode =3D=3D EFI_IFR_NUMERIC_OP) { // // Numeric minimum value will be used as default value when no def= ault is specified.=20 // DefaultData.Type =3D DefaultValueFromDefault; - switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - DefaultData.Value.u8 =3D IfrOneOf->data.u8.MinValue; - break; + if (QuestionReferBitField) { + // + // Since default value in bit field was stored as UINT32 type. + // + CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue, s= izeof (UINT32)); + } else { + switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + DefaultData.Value.u8 =3D IfrOneOf->data.u8.MinValue; + break; =20 - case EFI_IFR_NUMERIC_SIZE_2: - CopyMem (&DefaultData.Value.u16, &IfrOneOf->data.u16.MinValue, s= izeof (UINT16)); - break; + case EFI_IFR_NUMERIC_SIZE_2: + CopyMem (&DefaultData.Value.u16, &IfrOneOf->data.u16.MinValue, = sizeof (UINT16)); + break; =20 - case EFI_IFR_NUMERIC_SIZE_4: - CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue, s= izeof (UINT32)); - break; + case EFI_IFR_NUMERIC_SIZE_4: + CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue,= sizeof (UINT32)); + break; =20 - case EFI_IFR_NUMERIC_SIZE_8: - CopyMem (&DefaultData.Value.u64, &IfrOneOf->data.u64.MinValue, s= izeof (UINT64)); - break; + case EFI_IFR_NUMERIC_SIZE_8: + CopyMem (&DefaultData.Value.u64, &IfrOneOf->data.u64.MinValue,= sizeof (UINT64)); + break; =20 - default: - Status =3D EFI_INVALID_PARAMETER; - goto Done; + default: + Status =3D EFI_INVALID_PARAMETER; + goto Done; + } } // // Set default value base on the DefaultId list get from IFR data. // =20 for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData !=3D= &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { @@ -2439,11 +2479,11 @@ ParseIfrData ( // if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2484,11 +2524,14 @@ ParseIfrData ( // if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + if (QuestionReferBitField) { + VarWidth =3D 1; + } + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, QuestionReferBitField); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2515,11 +2558,15 @@ ParseIfrData ( if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT) =3D=3D EFI_IFR_C= HECKBOX_DEFAULT) { // // When flag is set, default value is TRUE. // DefaultData.Type =3D DefaultValueFromFlag; - DefaultData.Value.b =3D TRUE; + if (QuestionReferBitField) { + DefaultData.Value.u32 =3D TRUE; + } else { + DefaultData.Value.b =3D TRUE; + } InsertDefaultValue (BlockData, &DefaultData); =20 if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_STANDARD) { // // Record the SmallestDefaultId and update the SmallestIdFromFla= g. @@ -2540,11 +2587,15 @@ ParseIfrData ( if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG) =3D=3D EFI_I= FR_CHECKBOX_DEFAULT_MFG) { // // When flag is set, default value is TRUE. // DefaultData.Type =3D DefaultValueFromFlag; - DefaultData.Value.b =3D TRUE; + if (QuestionReferBitField) { + DefaultData.Value.u32 =3D TRUE; + } else { + DefaultData.Value.b =3D TRUE; + } InsertDefaultValue (BlockData, &DefaultData); =20 if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_MANUFACTURING) { // // Record the SmallestDefaultId and update the SmallestIdFromFla= g. @@ -2556,11 +2607,15 @@ ParseIfrData ( if (SmallestIdFromFlag) { // // When smallest default Id is given by the flag of CheckBox, set= default value with TRUE for other default Id in the DefaultId list. // DefaultData.Type =3D DefaultValueFromOtherDefault; - DefaultData.Value.b =3D TRUE; + if (QuestionReferBitField) { + DefaultData.Value.u32 =3D TRUE; + } else { + DefaultData.Value.b =3D TRUE; + } // // Set default value for all the default id in the DefaultId list. // for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData !=3D= &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); @@ -2570,11 +2625,15 @@ ParseIfrData ( } else { // // When flag is not set, default value is FASLE. // DefaultData.Type =3D DefaultValueFromDefault; - DefaultData.Value.b =3D FALSE; + if (QuestionReferBitField) { + DefaultData.Value.u32 =3D FALSE; + } else { + DefaultData.Value.b =3D FALSE; + } // // Set default value for all the default id in the DefaultId list. // for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData !=3D= &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); @@ -2612,11 +2671,11 @@ ParseIfrData ( if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 VarWidth =3D (UINT16) sizeof (EFI_HII_DATE); - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2654,11 +2713,11 @@ ParseIfrData ( if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 VarWidth =3D (UINT16) sizeof (EFI_HII_TIME); - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2696,11 +2755,11 @@ ParseIfrData ( if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 VarWidth =3D (UINT16) (IfrString->MaxSize * sizeof (UINT16)); - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2738,11 +2797,11 @@ ParseIfrData ( if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 VarWidth =3D (UINT16) (IfrPassword->MaxSize * sizeof (UINT16)); - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2930,11 +2989,15 @@ ParseIfrData ( // // Prepare new DefaultValue // DefaultData.Type =3D DefaultValueFromOpcode; DefaultData.DefaultId =3D VarDefaultId; - CopyMem (&DefaultData.Value, &IfrDefault->Value, IfrDefault->Header.= Length - OFFSET_OF (EFI_IFR_DEFAULT, Value)); + if (QuestionReferBitField) { + CopyMem (&DefaultData.Value.u32, &IfrDefault->Value.u32, sizeof (U= INT32)); + } else { + CopyMem (&DefaultData.Value, &IfrDefault->Value, IfrDefault->Heade= r.Length - OFFSET_OF (EFI_IFR_DEFAULT, Value)); + } =20 // If the value field is expression, set the cleaned flag. if (IfrDefault->Type =3D=3D EFI_IFR_TYPE_OTHER) { DefaultData.Cleaned =3D TRUE; } @@ -2972,10 +3035,11 @@ ParseIfrData ( =20 case EFI_IFR_END_OP: // // End Opcode is for Var question. // + QuestionReferBitField =3D FALSE; if (BlockData !=3D NULL) { if (BlockData->Scope > 0) { BlockData->Scope--; } if (BlockData->Scope =3D=3D 0) { @@ -2988,10 +3052,16 @@ ParseIfrData ( } } =20 break; =20 + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINT8*)IfrOpHdr + sizeof (EFI_IFR_OP_= HEADER)), &gEdkiiIfrBitVarstoreGuid)) { + QuestionReferBitField =3D TRUE; + } + break; + default: if (BlockData !=3D NULL) { if (BlockData->Scope > 0) { BlockData->Scope =3D (UINT8) (BlockData->Scope + IfrOpHdr->Scope= ); } @@ -3567,10 +3637,216 @@ GetStorageWidth ( =20 return StorageWidth; } =20 /** + Update the default value in the block data which is used as bit var stor= e. + + For example: + A question value saved in a bit fied: bitoffset =3D 1; bitwidth =3D 2;de= fault value =3D 1. + And corresponding block data info: offset=3D=3D0; width=3D=3D1;currently= the default value + is saved as 1.Actually the default value 1 need to be set to bit field 1= , so the + default value of this block data shuold be:2. + + typedef struct { + UINT8 Bit1 : 1; // + UINT8 Bit2 : 2; // Question saved in Bit2,so originalBlock info: offs= et =3D 0; width =3D 1;(byte level) defaul =3D 1. + // (default value record for the bit field) + ...... + }ExampleData; + + After function UpdateDefaultValue,the Block info is: offset =3D 0; width= =3D 1;(byte level) default =3D 2. + (default value reco= rd for the Block) + + UpdateDefaultValue function update default value of bit var block based = on the bit field info in the block. + + @param BlockLink The Link of the block data. + +**/ +VOID +UpdateDefaultValue ( + IN LIST_ENTRY *BlockLink +) +{ + LIST_ENTRY *Link; + LIST_ENTRY *ListEntry; + LIST_ENTRY *LinkDefault; + IFR_BLOCK_DATA *BlockData; + IFR_DEFAULT_DATA *DefaultValueData; + UINTN StartBit; + UINTN EndBit; + UINT32 *BitFieldDefaultValue; + UINT32 *ByteBlockDefaultValue; + + for ( Link =3D BlockLink->ForwardLink; Link !=3D BlockLink; Link =3D Lin= k->ForwardLink) { + BlockData =3D BASE_CR (Link, IFR_BLOCK_DATA, Entry); + if (!BlockData ->IsBitVar) { + continue; + } + ListEntry =3D &BlockData->DefaultValueEntry; + // + // Update the default value in the block data with all existing defaul= t id. + // + for (LinkDefault =3D ListEntry->ForwardLink; LinkDefault !=3D ListEntr= y; LinkDefault =3D LinkDefault->ForwardLink) { + // + // Get the default data, and the value of the default data is for so= me field in the block. + // + DefaultValueData =3D BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry); + BitFieldDefaultValue =3D (UINT32*)&DefaultValueData->Value; + ByteBlockDefaultValue =3D (UINT32*)&DefaultValueData->Value; + + StartBit =3D BlockData->BitOffset % 8; + EndBit =3D StartBit + BlockData->BitWidth - 1; + + // + // Set the bit field default value to related bit filed, then we wil= l got the new default vaule for the block data. + // + *ByteBlockDefaultValue =3D BitFieldWrite32 (0, StartBit, EndBit, *Bi= tFieldDefaultValue); + } + } +} + +/** +Merge the default value in two block datas which have overlap region. + +For bit fields, their related block data may have overlap region, such as: + +typedef struct { + UINT16 Bit1 : 6; // Question1 refer Bit1, Block1: offset =3D 0; width = =3D 1;(byte level) default =3D 1 + UINT16 Bit2 : 5; // Question2 refer Bit2, Block2: offset =3D 0; width = =3D 2;(byte level) default =3D 5 + // (default value record for the bit field) + ...... +}ExampleData; + +After function UpdateDefaultValue: +Block1: offset =3D 0; width =3D 1;(byte level) default =3D 1 +Block2: offset =3D 0; width =3D 2;(byte level) default =3D 320 (5 * (2 << = 6)) +(default value record for block) + +After function MergeBlockDefaultValue: +Block1: offset =3D 0; width =3D 1;(byte level) default =3D 65 +Block2: offset =3D 0; width =3D 2;(byte level) default =3D 321 +(Block1 and Block2 has overlap region, merge the overlap value to Block1 a= nd Blcok2) + +Block1 and Block2 have overlap byte region, but currntly the default value= of Block1 only contains +value of Bit1 (low 6 bits),the default value of Block2 only contains the v= alue of Bit2 (middle 5 bits). + +This fuction merge the default value of these two blocks, and make the def= ault value of block1 +also contain the value of lower 2 bits of the Bit2. And make the default v= alue of Block2 also +contain the default value of Bit1. + +We can get the total value of the whole block that just cover these two bl= ocks(in this case is: +block: offset =3D0; width =3D2;) then the value of block2 is same as block= , the value of block1 is +the first byte value of block. + +@param FirstBlock Point to the block date whose default value need to= be merged. +@param SecondBlock Point to the block date whose default value need to= be merged. + +**/ +VOID +MergeBlockDefaultValue ( + IN OUT IFR_BLOCK_DATA *FirstBlock, + IN OUT IFR_BLOCK_DATA *SecondBlock +) +{ + LIST_ENTRY *FirstListEntry; + LIST_ENTRY *SecondListEntry; + LIST_ENTRY *FirstDefaultLink; + LIST_ENTRY *SecondDefaultLink; + IFR_DEFAULT_DATA *FirstDefaultValueData; + IFR_DEFAULT_DATA *SecondDefaultValueData; + UINT32 *FirstDefaultValue; + UINT32 *SecondDefaultValue; + UINT64 TotalValue; + UINT64 ShiftedValue; + UINT16 OffsetShift; + + FirstListEntry =3D &FirstBlock->DefaultValueEntry; + for (FirstDefaultLink =3D FirstListEntry->ForwardLink; FirstDefaultLink = !=3D FirstListEntry; FirstDefaultLink =3D FirstDefaultLink->ForwardLink) { + FirstDefaultValueData =3D BASE_CR (FirstDefaultLink, IFR_DEFAULT_DATA,= Entry); + SecondListEntry =3D &SecondBlock->DefaultValueEntry; + for (SecondDefaultLink =3D SecondListEntry->ForwardLink; SecondDefault= Link !=3D SecondListEntry; SecondDefaultLink =3D SecondDefaultLink->Forward= Link) { + SecondDefaultValueData =3D BASE_CR (SecondDefaultLink, IFR_DEFAULT_D= ATA, Entry); + if (FirstDefaultValueData->DefaultId !=3D SecondDefaultValueData->De= faultId) { + continue; + } + // + // Find default value with same default id in the two blocks. + // + FirstDefaultValue =3D (UINT32*)&(FirstDefaultValueData->Value); + SecondDefaultValue =3D (UINT32*)&(SecondDefaultValueData->Value); + // + // 1. Get the default value of the whole blcok that can just cover F= irstBlock and SecondBlock. + // 2. Get the default value of FirstBlock and SecondBlock form the v= alue of whole block based + // on the offset and width of FirstBlock and SecondBlock. + // + if (FirstBlock->Offset > SecondBlock->Offset) { + OffsetShift =3D FirstBlock->Offset - SecondBlock->Offset; + ShiftedValue =3D LShiftU64 ((UINT64)*FirstDefaultValue, OffsetShif= t * 8); + TotalValue =3D ShiftedValue | (UINT64)(*SecondDefaultValue); + *SecondDefaultValue =3D (UINT32) BitFieldRead64 (TotalValue, 0, Se= condBlock->Width * 8 -1); + *FirstDefaultValue =3D (UINT32) BitFieldRead64 (TotalValue, Offset= Shift * 8, OffsetShift * 8 + FirstBlock->Width *8 -1); + } else { + OffsetShift =3D SecondBlock->Offset -FirstBlock->Offset; + ShiftedValue =3D LShiftU64 ((UINT64)*SecondDefaultValue, OffsetShi= ft * 8); + TotalValue =3D ShiftedValue | (UINT64)(*FirstDefaultValue); + *FirstDefaultValue =3D (UINT32) BitFieldRead64 (TotalValue, 0, Fir= stBlock->Width * 8 -1); + *SecondDefaultValue =3D (UINT32) BitFieldRead64 (TotalValue, Offse= tShift * 8, OffsetShift * 8 + SecondBlock->Width *8 -1); + } + } + } +} + +/** + +Update the default value in the block data which used as Bit VarStore + +@param BlockLink The Link of the block data. + +**/ +VOID +UpdateBlockDataArray ( + IN LIST_ENTRY *BlockLink +) +{ + LIST_ENTRY *Link; + LIST_ENTRY *TempLink; + IFR_BLOCK_DATA *BlockData; + IFR_BLOCK_DATA *NextBlockData; + + // + // 1. Update default value in BitVar block data. + // Sine some block datas are used as BitVarStore, then the default value= recored in the block + // is for related bit field in the block. so we need to set the default = value to the related bit + // fields in the block data if the block data is used as bit varstore, t= hen the default value of + // the block will be updated. + // + UpdateDefaultValue (BlockLink); + + // + // 2.Update default value for overlap BitVar blcok datas. + // For block datas have overlap region, we need to merge the default val= ue in different blocks. + // + for (Link =3D BlockLink->ForwardLink; Link !=3D BlockLink; Link =3D Link= ->ForwardLink) { + BlockData =3D BASE_CR (Link, IFR_BLOCK_DATA, Entry); + if (!BlockData ->IsBitVar) { + continue; + } + for (TempLink =3D Link->ForwardLink; TempLink !=3D BlockLink; TempLink= =3D TempLink->ForwardLink) { + NextBlockData =3D BASE_CR (TempLink, IFR_BLOCK_DATA, Entry); + if (!NextBlockData->IsBitVar || NextBlockData->Offset >=3D BlockData= ->Offset + BlockData->Width || BlockData->Offset >=3D NextBlockData->Offset= + NextBlockData->Width) { + continue; + } + // + // Find two blocks are used as bit VarStore and have overlap region,= so need to merge default value of these two blocks. + // + MergeBlockDefaultValue (BlockData, NextBlockData); + } + } +} + +/** Generate ConfigAltResp string base on the varstore info. =20 @param HiiHandle Hii Handle for this hii package. @param ConfigHdr The config header for this varstore. @param VarStorageData The varstore info. @@ -3610,10 +3886,12 @@ GenerateAltConfigResp ( // // Add length for + '\0' // Length =3D StrLen (ConfigHdr) + 1; =20 + UpdateBlockDataArray (&VarStorageData->BlockEntry); + for (Link =3D DefaultIdArray->Entry.ForwardLink; Link !=3D &DefaultIdArr= ay->Entry; Link =3D Link->ForwardLink) { DefaultId =3D BASE_CR (Link, IFR_DEFAULT_DATA, Entry); // // Add length for "&&ALTCFG=3DXXXX" // |1| StrLen (ConfigHdr) | 8 | 4 | diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModul= ePkg/Universal/HiiDatabaseDxe/HiiDatabase.h index e6760c3..320754c 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h @@ -1,9 +1,9 @@ /** @file Private structures definitions in HiiDatabase. =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, 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 =20 @@ -29,10 +29,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include #include =20 #include #include +#include =20 =20 #include #include #include @@ -75,15 +76,18 @@ typedef struct { =20 typedef struct { LIST_ENTRY Entry; // Link to Block array UINT16 Offset; UINT16 Width; + UINT16 BitOffset; + UINT16 BitWidth; EFI_QUESTION_ID QuestionId; UINT8 OpCode; UINT8 Scope; LIST_ENTRY DefaultValueEntry; // Link to its default value array CHAR16 *Name; + BOOLEAN IsBitVar; } IFR_BLOCK_DATA; =20 // // Get default value from IFR data. // diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf b/Mde= ModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf index 6bb1d03..fc15b30 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf @@ -2,11 +2,11 @@ # The DXE driver produces HII protocols defined in UEFI specification. # # This driver produces all required HII serivces that includes HiiDataBase= , HiiString, # HiiFont, HiiConfigRouting. To support UEFI HII, this driver is required. # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials =20 # are licensed and made available under the terms and conditions of the B= SD License =20 # which accompanies this distribution. The full text of the license may b= e found at =20 # http://opensource.org/licenses/bsd-license.php =20 @@ -88,10 +88,11 @@ ## CONSUMES ## Event ## PRODUCES ## Event gEfiHiiKeyBoardLayoutGuid gEfiHiiImageDecoderNameJpegGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSuppo= rtHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID gEfiHiiImageDecoderNamePngGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSuppo= rtHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID + gEdkiiIfrBitVarstoreGuid = ## SOMETIMES_CONSUMES ## GUID =20 [Depex] TRUE =20 [UserExtensions.TianoCore."ExtraFiles"] --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel