When do discard action, enable callback action for questions which have value changed.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13509 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ydong10
2012-07-06 02:27:33 +00:00
parent 6e7ba5e34a
commit 816a711058
7 changed files with 255 additions and 94 deletions

View File

@@ -891,7 +891,7 @@ IdToQuestion (
// to keep synchronous, always reload the Question Value. // to keep synchronous, always reload the Question Value.
// //
if (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) { if (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
GetQuestionValue (FormSet, Form, Question, FALSE); GetQuestionValue (FormSet, Form, Question, GetSetValueWithHiiDriver);
} }
return Question; return Question;
@@ -2142,7 +2142,7 @@ GetQuestionValueFromForm (
// //
// Get the question value. // Get the question value.
// //
Status = GetQuestionValue(FormSet, Form, Question, FALSE); Status = GetQuestionValue(FormSet, Form, Question, GetSetValueWithHiiDriver);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
GetTheVal = FALSE; GetTheVal = FALSE;
goto Done; goto Done;
@@ -2343,7 +2343,7 @@ EvaluateExpression (
// //
// Get value from string except for STRING value. // Get value from string except for STRING value.
// //
Status = GetValueByName (OpCode->VarStorage, OpCode->ValueName, &StrPtr); Status = GetValueByName (OpCode->VarStorage, OpCode->ValueName, &StrPtr, GetSetValueWithEditBuffer);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
ASSERT (StrPtr != NULL); ASSERT (StrPtr != NULL);
TempLength = StrLen (StrPtr); TempLength = StrLen (StrPtr);
@@ -2796,7 +2796,7 @@ EvaluateExpression (
for (Index = 0; Index < OpCode->ValueWidth; Index ++, TempBuffer --) { for (Index = 0; Index < OpCode->ValueWidth; Index ++, TempBuffer --) {
StrPtr += UnicodeValueToString (StrPtr, PREFIX_ZERO | RADIX_HEX, *TempBuffer, 2); StrPtr += UnicodeValueToString (StrPtr, PREFIX_ZERO | RADIX_HEX, *TempBuffer, 2);
} }
Status = SetValueByName (OpCode->VarStorage, OpCode->ValueName, NameValue, TRUE); Status = SetValueByName (OpCode->VarStorage, OpCode->ValueName, NameValue, GetSetValueWithEditBuffer);
FreePool (NameValue); FreePool (NameValue);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Data1.Value.b = TRUE; Data1.Value.b = TRUE;

View File

@@ -799,9 +799,9 @@ EnterCarriageReturn:
// //
// Input value is not valid, restore Question Value // Input value is not valid, restore Question Value
// //
GetQuestionValue (FormSet, Form, Question, TRUE); GetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);
} else { } else {
SetQuestionValue (FormSet, Form, Question, TRUE); SetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);
if (!DateOrTime || (Question->Storage != NULL)) { if (!DateOrTime || (Question->Storage != NULL)) {
// //
// NV flag is unnecessary for RTC type of Date/Time // NV flag is unnecessary for RTC type of Date/Time
@@ -1351,9 +1351,9 @@ TheKey:
// //
// Input value is not valid, restore Question Value // Input value is not valid, restore Question Value
// //
GetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE); GetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);
} else { } else {
SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE); SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);
UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE); UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
} }

View File

