Add support for newly defined VarStore type EFI_IFR_TYPE_UNDEFINED, EFI_IFR_TYPE_ACTION and EFI_IFR_TYPE_BUFFER in UEFI spec.

Note: with this update, the limitation for "OrderedList should use array of data type UINT8 as its storage" is removed; now OrderedList could use any data type (UINT8/UINT16/UINT32/UINT64) as its storage array.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9360 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xdu2 2009-10-26 03:03:47 +00:00
parent d66e6c1687
commit d02847d3c0
7 changed files with 195 additions and 32 deletions

View File

@ -810,6 +810,7 @@ ParseOpCodes (
FORMSET_DEFAULTSTORE *DefaultStore;
QUESTION_DEFAULT *CurrentDefault;
QUESTION_OPTION *CurrentOption;
UINT8 Width;
CHAR8 *AsciiString;
UINT16 NumberOfStatement;
UINT16 NumberOfExpression;
@ -1019,7 +1020,7 @@ ParseOpCodes (
break;
case EFI_IFR_UNDEFINED_OP:
Value->Type = EFI_IFR_TYPE_OTHER;
Value->Type = EFI_IFR_TYPE_UNDEFINED;
break;
case EFI_IFR_VERSION_OP:
@ -1214,6 +1215,7 @@ ParseOpCodes (
case EFI_IFR_ACTION_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
ASSERT (CurrentStatement != NULL);
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_ACTION;
if (OpCodeLength == sizeof (EFI_IFR_ACTION_1)) {
//
@ -1228,6 +1230,7 @@ ParseOpCodes (
case EFI_IFR_REF_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
ASSERT (CurrentStatement != NULL);
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_UNDEFINED;
CopyMem (&CurrentStatement->RefFormId, &((EFI_IFR_REF *) OpCodeData)->FormId, sizeof (EFI_FORM_ID));
if (OpCodeLength >= sizeof (EFI_IFR_REF2)) {
CopyMem (&CurrentStatement->RefQuestionId, &((EFI_IFR_REF2 *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));
@ -1300,16 +1303,8 @@ ParseOpCodes (
CurrentStatement->Flags = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->Flags;
CurrentStatement->MaxContainers = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->MaxContainers;
CurrentStatement->StorageWidth = (UINT16)(CurrentStatement->MaxContainers * sizeof (UINT8));
InitializeRequestElement (FormSet, CurrentStatement);
//
// No buffer type is defined in EFI_IFR_TYPE_VALUE, so a Configuration Driver
// has to use FormBrowser2.Callback() to retrieve the uncommited data for
// an interactive orderedlist (i.e. with EFI_IFR_FLAG_CALLBACK flag set).
//
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_OTHER;
CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth);
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_BUFFER;
if (Scope != 0) {
SuppressForOption = TRUE;
@ -1459,6 +1454,42 @@ ParseOpCodes (
// Insert to Option list of current Question
//
InsertTailList (&CurrentStatement->OptionListHead, &CurrentOption->Link);
//
// Now we know the Storage width of nested Ordered List
//
if ((CurrentStatement->Operand == EFI_IFR_ORDERED_LIST_OP) && (CurrentStatement->BufferValue == NULL)) {
Width = 1;
switch (CurrentOption->Value.Type) {
case EFI_IFR_TYPE_NUM_SIZE_8:
Width = 1;
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
Width = 2;
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
Width = 4;
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
Width = 8;
break;
default:
//
// Invalid type for Ordered List
//
break;
}
CurrentStatement->StorageWidth = (UINT16) (CurrentStatement->MaxContainers * Width);
CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth);
CurrentStatement->ValueType = CurrentOption->Value.Type;
InitializeRequestElement (FormSet, CurrentStatement);
}
break;
//

View File

@ -1,7 +1,7 @@
/** @file
Implementation for handling user input from the User Interfaces.
Copyright (c) 2004 - 2007, Intel Corporation
Copyright (c) 2004 - 2009, 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
@ -707,6 +707,7 @@ GetSelectionInputPopUp (
LIST_ENTRY *Link;
BOOLEAN OrderedList;
UINT8 *ValueArray;
UINT8 ValueType;
EFI_HII_VALUE HiiValue;
EFI_HII_VALUE *HiiValueArray;
UINTN OptionCount;
@ -717,6 +718,7 @@ GetSelectionInputPopUp (
DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;
ValueArray = NULL;
ValueType = 0;
CurrentOption = NULL;
ShowDownArrow = FALSE;
ShowUpArrow = FALSE;
@ -737,7 +739,7 @@ GetSelectionInputPopUp (
//
if (OrderedList) {
for (Index = 0; Index < Question->MaxContainers; Index++) {
if (ValueArray[Index] == 0) {
if (GetArrayData (ValueArray, ValueType, Index) == 0) {
break;
}
}
@ -763,8 +765,8 @@ GetSelectionInputPopUp (
Link = GetFirstNode (&Question->OptionListHead);
for (Index = 0; Index < OptionCount; Index++) {
if (OrderedList) {
HiiValueArray[Index].Type = EFI_IFR_TYPE_NUM_SIZE_8;
HiiValueArray[Index].Value.u8 = ValueArray[Index];
HiiValueArray[Index].Type = ValueType;
HiiValueArray[Index].Value.u64 = GetArrayData (ValueArray, ValueType, Index);
} else {
OneOfOption = QUESTION_OPTION_FROM_LINK (Link);
CopyMem (&HiiValueArray[Index], &OneOfOption->Value, sizeof (EFI_HII_VALUE));
@ -1060,11 +1062,11 @@ TheKey:
// Restore link list order for orderedlist
//
if (OrderedList) {
HiiValue.Type = EFI_IFR_TYPE_NUM_SIZE_8;
HiiValue.Type = ValueType;
HiiValue.Value.u64 = 0;
for (Index = 0; Index < Question->MaxContainers; Index++) {
HiiValue.Value.u8 = ValueArray[Index];
if (HiiValue.Value.u8 != 0) {
HiiValue.Value.u64 = GetArrayData (ValueArray, ValueType, Index);
if (HiiValue.Value.u64 == 0) {
break;
}
@ -1097,7 +1099,7 @@ TheKey:
while (!IsNull (&Question->OptionListHead, Link)) {
OneOfOption = QUESTION_OPTION_FROM_LINK (Link);
Question->BufferValue[Index] = OneOfOption->Value.Value.u8;
SetArrayData (ValueArray, ValueType, Index, OneOfOption->Value.Value.u64);
Index++;
if (Index > Question->MaxContainers) {

View File

@ -876,11 +876,6 @@ SetupBrowser (
}
do {
//
// Displays the Header and Footer borders
//
DisplayPageFrame ();
//
// Initialize Selection->Form
//
@ -911,6 +906,11 @@ SetupBrowser (
return Status;
}
//
// Displays the Header and Footer borders
//
DisplayPageFrame ();
//
// Display form
//

View File

@ -2,7 +2,7 @@
Implementation for handling the User Interface option processing.
Copyright (c) 2004 - 2008, Intel Corporation
Copyright (c) 2004 - 2009, 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
@ -101,6 +101,96 @@ ValueToOption (
}
/**
Return data element in an Array by its Index.
@param Array The data array.
@param Type Type of the data in this array.
@param Index Zero based index for data in this array.
@retval Value The data to be returned
**/
UINT64
GetArrayData (
IN VOID *Array,
IN UINT8 Type,
IN UINTN Index
)
{
UINT64 Data;
ASSERT (Array != NULL);
Data = 0;
switch (Type) {
case EFI_IFR_TYPE_NUM_SIZE_8:
Data = (UINT64) *(((UINT8 *) Array) + Index);
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
Data = (UINT64) *(((UINT16 *) Array) + Index);
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
Data = (UINT64) *(((UINT32 *) Array) + Index);
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
Data = (UINT64) *(((UINT64 *) Array) + Index);
break;
default:
break;
}
return Data;
}
/**
Set value of a data element in an Array by its Index.
@param Array The data array.
@param Type Type of the data in this array.
@param Index Zero based index for data in this array.
@param Value The value to be set.
**/
VOID
SetArrayData (
IN VOID *Array,
IN UINT8 Type,
IN UINTN Index,
IN UINT64 Value
)
{
ASSERT (Array != NULL);
switch (Type) {
case EFI_IFR_TYPE_NUM_SIZE_8:
*(((UINT8 *) Array) + Index) = (UINT8) Value;
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
*(((UINT16 *) Array) + Index) = (UINT16) Value;
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
*(((UINT32 *) Array) + Index) = (UINT32) Value;
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
*(((UINT64 *) Array) + Index) = (UINT64) Value;
break;
default:
break;
}
}
/**
Print Question Value according to it's storage width and display attributes.
@ -311,6 +401,8 @@ ProcessOptions (
UINT16 Maximum;
QUESTION_OPTION *Option;
UINTN Index2;
UINT8 *ValueArray;
UINT8 ValueType;
Status = EFI_SUCCESS;
@ -325,13 +417,15 @@ ProcessOptions (
QuestionValue = &Question->HiiValue;
Maximum = (UINT16) Question->Maximum;
ValueArray = Question->BufferValue;
ValueType = Question->ValueType;
switch (Question->Operand) {
case EFI_IFR_ORDERED_LIST_OP:
//
// Initialize Option value array
//
if (Question->BufferValue[0] == 0) {
if (GetArrayData (ValueArray, ValueType, 0) == 0) {
GetQuestionDefault (Selection->FormSet, Selection->Form, Question, 0);
}
@ -348,11 +442,11 @@ ProcessOptions (
*OptionString = AllocateZeroPool (Question->MaxContainers * BufferSize);
ASSERT (*OptionString);
HiiValue.Type = EFI_IFR_TYPE_NUM_SIZE_8;
HiiValue.Type = ValueType;
HiiValue.Value.u64 = 0;
for (Index = 0; Index < Question->MaxContainers; Index++) {
HiiValue.Value.u8 = Question->BufferValue[Index];
if (HiiValue.Value.u8 == 0) {
HiiValue.Value.u64 = GetArrayData (ValueArray, ValueType, Index);
if (HiiValue.Value.u64 == 0) {
//
// Values for the options in ordered lists should never be a 0
//
@ -375,10 +469,11 @@ ProcessOptions (
Index2 = 0;
while (!IsNull (&Question->OptionListHead, Link) && Index2 < Question->MaxContainers) {
Option = QUESTION_OPTION_FROM_LINK (Link);
Question->BufferValue[Index2++] = Option->Value.Value.u8;
SetArrayData (ValueArray, ValueType, Index2, Option->Value.Value.u64);
Index2++;
Link = GetNextNode (&Question->OptionListHead, Link);
}
Question->BufferValue[Index2] = 0;
SetArrayData (ValueArray, ValueType, Index2, 0);
Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);
UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);

View File

@ -1909,7 +1909,7 @@ GetQuestionDefault (
while (!IsNull (&Question->OptionListHead, Link)) {
Option = QUESTION_OPTION_FROM_LINK (Link);
Question->BufferValue[Index] = Option->Value.Value.u8;
SetArrayData (Question->BufferValue, Question->ValueType, Index, Option->Value.Value.u64);
Index++;
if (Index >= Question->MaxContainers) {

View File

@ -346,6 +346,7 @@ typedef struct {
EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numberic, oneof
UINT8 *BufferValue; // Edit copy for string, password, orderedlist
UINT8 ValueType; // Data type for orderedlist value array
//
// OpCode specific members

View File

@ -516,6 +516,40 @@ ValueToOption (
IN EFI_HII_VALUE *OptionValue
);
/**
Return data element in an Array by its Index.
@param Array The data array.
@param Type Type of the data in this array.
@param Index Zero based index for data in this array.
@retval Value The data to be returned
**/
UINT64
GetArrayData (
IN VOID *Array,
IN UINT8 Type,
IN UINTN Index
);
/**
Set value of a data element in an Array by its Index.
@param Array The data array.
@param Type Type of the data in this array.
@param Index Zero based index for data in this array.
@param Value The value to be set.
**/
VOID
SetArrayData (
IN VOID *Array,
IN UINT8 Type,
IN UINTN Index,
IN UINT64 Value
);
/**
Process a Question's Option (whether selected or un-selected).