/** @file\r
Entry and initialization module for the browser.\r
\r
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
//\r
// Initialize internal data structures of FormSet\r
//\r
- Status = InitializeFormSet (Selection->Handle, &Selection->FormSetGuid, FormSet);\r
+ Status = InitializeFormSet (Selection->Handle, &Selection->FormSetGuid, FormSet, TRUE);\r
if (EFI_ERROR (Status) || IsListEmpty (&FormSet->FormListHead)) {\r
DestroyFormSet (FormSet);\r
break;\r
\r
Status = EFI_SUCCESS;\r
Value = NULL;\r
+ Result = NULL;\r
\r
//\r
// Statement don't have storage, skip them\r
if (Question->ValueExpression != NULL) {\r
Status = EvaluateExpression (FormSet, Form, Question->ValueExpression);\r
if (!EFI_ERROR (Status)) {\r
- CopyMem (&Question->HiiValue, &Question->ValueExpression->Result, sizeof (EFI_HII_VALUE));\r
+ if (Question->ValueExpression->Result.Type == EFI_IFR_TYPE_BUFFER) {\r
+ ASSERT (Question->HiiValue.Type == EFI_IFR_TYPE_BUFFER && Question->HiiValue.Buffer != NULL);\r
+ if (Question->StorageWidth > Question->ValueExpression->Result.BufferLen) {\r
+ CopyMem (Question->HiiValue.Buffer, Question->ValueExpression->Result.Buffer, Question->ValueExpression->Result.BufferLen);\r
+ Question->HiiValue.BufferLen = Question->ValueExpression->Result.BufferLen;\r
+ } else {\r
+ CopyMem (Question->HiiValue.Buffer, Question->ValueExpression->Result.Buffer, Question->StorageWidth);\r
+ Question->HiiValue.BufferLen = Question->StorageWidth;\r
+ }\r
+ FreePool (Question->ValueExpression->Result.Buffer);\r
+ }\r
+ Question->HiiValue.Type = Question->ValueExpression->Result.Type;\r
+ CopyMem (&Question->HiiValue.Value, &Question->ValueExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE)); \r
}\r
return Status;\r
}\r
//\r
if (Question->ReadExpression != NULL && Form->FormType == STANDARD_MAP_FORM_TYPE) {\r
Status = EvaluateExpression (FormSet, Form, Question->ReadExpression);\r
- if (!EFI_ERROR (Status) && (Question->ReadExpression->Result.Type < EFI_IFR_TYPE_OTHER)) {\r
+ if (!EFI_ERROR (Status) && \r
+ ((Question->ReadExpression->Result.Type < EFI_IFR_TYPE_OTHER) || (Question->ReadExpression->Result.Type == EFI_IFR_TYPE_BUFFER))) {\r
//\r
// Only update question value to the valid result.\r
//\r
- CopyMem (&Question->HiiValue, &Question->ReadExpression->Result, sizeof (EFI_HII_VALUE));\r
+ if (Question->ReadExpression->Result.Type == EFI_IFR_TYPE_BUFFER) {\r
+ ASSERT (Question->HiiValue.Type == EFI_IFR_TYPE_BUFFER && Question->HiiValue.Buffer != NULL);\r
+ if (Question->StorageWidth > Question->ReadExpression->Result.BufferLen) {\r
+ CopyMem (Question->HiiValue.Buffer, Question->ReadExpression->Result.Buffer, Question->ReadExpression->Result.BufferLen);\r
+ Question->HiiValue.BufferLen = Question->ReadExpression->Result.BufferLen;\r
+ } else {\r
+ CopyMem (Question->HiiValue.Buffer, Question->ReadExpression->Result.Buffer, Question->StorageWidth);\r
+ Question->HiiValue.BufferLen = Question->StorageWidth;\r
+ }\r
+ FreePool (Question->ReadExpression->Result.Buffer);\r
+ }\r
+ Question->HiiValue.Type = Question->ReadExpression->Result.Type;\r
+ CopyMem (&Question->HiiValue.Value, &Question->ReadExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE)); \r
return EFI_SUCCESS;\r
}\r
}\r
FreePool (Value);\r
}\r
} else {\r
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {\r
+ if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
//\r
// Request current settings from Configuration Driver\r
//\r
}\r
}\r
}\r
- FreePool (Result);\r
\r
if (EFI_ERROR (Status)) {\r
+ FreePool (Result);\r
return Status;\r
}\r
} else if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {\r
} else {\r
SetValueByName (Storage, Question->VariableName, Value, TRUE);\r
}\r
+\r
+ if (Result != NULL) {\r
+ FreePool (Result);\r
+ }\r
}\r
\r
return Status;\r
}\r
\r
if (!Cached) {\r
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {\r
+ if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
//\r
// <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" ||\r
// <ConfigHdr> + "&" + <VariableName> + "=" + "<string>"\r
return Status;\r
}\r
\r
- if (Expression->Result.Value.b) {\r
+ if ((Expression->Result.Type == EFI_IFR_TYPE_BOOLEAN) && Expression->Result.Value.b) {\r
//\r
// Condition meet, show up error message\r
//\r
return Status;\r
}\r
\r
- CopyMem (HiiValue, &Default->ValueExpression->Result, sizeof (EFI_HII_VALUE));\r
+ if (Default->ValueExpression->Result.Type == EFI_IFR_TYPE_BUFFER) {\r
+ ASSERT (HiiValue->Type == EFI_IFR_TYPE_BUFFER && Question->BufferValue != NULL);\r
+ if (Question->StorageWidth > Default->ValueExpression->Result.BufferLen) {\r
+ CopyMem (Question->HiiValue.Buffer, Default->ValueExpression->Result.Buffer, Default->ValueExpression->Result.BufferLen);\r
+ Question->HiiValue.BufferLen = Default->ValueExpression->Result.BufferLen;\r
+ } else {\r
+ CopyMem (Question->HiiValue.Buffer, Default->ValueExpression->Result.Buffer, Question->StorageWidth);\r
+ Question->HiiValue.BufferLen = Question->StorageWidth;\r
+ }\r
+ FreePool (Default->ValueExpression->Result.Buffer);\r
+ }\r
+ HiiValue->Type = Default->ValueExpression->Result.Type;\r
+ CopyMem (&HiiValue->Value, &Default->ValueExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE)); \r
} else {\r
//\r
// Default value is embedded in EFI_IFR_DEFAULT\r
EFI_HII_HANDLE *HiiHandles;\r
UINTN Index;\r
EFI_GUID ZeroGuid;\r
- UINTN BackUpClassOfVfr;\r
\r
//\r
// Check the supported setting level.\r
//\r
// If Question is disabled, don't reset it to default\r
//\r
- if (Question->DisableExpression != NULL) {\r
- Status = EvaluateExpression (FormSet, Form, Question->DisableExpression);\r
- if (!EFI_ERROR (Status) && Question->DisableExpression->Result.Value.b) {\r
+ if (Question->Expression != NULL) {\r
+ if (EvaluateExpressionList(Question->Expression, TRUE, FormSet, Form) == ExpressDisable) {\r
continue;\r
}\r
}\r
// Open all FormSet by locate HII packages.\r
// Initiliaze the maintain FormSet to store default data as back up data.\r
//\r
- BackUpClassOfVfr = gClassOfVfr;\r
BackUpFormSet = gOldFormSet;\r
gOldFormSet = NULL;\r
\r
LocalFormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET));\r
ASSERT (LocalFormSet != NULL);\r
ZeroMem (&ZeroGuid, sizeof (ZeroGuid));\r
- Status = InitializeFormSet (HiiHandles[Index], &ZeroGuid, LocalFormSet);\r
+ Status = InitializeFormSet (HiiHandles[Index], &ZeroGuid, LocalFormSet, FALSE);\r
if (EFI_ERROR (Status) || IsListEmpty (&LocalFormSet->FormListHead)) {\r
DestroyFormSet (LocalFormSet);\r
continue;\r
DestroyFormSet (LocalFormSet);\r
continue;\r
}\r
- \r
+ //\r
+ // Initilize Questions' Value\r
+ //\r
+ LoadFormSetConfig (NULL, LocalFormSet);\r
+ if (EFI_ERROR (Status)) {\r
+ DestroyFormSet (LocalFormSet);\r
+ continue;\r
+ }\r
+\r
//\r
// Add FormSet into the maintain list.\r
//\r
//\r
FreePool (HiiHandles);\r
gOldFormSet = BackUpFormSet;\r
- gClassOfVfr = BackUpClassOfVfr;\r
\r
//\r
// Set Default Value for each FormSet in the maintain list.\r
@param Selection Selection contains the information about \r
the Selection, form and formset to be displayed.\r
Selection action may be updated in retrieve callback.\r
+ If Selection is NULL, only initialize Question value.\r
@param FormSet FormSet data structure.\r
@param Form Form data structure.\r
\r
//\r
// According the spec, ref opcode try to get value from call back with "retrieve" type.\r
//\r
- if ((Question->Operand == EFI_IFR_REF_OP) && (FormSet->ConfigAccess != NULL)) {\r
+ if ((Question->Operand == EFI_IFR_REF_OP) && (FormSet->ConfigAccess != NULL) && (Selection != NULL)) {\r
Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
// Check whether EfiVarstore with CallBack can be got.\r
//\r
if ((FormSet->ConfigAccess != NULL) &&\r
+ (Selection != NULL) &&\r
(Selection->Action != UI_ACTION_REFRESH_FORMSET) &&\r
(Question->QuestionId != 0) && \r
(Question->Storage != NULL) &&\r
@param Selection Selection contains the information about \r
the Selection, form and formset to be displayed.\r
Selection action may be updated in retrieve callback.\r
+ If Selection is NULL, only initialize Question value.\r
@param FormSet FormSet data structure.\r
\r
@retval EFI_SUCCESS The function completed successfully.\r
found in package list.\r
On output, GUID of the formset found(if not NULL).\r
@param FormSet FormSet data structure.\r
+ @param UpdateGlobalVar Whether need to update the global variable.\r
\r
@retval EFI_SUCCESS The function completed successfully.\r
@retval EFI_NOT_FOUND The specified FormSet could not be found.\r
InitializeFormSet (\r
IN EFI_HII_HANDLE Handle,\r
IN OUT EFI_GUID *FormSetGuid,\r
- OUT FORM_BROWSER_FORMSET *FormSet\r
+ OUT FORM_BROWSER_FORMSET *FormSet,\r
+ IN BOOLEAN UpdateGlobalVar \r
)\r
{\r
EFI_STATUS Status;\r
return Status;\r
}\r
\r
+ // \r
+ // If not need to update the global variable, just return.\r
+ //\r
+ if (!UpdateGlobalVar) {\r
+ return Status;\r
+ }\r
+\r
//\r
// Set VFR type by FormSet SubClass field\r
//\r