From nobody Sat Nov 2 10:37:45 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.zoho.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 149251961934859.644197051455194; Tue, 18 Apr 2017 05:46:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D5EC42195407B; Tue, 18 Apr 2017 05:46:56 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 7C8AB21954085 for ; Tue, 18 Apr 2017 05:46:55 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 18 Apr 2017 05:46:55 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 18 Apr 2017 05:46:54 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,219,1488873600"; d="scan'208";a="90823051" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 18 Apr 2017 20:46:30 +0800 Message-Id: <1492519592-173060-3-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> References: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [RFC patch 2/4] MdeModulePkg/SetupBrowser: 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" For oneof/numeric/CheckBox(storage can be Bit EFI VarStore) If we want question value can be updated and shown correctly in UI page, we need do enhancements in following cases: 1. Parse the Ifr data to get the bit EFI VarStore info correctly. 2. Set/get value to/from bit EFI VarStore correctly. Cc: Eric Dong Cc: Liming Gao Cc: Dandan Bi Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 137 +++++++++++++++++-= ---- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 106 ++++++++++++++++- MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 3 + 3 files changed, 208 insertions(+), 38 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModuleP= kg/Universal/SetupBrowserDxe/IfrParse.c index 6b3e5e0..ccd6790 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -15,10 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include "Setup.h" =20 UINT16 mStatementIndex; UINT16 mExpressionOpCodeIndex; EFI_QUESTION_ID mUsedQuestionId; +EFI_GUID mBitVarstoreGuid =3D {0x82DDD68B, 0x9163, 0x4187, {0x9B,= 0x27, 0x20, 0xA8, 0xFD, 0x60 ,0xA7 , 0x1D}}; +BOOLEAN mQuestionReferBitVar =3D FALSE; + extern LIST_ENTRY gBrowserStorageList; /** Initialize Statement header members. =20 @param OpCodeData Pointer of the raw OpCode data. @@ -559,10 +562,11 @@ CreateStorage ( } =20 BrowserStorage->HiiHandle =3D FormSet->HiiHandle; =20 BrowserStorage->Initialized =3D FALSE; + BrowserStorage->IsBitVarStore =3D FALSE; } =20 Storage->BrowserStorage =3D BrowserStorage; InitializeConfigHdr (FormSet, Storage); Storage->ConfigRequest =3D AllocateCopyPool (StrSize (Storage->ConfigHdr= ), Storage->ConfigHdr); @@ -1312,10 +1316,12 @@ ParseOpCodes ( BOOLEAN InUnknownScope; UINT8 UnknownDepth; FORMSET_DEFAULTSTORE *PreDefaultStore; LIST_ENTRY *DefaultLink; BOOLEAN HaveInserted; + UINT16 ByteWidth; + UINT16 BitWidth; =20 SuppressForQuestion =3D FALSE; SuppressForOption =3D FALSE; InScopeDisable =3D FALSE; DepthOfDisable =3D 0; @@ -1978,47 +1984,99 @@ ParseOpCodes ( ASSERT(CurrentStatement !=3D NULL); =20 CurrentStatement->Flags =3D ((EFI_IFR_ONE_OF *) OpCodeData)->Flags; Value =3D &CurrentStatement->HiiValue; =20 - switch (CurrentStatement->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - CurrentStatement->Minimum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u8.MinValue; - CurrentStatement->Maximum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u8.MaxValue; - CurrentStatement->Step =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u8.Step; - CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT8); - Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_8; - break; + if (mQuestionReferBitVar) { + mQuestionReferBitVar =3D FALSE; + CurrentStatement->StorageBitWidth =3D CurrentStatement->Flags & 0X= 0F; + CurrentStatement->Storage->IsBitVarStore =3D TRUE; + CurrentStatement->VarBitOffset =3D CurrentStatement->VarStoreInfo.= VarOffset; + CurrentStatement->VarStoreInfo.VarOffset =3D CurrentStatement->Var= BitOffset / 8; + BitWidth =3D CurrentStatement->VarBitOffset - (CurrentStatement->V= arStoreInfo.VarOffset * 8) + CurrentStatement->StorageBitWidth; + ByteWidth =3D BitWidth / 8; + CurrentStatement->StorageWidth =3D (BitWidth % 8 =3D=3D 0? ByteWid= th: ByteWidth + 1); + CurrentStatement->Minimum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u32.MinValue; + CurrentStatement->Maximum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u32.MaxValue; + CurrentStatement->Step =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u32.Step; + if (Operand =3D=3D EFI_IFR_NUMERIC_OP) { + switch (CurrentStatement->StorageWidth) { + case 1: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &=3D 0x30; + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NU= M_SIZE_8; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue =3D (UINT= 8)CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue =3D (UINT= 8)CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step =3D (UINT8)Cu= rrentStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_8; + break; + case 2: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &=3D 0x30; + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NUM= _SIZE_16; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MinValue =3D (UINT= 16)CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MaxValue =3D (UINT= 16)CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.Step =3D (UINT16)C= urrentStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_16; + break; + case 3: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &=3D 0x30; + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NU= M_SIZE_32; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue =3D (UIN= T32)CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue =3D (UIN= T32)CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step =3D (UINT32)= CurrentStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_32; + break; + case 4: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &=3D 0x30; + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NU= M_SIZE_32; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue =3D (UIN= T32)CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue =3D (UIN= T32)CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step =3D (UINT32)= CurrentStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_32; + break; + default: + break; + } + } + } else { =20 - case EFI_IFR_NUMERIC_SIZE_2: - CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u16.MinValue, sizeof (UINT16)); - CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u16.MaxValue, sizeof (UINT16)); - CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u16.Step, sizeof (UINT16)); - CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT16); - Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_16; - break; + switch (CurrentStatement->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + CurrentStatement->Minimum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->= data.u8.MinValue; + CurrentStatement->Maximum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->= data.u8.MaxValue; + CurrentStatement->Step =3D ((EFI_IFR_NUMERIC *) OpCodeData)->= data.u8.Step; + CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT8); + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_8; + break; =20 - case EFI_IFR_NUMERIC_SIZE_4: - CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u32.MinValue, sizeof (UINT32)); - CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u32.MaxValue, sizeof (UINT32)); - CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u32.Step, sizeof (UINT32)); - CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT32); - Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_32; - break; + case EFI_IFR_NUMERIC_SIZE_2: + CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u16.MinValue, sizeof (UINT16)); + CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u16.MaxValue, sizeof (UINT16)); + CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u16.Step, sizeof (UINT16)); + CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT16); + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_16; + break; =20 - case EFI_IFR_NUMERIC_SIZE_8: - CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u64.MinValue, sizeof (UINT64)); - CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u64.MaxValue, sizeof (UINT64)); - CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u64.Step, sizeof (UINT64)); - CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT64); - Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_64; - break; + case EFI_IFR_NUMERIC_SIZE_4: + CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u32.MinValue, sizeof (UINT32)); + CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u32.MaxValue, sizeof (UINT32)); + CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u32.Step, sizeof (UINT32)); + CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT32); + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_32; + break; =20 - default: - break; - } + case EFI_IFR_NUMERIC_SIZE_8: + CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u64.MinValue, sizeof (UINT64)); + CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u64.MaxValue, sizeof (UINT64)); + CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u64.Step, sizeof (UINT64)); + CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT64); + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_64; + break; =20 + default: + break; + } + } InitializeRequestElement (FormSet, CurrentStatement, CurrentForm); =20 if ((Operand =3D=3D EFI_IFR_ONE_OF_OP) && Scope !=3D 0) { SuppressForOption =3D TRUE; } @@ -2045,10 +2103,21 @@ ParseOpCodes ( =20 CurrentStatement->Flags =3D ((EFI_IFR_CHECKBOX *) OpCodeData)->Flags; CurrentStatement->StorageWidth =3D (UINT16) sizeof (BOOLEAN); CurrentStatement->HiiValue.Type =3D EFI_IFR_TYPE_BOOLEAN; =20 + if (mQuestionReferBitVar) { + mQuestionReferBitVar =3D FALSE; + CurrentStatement->StorageBitWidth =3D 1; + CurrentStatement->Storage->IsBitVarStore =3D TRUE; + CurrentStatement->VarBitOffset =3D CurrentStatement->VarStoreInfo.= VarOffset; + CurrentStatement->VarStoreInfo.VarOffset =3D CurrentStatement->Var= BitOffset / 8; + BitWidth =3D CurrentStatement->VarBitOffset - (CurrentStatement->V= arStoreInfo.VarOffset * 8) + CurrentStatement->StorageBitWidth; + ByteWidth =3D BitWidth / 8; + CurrentStatement->StorageWidth =3D (BitWidth % 8 =3D=3D 0? ByteWid= th: ByteWidth + 1); + } + InitializeRequestElement (FormSet, CurrentStatement, CurrentForm); =20 break; =20 case EFI_IFR_STRING_OP: @@ -2594,10 +2663,14 @@ ParseOpCodes ( // // Vendor specific // case EFI_IFR_GUID_OP: =20 CurrentStatement =3D CreateStatement (OpCodeData, FormSet, CurrentFo= rm); + if (CompareGuid ((EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER= )), &mBitVarstoreGuid)) { + Scope =3D 0; + mQuestionReferBitVar =3D TRUE; + } break; =20 // // Scope End // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/= Universal/SetupBrowserDxe/Setup.c index 83dc2b8..6b46581 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1392,10 +1392,14 @@ BufferToValue ( UINTN Index; UINT8 DigitUint8; BOOLEAN IsString; UINTN Length; EFI_STATUS Status; + UINT8 *Buffer; + UINT32 Mask; + UINT32 PreBits; + UINT32 BufferValue; =20 IsString =3D (BOOLEAN) ((Question->HiiValue.Type =3D=3D EFI_IFR_TYPE_STR= ING) ? TRUE : FALSE); if (Question->Storage->Type =3D=3D EFI_HII_VARSTORE_BUFFER ||=20 Question->Storage->Type =3D=3D EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)= { IsBufferStorage =3D TRUE; @@ -1413,11 +1417,17 @@ BufferToValue ( Dst =3D Question->BufferValue; } else { // // Other type of Questions // - Dst =3D (UINT8 *) &Question->HiiValue.Value; + if (Question->Storage->IsBitVarStore) { + Buffer =3D (UINT8 *)AllocateZeroPool (Question->StorageWidth); + ASSERT (Buffer !=3D NULL); + Dst =3D Buffer; + } else { + Dst =3D (UINT8 *) &Question->HiiValue.Value; + } } =20 // // Temp cut at the end of this section, end with '\0' or '&'. // @@ -1471,10 +1481,27 @@ BufferToValue ( } } =20 *StringPtr =3D TempChar; =20 + if (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarOffset = * 8; + Mask =3D (1 << Question->StorageBitWidth) - 1; + BufferValue =3D *(Buffer); + BufferValue |=3D *(Buffer + 1) << 8; + BufferValue |=3D *(Buffer + 2) << 16; + BufferValue |=3D *(Buffer + 3) << 24; + BufferValue >>=3D PreBits; + BufferValue &=3D Mask; + + CopyMem ((UINT8 *) &Question->HiiValue.Value, (UINT8*)&BufferValue, Qu= estion->StorageWidth); + + if (Buffer !=3D NULL) { + FreePool (Buffer); + } + } + return Status; } =20 /** Get Question's current Value. @@ -1509,10 +1536,13 @@ GetQuestionValue ( CHAR16 *Result; CHAR16 *Value; UINTN Length; BOOLEAN IsBufferStorage; UINTN MaxLen; + UINT32 PreBits; + UINT32 Mask; + UINT32 BufferValue; =20 Status =3D EFI_SUCCESS; Value =3D NULL; Result =3D NULL; =20 @@ -1676,16 +1706,40 @@ GetQuestionValue ( if (IsBufferStorage) { if (GetValueFrom =3D=3D GetSetValueWithEditBuffer) { // // Copy from storage Edit buffer // - CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffs= et, StorageWidth); + if (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarO= ffset * 8;; + Mask =3D (1<< Question->StorageBitWidth) -1; + BufferValue =3D *(Storage->EditBuffer + Question->VarStoreInfo.V= arOffset); + BufferValue |=3D *(Storage->EditBuffer + Question->VarStoreInfo.= VarOffset + 1) << 8; + BufferValue |=3D *(Storage->EditBuffer + Question->VarStoreInfo.= VarOffset + 2) << 16; + BufferValue |=3D *(Storage->EditBuffer + Question->VarStoreInfo.= VarOffset + 3) << 24; + BufferValue >>=3D PreBits; + BufferValue &=3D Mask; + CopyMem (Dst, (UINT8*)&BufferValue, StorageWidth); + } else { + CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOf= fset, StorageWidth); + } } else { // // Copy from storage Edit buffer // - CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, = StorageWidth); + if (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarO= ffset * 8;; + Mask =3D (1<< Question->StorageBitWidth) -1; + BufferValue =3D *(Storage->Buffer + Question->VarStoreInfo.VarOf= fset); + BufferValue |=3D *(Storage->Buffer + Question->VarStoreInfo.VarO= ffset + 1) << 8; + BufferValue |=3D *(Storage->Buffer + Question->VarStoreInfo.VarO= ffset + 2) << 16; + BufferValue |=3D *(Storage->Buffer + Question->VarStoreInfo.VarO= ffset + 3) << 24; + BufferValue >>=3D PreBits; + BufferValue &=3D Mask; + CopyMem (Dst, (UINT8*)&BufferValue, StorageWidth); + } else { + CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset= , StorageWidth); + } } } else { Value =3D NULL; Status =3D GetValueByName (Storage, Question->VariableName, &Value, = GetValueFrom); if (EFI_ERROR (Status)) { @@ -1825,10 +1879,14 @@ SetQuestionValue ( CHAR16 *TemName; CHAR16 *TemString; UINTN Index; NAME_VALUE_NODE *Node; UINTN MaxLen; + UINT32 PreBits; + UINT32 Mask; + UINT32 Buffer; + UINT32 SrcValue; =20 Status =3D EFI_SUCCESS; Node =3D NULL; =20 if (SetValueTo >=3D GetSetValueWithMax) { @@ -1947,17 +2005,53 @@ SetQuestionValue ( if (SetValueTo =3D=3D GetSetValueWithEditBuffer || SetValueTo =3D=3D Get= SetValueWithBuffer) { if (IsBufferStorage) { if (SetValueTo =3D=3D GetSetValueWithEditBuffer) { // // Copy to storage edit buffer - // =20 - CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, S= rc, StorageWidth); + // + if (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarO= ffset * 8; + SrcValue =3D (UINT32)(*Src); + SrcValue <<=3D PreBits; + Mask =3D (1<< Question->StorageBitWidth) -1; + Mask <<=3D PreBits; + Buffer =3D *(Storage->EditBuffer + Question->VarStoreInfo.VarOff= set); + Buffer |=3D *(Storage->EditBuffer + Question->VarStoreInfo.VarOf= fset + 1) << 8; + Buffer |=3D *(Storage->EditBuffer + Question->VarStoreInfo.VarOf= fset + 2) << 16; + Buffer |=3D *(Storage->EditBuffer + Question->VarStoreInfo.VarOf= fset + 3) << 24; + + Buffer =3D (Buffer & (~Mask)) | SrcValue; + *(Storage->EditBuffer + Question->VarStoreInfo.VarOffset) =3D (U= INT8) Buffer & 0xFF; + *(Storage->EditBuffer + Question->VarStoreInfo.VarOffset + 1) = =3D (UINT8) (Buffer >> 8); + *(Storage->EditBuffer + Question->VarStoreInfo.VarOffset + 2) = =3D (UINT8) (Buffer >> 16); + *(Storage->EditBuffer + Question->VarStoreInfo.VarOffset + 3) = =3D (UINT8) (Buffer >> 24); + } else { + CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset,= Src, StorageWidth); + } } else if (SetValueTo =3D=3D GetSetValueWithBuffer) { // // Copy to storage edit buffer // =20 - CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, = StorageWidth); + if (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarO= ffset * 8; + SrcValue =3D (UINT32)(*Src); + SrcValue <<=3D PreBits; + Mask =3D (1<< Question->StorageBitWidth) -1; + Mask <<=3D PreBits; + Buffer =3D *(Storage->Buffer + Question->VarStoreInfo.VarOffset); + Buffer |=3D *(Storage->Buffer + Question->VarStoreInfo.VarOffset= + 1) << 8; + Buffer |=3D *(Storage->Buffer + Question->VarStoreInfo.VarOffset= + 2) << 16; + Buffer |=3D *(Storage->Buffer + Question->VarStoreInfo.VarOffset= + 3) << 24; + + Buffer =3D (Buffer & (~Mask)) | SrcValue; + *(Storage->Buffer + Question->VarStoreInfo.VarOffset) =3D (UINT8= ) Buffer & 0xFF; + *(Storage->Buffer + Question->VarStoreInfo.VarOffset + 1) =3D (U= INT8) (Buffer >> 8); + *(Storage->Buffer + Question->VarStoreInfo.VarOffset + 2) =3D (U= INT8) (Buffer >> 16); + *(Storage->Buffer + Question->VarStoreInfo.VarOffset + 3) =3D (U= INT8) (Buffer >> 24); + } else { + CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src= , StorageWidth); + } } } else { if (IsString) { // // Allocate enough string buffer. diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/= Universal/SetupBrowserDxe/Setup.h index f1accdf..f919b76 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -137,10 +137,11 @@ typedef struct { LIST_ENTRY Link; =20 UINT8 Type; // Storage type =20 BOOLEAN Initialized; // Whether this varstore is initialized= , efi varstore not used. + BOOLEAN IsBitVarStore; // whether this is bit varstore. =20 EFI_HII_HANDLE HiiHandle; // HiiHandle for this varstore, efi var= store not used. EFI_GUID Guid; =20 CHAR16 *Name; // For EFI_IFR_VARSTORE @@ -327,10 +328,12 @@ struct _FORM_BROWSER_STATEMENT{ EFI_QUESTION_ID QuestionId; // The value of zero is reserved EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no = variable storage BROWSER_STORAGE *Storage; VAR_STORE_INFO VarStoreInfo; UINT16 StorageWidth; + UINT16 StorageBitWidth; + UINT16 VarBitOffset; UINT8 QuestionFlags; CHAR16 *VariableName; // Name/Value or EFI Variable na= me CHAR16 *BlockName; // Buffer storage block name: "O= FFSET=3D...WIDTH=3D..." =20 EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numbe= ric, oneof --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel