diff options
author | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-12-23 06:47:50 +0000 |
---|---|---|
committer | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-12-23 06:47:50 +0000 |
commit | e2100bfa651cd0d1295ef13451b9cf4adddb8bfa (patch) | |
tree | f66ecec3f0655199fb98e79780e376c82891d40a | |
parent | 7b546f7480c39e72d230970cf114ab333c912eb7 (diff) | |
download | edk2-platforms-e2100bfa651cd0d1295ef13451b9cf4adddb8bfa.tar.xz |
1. Support inconsistent if opcode used in string/password opcode.
2. Add sample code of using inconsistent if opcode in string opcode.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11196 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c | 12 | ||||
-rw-r--r-- | MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 3 | ||||
-rw-r--r-- | MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni | bin | 48460 -> 49092 bytes | |||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 15 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c | 14 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c | 71 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 21 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Ui.c | 22 |
8 files changed, 89 insertions, 69 deletions
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index efd260512a..9b664b4958 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -910,9 +910,6 @@ DriverCallback ( return EFI_INVALID_PARAMETER;
}
- if ((Type == EFI_IFR_TYPE_STRING) && (Value->string == 0)) {
- return EFI_INVALID_PARAMETER;
- }
Status = EFI_SUCCESS;
PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
@@ -1167,6 +1164,15 @@ DriverCallback ( case 0x2000:
//
+ // Only used to update the state.
+ //
+ if ((Type == EFI_IFR_TYPE_STRING) && (Value->string == 0) &&
+ (PrivateData->PasswordState == BROWSER_STATE_SET_PASSWORD)) {
+ PrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD;
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
// When try to set a new password, user will be chanlleged with old password.
// The Callback is responsible for validating old password input by user,
// If Callback return EFI_SUCCESS, it indicates validation pass.
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr index e82cccc9db..00982700b7 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -285,6 +285,9 @@ formset key = 0x1236,
minsize = 6,
maxsize = 40,
+ inconsistentif prompt = STRING_TOKEN(STR_STRING_CHECK_ERROR_POPUP),
+ pushthis != stringref(STRING_TOKEN(STR_STRING_CHECK))
+ endif
endstring;
//
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni Binary files differindex 4abcfa2cd7..5b65a1bc1b 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni +++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index 4923478954..314f91b529 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -542,11 +542,13 @@ DestroyStorage ( /**
Free resources of a Statement.
+ @param FormSet Pointer of the FormSet
@param Statement Pointer of the Statement
**/
VOID
DestroyStatement (
+ IN FORM_BROWSER_FORMSET *FormSet,
IN OUT FORM_BROWSER_STATEMENT *Statement
)
{
@@ -608,18 +610,23 @@ DestroyStatement ( if (Statement->BufferValue != NULL) {
FreePool (Statement->BufferValue);
}
+ if (Statement->Operand == EFI_IFR_STRING_OP || Statement->Operand == EFI_IFR_PASSWORD_OP) {
+ DeleteString(Statement->HiiValue.Value.string, FormSet->HiiHandle);
+ }
}
/**
Free resources of a Form.
+ @param FormSet Pointer of the FormSet
@param Form Pointer of the Form.
**/
VOID
DestroyForm (
- IN OUT FORM_BROWSER_FORM *Form
+ IN FORM_BROWSER_FORMSET *FormSet,
+ IN OUT FORM_BROWSER_FORM *Form
)
{
LIST_ENTRY *Link;
@@ -645,7 +652,7 @@ DestroyForm ( Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
RemoveEntryList (&Statement->Link);
- DestroyStatement (Statement);
+ DestroyStatement (FormSet, Statement);
}
//
@@ -731,7 +738,7 @@ DestroyFormSet ( Form = FORM_BROWSER_FORM_FROM_LINK (Link);
RemoveEntryList (&Form->Link);
- DestroyForm (Form);
+ DestroyForm (FormSet, Form);
}
}
@@ -1580,6 +1587,7 @@ ParseOpCodes ( CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING;
CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth + sizeof (CHAR16));
+ CurrentStatement->HiiValue.Value.string = NewString ((CHAR16*) CurrentStatement->BufferValue, FormSet->HiiHandle);
InitializeRequestElement (FormSet, CurrentStatement);
break;
@@ -1598,6 +1606,7 @@ ParseOpCodes ( CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING;
CurrentStatement->BufferValue = AllocateZeroPool ((CurrentStatement->StorageWidth + sizeof (CHAR16)));
+ CurrentStatement->HiiValue.Value.string = NewString ((CHAR16*) CurrentStatement->BufferValue, FormSet->HiiHandle);
InitializeRequestElement (FormSet, CurrentStatement);
break;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index a2704511c2..6d9a555b49 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -1103,12 +1103,7 @@ SetupBrowser ( HiiValue = &Statement->HiiValue;
TypeValue = &HiiValue->Value;
- if (HiiValue->Type == EFI_IFR_TYPE_STRING) {
- //
- // Create String in HII database for Configuration Driver to retrieve
- //
- HiiValue->Value.string = NewString ((CHAR16 *) Statement->BufferValue, Selection->FormSet->HiiHandle);
- } else if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
+ if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
//
// For OrderedList, passing in the value buffer to Callback()
//
@@ -1124,13 +1119,6 @@ SetupBrowser ( &ActionRequest
);
- if (HiiValue->Type == EFI_IFR_TYPE_STRING) {
- //
- // Clean the String in HII Database
- //
- DeleteString (HiiValue->Value.string, Selection->FormSet->HiiHandle);
- }
-
if (!EFI_ERROR (Status)) {
switch (ActionRequest) {
case EFI_BROWSER_ACTION_REQUEST_RESET:
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c b/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c index a4d19e0afe..e654545bf7 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c @@ -302,9 +302,8 @@ PasswordCallback ( EFI_STATUS Status;
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
EFI_BROWSER_ACTION_REQUEST ActionRequest;
- EFI_HII_VALUE *QuestionValue;
+ EFI_IFR_TYPE_VALUE IfrTypeValue;
- QuestionValue = &MenuOption->ThisTag->HiiValue;
ConfigAccess = Selection->FormSet->ConfigAccess;
if (ConfigAccess == NULL) {
return EFI_UNSUPPORTED;
@@ -314,9 +313,9 @@ PasswordCallback ( // Prepare password string in HII database
//
if (String != NULL) {
- QuestionValue->Value.string = NewString (String, Selection->FormSet->HiiHandle);
+ IfrTypeValue.string = NewString (String, Selection->FormSet->HiiHandle);
} else {
- QuestionValue->Value.string = 0;
+ IfrTypeValue.string = 0;
}
//
@@ -326,8 +325,8 @@ PasswordCallback ( ConfigAccess,
EFI_BROWSER_ACTION_CHANGING,
MenuOption->ThisTag->QuestionId,
- QuestionValue->Type,
- &QuestionValue->Value,
+ MenuOption->ThisTag->HiiValue.Type,
+ &IfrTypeValue,
&ActionRequest
);
@@ -335,7 +334,7 @@ PasswordCallback ( // Remove password string from HII database
//
if (String != NULL) {
- DeleteString (QuestionValue->Value.string, Selection->FormSet->HiiHandle);
+ DeleteString (IfrTypeValue.string, Selection->FormSet->HiiHandle);
}
return Status;
@@ -402,12 +401,14 @@ ProcessOptions ( UINTN Index2;
UINT8 *ValueArray;
UINT8 ValueType;
+ EFI_STRING_ID StringId;
Status = EFI_SUCCESS;
StringPtr = NULL;
Character[1] = L'\0';
*OptionString = NULL;
+ StringId = 0;
ZeroMem (FormattedNumber, 21 * sizeof (CHAR16));
BufferSize = (gOptionBlockWidth + 1) * 2 * gScreenDimensions.BottomRow;
@@ -742,10 +743,16 @@ ProcessOptions ( Status = ReadString (MenuOption, gPromptForData, StringPtr);
if (!EFI_ERROR (Status)) {
- CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));
- SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);
+ HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, StringPtr, NULL);
+ Status = ValidateQuestion(Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);
+ if (EFI_ERROR (Status)) {
+ HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);
+ } else {
+ CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));
+ SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);
- UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
+ UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
+ }
}
FreePool (StringPtr);
@@ -890,13 +897,47 @@ ProcessOptions ( //
if (StrCmp (StringPtr, TempString) == 0) {
//
- // Two password match, send it to Configuration Driver
+ // Prepare the Question->HiiValue.Value.string for ValidateQuestion use.
//
- if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {
- PasswordCallback (Selection, MenuOption, StringPtr);
+ if((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {
+ StringId = Question->HiiValue.Value.string;
+ Question->HiiValue.Value.string = NewString (StringPtr, Selection->FormSet->HiiHandle);
} else {
- CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));
- SetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);
+ HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, StringPtr, NULL);
+ }
+
+ Status = ValidateQuestion(Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);
+
+ //
+ // Researve the Question->HiiValue.Value.string.
+ //
+ if((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {
+ DeleteString(Question->HiiValue.Value.string, Selection->FormSet->HiiHandle);
+ Question->HiiValue.Value.string = StringId;
+ }
+
+ if (EFI_ERROR (Status)) {
+ //
+ // Reset state machine for interactive password
+ //
+ if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {
+ PasswordCallback (Selection, MenuOption, NULL);
+ } else {
+ //
+ // Researve the Question->HiiValue.Value.string.
+ //
+ HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);
+ }
+ } else {
+ //
+ // Two password match, send it to Configuration Driver
+ //
+ if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {
+ PasswordCallback (Selection, MenuOption, StringPtr);
+ } else {
+ CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));
+ SetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);
+ }
}
} else {
//
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 740ee50d0b..4896a076a5 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -2077,7 +2077,11 @@ LoadFormConfig ( if (EFI_ERROR (Status)) {
return Status;
}
-
+
+ if ((Question->Operand == EFI_IFR_STRING_OP) || (Question->Operand == EFI_IFR_PASSWORD_OP)) {
+ HiiSetString (FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);
+ }
+
//
// Check whether EfiVarstore with CallBack can be got.
//
@@ -2109,12 +2113,7 @@ LoadFormConfig ( ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
HiiValue = &Question->HiiValue;
BufferValue = (UINT8 *) &Question->HiiValue.Value;
- if (HiiValue->Type == EFI_IFR_TYPE_STRING) {
- //
- // Create String in HII database for Configuration Driver to retrieve
- //
- HiiValue->Value.string = NewString ((CHAR16 *) Question->BufferValue, FormSet->HiiHandle);
- } else if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
+ if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
BufferValue = Question->BufferValue;
}
@@ -2126,14 +2125,6 @@ LoadFormConfig ( (EFI_IFR_TYPE_VALUE *) BufferValue,
&ActionRequest
);
-
- if (HiiValue->Type == EFI_IFR_TYPE_STRING) {
- //
- // Clean the String in HII Database
- //
- DeleteString (HiiValue->Value.string, FormSet->HiiHandle);
- }
-
if (!EFI_ERROR (Status)) {
switch (ActionRequest) {
case EFI_BROWSER_ACTION_REQUEST_RESET:
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index 6e851ed7bd..36ae3db0da 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -341,7 +341,6 @@ RefreshForm ( UI_MENU_SELECTION *Selection;
FORM_BROWSER_STATEMENT *Question;
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
- EFI_HII_VALUE *HiiValue;
EFI_BROWSER_ACTION_REQUEST ActionRequest;
if (gMenuRefreshHead != NULL) {
@@ -384,31 +383,14 @@ RefreshForm ( ConfigAccess = Selection->FormSet->ConfigAccess;
if (((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) && (ConfigAccess != NULL)) {
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
-
- HiiValue = &Question->HiiValue;
- if (HiiValue->Type == EFI_IFR_TYPE_STRING) {
- //
- // Create String in HII database for Configuration Driver to retrieve
- //
- HiiValue->Value.string = NewString ((CHAR16 *) Question->BufferValue, Selection->FormSet->HiiHandle);
- }
-
Status = ConfigAccess->Callback (
ConfigAccess,
EFI_BROWSER_ACTION_CHANGING,
Question->QuestionId,
- HiiValue->Type,
- &HiiValue->Value,
+ Question->HiiValue.Type,
+ &Question->HiiValue.Value,
&ActionRequest
);
-
- if (HiiValue->Type == EFI_IFR_TYPE_STRING) {
- //
- // Clean the String in HII Database
- //
- DeleteString (HiiValue->Value.string, Selection->FormSet->HiiHandle);
- }
-
if (!EFI_ERROR (Status)) {
switch (ActionRequest) {
case EFI_BROWSER_ACTION_REQUEST_RESET:
|