/** @file\r
Entry and initialization module for the browser.\r
\r
-Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2016, 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
GetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);\r
\r
+ if (Question->Operand == EFI_IFR_STRING_OP){\r
+ HiiSetString (FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);\r
+ }\r
+\r
if (Question->HiiValue.Type == EFI_IFR_TYPE_BUFFER) {\r
TypeValue = (EFI_IFR_TYPE_VALUE *) Question->BufferValue;\r
} else {\r
}\r
}\r
\r
+/**\r
+ When submit the question value, call the callback function with Submitted type\r
+ to inform the hii driver.\r
+\r
+ @param FormSet FormSet data structure.\r
+ @param Form Form data structure.\r
+\r
+**/\r
+VOID\r
+SubmitCallbackForForm (\r
+ IN FORM_BROWSER_FORMSET *FormSet,\r
+ IN FORM_BROWSER_FORM *Form\r
+ )\r
+{\r
+ LIST_ENTRY *Link;\r
+ FORM_BROWSER_STATEMENT *Question;\r
+ EFI_IFR_TYPE_VALUE *TypeValue;\r
+ EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
+\r
+ if (FormSet->ConfigAccess == NULL) {\r
+ return;\r
+ }\r
+\r
+ Link = GetFirstNode (&Form->StatementListHead);\r
+ while (!IsNull (&Form->StatementListHead, Link)) {\r
+ Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);\r
+ Link = GetNextNode (&Form->StatementListHead, Link);\r
+\r
+ if (Question->Storage == NULL || Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {\r
+ continue;\r
+ }\r
+\r
+ if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) {\r
+ continue;\r
+ }\r
+\r
+ if (Question->Operand == EFI_IFR_PASSWORD_OP) {\r
+ continue;\r
+ }\r
+\r
+ if (Question->HiiValue.Type == EFI_IFR_TYPE_BUFFER) {\r
+ TypeValue = (EFI_IFR_TYPE_VALUE *) Question->BufferValue;\r
+ } else {\r
+ TypeValue = &Question->HiiValue.Value;\r
+ }\r
+\r
+ ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
+ FormSet->ConfigAccess->Callback (\r
+ FormSet->ConfigAccess,\r
+ EFI_BROWSER_ACTION_SUBMITTED,\r
+ Question->QuestionId,\r
+ Question->HiiValue.Type,\r
+ TypeValue,\r
+ &ActionRequest\r
+ );\r
+ }\r
+}\r
+\r
+/**\r
+ When value set Success, call the submit callback function.\r
+\r
+ @param FormSet FormSet data structure.\r
+ @param Form Form data structure.\r
+\r
+**/\r
+VOID\r
+SubmitCallback (\r
+ IN FORM_BROWSER_FORMSET *FormSet,\r
+ IN FORM_BROWSER_FORM *Form\r
+ )\r
+{\r
+ FORM_BROWSER_FORM *CurrentForm;\r
+ LIST_ENTRY *Link;\r
+\r
+ if (Form != NULL) {\r
+ SubmitCallbackForForm(FormSet, Form);\r
+ return;\r
+ }\r
+\r
+ Link = GetFirstNode (&FormSet->FormListHead);\r
+ while (!IsNull (&FormSet->FormListHead, Link)) {\r
+ CurrentForm = FORM_BROWSER_FORM_FROM_LINK (Link);\r
+ Link = GetNextNode (&FormSet->FormListHead, Link);\r
+\r
+ SubmitCallbackForForm(FormSet, CurrentForm);\r
+ }\r
+}\r
+\r
/**\r
Validate the HiiHandle.\r
\r
return (BOOLEAN) (*RetForm != NULL);\r
}\r
\r
+/**\r
+ Base on the return Progress string to get the SyncConfigRequest and RestoreConfigRequest\r
+ for form and formset.\r
+\r
+ @param Storage Storage which has this Progress string.\r
+ @param ConfigRequest The ConfigRequest string.\r
+ @param Progress The Progress string which has the first fail string.\r
+ @param RestoreConfigRequest Return the RestoreConfigRequest string.\r
+ @param SyncConfigRequest Return the SyncConfigRequest string.\r
+\r
+**/\r
+VOID\r
+GetSyncRestoreConfigRequest(\r
+ IN BROWSER_STORAGE *Storage,\r
+ IN EFI_STRING ConfigRequest,\r
+ IN EFI_STRING Progress,\r
+ OUT EFI_STRING *RestoreConfigRequest,\r
+ OUT EFI_STRING *SyncConfigRequest\r
+ )\r
+{\r
+ EFI_STRING EndStr;\r
+ EFI_STRING ConfigHdrEndStr;\r
+ EFI_STRING ElementStr;\r
+ UINTN TotalSize;\r
+ UINTN RestoreEleSize;\r
+ UINTN SyncSize;\r
+\r
+ ASSERT ((*Progress == L'&') || (*Progress == L'G'));\r
+ //\r
+ // If the Progress starts with ConfigHdr, means the failure is in the first name / value pair.\r
+ // Need to restore all the fields in the ConfigRequest.\r
+ //\r
+ if (*Progress == L'G') {\r
+ *RestoreConfigRequest = AllocateCopyPool (StrSize (ConfigRequest), ConfigRequest);\r
+ ASSERT (*RestoreConfigRequest != NULL);\r
+ return;\r
+ }\r
+\r
+ //\r
+ // Find the first fail "NAME" or "OFFSET=0x####&WIDTH=0x####" string.\r
+ //\r
+ if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
+ //\r
+ // For Name/Value type, the data is "&Fred=16&George=16&Ron=12" formset,\r
+ // here, just keep the "Fred" string.\r
+ //\r
+ EndStr = StrStr (Progress, L"=");\r
+ ASSERT (EndStr != NULL);\r
+ *EndStr = L'\0';\r
+ //\r
+ // Find the ConfigHdr in ConfigRequest.\r
+ //\r
+ ConfigHdrEndStr = StrStr (ConfigRequest, L"PATH=");\r
+ ASSERT (ConfigHdrEndStr != NULL);\r
+ while (*ConfigHdrEndStr != L'&') {\r
+ ConfigHdrEndStr++;\r
+ }\r
+ } else {\r
+ //\r
+ // For Buffer type, the data is "OFFSET=0x####&WIDTH=0x####&VALUE=0x####",\r
+ // here, just keep the "OFFSET=0x####&WIDTH=0x####" string.\r
+ //\r
+ EndStr = StrStr (Progress, L"&VALUE=");\r
+ ASSERT (EndStr != NULL);\r
+ *EndStr = L'\0';\r
+ //\r
+ // Find the ConfigHdr in ConfigRequest.\r
+ //\r
+ ConfigHdrEndStr = StrStr (ConfigRequest, L"&OFFSET=");\r
+ }\r
+ //\r
+ // Find the first fail pair in the ConfigRequest.\r
+ //\r
+ ElementStr = StrStr (ConfigRequest, Progress);\r
+ ASSERT (ElementStr != NULL);\r
+ //\r
+ // To get the RestoreConfigRequest.\r
+ //\r
+ RestoreEleSize = StrSize (ElementStr);\r
+ TotalSize = (ConfigHdrEndStr - ConfigRequest) * sizeof (CHAR16) + RestoreEleSize + sizeof (CHAR16);\r
+ *RestoreConfigRequest = AllocateZeroPool (TotalSize);\r
+ ASSERT (*RestoreConfigRequest != NULL);\r
+ StrnCpyS (*RestoreConfigRequest, TotalSize / sizeof (CHAR16), ConfigRequest, ConfigHdrEndStr - ConfigRequest);\r
+ StrCatS (*RestoreConfigRequest, TotalSize / sizeof (CHAR16), ElementStr);\r
+ //\r
+ // To get the SyncConfigRequest.\r
+ //\r
+ SyncSize = StrSize (ConfigRequest) - RestoreEleSize + sizeof (CHAR16);\r
+ *SyncConfigRequest = AllocateZeroPool (SyncSize);\r
+ ASSERT (*SyncConfigRequest != NULL);\r
+ StrnCpyS (*SyncConfigRequest, SyncSize / sizeof (CHAR16), ConfigRequest, SyncSize / sizeof (CHAR16) - 1);\r
+\r
+ //\r
+ // restore the Progress string to the original format.\r
+ //\r
+ if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
+ *EndStr = L'=';\r
+ } else {\r
+ *EndStr = L'&';\r
+ }\r
+}\r
+\r
/**\r
Popup an save error info and get user input.\r
\r
FreePool (ConfigResp);\r
\r
if (EFI_ERROR (Status)) {\r
+ //\r
+ // Submit fail, to get the RestoreConfigRequest and SyncConfigRequest.\r
+ //\r
+ GetSyncRestoreConfigRequest (ConfigInfo->Storage, ConfigInfo->ConfigRequest, Progress, &ConfigInfo->RestoreConfigRequest, &ConfigInfo->SyncConfigRequest);\r
InsertTailList (&gBrowserSaveFailFormSetList, &ConfigInfo->SaveFailLink);\r
continue;\r
}\r
while (!IsNull (&gBrowserSaveFailFormSetList, Link)) {\r
ConfigInfo = FORM_BROWSER_CONFIG_REQUEST_FROM_SAVE_FAIL_LINK (Link);\r
Link = GetNextNode (&gBrowserSaveFailFormSetList, Link);\r
-\r
- SynchronizeStorage(ConfigInfo->Storage, ConfigInfo->ConfigRequest, FALSE);\r
+ //\r
+ // Process the submit fail question, base on the RestoreConfigRequest to restore the EditBuffer\r
+ // base on the SyncConfigRequest to Sync the buffer.\r
+ //\r
+ SynchronizeStorage (ConfigInfo->Storage, ConfigInfo->RestoreConfigRequest, FALSE);\r
+ FreePool (ConfigInfo->RestoreConfigRequest);\r
+ ConfigInfo->RestoreConfigRequest = NULL;\r
+ if (ConfigInfo->SyncConfigRequest != NULL) {\r
+ SynchronizeStorage(ConfigInfo->Storage, ConfigInfo->SyncConfigRequest, TRUE);\r
+ FreePool (ConfigInfo->SyncConfigRequest);\r
+ ConfigInfo->SyncConfigRequest = NULL;\r
+ }\r
\r
Status = EFI_SUCCESS;\r
}\r
//\r
ValueChangeResetFlagUpdate(TRUE, FormSet, Form);\r
\r
+ //\r
+ // 6 Call callback with Submitted type to inform the driver.\r
+ //\r
+ SubmitCallback (FormSet, Form);\r
+\r
return Status;\r
}\r
\r
&Progress\r
);\r
if (EFI_ERROR (Status)) {\r
+ //\r
+ // Submit fail, to get the RestoreConfigRequest and SyncConfigRequest.\r
+ //\r
+ GetSyncRestoreConfigRequest (FormSetStorage->BrowserStorage, FormSetStorage->ConfigRequest, Progress, &FormSetStorage->RestoreConfigRequest, &FormSetStorage->SyncConfigRequest);\r
InsertTailList (&FormSet->SaveFailStorageListHead, &FormSetStorage->SaveFailLink);\r
if (!HasInserted) {\r
//\r
FormSetStorage = FORMSET_STORAGE_FROM_SAVE_FAIL_LINK (Link);\r
Storage = FormSetStorage->BrowserStorage;\r
Link = GetNextNode (&FormSet->SaveFailStorageListHead, Link);\r
-\r
- SynchronizeStorage(FormSetStorage->BrowserStorage, FormSetStorage->ConfigRequest, FALSE);\r
+ //\r
+ // Process the submit fail question, base on the RestoreConfigRequest to restore the EditBuffer\r
+ // base on the SyncConfigRequest to Sync the buffer.\r
+ //\r
+ SynchronizeStorage (FormSetStorage->BrowserStorage, FormSetStorage->RestoreConfigRequest, FALSE);\r
+ FreePool (FormSetStorage->RestoreConfigRequest);\r
+ FormSetStorage->RestoreConfigRequest = NULL;\r
+ if (FormSetStorage->SyncConfigRequest != NULL) {\r
+ SynchronizeStorage(FormSetStorage->BrowserStorage, FormSetStorage->SyncConfigRequest, TRUE);\r
+ FreePool (FormSetStorage->SyncConfigRequest);\r
+ FormSetStorage->SyncConfigRequest = NULL;\r
+ }\r
\r
Status = EFI_SUCCESS;\r
}\r
// \r
ValueChangeResetFlagUpdate(TRUE, FormSet, NULL);\r
\r
+ //\r
+ // 6. Call callback with Submitted type to inform the driver.\r
+ //\r
+ SubmitCallback (FormSet, NULL);\r
+\r
return Status;\r
}\r
\r
while (!IsNull (&LocalFormSet->SaveFailStorageListHead, StorageLink)) {\r
FormSetStorage = FORMSET_STORAGE_FROM_SAVE_FAIL_LINK (StorageLink);\r
StorageLink = GetNextNode (&LocalFormSet->SaveFailStorageListHead, StorageLink);\r
-\r
- SynchronizeStorage(FormSetStorage->BrowserStorage, FormSetStorage->ConfigRequest, FALSE);\r
+ //\r
+ // Process the submit fail question, base on the RestoreConfigRequest to restore the EditBuffer\r
+ // base on the SyncConfigRequest to Sync the buffer.\r
+ //\r
+ SynchronizeStorage (FormSetStorage->BrowserStorage, FormSetStorage->RestoreConfigRequest, FALSE);\r
+ FreePool (FormSetStorage->RestoreConfigRequest);\r
+ FormSetStorage->RestoreConfigRequest = NULL;\r
+ if ( FormSetStorage->SyncConfigRequest != NULL) {\r
+ SynchronizeStorage (FormSetStorage->BrowserStorage, FormSetStorage->SyncConfigRequest, TRUE);\r
+ FreePool (FormSetStorage->SyncConfigRequest);\r
+ FormSetStorage->SyncConfigRequest = NULL;\r
+ }\r
}\r
}\r
\r
EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
INTN Action;\r
CHAR16 *NewString;\r
+ EFI_IFR_TYPE_VALUE *TypeValue;\r
\r
Status = EFI_NOT_FOUND;\r
StrValue = NULL;\r
// 5, set flags of EFI_IFR_CHECKBOX (provide Standard and Manufacturing default) (lowest priority)\r
//\r
HiiValue = &Question->HiiValue;\r
+ TypeValue = &HiiValue->Value;\r
+ if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
+ //\r
+ // For orderedlist, need to pass the BufferValue to Callback function.\r
+ //\r
+ TypeValue = (EFI_IFR_TYPE_VALUE *) Question->BufferValue;\r
+ }\r
\r
//\r
// Get Question defaut value from call back function.\r
Action,\r
Question->QuestionId,\r
HiiValue->Type,\r
- &HiiValue->Value,\r
+ TypeValue,\r
&ActionRequest\r
);\r
if (!EFI_ERROR (Status)) {\r
VOID\r
)\r
{\r
- BROWSER_CONTEXT *Context;\r
- FORM_ENTRY_INFO *MenuList;\r
+ BROWSER_CONTEXT *Context;\r
+ FORM_ENTRY_INFO *MenuList;\r
+ FORM_BROWSER_FORMSET *FormSet;\r
\r
gBrowserContextCount++;\r
if (gBrowserContextCount == 1) {\r
Context->HiiHandle = mCurrentHiiHandle;\r
Context->FormId = mCurrentFormId;\r
CopyGuid (&Context->FormSetGuid, &mCurrentFormSetGuid);\r
+ Context->SystemLevelFormSet = mSystemLevelFormSet;\r
+ Context->CurFakeQestId = mCurFakeQestId;\r
+ Context->HiiPackageListUpdated = mHiiPackageListUpdated;\r
+ Context->FinishRetrieveCall = mFinishRetrieveCall;\r
\r
//\r
// Save the menu history data.\r
InsertTailList(&Context->FormHistoryList, &MenuList->Link);\r
}\r
\r
+ //\r
+ // Save formset list.\r
+ //\r
+ InitializeListHead(&Context->FormSetList);\r
+ while (!IsListEmpty (&gBrowserFormSetList)) {\r
+ FormSet = FORM_BROWSER_FORMSET_FROM_LINK (gBrowserFormSetList.ForwardLink);\r
+ RemoveEntryList (&FormSet->Link);\r
+\r
+ InsertTailList(&Context->FormSetList, &FormSet->Link);\r
+ }\r
+\r
//\r
// Insert to FormBrowser context list\r
//\r
{\r
LIST_ENTRY *Link;\r
BROWSER_CONTEXT *Context;\r
- FORM_ENTRY_INFO *MenuList;\r
+ FORM_ENTRY_INFO *MenuList;\r
+ FORM_BROWSER_FORMSET *FormSet;\r
\r
ASSERT (gBrowserContextCount != 0);\r
gBrowserContextCount--;\r
mCurrentHiiHandle = Context->HiiHandle;\r
mCurrentFormId = Context->FormId;\r
CopyGuid (&mCurrentFormSetGuid, &Context->FormSetGuid);\r
+ mSystemLevelFormSet = Context->SystemLevelFormSet;\r
+ mCurFakeQestId = Context->CurFakeQestId;\r
+ mHiiPackageListUpdated = Context->HiiPackageListUpdated;\r
+ mFinishRetrieveCall = Context->FinishRetrieveCall;\r
\r
//\r
// Restore the menu history data.\r
InsertTailList(&mPrivateData.FormBrowserEx2.FormViewHistoryHead, &MenuList->Link);\r
}\r
\r
+ //\r
+ // Restore the Formset data.\r
+ //\r
+ while (!IsListEmpty (&Context->FormSetList)) {\r
+ FormSet = FORM_BROWSER_FORMSET_FROM_LINK (Context->FormSetList.ForwardLink);\r
+ RemoveEntryList (&FormSet->Link);\r
+\r
+ InsertTailList(&gBrowserFormSetList, &FormSet->Link);\r
+ }\r
+\r
//\r
// Remove from FormBrowser context list\r
//\r
@retval EFI_INVALID_PARAMETER KeyData is NULL or HelpString is NULL on register.\r
@retval EFI_NOT_FOUND KeyData is not found to be unregistered.\r
@retval EFI_UNSUPPORTED Key represents a printable character. It is conflicted with Browser.\r
+ @retval EFI_ALREADY_STARTED Key already been registered for one hot key.\r
**/\r
EFI_STATUS\r
EFIAPI\r
return EFI_NOT_FOUND;\r
}\r
}\r
- \r
+\r
+ if (HotKey != NULL) {\r
+ return EFI_ALREADY_STARTED;\r
+ }\r
+\r
//\r
- // Register HotKey into List.\r
+ // Create new Key, and add it into List.\r
//\r
- if (HotKey == NULL) {\r
- //\r
- // Create new Key, and add it into List.\r
- //\r
- HotKey = AllocateZeroPool (sizeof (BROWSER_HOT_KEY));\r
- ASSERT (HotKey != NULL);\r
- HotKey->Signature = BROWSER_HOT_KEY_SIGNATURE;\r
- HotKey->KeyData = AllocateCopyPool (sizeof (EFI_INPUT_KEY), KeyData);\r
- InsertTailList (&gBrowserHotKeyList, &HotKey->Link);\r
- }\r
+ HotKey = AllocateZeroPool (sizeof (BROWSER_HOT_KEY));\r
+ ASSERT (HotKey != NULL);\r
+ HotKey->Signature = BROWSER_HOT_KEY_SIGNATURE;\r
+ HotKey->KeyData = AllocateCopyPool (sizeof (EFI_INPUT_KEY), KeyData);\r
+ InsertTailList (&gBrowserHotKeyList, &HotKey->Link);\r
\r
//\r
// Fill HotKey information.\r