MdeModulePkg: Enable reconnect request from action request or question flag.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17516 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Eric Dong 2015-05-27 02:32:59 +00:00 committed by ydong10
parent 1c2a496292
commit f2e7732e44
6 changed files with 143 additions and 13 deletions

View File

@ -1,7 +1,7 @@
/** @file
FormDiplay protocol to show Form
Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@ -39,6 +39,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define BROWSER_INCONSISTENT_IF BROWSER_ERROR | 0x06
#define BROWSER_WARNING_IF BROWSER_ERROR | 0x07
#define BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF BROWSER_ERROR | 0x08
#define BROWSER_RECONNECT_REQUIRED BROWSER_ERROR | 0x09
#define BROWSER_RECONNECT_FAIL BROWSER_ERROR | 0x0A
#define BROWSER_RECONNECT_SAVE_CHANGES BROWSER_ERROR | 0x0B
#define FORM_DISPLAY_ENGINE_STATEMENT_VERSION_1 0x10000
#define FORM_DISPLAY_ENGINE_VERSION_1 0x10000

View File

@ -113,9 +113,13 @@ FORM_ENTRY_INFO gOldFormEntry = {0};
//
// Browser Global Strings
//
CHAR16 *gReconnectConfirmChanges;
CHAR16 *gReconnectFail;
CHAR16 *gReconnectRequired;
CHAR16 *gChangesOpt;
CHAR16 *gFormNotFound;
CHAR16 *gNoSubmitIf;
CHAR16 *gBrwoserError;
CHAR16 *gBrowserError;
CHAR16 *gSaveFailed;
CHAR16 *gNoSubmitIfFailed;
CHAR16 *gSaveProcess;
@ -203,9 +207,13 @@ InitializeDisplayStrings (
VOID
)
{
gReconnectConfirmChanges = GetToken (STRING_TOKEN (RECONNECT_CONFIRM_CHANGES), gHiiHandle);
mUnknownString = GetToken (STRING_TOKEN (UNKNOWN_STRING), gHiiHandle);
gSaveFailed = GetToken (STRING_TOKEN (SAVE_FAILED), gHiiHandle);
gNoSubmitIfFailed = GetToken (STRING_TOKEN (NO_SUBMIT_IF_CHECK_FAILED), gHiiHandle);
gReconnectFail = GetToken (STRING_TOKEN (RECONNECT_FAILED), gHiiHandle);
gReconnectRequired = GetToken (STRING_TOKEN (RECONNECT_REQUIRED), gHiiHandle);
gChangesOpt = GetToken (STRING_TOKEN (RECONNECT_CHANGES_OPTIONS), gHiiHandle);
gSaveProcess = GetToken (STRING_TOKEN (DISCARD_OR_JUMP), gHiiHandle);
gSaveNoSubmitProcess = GetToken (STRING_TOKEN (DISCARD_OR_CHECK), gHiiHandle);
gDiscardChange = GetToken (STRING_TOKEN (DISCARD_OR_JUMP_DISCARD), gHiiHandle);
@ -225,7 +233,7 @@ InitializeDisplayStrings (
gProtocolNotFound = GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND), gHiiHandle);
gFormNotFound = GetToken (STRING_TOKEN (STATUS_BROWSER_FORM_NOT_FOUND), gHiiHandle);
gNoSubmitIf = GetToken (STRING_TOKEN (STATUS_BROWSER_NO_SUBMIT_IF), gHiiHandle);
gBrwoserError = GetToken (STRING_TOKEN (STATUS_BROWSER_ERROR), gHiiHandle);
gBrowserError = GetToken (STRING_TOKEN (STATUS_BROWSER_ERROR), gHiiHandle);
gConfirmDefaultMsg = GetToken (STRING_TOKEN (CONFIRM_DEFAULT_MESSAGE), gHiiHandle);
gConfirmDiscardMsg = GetToken (STRING_TOKEN (CONFIRM_DISCARD_MESSAGE), gHiiHandle);
gConfirmSubmitMsg = GetToken (STRING_TOKEN (CONFIRM_SUBMIT_MESSAGE), gHiiHandle);
@ -256,6 +264,10 @@ FreeDisplayStrings (
FreePool (gEmptyString);
FreePool (gSaveFailed);
FreePool (gNoSubmitIfFailed);
FreePool (gReconnectFail);
FreePool (gReconnectRequired);
FreePool (gChangesOpt);
FreePool (gReconnectConfirmChanges);
FreePool (gSaveProcess);
FreePool (gSaveNoSubmitProcess);
FreePool (gDiscardChange);
@ -272,7 +284,7 @@ FreeDisplayStrings (
FreePool (gOptionMismatch);
FreePool (gFormSuppress);
FreePool (gProtocolNotFound);
FreePool (gBrwoserError);
FreePool (gBrowserError);
FreePool (gNoSubmitIf);
FreePool (gFormNotFound);
FreePool (gConfirmDefaultMsg);
@ -3776,8 +3788,20 @@ BrowserStatusProcess (
ErrorInfo = gNoSubmitIfFailed;
break;
case BROWSER_RECONNECT_FAIL:
ErrorInfo = gReconnectFail;
break;
case BROWSER_RECONNECT_SAVE_CHANGES:
ErrorInfo = gReconnectConfirmChanges;
break;
case BROWSER_RECONNECT_REQUIRED:
ErrorInfo = gReconnectRequired;
break;
default:
ErrorInfo = gBrwoserError;
ErrorInfo = gBrowserError;
break;
}
}
@ -3785,15 +3809,21 @@ BrowserStatusProcess (
switch (gFormData->BrowserStatus) {
case BROWSER_SUBMIT_FAIL:
case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF:
case BROWSER_RECONNECT_SAVE_CHANGES:
ASSERT (gUserInput != NULL);
if (gFormData->BrowserStatus == (BROWSER_SUBMIT_FAIL)) {
PrintString = gSaveProcess;
JumpToFormSet = gJumpToFormSet[0];
DiscardChange = gDiscardChange[0];
} else if (gFormData->BrowserStatus == (BROWSER_RECONNECT_SAVE_CHANGES)){
PrintString = gChangesOpt;
JumpToFormSet = gConfirmOptYes[0];
DiscardChange = gConfirmOptNo[0];
} else {
PrintString = gSaveNoSubmitProcess;
JumpToFormSet = gCheckError[0];
DiscardChange = gDiscardChange[0];
}
DiscardChange = gDiscardChange[0];
do {
CreateDialog (&Key, gEmptyString, ErrorInfo, PrintString, gEmptyString, NULL);

View File

@ -1884,6 +1884,30 @@ FindNextMenu (
return TRUE;
}
/**
Reconnect the controller.
@param DriverHandle The controller handle which need to be reconnect.
@retval TRUE do the reconnect behavior success.
@retval FALSE do the reconnect behavior failed.
**/
BOOLEAN
ReconnectController (
IN EFI_HANDLE DriverHandle
)
{
EFI_STATUS Status;
Status = gBS->DisconnectController(DriverHandle, NULL, NULL);
if (!EFI_ERROR (Status)) {
Status = gBS->ConnectController(DriverHandle, NULL, NULL, TRUE);
}
return Status == EFI_SUCCESS;
}
/**
Call the call back function for the question and process the return action.
@ -2055,6 +2079,10 @@ ProcessCallBackFunction (
SettingLevel = FormLevel;
break;
case EFI_BROWSER_ACTION_REQUEST_RECONNECT:
gCallbackReconnect = TRUE;
break;
default:
break;
}
@ -2155,6 +2183,28 @@ ProcessCallBackFunction (
}
}
if (gCallbackReconnect && (EFI_BROWSER_ACTION_CHANGED == Action)) {
//
// Confirm changes with user first.
//
if (IsNvUpdateRequiredForFormSet(FormSet)) {
if (BROWSER_ACTION_DISCARD == PopupErrorMessage(BROWSER_RECONNECT_SAVE_CHANGES, NULL, NULL, NULL)) {
gCallbackReconnect = FALSE;
DiscardFormIsRequired = TRUE;
} else {
SubmitFormIsRequired = TRUE;
}
} else {
PopupErrorMessage(BROWSER_RECONNECT_REQUIRED, NULL, NULL, NULL);
}
//
// Exit current formset before do the reconnect.
//
NeedExit = TRUE;
SettingLevel = FormSetLevel;
}
if (SubmitFormIsRequired && !SkipSaveOrDiscard) {
SubmitForm (FormSet, Form, SettingLevel);
}
@ -2476,13 +2526,18 @@ SetupBrowser (
}
//
// If question has EFI_IFR_FLAG_RESET_REQUIRED flag and without storage and process question success till here,
// trig the gResetFlag.
// If question has EFI_IFR_FLAG_RESET_REQUIRED/EFI_IFR_FLAG_RECONNECT_REQUIRED flag and without storage
// and process question success till here, trig the gResetFlag/gFlagReconnect.
//
if ((Status == EFI_SUCCESS) &&
(Statement->Storage == NULL) &&
((Statement->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0)) {
gResetRequired = TRUE;
(Statement->Storage == NULL)) {
if ((Statement->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0) {
gResetRequired = TRUE;
}
if ((Statement->QuestionFlags & EFI_IFR_FLAG_RECONNECT_REQUIRED) != 0) {
gFlagReconnect = TRUE;
}
}
}

View File

@ -55,6 +55,8 @@ LIST_ENTRY gBrowserSaveFailFormSetList = INITIALIZE_LIST_HEAD_VARIABLE (gBr
BOOLEAN mSystemSubmit = FALSE;
BOOLEAN gResetRequired;
BOOLEAN gExitRequired;
BOOLEAN gFlagReconnect;
BOOLEAN gCallbackReconnect;
BROWSER_SETTING_SCOPE gBrowserSettingScope = FormSetLevel;
BOOLEAN mBrowserScopeFirstSet = TRUE;
EXIT_HANDLER ExitHandlerFunction = NULL;
@ -483,6 +485,7 @@ SendForm (
UINTN Index;
FORM_BROWSER_FORMSET *FormSet;
FORM_ENTRY_INFO *MenuList;
BOOLEAN RetVal;
//
// If EDKII_FORM_DISPLAY_ENGINE_PROTOCOL not found, return EFI_UNSUPPORTED.
@ -496,8 +499,10 @@ SendForm (
//
SaveBrowserContext ();
gFlagReconnect = FALSE;
gResetRequired = FALSE;
gExitRequired = FALSE;
gCallbackReconnect = FALSE;
Status = EFI_SUCCESS;
gEmptyString = L"";
gDisplayFormData.ScreenDimensions = (EFI_SCREEN_DESCRIPTOR *) ScreenDimensions;
@ -547,6 +552,15 @@ SendForm (
gCurrentSelection = NULL;
mSystemLevelFormSet = NULL;
if (gFlagReconnect || gCallbackReconnect) {
RetVal = ReconnectController (FormSet->DriverHandle);
if (!RetVal) {
PopupErrorMessage(BROWSER_RECONNECT_FAIL, NULL, NULL, NULL);
}
gFlagReconnect = FALSE;
gCallbackReconnect = FALSE;
}
//
// If no data is changed, don't need to save current FormSet into the maintain list.
//
@ -2523,8 +2537,14 @@ UpdateFlagForForm (
//
// Only the changed data has been saved, then need to set the reset flag.
//
if (SetFlag && OldValue && !Question->ValueChanged && ((Question->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0)) {
gResetRequired = TRUE;
if (SetFlag && OldValue && !Question->ValueChanged) {
if ((Question->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0) {
gResetRequired = TRUE;
}
if ((Question->QuestionFlags & EFI_IFR_FLAG_RECONNECT_REQUIRED) != 0) {
gFlagReconnect = TRUE;
}
}
}
}
@ -5524,6 +5544,8 @@ SaveBrowserContext (
//
Context->Selection = gCurrentSelection;
Context->ResetRequired = gResetRequired;
Context->FlagReconnect = gFlagReconnect;
Context->CallbackReconnect = gCallbackReconnect;
Context->ExitRequired = gExitRequired;
Context->HiiHandle = mCurrentHiiHandle;
Context->FormId = mCurrentFormId;
@ -5579,6 +5601,8 @@ RestoreBrowserContext (
//
gCurrentSelection = Context->Selection;
gResetRequired = Context->ResetRequired;
gFlagReconnect = Context->FlagReconnect;
gCallbackReconnect = Context->CallbackReconnect;
gExitRequired = Context->ExitRequired;
mCurrentHiiHandle = Context->HiiHandle;
mCurrentFormId = Context->FormId;

View File

@ -528,6 +528,8 @@ typedef struct {
//
// Globals defined in Setup.c
//
BOOLEAN FlagReconnect;
BOOLEAN CallbackReconnect;
BOOLEAN ResetRequired;
BOOLEAN ExitRequired;
EFI_HII_HANDLE HiiHandle;
@ -566,6 +568,8 @@ extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting;
extern EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mPathFromText;
extern EDKII_FORM_DISPLAY_ENGINE_PROTOCOL *mFormDisplay;
extern BOOLEAN gCallbackReconnect;
extern BOOLEAN gFlagReconnect;
extern BOOLEAN gResetRequired;
extern BOOLEAN gExitRequired;
extern LIST_ENTRY gBrowserFormSetList;
@ -1831,4 +1835,18 @@ GetFstStgFromBrsStg (
IN BROWSER_STORAGE *Storage
);
/**
Reconnect the controller.
@param DriverHandle The controller handle which need to be reconnect.
@retval TRUE do the reconnect behavior success.
@retval FALSE do the reconnect behavior failed.
**/
BOOLEAN
ReconnectController (
IN EFI_HANDLE DriverHandle
);
#endif