summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2017-09-20 20:19:04 +0800
committerEric Dong <eric.dong@intel.com>2017-09-21 16:17:42 +0800
commit560a435df02b233ea33ae543aeab76b2201de849 (patch)
treede315a922e6360c101e1f043f91154905e1acf77 /MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
parent37cd16ac57fcbe5f6ecd15f85ea51621d08cde59 (diff)
downloadedk2-560a435df02b233ea33ae543aeab76b2201de849.zip
edk2-560a435df02b233ea33ae543aeab76b2201de849.tar.gz
edk2-560a435df02b233ea33ae543aeab76b2201de849.tar.bz2
MdeModulePkg/SetupBrowser: Handle questions with Bit VarStore
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=545 For oneof/numeric/CheckBox(storage can be Bit VarStore) If the 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 VarStore info correctly. 2. Set/get value to/from bit VarStore correctly. Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/SetupBrowserDxe/Setup.c')
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.c117
1 files changed, 109 insertions, 8 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 89e06de..48beeb6 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -1369,6 +1369,71 @@ ConfigRespToStorage (
}
/**
+ Get bit field value from the buffer and then set the value for the question.
+ Note: Data type UINT32 can cover all the bit field value.
+
+ @param Question The question refer to bit field.
+ @param Buffer Point to the buffer which the question value get from.
+
+**/
+VOID
+GetBitsQuestionValue (
+ IN FORM_BROWSER_STATEMENT *Question,
+ IN UINT8 *Buffer
+ )
+{
+ UINTN StartBit;
+ UINTN EndBit;
+ UINT32 RetVal;
+ UINT32 BufferValue;
+
+ StartBit = Question->BitVarOffset % 8;
+ EndBit = StartBit + Question->BitStorageWidth - 1;
+
+ CopyMem ((UINT8 *) &BufferValue, Buffer, Question->StorageWidth);
+
+ RetVal = BitFieldRead32 (BufferValue, StartBit, EndBit);
+
+ //
+ // Set question value.
+ // Note: Since Question with BufferValue (orderedlist, password, string)are not supported to refer bit field.
+ // Only oneof/checkbox/oneof can support bit field.So we can copy the value to the Hiivalue of Question directly.
+ //
+ CopyMem ((UINT8 *) &Question->HiiValue.Value, (UINT8 *) &RetVal, Question->StorageWidth);
+}
+
+/**
+ Set bit field value to the buffer.
+ Note: Data type UINT32 can cover all the bit field value.
+
+ @param Question The question refer to bit field.
+ @param Buffer Point to the buffer which the question value set to.
+ @param Value The bit field value need to set.
+
+**/
+VOID
+SetBitsQuestionValue (
+ IN FORM_BROWSER_STATEMENT *Question,
+ IN OUT UINT8 *Buffer,
+ IN UINT32 Value
+ )
+{
+ UINT32 Operand;
+ UINTN StartBit;
+ UINTN EndBit;
+ UINT32 RetVal;
+
+ StartBit = Question->BitVarOffset % 8;
+ EndBit = StartBit + Question->BitStorageWidth - 1;
+
+ CopyMem ((UINT8*) &Operand, Buffer, Question->StorageWidth);
+
+ RetVal = BitFieldWrite32 (Operand, StartBit, EndBit, Value);
+
+ CopyMem (Buffer, (UINT8*) &RetVal, Question->StorageWidth);
+}
+
+/**
Convert the buffer value to HiiValue.
@param Question The question.
@@ -1395,6 +1460,9 @@ BufferToValue (
BOOLEAN IsString;
UINTN Length;
EFI_STATUS Status;
+ UINT8 *Buffer;
+
+ Buffer = NULL;
IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE);
if (Question->Storage->Type == EFI_HII_VARSTORE_BUFFER ||
@@ -1416,7 +1484,13 @@ BufferToValue (
//
// Other type of Questions
//
- Dst = (UINT8 *) &Question->HiiValue.Value;
+ if (Question->QuestionReferToBitField) {
+ Buffer = (UINT8 *)AllocateZeroPool (Question->StorageWidth);
+ ASSERT (Buffer != NULL);
+ Dst = Buffer;
+ } else {
+ Dst = (UINT8 *) &Question->HiiValue.Value;
+ }
}
//
@@ -1474,6 +1548,13 @@ BufferToValue (
*StringPtr = TempChar;
+ if (Question->QuestionReferToBitField) {
+ GetBitsQuestionValue (Question, Buffer);
+ if (Buffer != NULL) {
+ FreePool (Buffer);
+ }
+ }
+
return Status;
}
@@ -1678,13 +1759,23 @@ GetQuestionValue (
if (GetValueFrom == GetSetValueWithEditBuffer) {
//
// Copy from storage Edit buffer
+ // If the Question refer to bit filed, get the value in the related bit filed.
//
- CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);
+ if (Question->QuestionReferToBitField) {
+ GetBitsQuestionValue (Question, Storage->EditBuffer + Question->VarStoreInfo.VarOffset);
+ } else {
+ CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);
+ }
} else {
//
// Copy from storage Edit buffer
+ // If the Question refer to bit filed, get the value in the related bit filed.
//
- CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);
+ if (Question->QuestionReferToBitField) {
+ GetBitsQuestionValue (Question, Storage->Buffer + Question->VarStoreInfo.VarOffset);
+ } else {
+ CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);
+ }
}
} else {
Value = NULL;
@@ -1950,13 +2041,23 @@ SetQuestionValue (
if (SetValueTo == GetSetValueWithEditBuffer) {
//
// Copy to storage edit buffer
- //
- CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
+ // If the Question refer to bit filed, copy the value in related bit filed to storage edit buffer.
+ //
+ if (Question->QuestionReferToBitField) {
+ SetBitsQuestionValue (Question, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, (UINT32)(*Src));
+ } else {
+ CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
+ }
} else if (SetValueTo == GetSetValueWithBuffer) {
//
- // Copy to storage edit buffer
- //
- CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
+ // Copy to storage buffer
+ // If the Question refer to bit filed, copy the value in related bit filed to storage buffer.
+ //
+ if (Question->QuestionReferToBitField) {
+ SetBitsQuestionValue (Question, Storage->Buffer + Question->VarStoreInfo.VarOffset, (UINT32)(*Src));
+ } else {
+ CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
+ }
}
} else {
if (IsString) {