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
This commit is contained in:
ydong10 2010-12-23 06:47:50 +00:00
parent 7b546f7480
commit e2100bfa65
8 changed files with 89 additions and 69 deletions

View File

@ -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);
@ -1166,6 +1163,15 @@ DriverCallback (
break;
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,

View File

@ -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;
//

View File

@ -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;

View File

@ -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:

View File

@ -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 {
//

View File

@ -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:

View File

@ -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: