return Status;\r
}\r
\r
+/**\r
+ Get bit field value from the buffer and then set the value for the question.\r
+ Note: Data type UINT32 can cover all the bit field value.\r
+\r
+ @param Question The question refer to bit field.\r
+ @param Buffer Point to the buffer which the question value get from.\r
+\r
+**/\r
+VOID\r
+GetBitsQuestionValue (\r
+ IN FORM_BROWSER_STATEMENT *Question,\r
+ IN UINT8 *Buffer\r
+ )\r
+{\r
+ UINTN StartBit;\r
+ UINTN EndBit;\r
+ UINT32 RetVal;\r
+ UINT32 BufferValue;\r
+\r
+ StartBit = Question->BitVarOffset % 8;\r
+ EndBit = StartBit + Question->BitStorageWidth - 1;\r
+\r
+ CopyMem ((UINT8 *) &BufferValue, Buffer, Question->StorageWidth);\r
+\r
+ RetVal = BitFieldRead32 (BufferValue, StartBit, EndBit);\r
+\r
+ //\r
+ // Set question value.\r
+ // Note: Since Question with BufferValue (orderedlist, password, string)are not supported to refer bit field.\r
+ // Only oneof/checkbox/oneof can support bit field.So we can copy the value to the Hiivalue of Question directly.\r
+ //\r
+ CopyMem ((UINT8 *) &Question->HiiValue.Value, (UINT8 *) &RetVal, Question->StorageWidth);\r
+}\r
+\r
+/**\r
+ Set bit field value to the buffer.\r
+ Note: Data type UINT32 can cover all the bit field value.\r
+\r
+ @param Question The question refer to bit field.\r
+ @param Buffer Point to the buffer which the question value set to.\r
+ @param Value The bit field value need to set.\r
+\r
+**/\r
+VOID\r
+SetBitsQuestionValue (\r
+ IN FORM_BROWSER_STATEMENT *Question,\r
+ IN OUT UINT8 *Buffer,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ UINT32 Operand;\r
+ UINTN StartBit;\r
+ UINTN EndBit;\r
+ UINT32 RetVal;\r
+\r
+ StartBit = Question->BitVarOffset % 8;\r
+ EndBit = StartBit + Question->BitStorageWidth - 1;\r
+\r
+ CopyMem ((UINT8*) &Operand, Buffer, Question->StorageWidth);\r
+\r
+ RetVal = BitFieldWrite32 (Operand, StartBit, EndBit, Value);\r
+\r
+ CopyMem (Buffer, (UINT8*) &RetVal, Question->StorageWidth);\r
+}\r
+\r
/**\r
Convert the buffer value to HiiValue.\r
\r
BOOLEAN IsString;\r
UINTN Length;\r
EFI_STATUS Status;\r
+ UINT8 *Buffer;\r
+\r
+ Buffer = NULL;\r
\r
IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE);\r
if (Question->Storage->Type == EFI_HII_VARSTORE_BUFFER || \r
//\r
// Other type of Questions\r
//\r
- Dst = (UINT8 *) &Question->HiiValue.Value;\r
+ if (Question->QuestionReferToBitField) {\r
+ Buffer = (UINT8 *)AllocateZeroPool (Question->StorageWidth);\r
+ ASSERT (Buffer != NULL);\r
+ Dst = Buffer;\r
+ } else {\r
+ Dst = (UINT8 *) &Question->HiiValue.Value;\r
+ }\r
}\r
\r
//\r
\r
*StringPtr = TempChar;\r
\r
+ if (Question->QuestionReferToBitField) {\r
+ GetBitsQuestionValue (Question, Buffer);\r
+ if (Buffer != NULL) {\r
+ FreePool (Buffer);\r
+ }\r
+ }\r
+\r
return Status;\r
}\r
\r
if (GetValueFrom == GetSetValueWithEditBuffer) {\r
//\r
// Copy from storage Edit buffer\r
+ // If the Question refer to bit filed, get the value in the related bit filed.\r
//\r
- CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+ if (Question->QuestionReferToBitField) {\r
+ GetBitsQuestionValue (Question, Storage->EditBuffer + Question->VarStoreInfo.VarOffset);\r
+ } else {\r
+ CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+ }\r
} else {\r
//\r
// Copy from storage Edit buffer\r
+ // If the Question refer to bit filed, get the value in the related bit filed.\r
//\r
- CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+ if (Question->QuestionReferToBitField) {\r
+ GetBitsQuestionValue (Question, Storage->Buffer + Question->VarStoreInfo.VarOffset);\r
+ } else {\r
+ CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+ }\r
}\r
} else {\r
Value = NULL;\r
if (SetValueTo == GetSetValueWithEditBuffer) {\r
//\r
// Copy to storage edit buffer\r
- // \r
- CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
+ // If the Question refer to bit filed, copy the value in related bit filed to storage edit buffer.\r
+ //\r
+ if (Question->QuestionReferToBitField) {\r
+ SetBitsQuestionValue (Question, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, (UINT32)(*Src));\r
+ } else {\r
+ CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
+ }\r
} else if (SetValueTo == GetSetValueWithBuffer) {\r
//\r
- // Copy to storage edit buffer\r
- // \r
- CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
+ // Copy to storage buffer\r
+ // If the Question refer to bit filed, copy the value in related bit filed to storage buffer.\r
+ //\r
+ if (Question->QuestionReferToBitField) {\r
+ SetBitsQuestionValue (Question, Storage->Buffer + Question->VarStoreInfo.VarOffset, (UINT32)(*Src));\r
+ } else {\r
+ CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
+ }\r
}\r
} else {\r
if (IsString) {\r