summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c
diff options
context:
space:
mode:
authorxdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-10-26 03:03:47 +0000
committerxdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-10-26 03:03:47 +0000
commitd02847d3c09bd897934e71d54921e9a2c5baf596 (patch)
tree30996560878807083f3991848d60f09e8b0fbbda /MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c
parentd66e6c168749f686f3be04809923da74f153f340 (diff)
downloadedk2-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/ProcessOptions.c')
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c111
1 files changed, 103 insertions, 8 deletions
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);