diff options
author | xdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-10-26 03:03:47 +0000 |
---|---|---|
committer | xdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-10-26 03:03:47 +0000 |
commit | d02847d3c09bd897934e71d54921e9a2c5baf596 (patch) | |
tree | 30996560878807083f3991848d60f09e8b0fbbda /MdeModulePkg/Universal/SetupBrowserDxe | |
parent | d66e6c168749f686f3be04809923da74f153f340 (diff) | |
download | edk2-platforms-d02847d3c09bd897934e71d54921e9a2c5baf596.tar.xz |
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
Diffstat (limited to 'MdeModulePkg/Universal/SetupBrowserDxe')
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 51 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c | 18 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c | 10 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c | 111 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 2 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 1 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Ui.h | 34 |
7 files changed, 195 insertions, 32 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index 7d31ed5e9f..3285cfe5aa 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -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;
//
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c index cb45a0b580..bef096c0eb 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c @@ -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) {
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 364bc9d021..bb9514c315 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -877,11 +877,6 @@ SetupBrowser ( do {
//
- // Displays the Header and Footer borders
- //
- DisplayPageFrame ();
-
- //
// Initialize Selection->Form
//
if (Selection->FormId == 0) {
@@ -912,6 +907,11 @@ SetupBrowser ( }
//
+ // Displays the Header and Footer borders
+ //
+ DisplayPageFrame ();
+
+ //
// Display form
//
Status = DisplayForm (Selection);
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c b/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c index 447e6a2718..3dfb567c0f 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c @@ -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
@@ -102,6 +102,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.
@param Question The Question to be printed.
@@ -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);
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index a8393aa502..153dbf4aa4 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -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) {
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index 91b5aaee40..61e2131f33 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -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
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h index f7d4ad1d7f..da1ddc4ada 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h @@ -517,6 +517,40 @@ 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
+ );
+
+/**
+ 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).
@param Selection Pointer to UI_MENU_SELECTION.
|