@@ -1287,7 +1287,7 @@ ProcessCallBackFunction (
// "retrieve" should update to the question's temp buffer. // "retrieve" should update to the question's temp buffer.
// //
if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) { if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) {
SetQuestionValue(Selection->FormSet, Selection->Form, Statement, TRUE); SetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer);
} }
} else { } else {
// //
@@ -1295,7 +1295,7 @@ ProcessCallBackFunction (
// "retrieve", should restore the question's value. // "retrieve", should restore the question's value.
// //
if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) { if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) {
GetQuestionValue(Selection->FormSet, Selection->Form, Statement, TRUE); GetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer);
} }
if (Status == EFI_UNSUPPORTED) { if (Status == EFI_UNSUPPORTED) {

View File

@@ -482,7 +482,7 @@ ProcessOptions (
} }
SetArrayData (ValueArray, ValueType, Index2, 0); SetArrayData (ValueArray, ValueType, Index2, 0);
Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE); Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);
UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE); UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
FreePool (*OptionString); FreePool (*OptionString);
@@ -551,7 +551,7 @@ ProcessOptions (
if ((Option->SuppressExpression == NULL) || if ((Option->SuppressExpression == NULL) ||
(EvaluateExpressionList(Option->SuppressExpression, FALSE, NULL, NULL) == ExpressFalse)) { (EvaluateExpressionList(Option->SuppressExpression, FALSE, NULL, NULL) == ExpressFalse)) {
CopyMem (QuestionValue, &Option->Value, sizeof (EFI_HII_VALUE)); CopyMem (QuestionValue, &Option->Value, sizeof (EFI_HII_VALUE));
SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE); SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);
UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE); UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
break; break;
} }
@@ -587,7 +587,7 @@ ProcessOptions (
(EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) == ExpressFalse)) { (EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) == ExpressFalse)) {
Suppress = FALSE; Suppress = FALSE;
CopyMem (QuestionValue, &OneOfOption->Value, sizeof (EFI_HII_VALUE)); CopyMem (QuestionValue, &OneOfOption->Value, sizeof (EFI_HII_VALUE));
SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE); SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);
UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE); UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
gST->ConOut->SetAttribute (gST->ConOut, PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND); gST->ConOut->SetAttribute (gST->ConOut, PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND);
break; break;
@@ -640,7 +640,7 @@ ProcessOptions (
// //
// Save Question value // Save Question value
// //
Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE); Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);
UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE); UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
} }
@@ -753,7 +753,7 @@ ProcessOptions (
HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL); HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);
} else { } else {
CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16)); CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));
SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE); SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);
UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE); UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
} }
@@ -940,7 +940,7 @@ ProcessOptions (
PasswordCallback (Selection, MenuOption, StringPtr); PasswordCallback (Selection, MenuOption, StringPtr);
} else { } else {
CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16)); CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));
SetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE); SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithHiiDriver);
} }
} }
} else { } else {

View File

@@ -933,6 +933,7 @@ SynchronizeStorage (
@param Storage The NameValue Storage. @param Storage The NameValue Storage.
@param Name The Name. @param Name The Name.
@param Value The retured Value. @param Value The retured Value.
@param GetValueFrom Where to get source value, from EditValue or Value.
@retval EFI_SUCCESS Value found for given Name. @retval EFI_SUCCESS Value found for given Name.
@retval EFI_NOT_FOUND No such Name found in NameValue storage. @retval EFI_NOT_FOUND No such Name found in NameValue storage.
@@ -940,14 +941,19 @@ SynchronizeStorage (
**/ **/
EFI_STATUS EFI_STATUS
GetValueByName ( GetValueByName (
IN FORMSET_STORAGE *Storage, IN FORMSET_STORAGE *Storage,
IN CHAR16 *Name, IN CHAR16 *Name,
IN OUT CHAR16 **Value IN OUT CHAR16 **Value,
IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
) )
{ {
LIST_ENTRY *Link; LIST_ENTRY *Link;
NAME_VALUE_NODE *Node; NAME_VALUE_NODE *Node;
if (GetValueFrom != GetSetValueWithEditBuffer && GetValueFrom != GetSetValueWithBuffer) {
return EFI_INVALID_PARAMETER;
}
*Value = NULL; *Value = NULL;
Link = GetFirstNode (&Storage->NameValueListHead); Link = GetFirstNode (&Storage->NameValueListHead);
@@ -955,7 +961,11 @@ GetValueByName (
Node = NAME_VALUE_NODE_FROM_LINK (Link); Node = NAME_VALUE_NODE_FROM_LINK (Link);
if (StrCmp (Name, Node->Name) == 0) { if (StrCmp (Name, Node->Name) == 0) {
NewStringCpy (Value, Node->EditValue); if (GetValueFrom == GetSetValueWithEditBuffer) {
NewStringCpy (Value, Node->EditValue);
} else {
NewStringCpy (Value, Node->Value);
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -972,7 +982,7 @@ GetValueByName (
@param Storage The NameValue Storage. @param Storage The NameValue Storage.
@param Name The Name. @param Name The Name.
@param Value The Value to set. @param Value The Value to set.
@param Edit Whether update editValue or Value. @param SetValueTo Whether update editValue or Value.
@retval EFI_SUCCESS Value found for given Name. @retval EFI_SUCCESS Value found for given Name.
@retval EFI_NOT_FOUND No such Name found in NameValue storage. @retval EFI_NOT_FOUND No such Name found in NameValue storage.
@@ -983,19 +993,23 @@ SetValueByName (
IN FORMSET_STORAGE *Storage, IN FORMSET_STORAGE *Storage,
IN CHAR16 *Name, IN CHAR16 *Name,
IN CHAR16 *Value, IN CHAR16 *Value,
IN BOOLEAN Edit IN GET_SET_QUESTION_VALUE_WITH SetValueTo
) )
{ {
LIST_ENTRY *Link; LIST_ENTRY *Link;
NAME_VALUE_NODE *Node; NAME_VALUE_NODE *Node;
CHAR16 *Buffer; CHAR16 *Buffer;
if (SetValueTo != GetSetValueWithEditBuffer && SetValueTo != GetSetValueWithBuffer) {
return EFI_INVALID_PARAMETER;
}
Link = GetFirstNode (&Storage->NameValueListHead); Link = GetFirstNode (&Storage->NameValueListHead);
while (!IsNull (&Storage->NameValueListHead, Link)) { while (!IsNull (&Storage->NameValueListHead, Link)) {
Node = NAME_VALUE_NODE_FROM_LINK (Link); Node = NAME_VALUE_NODE_FROM_LINK (Link);
if (StrCmp (Name, Node->Name) == 0) { if (StrCmp (Name, Node->Name) == 0) {
if (Edit) { if (SetValueTo == GetSetValueWithEditBuffer) {
Buffer = Node->EditValue; Buffer = Node->EditValue;
} else { } else {
Buffer = Node->Value; Buffer = Node->Value;
@@ -1005,7 +1019,7 @@ SetValueByName (
} }
Buffer = AllocateCopyPool (StrSize (Value), Value); Buffer = AllocateCopyPool (StrSize (Value), Value);
ASSERT (Buffer != NULL); ASSERT (Buffer != NULL);
if (Edit) { if (SetValueTo == GetSetValueWithEditBuffer) {
Node->EditValue = Buffer; Node->EditValue = Buffer;
} else { } else {
Node->Value = Buffer; Node->Value = Buffer;
@@ -1162,7 +1176,7 @@ ConfigRespToStorage (
if (StrPtr != NULL) { if (StrPtr != NULL) {
*StrPtr = 0; *StrPtr = 0;
} }
SetValueByName (Storage, Name, Value, TRUE); SetValueByName (Storage, Name, Value, GetSetValueWithEditBuffer);
} }
break; break;
@@ -1182,8 +1196,7 @@ ConfigRespToStorage (
@param FormSet FormSet data structure. @param FormSet FormSet data structure.
@param Form Form data structure. @param Form Form data structure.
@param Question Question to be initialized. @param Question Question to be initialized.
@param Cached TRUE: get from Edit copy FALSE: get from original @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
Storage
@retval EFI_SUCCESS The function completed successfully. @retval EFI_SUCCESS The function completed successfully.
@@ -1193,7 +1206,7 @@ GetQuestionValue (
IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORMSET *FormSet,
IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_FORM *Form,
IN OUT FORM_BROWSER_STATEMENT *Question, IN OUT FORM_BROWSER_STATEMENT *Question,
IN BOOLEAN Cached IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@@ -1222,6 +1235,10 @@ GetQuestionValue (
Value = NULL; Value = NULL;
Result = NULL; Result = NULL;
if (GetValueFrom >= GetSetValueWithMax) {
return EFI_INVALID_PARAMETER;
}
// //
// Statement don't have storage, skip them // Statement don't have storage, skip them
// //
@@ -1373,15 +1390,22 @@ GetQuestionValue (
IsBufferStorage = FALSE; IsBufferStorage = FALSE;
} }
IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE); IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE);
if (Cached) { if (GetValueFrom == GetSetValueWithEditBuffer || GetValueFrom == GetSetValueWithBuffer ) {
if (IsBufferStorage) { if (IsBufferStorage) {
// if (GetValueFrom == GetSetValueWithEditBuffer) {
// Copy from storage Edit buffer //
// // Copy from storage Edit buffer
CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth); //
CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);
} else {
//
// Copy from storage Edit buffer
//
CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);
}
} else { } else {
Value = NULL; Value = NULL;
Status = GetValueByName (Storage, Question->VariableName, &Value); Status = GetValueByName (Storage, Question->VariableName, &Value, GetValueFrom);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@@ -1578,7 +1602,7 @@ GetQuestionValue (
if (IsBufferStorage) { if (IsBufferStorage) {
CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Dst, StorageWidth); CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Dst, StorageWidth);
} else { } else {
SetValueByName (Storage, Question->VariableName, Value, TRUE); SetValueByName (Storage, Question->VariableName, Value, GetSetValueWithEditBuffer);
} }
if (Result != NULL) { if (Result != NULL) {
@@ -1596,8 +1620,7 @@ GetQuestionValue (
@param FormSet FormSet data structure. @param FormSet FormSet data structure.
@param Form Form data structure. @param Form Form data structure.
@param Question Pointer to the Question. @param Question Pointer to the Question.
@param Cached TRUE: set to Edit copy FALSE: set to original @param SetValueTo Update the question value to editbuffer , buffer or hii driver.
Storage
@retval EFI_SUCCESS The function completed successfully. @retval EFI_SUCCESS The function completed successfully.
@@ -1607,7 +1630,7 @@ SetQuestionValue (
IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORMSET *FormSet,
IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_FORM *Form,
IN OUT FORM_BROWSER_STATEMENT *Question, IN OUT FORM_BROWSER_STATEMENT *Question,
IN BOOLEAN Cached IN GET_SET_QUESTION_VALUE_WITH SetValueTo
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@@ -1632,6 +1655,10 @@ SetQuestionValue (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
if (SetValueTo >= GetSetValueWithMax) {
return EFI_INVALID_PARAMETER;
}
// //
// Statement don't have storage, skip them // Statement don't have storage, skip them
// //
@@ -1747,47 +1774,55 @@ SetQuestionValue (
IsBufferStorage = FALSE; IsBufferStorage = FALSE;
} }
IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE); IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE);
if (IsBufferStorage) {
// if (SetValueTo == GetSetValueWithEditBuffer || SetValueTo == GetSetValueWithBuffer) {
// Copy to storage edit buffer if (IsBufferStorage) {
// if (SetValueTo == GetSetValueWithEditBuffer) {
CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth); //
} else { // Copy to storage edit buffer
if (IsString) { //
// CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
// Allocate enough string buffer. } else if (SetValueTo == GetSetValueWithBuffer) {
// //
Value = NULL; // Copy to storage edit buffer
BufferLen = ((StrLen ((CHAR16 *) Src) * 4) + 1) * sizeof (CHAR16); //
Value = AllocateZeroPool (BufferLen); CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
ASSERT (Value != NULL);
//
// Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
//
TemName = (CHAR16 *) Src;
TemString = Value;
for (; *TemName != L'\0'; TemName++) {
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);
} }
} else { } else {
BufferLen = StorageWidth * 2 + 1; if (IsString) {
Value = AllocateZeroPool (BufferLen * sizeof (CHAR16)); //
ASSERT (Value != NULL); // Allocate enough string buffer.
// //
// Convert Buffer to Hex String Value = NULL;
// BufferLen = ((StrLen ((CHAR16 *) Src) * 4) + 1) * sizeof (CHAR16);
TemBuffer = Src + StorageWidth - 1; Value = AllocateZeroPool (BufferLen);
TemString = Value; ASSERT (Value != NULL);
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) { //
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2); // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
//
TemName = (CHAR16 *) Src;
TemString = Value;
for (; *TemName != L'\0'; TemName++) {
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);
}
} else {
BufferLen = StorageWidth * 2 + 1;
Value = AllocateZeroPool (BufferLen * sizeof (CHAR16));
ASSERT (Value != NULL);
//
// Convert Buffer to Hex String
//
TemBuffer = Src + StorageWidth - 1;
TemString = Value;
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
}
} }
Status = SetValueByName (Storage, Question->VariableName, Value, SetValueTo);
FreePool (Value);
} }
} else if (SetValueTo == GetSetValueWithHiiDriver) {
Status = SetValueByName (Storage, Question->VariableName, Value, TRUE);
FreePool (Value);
}
if (!Cached) {
if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) { if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
// //
// <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" || // <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" ||
@@ -2115,6 +2150,105 @@ SynchronizeStorageForForm (
return Status; return Status;
} }
/**
When discard the question value, call the callback function with Changed type
to inform the hii driver.
@param FormSet FormSet data structure.
@param Form Form data structure.
**/
VOID
SendDiscardInfoToDriver (
IN FORM_BROWSER_FORMSET *FormSet,
IN FORM_BROWSER_FORM *Form
)
{
LIST_ENTRY *Link;
FORM_BROWSER_STATEMENT *Question;
EFI_STATUS Status;
EFI_HII_VALUE HiiValue;
UINT8 *BufferValue;
BOOLEAN ValueChanged;
EFI_IFR_TYPE_VALUE *TypeValue;
EFI_BROWSER_ACTION_REQUEST ActionRequest;
ValueChanged = FALSE;
BufferValue = NULL;
if(!Form->NvUpdateRequired) {
return;
}
Link = GetFirstNode (&Form->StatementListHead);
while (!IsNull (&Form->StatementListHead, Link)) {
Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
Link = GetNextNode (&Form->StatementListHead, Link);
if (Question->Storage == NULL || Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
continue;
}
if (Question->Operand == EFI_IFR_PASSWORD_OP) {
continue;
}
if (Question->BufferValue != NULL) {
BufferValue = AllocateZeroPool (Question->StorageWidth);
ASSERT (BufferValue != NULL);
CopyMem (BufferValue, Question->BufferValue, Question->StorageWidth);
} else {
HiiValue.Type = Question->HiiValue.Type;
CopyMem (&HiiValue.Value, &Question->HiiValue.Value, sizeof (EFI_IFR_TYPE_VALUE));
}
Status = GetQuestionValue (FormSet, Form, Question, GetSetValueWithBuffer);
if (EFI_ERROR (Status)) {
if (BufferValue != NULL) {
FreePool (BufferValue);
BufferValue = NULL;
}
continue;
}
if (Question->BufferValue != NULL) {
if (CompareMem (BufferValue, Question->BufferValue, Question->StorageWidth)) {
ValueChanged = TRUE;
}
} else {
if (CompareMem (&HiiValue.Value, &Question->HiiValue.Value, sizeof (EFI_IFR_TYPE_VALUE))) {
ValueChanged = TRUE;
}
}
if (BufferValue != NULL) {
FreePool (BufferValue);
BufferValue = NULL;
}
if (!ValueChanged) {
continue;
}
ValueChanged = FALSE;
if (Question->HiiValue.Type == EFI_IFR_TYPE_BUFFER) {
TypeValue = (EFI_IFR_TYPE_VALUE *) Question->BufferValue;
} else {
TypeValue = &Question->HiiValue.Value;
}
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
FormSet->ConfigAccess->Callback (
FormSet->ConfigAccess,
EFI_BROWSER_ACTION_CHANGED,
Question->QuestionId,
Question->HiiValue.Type,
TypeValue,
&ActionRequest
);
}
}
/** /**
Discard data based on the input setting scope (Form, FormSet or System). Discard data based on the input setting scope (Form, FormSet or System).
@@ -2164,6 +2298,11 @@ DiscardForm (
continue; continue;
} }
//
// Call callback with Changed type to inform the driver.
//
SendDiscardInfoToDriver (FormSet, Form);
// //
// Prepare <ConfigResp> // Prepare <ConfigResp>
// //
@@ -2172,6 +2311,18 @@ DiscardForm (
Form->NvUpdateRequired = FALSE; Form->NvUpdateRequired = FALSE;
} else if (SettingScope == FormSetLevel && IsNvUpdateRequired(FormSet)) { } else if (SettingScope == FormSetLevel && IsNvUpdateRequired(FormSet)) {
Link = GetFirstNode (&FormSet->FormListHead);
while (!IsNull (&FormSet->FormListHead, Link)) {
Form = FORM_BROWSER_FORM_FROM_LINK (Link);
Link = GetNextNode (&FormSet->FormListHead, Link);
//
// Call callback with Changed type to inform the driver.
//
SendDiscardInfoToDriver (FormSet, Form);
}
// //
// Discard Buffer storage or Name/Value storage // Discard Buffer storage or Name/Value storage
// //
@@ -3060,7 +3211,7 @@ ExtractDefault (
// //
if ((Question->Storage != NULL) && if ((Question->Storage != NULL) &&
(Question->Storage->Type != EFI_HII_VARSTORE_EFI_VARIABLE)) { (Question->Storage->Type != EFI_HII_VARSTORE_EFI_VARIABLE)) {
SetQuestionValue (FormSet, Form, Question, TRUE); SetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);
// //
// Update Form NV flag. // Update Form NV flag.
// //
@@ -3183,7 +3334,7 @@ LoadFormConfig (
// //
// Initialize local copy of Value for each Question // Initialize local copy of Value for each Question
// //
Status = GetQuestionValue (FormSet, Form, Question, TRUE); Status = GetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@@ -3389,8 +3540,8 @@ CopyStorage (
while (!IsNull (&Src->NameValueListHead, Link)) { while (!IsNull (&Src->NameValueListHead, Link)) {
Node = NAME_VALUE_NODE_FROM_LINK (Link); Node = NAME_VALUE_NODE_FROM_LINK (Link);
SetValueByName (Dst, Node->Name, Node->EditValue, TRUE); SetValueByName (Dst, Node->Name, Node->EditValue, GetSetValueWithEditBuffer);
SetValueByName (Dst, Node->Name, Node->Value, FALSE); SetValueByName (Dst, Node->Name, Node->Value, GetSetValueWithBuffer);
Link = GetNextNode (&Src->NameValueListHead, Link); Link = GetNextNode (&Src->NameValueListHead, Link);
} }

View File

@@ -584,6 +584,16 @@ typedef enum {
GetDefaultForMax // Invalid value. GetDefaultForMax // Invalid value.
} BROWSER_GET_DEFAULT_VALUE; } BROWSER_GET_DEFAULT_VALUE;
//
// Get/set question value from/to.
//
typedef enum {
GetSetValueWithEditBuffer, // Get/Set question value from/to editbuffer in the storage.
GetSetValueWithBuffer, // Get/Set question value from/to buffer in the storage.
GetSetValueWithHiiDriver, // Get/Set question value from/to hii driver.
GetSetValueWithMax // Invalid value.
} GET_SET_QUESTION_VALUE_WITH;
extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
extern EFI_HII_STRING_PROTOCOL *mHiiString; extern EFI_HII_STRING_PROTOCOL *mHiiString;
extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting; extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting;
@@ -887,6 +897,7 @@ CreateDialog (
@param Storage The NameValue Storage. @param Storage The NameValue Storage.
@param Name The Name. @param Name The Name.
@param Value The retured Value. @param Value The retured Value.
@param GetValueFrom Where to get source value, from EditValue or Value.
@retval EFI_SUCCESS Value found for given Name. @retval EFI_SUCCESS Value found for given Name.
@retval EFI_NOT_FOUND No such Name found in NameValue storage. @retval EFI_NOT_FOUND No such Name found in NameValue storage.
@@ -894,9 +905,10 @@ CreateDialog (
**/ **/
EFI_STATUS EFI_STATUS
GetValueByName ( GetValueByName (
IN FORMSET_STORAGE *Storage, IN FORMSET_STORAGE *Storage,
IN CHAR16 *Name, IN CHAR16 *Name,
IN OUT CHAR16 **Value IN OUT CHAR16 **Value,
IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
); );
/** /**
@@ -905,7 +917,7 @@ GetValueByName (
@param Storage The NameValue Storage. @param Storage The NameValue Storage.
@param Name The Name. @param Name The Name.
@param Value The Value to set. @param Value The Value to set.
@param Edit Whether update editValue or Value. @param SetValueTo Whether update editValue or Value.
@retval EFI_SUCCESS Value found for given Name. @retval EFI_SUCCESS Value found for given Name.
@retval EFI_NOT_FOUND No such Name found in NameValue storage. @retval EFI_NOT_FOUND No such Name found in NameValue storage.
@@ -913,10 +925,10 @@ GetValueByName (
**/ **/
EFI_STATUS EFI_STATUS
SetValueByName ( SetValueByName (
IN FORMSET_STORAGE *Storage, IN FORMSET_STORAGE *Storage,
IN CHAR16 *Name, IN CHAR16 *Name,
IN CHAR16 *Value, IN CHAR16 *Value,
IN BOOLEAN Edit IN GET_SET_QUESTION_VALUE_WITH SetValueTo
); );
/** /**
@@ -925,8 +937,7 @@ SetValueByName (
@param FormSet FormSet data structure. @param FormSet FormSet data structure.
@param Form Form data structure. @param Form Form data structure.
@param Question Question to be initialized. @param Question Question to be initialized.
@param Cached TRUE: get from Edit copy FALSE: get from original @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
Storage
@retval EFI_SUCCESS The function completed successfully. @retval EFI_SUCCESS The function completed successfully.
@@ -936,7 +947,7 @@ GetQuestionValue (
IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORMSET *FormSet,
IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_FORM *Form,
IN OUT FORM_BROWSER_STATEMENT *Question, IN OUT FORM_BROWSER_STATEMENT *Question,
IN BOOLEAN Cached IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
); );
/** /**
@@ -945,8 +956,7 @@ GetQuestionValue (
@param FormSet FormSet data structure. @param FormSet FormSet data structure.
@param Form Form data structure. @param Form Form data structure.
@param Question Pointer to the Question. @param Question Pointer to the Question.
@param Cached TRUE: set to Edit copy FALSE: set to original @param SetValueTo Update the question value to editbuffer , buffer or hii driver.
Storage
@retval EFI_SUCCESS The function completed successfully. @retval EFI_SUCCESS The function completed successfully.
@@ -956,7 +966,7 @@ SetQuestionValue (
IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORMSET *FormSet,
IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_FORM *Form,
IN OUT FORM_BROWSER_STATEMENT *Question, IN OUT FORM_BROWSER_STATEMENT *Question,
IN BOOLEAN Cached IN GET_SET_QUESTION_VALUE_WITH SetValueTo
); );
/** /**

View File

@@ -439,7 +439,7 @@ RefreshQuestion (
Selection = MenuRefreshEntry->Selection; Selection = MenuRefreshEntry->Selection;
Question = MenuRefreshEntry->MenuOption->ThisTag; Question = MenuRefreshEntry->MenuOption->ThisTag;
Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE); Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithHiiDriver);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }