/** @file\r
Entry and initialization module for the browser.\r
\r
-Copyright (c) 2007 - 2014, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
LIST_ENTRY gBrowserSaveFailFormSetList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserSaveFailFormSetList);\r
\r
BOOLEAN mSystemSubmit = FALSE;\r
-BOOLEAN gResetRequired;\r
+BOOLEAN gResetRequiredFormLevel;\r
+BOOLEAN gResetRequiredSystemLevel = FALSE;\r
BOOLEAN gExitRequired;\r
+BOOLEAN gFlagReconnect;\r
+BOOLEAN gCallbackReconnect;\r
BROWSER_SETTING_SCOPE gBrowserSettingScope = FormSetLevel;\r
BOOLEAN mBrowserScopeFirstSet = TRUE;\r
EXIT_HANDLER ExitHandlerFunction = NULL;\r
CHAR16 *gEmptyString;\r
CHAR16 *mUnknownString = L"!";\r
\r
-EFI_GUID gZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};\r
-\r
extern EFI_GUID mCurrentFormSetGuid;\r
extern EFI_HII_HANDLE mCurrentHiiHandle;\r
extern UINT16 mCurrentFormId;\r
**/\r
FORM_ENTRY_INFO *\r
UiFindMenuList (\r
- IN EFI_HII_HANDLE HiiHandle, \r
+ IN EFI_HII_HANDLE HiiHandle,\r
IN EFI_GUID *FormSetGuid,\r
IN UINT16 FormId\r
)\r
while (!IsNull (&mPrivateData.FormBrowserEx2.FormViewHistoryHead, Link)) {\r
MenuList = FORM_ENTRY_INFO_FROM_LINK (Link);\r
Link = GetNextNode (&mPrivateData.FormBrowserEx2.FormViewHistoryHead, Link);\r
- \r
+\r
//\r
// If already find the menu, free the menus behind it.\r
//\r
// Find the same FromSet.\r
//\r
if (MenuList->HiiHandle == HiiHandle) {\r
- if (CompareGuid (&MenuList->FormSetGuid, &gZeroGuid)) {\r
+ if (IsZeroGuid (&MenuList->FormSetGuid)) {\r
//\r
// FormSetGuid is not specified.\r
//\r
\r
@param CurrentMenu Current Menu\r
@param SettingLevel Whether find parent menu in Form Level or Formset level.\r
- In form level, just find the parent menu; \r
+ In form level, just find the parent menu;\r
In formset level, find the parent menu which has different\r
formset guid value.\r
\r
if (CurrentMenu == NULL) {\r
return NULL;\r
}\r
- \r
+\r
ParentMenu = NULL;\r
Link = &CurrentMenu->Link;\r
\r
\r
/**\r
Copy current Menu list to the new menu list.\r
- \r
+\r
@param NewMenuListHead New create Menu list.\r
@param CurrentMenuListHead Current Menu list.\r
\r
UINTN Index;\r
FORM_BROWSER_FORMSET *FormSet;\r
FORM_ENTRY_INFO *MenuList;\r
+ BOOLEAN RetVal;\r
\r
//\r
// If EDKII_FORM_DISPLAY_ENGINE_PROTOCOL not found, return EFI_UNSUPPORTED.\r
//\r
if (mFormDisplay == NULL) {\r
+ DEBUG ((DEBUG_ERROR, "Fatal Error! EDKII_FORM_DISPLAY_ENGINE_PROTOCOL not found!"));\r
return EFI_UNSUPPORTED;\r
}\r
\r
//\r
SaveBrowserContext ();\r
\r
- gResetRequired = FALSE;\r
+ gFlagReconnect = FALSE;\r
+ gResetRequiredFormLevel = FALSE;\r
gExitRequired = FALSE;\r
+ gCallbackReconnect = FALSE;\r
Status = EFI_SUCCESS;\r
gEmptyString = L"";\r
gDisplayFormData.ScreenDimensions = (EFI_SCREEN_DESCRIPTOR *) ScreenDimensions;\r
gCurrentSelection = NULL;\r
mSystemLevelFormSet = NULL;\r
\r
+ if (gFlagReconnect || gCallbackReconnect) {\r
+ RetVal = ReconnectController (FormSet->DriverHandle);\r
+ if (!RetVal) {\r
+ PopupErrorMessage(BROWSER_RECONNECT_FAIL, NULL, NULL, NULL);\r
+ }\r
+ gFlagReconnect = FALSE;\r
+ gCallbackReconnect = FALSE;\r
+ }\r
+\r
//\r
// If no data is changed, don't need to save current FormSet into the maintain list.\r
//\r
\r
if (ActionRequest != NULL) {\r
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
- if (gResetRequired) {\r
+ if (gResetRequiredFormLevel) {\r
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_RESET;\r
}\r
}\r
distribution.\r
\r
**/\r
-EFI_STATUS \r
+EFI_STATUS\r
ProcessStorage (\r
IN OUT UINTN *ResultsDataSize,\r
IN OUT EFI_STRING *ResultsData,\r
CHAR16 *StrPtr;\r
UINTN BufferSize;\r
UINTN TmpSize;\r
+ UINTN MaxLen;\r
+ FORMSET_STORAGE *BrowserStorage;\r
\r
if (RetrieveData) {\r
//\r
// Skip <ConfigHdr> and '&' to point to <ConfigBody> when first copy the configbody.\r
// Also need to consider add "\0" at first time.\r
//\r
- StrPtr = ConfigResp + StrLen (Storage->ConfigHdr) + 1;\r
+ StrPtr = StrStr (ConfigResp, L"PATH");\r
+ ASSERT (StrPtr != NULL);\r
+ StrPtr = StrStr (StrPtr, L"&");\r
+ StrPtr += 1;\r
BufferSize = StrSize (StrPtr);\r
\r
-\r
//\r
// Copy the data if the input buffer is bigger enough.\r
//\r
if (*ResultsDataSize >= BufferSize) {\r
- StrCpy (*ResultsData, StrPtr);\r
+ StrCpyS (*ResultsData, *ResultsDataSize / sizeof (CHAR16), StrPtr);\r
}\r
\r
*ResultsDataSize = BufferSize;\r
//\r
// Prepare <ConfigResp>\r
//\r
+ BrowserStorage = GetFstStgFromBrsStg (Storage);\r
+ ASSERT (BrowserStorage != NULL);\r
TmpSize = StrLen (*ResultsData);\r
- BufferSize = (TmpSize + StrLen (Storage->ConfigHdr) + 2) * sizeof (CHAR16);\r
+ BufferSize = (TmpSize + StrLen (BrowserStorage->ConfigHdr) + 2) * sizeof (CHAR16);\r
+ MaxLen = BufferSize / sizeof (CHAR16);\r
ConfigResp = AllocateZeroPool (BufferSize);\r
ASSERT (ConfigResp != NULL);\r
\r
- StrCpy (ConfigResp, Storage->ConfigHdr);\r
- StrCat (ConfigResp, L"&");\r
- StrCat (ConfigResp, *ResultsData);\r
+ StrCpyS (ConfigResp, MaxLen, BrowserStorage->ConfigHdr);\r
+ StrCatS (ConfigResp, MaxLen, L"&");\r
+ StrCatS (ConfigResp, MaxLen, *ResultsData);\r
\r
//\r
// Update Browser uncommited data\r
}\r
\r
/**\r
- This routine called this service in the browser to retrieve or set certain uncommitted \r
- state information that resides in the open formsets. \r
+ This routine called this service in the browser to retrieve or set certain uncommitted\r
+ state information that resides in the open formsets.\r
\r
@param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL\r
instance.\r
//\r
// Different formsets may have same varstore, so here just set the flag\r
// not exit the circle.\r
- // \r
+ //\r
Found = TRUE;\r
break;\r
}\r
}\r
\r
FormsetStorage = FORMSET_STORAGE_FROM_LINK (Link);\r
- \r
+\r
Status = ProcessStorage (&TotalSize, &ResultsData, RetrieveData, FormsetStorage->BrowserStorage);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
Status = TotalSize <= *ResultsDataSize ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL;\r
*ResultsDataSize = TotalSize;\r
}\r
- \r
+\r
return Status;\r
\r
}\r
IN VOID *Context\r
)\r
{\r
- EFI_STATUS Status;\r
-\r
if (mFormDisplay != NULL) {\r
return;\r
}\r
\r
- Status = gBS->LocateProtocol (\r
+ gBS->LocateProtocol (\r
&gEdkiiFormDisplayEngineProtocolGuid,\r
NULL,\r
(VOID **) &mFormDisplay\r
&mPrivateData.FormBrowserEx2\r
);\r
ASSERT_EFI_ERROR (Status);\r
- \r
+\r
Status = gBS->InstallProtocolInterface (\r
&mPrivateData.Handle,\r
- &gEfiFormBrowserExProtocolGuid,\r
+ &gEdkiiFormBrowserExProtocolGuid,\r
EFI_NATIVE_INTERFACE,\r
&mPrivateData.FormBrowserEx\r
);\r
&Registration\r
);\r
}\r
- \r
+\r
return EFI_SUCCESS;\r
}\r
\r
)\r
{\r
CHAR16 *NewString;\r
- UINTN TmpSize;\r
+ UINTN MaxLen;\r
\r
if (*Dest == NULL) {\r
NewStringCpy (Dest, Src);\r
return;\r
}\r
\r
- TmpSize = StrSize (*Dest);\r
- NewString = AllocateZeroPool (TmpSize + StrSize (Src) - 1);\r
+ MaxLen = ( StrSize (*Dest) + StrSize (Src) - 1) / sizeof (CHAR16);\r
+ NewString = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
ASSERT (NewString != NULL);\r
\r
- StrCpy (NewString, *Dest);\r
- StrCat (NewString, Src);\r
+ StrCpyS (NewString, MaxLen, *Dest);\r
+ StrCatS (NewString, MaxLen, Src);\r
\r
FreePool (*Dest);\r
*Dest = NewString;\r
LIST_ENTRY *Link;\r
NAME_VALUE_NODE *Node;\r
UINT8 *SourceBuf;\r
+ FORMSET_STORAGE *FormsetStorage;\r
\r
Status = EFI_SUCCESS;\r
\r
\r
case EFI_HII_VARSTORE_NAME_VALUE:\r
*ConfigResp = NULL;\r
- NewStringCat (ConfigResp, Storage->ConfigHdr);\r
+ FormsetStorage = GetFstStgFromBrsStg(Storage);\r
+ ASSERT (FormsetStorage != NULL);\r
+ NewStringCat (ConfigResp, FormsetStorage->ConfigHdr);\r
\r
Link = GetFirstNode (&Storage->NameValueListHead);\r
while (!IsNull (&Storage->NameValueListHead, Link)) {\r
return Status;\r
}\r
\r
+/**\r
+ Get bit field value from the buffer and then set the value for the question.\r
+ Note: Data type UINT32 can cover all the bit field value.\r
+\r
+ @param Question The question refer to bit field.\r
+ @param Buffer Point to the buffer which the question value get from.\r
+\r
+**/\r
+VOID\r
+GetBitsQuestionValue (\r
+ IN FORM_BROWSER_STATEMENT *Question,\r
+ IN UINT8 *Buffer\r
+ )\r
+{\r
+ UINTN StartBit;\r
+ UINTN EndBit;\r
+ UINT32 RetVal;\r
+ UINT32 BufferValue;\r
+\r
+ StartBit = Question->BitVarOffset % 8;\r
+ EndBit = StartBit + Question->BitStorageWidth - 1;\r
+\r
+ CopyMem ((UINT8 *) &BufferValue, Buffer, Question->StorageWidth);\r
+\r
+ RetVal = BitFieldRead32 (BufferValue, StartBit, EndBit);\r
+\r
+ //\r
+ // Set question value.\r
+ // Note: Since Question with BufferValue (orderedlist, password, string)are not supported to refer bit field.\r
+ // Only oneof/checkbox/oneof can support bit field.So we can copy the value to the Hiivalue of Question directly.\r
+ //\r
+ CopyMem ((UINT8 *) &Question->HiiValue.Value, (UINT8 *) &RetVal, Question->StorageWidth);\r
+}\r
+\r
+/**\r
+ Set bit field value to the buffer.\r
+ Note: Data type UINT32 can cover all the bit field value.\r
+\r
+ @param Question The question refer to bit field.\r
+ @param Buffer Point to the buffer which the question value set to.\r
+ @param Value The bit field value need to set.\r
+\r
+**/\r
+VOID\r
+SetBitsQuestionValue (\r
+ IN FORM_BROWSER_STATEMENT *Question,\r
+ IN OUT UINT8 *Buffer,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ UINT32 Operand;\r
+ UINTN StartBit;\r
+ UINTN EndBit;\r
+ UINT32 RetVal;\r
+\r
+ StartBit = Question->BitVarOffset % 8;\r
+ EndBit = StartBit + Question->BitStorageWidth - 1;\r
+\r
+ CopyMem ((UINT8*) &Operand, Buffer, Question->StorageWidth);\r
+\r
+ RetVal = BitFieldWrite32 (Operand, StartBit, EndBit, Value);\r
+\r
+ CopyMem (Buffer, (UINT8*) &RetVal, Question->StorageWidth);\r
+}\r
+\r
+/**\r
+ Convert the buffer value to HiiValue.\r
+\r
+ @param Question The question.\r
+ @param Value Unicode buffer save the question value.\r
+\r
+ @retval Status whether convert the value success.\r
+\r
+**/\r
+EFI_STATUS\r
+BufferToValue (\r
+ IN OUT FORM_BROWSER_STATEMENT *Question,\r
+ IN CHAR16 *Value\r
+ )\r
+{\r
+ CHAR16 *StringPtr;\r
+ BOOLEAN IsBufferStorage;\r
+ CHAR16 *DstBuf;\r
+ CHAR16 TempChar;\r
+ UINTN LengthStr;\r
+ UINT8 *Dst;\r
+ CHAR16 TemStr[5];\r
+ UINTN Index;\r
+ UINT8 DigitUint8;\r
+ BOOLEAN IsString;\r
+ UINTN Length;\r
+ EFI_STATUS Status;\r
+ UINT8 *Buffer;\r
+\r
+ Buffer = NULL;\r
+\r
+ IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE);\r
+ if (Question->Storage->Type == EFI_HII_VARSTORE_BUFFER ||\r
+ Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {\r
+ IsBufferStorage = TRUE;\r
+ } else {\r
+ IsBufferStorage = FALSE;\r
+ }\r
+\r
+ //\r
+ // Question Value is provided by Buffer Storage or NameValue Storage\r
+ //\r
+ if (Question->BufferValue != NULL) {\r
+ //\r
+ // This Question is password or orderedlist\r
+ //\r
+ Dst = Question->BufferValue;\r
+ } else {\r
+ //\r
+ // Other type of Questions\r
+ //\r
+ if (Question->QuestionReferToBitField) {\r
+ Buffer = (UINT8 *)AllocateZeroPool (Question->StorageWidth);\r
+ if (Buffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ Dst = Buffer;\r
+ } else {\r
+ Dst = (UINT8 *) &Question->HiiValue.Value;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Temp cut at the end of this section, end with '\0' or '&'.\r
+ //\r
+ StringPtr = Value;\r
+ while (*StringPtr != L'\0' && *StringPtr != L'&') {\r
+ StringPtr++;\r
+ }\r
+ TempChar = *StringPtr;\r
+ *StringPtr = L'\0';\r
+\r
+ LengthStr = StrLen (Value);\r
+\r
+ //\r
+ // Value points to a Unicode hexadecimal string, we need to convert the string to the value with CHAR16/UINT8...type.\r
+ // When generating the Value string, we follow this rule: 1 byte -> 2 Unicode characters (for string: 2 byte(CHAR16) ->4 Unicode characters).\r
+ // So the maximum value string length of a question is : Question->StorageWidth * 2.\r
+ // If the value string length > Question->StorageWidth * 2, only set the string length as Question->StorageWidth * 2, then convert.\r
+ //\r
+ if (LengthStr > (UINTN) Question->StorageWidth * 2) {\r
+ Length = (UINTN) Question->StorageWidth * 2;\r
+ } else {\r
+ Length = LengthStr;\r
+ }\r
+\r
+ Status = EFI_SUCCESS;\r
+ if (!IsBufferStorage && IsString) {\r
+ //\r
+ // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"\r
+ // Add string tail char L'\0' into Length\r
+ //\r
+ DstBuf = (CHAR16 *) Dst;\r
+ ZeroMem (TemStr, sizeof (TemStr));\r
+ for (Index = 0; Index < Length; Index += 4) {\r
+ StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), Value + Index, 4);\r
+ DstBuf[Index/4] = (CHAR16) StrHexToUint64 (TemStr);\r
+ }\r
+ //\r
+ // Add tailing L'\0' character\r
+ //\r
+ DstBuf[Index/4] = L'\0';\r
+ } else {\r
+ ZeroMem (TemStr, sizeof (TemStr));\r
+ for (Index = 0; Index < Length; Index ++) {\r
+ TemStr[0] = Value[LengthStr - Index - 1];\r
+ DigitUint8 = (UINT8) StrHexToUint64 (TemStr);\r
+ if ((Index & 1) == 0) {\r
+ Dst [Index/2] = DigitUint8;\r
+ } else {\r
+ Dst [Index/2] = (UINT8) ((DigitUint8 << 4) + Dst [Index/2]);\r
+ }\r
+ }\r
+ }\r
+\r
+ *StringPtr = TempChar;\r
+\r
+ if (Buffer != NULL && Question->QuestionReferToBitField) {\r
+ GetBitsQuestionValue (Question, Buffer);\r
+ FreePool (Buffer);\r
+ }\r
+\r
+ return Status;\r
+}\r
\r
/**\r
Get Question's current Value.\r
UINTN StorageWidth;\r
EFI_TIME EfiTime;\r
BROWSER_STORAGE *Storage;\r
+ FORMSET_STORAGE *FormsetStorage;\r
EFI_IFR_TYPE_VALUE *QuestionValue;\r
CHAR16 *ConfigRequest;\r
CHAR16 *Progress;\r
CHAR16 *Result;\r
CHAR16 *Value;\r
- CHAR16 *StringPtr;\r
UINTN Length;\r
- UINTN Index;\r
- UINTN LengthStr;\r
BOOLEAN IsBufferStorage;\r
- BOOLEAN IsString;\r
- CHAR16 TemStr[5];\r
- UINT8 DigitUint8;\r
+ UINTN MaxLen;\r
\r
Status = EFI_SUCCESS;\r
Value = NULL;\r
FreePool (Question->ValueExpression->Result.Buffer);\r
}\r
Question->HiiValue.Type = Question->ValueExpression->Result.Type;\r
- CopyMem (&Question->HiiValue.Value, &Question->ValueExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE)); \r
+ CopyMem (&Question->HiiValue.Value, &Question->ValueExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE));\r
}\r
return Status;\r
}\r
- \r
+\r
//\r
// Get question value by read expression.\r
//\r
if (Question->ReadExpression != NULL && Form->FormType == STANDARD_MAP_FORM_TYPE) {\r
Status = EvaluateExpression (FormSet, Form, Question->ReadExpression);\r
- if (!EFI_ERROR (Status) && \r
+ if (!EFI_ERROR (Status) &&\r
((Question->ReadExpression->Result.Type < EFI_IFR_TYPE_OTHER) || (Question->ReadExpression->Result.Type == EFI_IFR_TYPE_BUFFER))) {\r
//\r
// Only update question value to the valid result.\r
FreePool (Question->ReadExpression->Result.Buffer);\r
}\r
Question->HiiValue.Type = Question->ReadExpression->Result.Type;\r
- CopyMem (&Question->HiiValue.Value, &Question->ReadExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE)); \r
+ CopyMem (&Question->HiiValue.Value, &Question->ReadExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE));\r
return EFI_SUCCESS;\r
}\r
}\r
}\r
\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ if (Question->Operand == EFI_IFR_DATE_OP){\r
+ QuestionValue->date.Year = 0xff;\r
+ QuestionValue->date.Month = 0xff;\r
+ QuestionValue->date.Day = 0xff;\r
+ } else {\r
+ QuestionValue->time.Hour = 0xff;\r
+ QuestionValue->time.Minute = 0xff;\r
+ QuestionValue->time.Second = 0xff;\r
+ }\r
+ return EFI_SUCCESS;\r
}\r
\r
if (Question->Operand == EFI_IFR_DATE_OP) {\r
Dst = (UINT8 *) &Question->HiiValue.Value;\r
}\r
\r
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER || \r
+ if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||\r
Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {\r
IsBufferStorage = TRUE;\r
} else {\r
IsBufferStorage = FALSE;\r
}\r
- IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE);\r
if (GetValueFrom == GetSetValueWithEditBuffer || GetValueFrom == GetSetValueWithBuffer ) {\r
if (IsBufferStorage) {\r
if (GetValueFrom == GetSetValueWithEditBuffer) {\r
//\r
// Copy from storage Edit buffer\r
+ // If the Question refer to bit filed, get the value in the related bit filed.\r
//\r
- CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+ if (Question->QuestionReferToBitField) {\r
+ GetBitsQuestionValue (Question, Storage->EditBuffer + Question->VarStoreInfo.VarOffset);\r
+ } else {\r
+ CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+ }\r
} else {\r
//\r
// Copy from storage Edit buffer\r
+ // If the Question refer to bit filed, get the value in the related bit filed.\r
//\r
- CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+ if (Question->QuestionReferToBitField) {\r
+ GetBitsQuestionValue (Question, Storage->Buffer + Question->VarStoreInfo.VarOffset);\r
+ } else {\r
+ CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+ }\r
}\r
} else {\r
Value = NULL;\r
}\r
\r
ASSERT (Value != NULL);\r
- LengthStr = StrLen (Value);\r
- Status = EFI_SUCCESS;\r
- if (IsString) {\r
- //\r
- // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"\r
- // Add string tail char L'\0' into Length\r
- //\r
- Length = StorageWidth + sizeof (CHAR16);\r
- if (Length < ((LengthStr / 4 + 1) * 2)) {\r
- Status = EFI_BUFFER_TOO_SMALL;\r
- } else {\r
- StringPtr = (CHAR16 *) Dst;\r
- ZeroMem (TemStr, sizeof (TemStr));\r
- for (Index = 0; Index < LengthStr; Index += 4) {\r
- StrnCpy (TemStr, Value + Index, 4);\r
- StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr);\r
- }\r
- //\r
- // Add tailing L'\0' character\r
- //\r
- StringPtr[Index/4] = L'\0';\r
- }\r
- } else {\r
- if (StorageWidth < ((LengthStr + 1) / 2)) {\r
- Status = EFI_BUFFER_TOO_SMALL;\r
- } else {\r
- ZeroMem (TemStr, sizeof (TemStr));\r
- for (Index = 0; Index < LengthStr; Index ++) {\r
- TemStr[0] = Value[LengthStr - Index - 1];\r
- DigitUint8 = (UINT8) StrHexToUint64 (TemStr);\r
- if ((Index & 1) == 0) {\r
- Dst [Index/2] = DigitUint8;\r
- } else {\r
- Dst [Index/2] = (UINT8) ((DigitUint8 << 4) + Dst [Index/2]);\r
- }\r
- }\r
- }\r
- }\r
-\r
+ Status = BufferToValue (Question, Value);\r
FreePool (Value);\r
}\r
} else {\r
+ FormsetStorage = GetFstStgFromVarId(FormSet, Question->VarStoreId);\r
+ ASSERT (FormsetStorage != NULL);\r
//\r
// <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||\r
// <ConfigHdr> + "&" + <VariableName>\r
//\r
if (IsBufferStorage) {\r
- Length = StrLen (Storage->ConfigHdr);\r
+ Length = StrLen (FormsetStorage->ConfigHdr);\r
Length += StrLen (Question->BlockName);\r
} else {\r
- Length = StrLen (Storage->ConfigHdr);\r
+ Length = StrLen (FormsetStorage->ConfigHdr);\r
Length += StrLen (Question->VariableName) + 1;\r
}\r
- ConfigRequest = AllocateZeroPool ((Length + 1) * sizeof (CHAR16));\r
+ // Allocate buffer include '\0'\r
+ MaxLen = Length + 1;\r
+ ConfigRequest = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
ASSERT (ConfigRequest != NULL);\r
\r
- StrCpy (ConfigRequest, Storage->ConfigHdr);\r
+ StrCpyS (ConfigRequest, MaxLen, FormsetStorage->ConfigHdr);\r
if (IsBufferStorage) {\r
- StrCat (ConfigRequest, Question->BlockName);\r
+ StrCatS (ConfigRequest, MaxLen, Question->BlockName);\r
} else {\r
- StrCat (ConfigRequest, L"&");\r
- StrCat (ConfigRequest, Question->VariableName);\r
+ StrCatS (ConfigRequest, MaxLen, L"&");\r
+ StrCatS (ConfigRequest, MaxLen, Question->VariableName);\r
}\r
\r
//\r
//\r
Value = Value + 1;\r
\r
- //\r
- // Suppress <AltResp> if any\r
- //\r
- StringPtr = Value;\r
- while (*StringPtr != L'\0' && *StringPtr != L'&') {\r
- StringPtr++;\r
- }\r
- *StringPtr = L'\0';\r
-\r
- LengthStr = StrLen (Value);\r
- Status = EFI_SUCCESS;\r
- if (!IsBufferStorage && IsString) {\r
- //\r
- // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"\r
- // Add string tail char L'\0' into Length\r
- //\r
- Length = StorageWidth + sizeof (CHAR16);\r
- if (Length < ((LengthStr / 4 + 1) * 2)) {\r
- Status = EFI_BUFFER_TOO_SMALL;\r
- } else {\r
- StringPtr = (CHAR16 *) Dst;\r
- ZeroMem (TemStr, sizeof (TemStr));\r
- for (Index = 0; Index < LengthStr; Index += 4) {\r
- StrnCpy (TemStr, Value + Index, 4);\r
- StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr);\r
- }\r
- //\r
- // Add tailing L'\0' character\r
- //\r
- StringPtr[Index/4] = L'\0';\r
- }\r
- } else {\r
- if (StorageWidth < ((LengthStr + 1) / 2)) {\r
- Status = EFI_BUFFER_TOO_SMALL;\r
- } else {\r
- ZeroMem (TemStr, sizeof (TemStr));\r
- for (Index = 0; Index < LengthStr; Index ++) {\r
- TemStr[0] = Value[LengthStr - Index - 1];\r
- DigitUint8 = (UINT8) StrHexToUint64 (TemStr);\r
- if ((Index & 1) == 0) {\r
- Dst [Index/2] = DigitUint8;\r
- } else {\r
- Dst [Index/2] = (UINT8) ((DigitUint8 << 4) + Dst [Index/2]);\r
- }\r
- }\r
- }\r
- }\r
-\r
+ Status = BufferToValue (Question, Value);\r
if (EFI_ERROR (Status)) {\r
FreePool (Result);\r
return Status;\r
UINTN BufferLen;\r
UINTN StorageWidth;\r
BROWSER_STORAGE *Storage;\r
+ FORMSET_STORAGE *FormsetStorage;\r
EFI_IFR_TYPE_VALUE *QuestionValue;\r
CHAR16 *ConfigResp;\r
CHAR16 *Progress;\r
CHAR16 *TemString;\r
UINTN Index;\r
NAME_VALUE_NODE *Node;\r
+ UINTN MaxLen;\r
\r
Status = EFI_SUCCESS;\r
Node = NULL;\r
if (Question->ValueExpression != NULL) {\r
return Status;\r
}\r
- \r
+\r
//\r
// Before set question value, evaluate its write expression.\r
//\r
Src = (UINT8 *) &Question->HiiValue.Value;\r
}\r
\r
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER || \r
+ if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||\r
Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {\r
IsBufferStorage = TRUE;\r
} else {\r
if (SetValueTo == GetSetValueWithEditBuffer) {\r
//\r
// Copy to storage edit buffer\r
- // \r
- CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
+ // If the Question refer to bit filed, copy the value in related bit filed to storage edit buffer.\r
+ //\r
+ if (Question->QuestionReferToBitField) {\r
+ SetBitsQuestionValue (Question, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, (UINT32)(*Src));\r
+ } else {\r
+ CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
+ }\r
} else if (SetValueTo == GetSetValueWithBuffer) {\r
//\r
- // Copy to storage edit buffer\r
- // \r
- CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
+ // Copy to storage buffer\r
+ // If the Question refer to bit filed, copy the value in related bit filed to storage buffer.\r
+ //\r
+ if (Question->QuestionReferToBitField) {\r
+ SetBitsQuestionValue (Question, Storage->Buffer + Question->VarStoreInfo.VarOffset, (UINT32)(*Src));\r
+ } else {\r
+ CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
+ }\r
}\r
} else {\r
if (IsString) {\r
TemName = (CHAR16 *) Src;\r
TemString = Value;\r
for (; *TemName != L'\0'; TemName++) {\r
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);\r
+ UnicodeValueToStringS (\r
+ TemString,\r
+ BufferLen - ((UINTN)TemString - (UINTN)Value),\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ *TemName,\r
+ 4\r
+ );\r
+ TemString += StrnLenS (TemString, (BufferLen - ((UINTN)TemString - (UINTN)Value)) / sizeof (CHAR16));\r
}\r
} else {\r
BufferLen = StorageWidth * 2 + 1;\r
TemBuffer = Src + StorageWidth - 1;\r
TemString = Value;\r
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {\r
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);\r
+ UnicodeValueToStringS (\r
+ TemString,\r
+ BufferLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)Value),\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ *TemBuffer,\r
+ 2\r
+ );\r
+ TemString += StrnLenS (TemString, BufferLen - ((UINTN)TemString - (UINTN)Value) / sizeof (CHAR16));\r
}\r
}\r
\r
} else {\r
Length += (StorageWidth * 2);\r
}\r
- ConfigResp = AllocateZeroPool ((StrLen (Storage->ConfigHdr) + Length + 1) * sizeof (CHAR16));\r
+ FormsetStorage = GetFstStgFromVarId(FormSet, Question->VarStoreId);\r
+ ASSERT (FormsetStorage != NULL);\r
+ MaxLen = StrLen (FormsetStorage->ConfigHdr) + Length + 1;\r
+ ConfigResp = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
ASSERT (ConfigResp != NULL);\r
\r
- StrCpy (ConfigResp, Storage->ConfigHdr);\r
+ StrCpyS (ConfigResp, MaxLen, FormsetStorage->ConfigHdr);\r
if (IsBufferStorage) {\r
- StrCat (ConfigResp, Question->BlockName);\r
- StrCat (ConfigResp, L"&VALUE=");\r
+ StrCatS (ConfigResp, MaxLen, Question->BlockName);\r
+ StrCatS (ConfigResp, MaxLen, L"&VALUE=");\r
} else {\r
- StrCat (ConfigResp, L"&");\r
- StrCat (ConfigResp, Question->VariableName);\r
- StrCat (ConfigResp, L"=");\r
+ StrCatS (ConfigResp, MaxLen, L"&");\r
+ StrCatS (ConfigResp, MaxLen, Question->VariableName);\r
+ StrCatS (ConfigResp, MaxLen, L"=");\r
}\r
\r
Value = ConfigResp + StrLen (ConfigResp);\r
TemName = (CHAR16 *) Src;\r
TemString = Value;\r
for (; *TemName != L'\0'; TemName++) {\r
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);\r
+ UnicodeValueToStringS (\r
+ TemString,\r
+ MaxLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ConfigResp),\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ *TemName,\r
+ 4\r
+ );\r
+ TemString += StrnLenS (TemString, MaxLen - ((UINTN)TemString - (UINTN)ConfigResp) / sizeof (CHAR16));\r
}\r
} else {\r
//\r
TemBuffer = Src + StorageWidth - 1;\r
TemString = Value;\r
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {\r
- TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);\r
+ UnicodeValueToStringS (\r
+ TemString,\r
+ MaxLen * sizeof (CHAR16) - ((UINTN)TemString - (UINTN)ConfigResp),\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ *TemBuffer,\r
+ 2\r
+ );\r
+ TemString += StrnLenS (TemString, MaxLen - ((UINTN)TemString - (UINTN)ConfigResp) / sizeof (CHAR16));\r
}\r
}\r
\r
return Status;\r
}\r
FreePool (ConfigResp);\r
- \r
+\r
//\r
// Sync storage, from editbuffer to buffer.\r
//\r
}\r
\r
/**\r
- Perform question check. \r
- \r
- If one question has more than one check, process form high priority to low. \r
+ Perform question check.\r
+\r
+ If one question has more than one check, process form high priority to low.\r
Only one error info will be popup.\r
\r
@param FormSet FormSet data structure.\r
\r
@param Storage The storage which need to sync.\r
@param ConfigRequest The config request string which used to sync storage.\r
- @param SyncOrRestore Sync the buffer to editbuffer or Restore the \r
+ @param SyncOrRestore Sync the buffer to editbuffer or Restore the\r
editbuffer to buffer\r
if TRUE, copy the editbuffer to the buffer.\r
if FALSE, copy the buffer to the editbuffer.\r
Status = EFI_SUCCESS;\r
Result = NULL;\r
\r
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER || \r
+ if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||\r
(Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {\r
BufferSize = Storage->Size;\r
\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
- Validate the FormSet. If the formset is not validate, remove it from the list.\r
-\r
- @param FormSet The input FormSet which need to validate.\r
+ When submit the question value, call the callback function with Submitted type\r
+ to inform the hii driver.\r
\r
- @retval TRUE The handle is validate.\r
- @retval FALSE The handle is invalidate.\r
+ @param FormSet FormSet data structure.\r
+ @param Form Form data structure.\r
\r
**/\r
-BOOLEAN\r
-ValidateHiiHandle (\r
- EFI_HII_HANDLE HiiHandle\r
+VOID\r
+SubmitCallbackForForm (\r
+ IN FORM_BROWSER_FORMSET *FormSet,\r
+ IN FORM_BROWSER_FORM *Form\r
)\r
{\r
- EFI_HII_HANDLE *HiiHandles;\r
- UINTN Index;\r
- BOOLEAN Find;\r
+ LIST_ENTRY *Link;\r
+ FORM_BROWSER_STATEMENT *Question;\r
+ EFI_IFR_TYPE_VALUE *TypeValue;\r
+ EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
\r
- if (HiiHandle == NULL) {\r
- return FALSE;\r
+ if (FormSet->ConfigAccess == NULL) {\r
+ return;\r
}\r
\r
- Find = FALSE;\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
- HiiHandles = HiiGetHiiHandles (NULL);\r
- ASSERT (HiiHandles != NULL);\r
+ if (Question->Storage == NULL || Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {\r
+ continue;\r
+ }\r
\r
- for (Index = 0; HiiHandles[Index] != NULL; Index++) {\r
- if (HiiHandles[Index] == HiiHandle) {\r
- Find = TRUE;\r
- break;\r
+ if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) {\r
+ continue;\r
}\r
- }\r
\r
- FreePool (HiiHandles);\r
+ if (Question->Operand == EFI_IFR_PASSWORD_OP) {\r
+ continue;\r
+ }\r
\r
- return Find;\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
- Validate the FormSet. If the formset is not validate, remove it from the list.\r
-\r
- @param FormSet The input FormSet which need to validate.\r
+ When value set Success, call the submit callback function.\r
\r
- @retval TRUE The handle is validate.\r
- @retval FALSE The handle is invalidate.\r
+ @param FormSet FormSet data structure.\r
+ @param Form Form data structure.\r
\r
**/\r
-BOOLEAN\r
-ValidateFormSet (\r
- FORM_BROWSER_FORMSET *FormSet\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
+ @param HiiHandle The input HiiHandle which need to validate.\r
+\r
+ @retval TRUE The handle is validate.\r
+ @retval FALSE The handle is invalidate.\r
+\r
+**/\r
+BOOLEAN\r
+ValidateHiiHandle (\r
+ EFI_HII_HANDLE HiiHandle\r
+ )\r
+{\r
+ EFI_HII_HANDLE *HiiHandles;\r
+ UINTN Index;\r
+ BOOLEAN Find;\r
+\r
+ if (HiiHandle == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
+ Find = FALSE;\r
+\r
+ HiiHandles = HiiGetHiiHandles (NULL);\r
+ ASSERT (HiiHandles != NULL);\r
+\r
+ for (Index = 0; HiiHandles[Index] != NULL; Index++) {\r
+ if (HiiHandles[Index] == HiiHandle) {\r
+ Find = TRUE;\r
+ break;\r
+ }\r
+ }\r
+\r
+ FreePool (HiiHandles);\r
+\r
+ return Find;\r
+}\r
+\r
+/**\r
+ Validate the FormSet. If the formset is not validate, remove it from the list.\r
+\r
+ @param FormSet The input FormSet which need to validate.\r
+\r
+ @retval TRUE The handle is validate.\r
+ @retval FALSE The handle is invalidate.\r
+\r
+**/\r
+BOOLEAN\r
+ValidateFormSet (\r
+ FORM_BROWSER_FORMSET *FormSet\r
)\r
{\r
BOOLEAN Find;\r
ASSERT (FormSet != NULL);\r
\r
Find = ValidateHiiHandle(FormSet->HiiHandle);\r
- if (!Find) {\r
+ //\r
+ // Should not remove the formset which is being used.\r
+ //\r
+ if (!Find && (FormSet != gCurrentSelection->FormSet)) {\r
CleanBrowserStorage(FormSet);\r
RemoveEntryList (&FormSet->Link);\r
DestroyFormSet (FormSet);\r
//\r
// Only the changed data has been saved, then need to set the reset flag.\r
//\r
- if (SetFlag && OldValue && !Question->ValueChanged && ((Question->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0)) {\r
- gResetRequired = TRUE;\r
- } \r
+ if (SetFlag && OldValue && !Question->ValueChanged) {\r
+ if ((Question->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0) {\r
+ gResetRequiredFormLevel = TRUE;\r
+ gResetRequiredSystemLevel = TRUE;\r
+ }\r
+\r
+ if ((Question->QuestionFlags & EFI_IFR_FLAG_RECONNECT_REQUIRED) != 0) {\r
+ gFlagReconnect = TRUE;\r
+ }\r
+ }\r
}\r
}\r
\r
Also clean ValueChanged flag for all statements.\r
\r
Form level or formset level, only one.\r
- \r
+\r
@param SetFlag Whether need to set the Reset Flag.\r
@param FormSet FormSet data structure.\r
@param Form Form data structure.\r
ValueChangeResetFlagUpdate (\r
IN BOOLEAN SetFlag,\r
IN FORM_BROWSER_FORMSET *FormSet,\r
- IN FORM_BROWSER_FORM *Form \r
+ IN FORM_BROWSER_FORM *Form\r
)\r
{\r
FORM_BROWSER_FORM *CurrentForm;\r
}\r
\r
/**\r
- Base on the return Progress string to find the form. \r
- \r
+ Base on the return Progress string to find the form.\r
+\r
Base on the first return Offset/Width (Name) string to find the form\r
which keep this string.\r
\r
*RetQuestion = Statement;\r
break;\r
}\r
+\r
+ if (Statement->VariableName != NULL && StrStr (Statement->VariableName, Progress) != NULL) {\r
+ *RetQuestion = Statement;\r
+ break;\r
+ }\r
}\r
}\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
ASSERT (StringBuffer != NULL);\r
\r
UnicodeSPrint (\r
- StringBuffer, \r
- 24 * sizeof (CHAR16) + StrSize (FormTitle), \r
- L"Submit Fail For Form: %s.", \r
+ StringBuffer,\r
+ 24 * sizeof (CHAR16) + StrSize (FormTitle),\r
+ L"Submit Fail For Form: %s.",\r
FormTitle\r
);\r
\r
ASSERT (StringBuffer != NULL);\r
\r
UnicodeSPrint (\r
- StringBuffer, \r
- 24 * sizeof (CHAR16) + StrSize (FormTitle), \r
- L"NO_SUBMIT_IF error For Form: %s.", \r
+ StringBuffer,\r
+ 24 * sizeof (CHAR16) + StrSize (FormTitle),\r
+ L"NO_SUBMIT_IF error For Form: %s.",\r
FormTitle\r
);\r
\r
while (!IsNull (&FormSet->FormListHead, Link)) {\r
Form = FORM_BROWSER_FORM_FROM_LINK (Link);\r
Link = GetNextNode (&FormSet->FormListHead, Link);\r
- \r
+\r
//\r
// Call callback with Changed type to inform the driver.\r
//\r
mSystemLevelFormSet = OldFormSet;\r
}\r
\r
- return EFI_SUCCESS; \r
+ return EFI_SUCCESS;\r
}\r
\r
/**\r
EFI_STRING Progress;\r
BROWSER_STORAGE *Storage;\r
FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;\r
+ BOOLEAN SubmitFormFail;\r
+\r
+ SubmitFormFail = FALSE;\r
\r
if (!IsNvUpdateRequiredForForm (Form)) {\r
return EFI_SUCCESS;\r
ConfigResp,\r
&Progress\r
);\r
- FreePool (ConfigResp);\r
\r
if (EFI_ERROR (Status)) {\r
+ //\r
+ // Submit fail, to get the RestoreConfigRequest and SyncConfigRequest.\r
+ //\r
+ SubmitFormFail = TRUE;\r
+ GetSyncRestoreConfigRequest (ConfigInfo->Storage, ConfigInfo->ConfigRequest, Progress, &ConfigInfo->RestoreConfigRequest, &ConfigInfo->SyncConfigRequest);\r
InsertTailList (&gBrowserSaveFailFormSetList, &ConfigInfo->SaveFailLink);\r
+ FreePool (ConfigResp);\r
continue;\r
}\r
\r
+ FreePool (ConfigResp);\r
//\r
// 3. Config success, update storage shadow Buffer, only update the data belong to this form.\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
+ SendDiscardInfoToDriver (FormSet,Form);\r
} else {\r
Status = EFI_UNSUPPORTED;\r
}\r
//\r
ValueChangeResetFlagUpdate(TRUE, FormSet, Form);\r
\r
+ //\r
+ // 6 Call callback with Submitted type to inform the driver.\r
+ //\r
+ if (!SubmitFormFail) {\r
+ SubmitCallback (FormSet, Form);\r
+ }\r
+\r
return Status;\r
}\r
\r
\r
@param FormSet FormSet data structure.\r
@param SkipProcessFail Whether skip to process the save failed storage.\r
- If submit formset is called when do system level save, \r
- set this value to true and process the failed formset \r
- together. \r
+ If submit formset is called when do system level save,\r
+ set this value to true and process the failed formset\r
+ together.\r
if submit formset is called when do formset level save,\r
set the value to false and process the failed storage\r
right after process all storages for this formset.\r
FORM_BROWSER_FORM *Form;\r
BOOLEAN HasInserted;\r
FORM_BROWSER_STATEMENT *Question;\r
+ BOOLEAN SubmitFormSetFail;\r
+ BOOLEAN DiscardChange;\r
\r
HasInserted = FALSE;\r
+ SubmitFormSetFail = FALSE;\r
+ DiscardChange = FALSE;\r
\r
if (!IsNvUpdateRequiredForFormSet (FormSet)) {\r
return EFI_SUCCESS;\r
}\r
\r
- Form = NULL; \r
+ Form = NULL;\r
Status = NoSubmitCheck (FormSet, &Form, &Question);\r
if (EFI_ERROR (Status)) {\r
if (SkipProcessFail) {\r
&Progress\r
);\r
if (EFI_ERROR (Status)) {\r
+ //\r
+ // Submit fail, to get the RestoreConfigRequest and SyncConfigRequest.\r
+ //\r
+ SubmitFormSetFail = TRUE;\r
+ GetSyncRestoreConfigRequest (FormSetStorage->BrowserStorage, FormSetStorage->ConfigRequest, Progress, &FormSetStorage->RestoreConfigRequest, &FormSetStorage->SyncConfigRequest);\r
InsertTailList (&FormSet->SaveFailStorageListHead, &FormSetStorage->SaveFailLink);\r
if (!HasInserted) {\r
//\r
// If not in system level, just handl the save failed storage here.\r
//\r
if (ConfirmSaveFail (Form->FormTitle, FormSet->HiiHandle) == BROWSER_ACTION_DISCARD) {\r
+ DiscardChange = TRUE;\r
Link = GetFirstNode (&FormSet->SaveFailStorageListHead);\r
while (!IsNull (&FormSet->SaveFailStorageListHead, Link)) {\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
}\r
\r
+ //\r
+ // If user discard the change, send the discard info to driver.\r
+ //\r
+ if (DiscardChange) {\r
+ Link = GetFirstNode (&FormSet->FormListHead);\r
+ while (!IsNull (&FormSet->FormListHead, Link)) {\r
+ Form = FORM_BROWSER_FORM_FROM_LINK (Link);\r
+ Link = GetNextNode (&FormSet->FormListHead, Link);\r
+ //\r
+ // Call callback with Changed type to inform the driver.\r
+ //\r
+ SendDiscardInfoToDriver (FormSet, Form);\r
+ }\r
+ }\r
+\r
//\r
// 5. Update the NV flag.\r
- // \r
+ //\r
ValueChangeResetFlagUpdate(TRUE, FormSet, NULL);\r
\r
+ //\r
+ // 6. Call callback with Submitted type to inform the driver.\r
+ //\r
+ if (!SubmitFormSetFail) {\r
+ SubmitCallback (FormSet, NULL);\r
+ }\r
+\r
return Status;\r
}\r
\r
{\r
EFI_STATUS Status;\r
LIST_ENTRY *Link;\r
+ LIST_ENTRY *FormLink;\r
LIST_ENTRY *StorageLink;\r
- BROWSER_STORAGE *Storage;\r
FORMSET_STORAGE *FormSetStorage;\r
FORM_BROWSER_FORM *Form;\r
FORM_BROWSER_FORMSET *LocalFormSet;\r
\r
//\r
// Remove maintain backup list after save except for the current using FormSet.\r
- // \r
+ //\r
if (!IsHiiHandleInBrowserContext (LocalFormSet->HiiHandle)) {\r
CleanBrowserStorage(LocalFormSet);\r
RemoveEntryList (&LocalFormSet->Link);\r
StorageLink = GetFirstNode (&LocalFormSet->StorageListHead);\r
while (!IsNull (&LocalFormSet->StorageListHead, StorageLink)) {\r
FormSetStorage = FORMSET_STORAGE_FROM_LINK (StorageLink);\r
- Storage = FormSetStorage->BrowserStorage;\r
StorageLink = GetNextNode (&LocalFormSet->StorageListHead, StorageLink);\r
\r
SynchronizeStorage(FormSetStorage->BrowserStorage, FormSetStorage->ConfigRequest, FALSE);\r
StorageLink = GetFirstNode (&LocalFormSet->SaveFailStorageListHead);\r
while (!IsNull (&LocalFormSet->SaveFailStorageListHead, StorageLink)) {\r
FormSetStorage = FORMSET_STORAGE_FROM_SAVE_FAIL_LINK (StorageLink);\r
- Storage = FormSetStorage->BrowserStorage;\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
+ FormLink = GetFirstNode (&LocalFormSet->FormListHead);\r
+ while (!IsNull (&LocalFormSet->FormListHead, FormLink)) {\r
+ Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);\r
+ FormLink = GetNextNode (&LocalFormSet->FormListHead, FormLink);\r
+ //\r
+ // Call callback with Changed type to inform the driver.\r
+ //\r
+ SendDiscardInfoToDriver (LocalFormSet, Form);\r
+ }\r
+\r
if (!IsHiiHandleInBrowserContext (LocalFormSet->HiiHandle)) {\r
CleanBrowserStorage(LocalFormSet);\r
RemoveEntryList (&LocalFormSet->Link);\r
}\r
\r
/**\r
- Get Question default value from AltCfg string.\r
+ Converts the unicode character of the string from uppercase to lowercase.\r
+ This is a internal function.\r
+\r
+ @param ConfigString String to be converted\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HiiToLower (\r
+ IN EFI_STRING ConfigString\r
+ )\r
+{\r
+ EFI_STRING String;\r
+ BOOLEAN Lower;\r
+\r
+ ASSERT (ConfigString != NULL);\r
+\r
+ //\r
+ // Convert all hex digits in range [A-F] in the configuration header to [a-f]\r
+ //\r
+ for (String = ConfigString, Lower = FALSE; *String != L'\0'; String++) {\r
+ if (*String == L'=') {\r
+ Lower = TRUE;\r
+ } else if (*String == L'&') {\r
+ Lower = FALSE;\r
+ } else if (Lower && *String >= L'A' && *String <= L'F') {\r
+ *String = (CHAR16) (*String - L'A' + L'a');\r
+ }\r
+ }\r
+}\r
+\r
+/**\r
+ Find the point in the ConfigResp string for this question.\r
\r
- @param FormSet The form set.\r
@param Question The question.\r
- @param DefaultId The default Id.\r
+ @param ConfigResp Get ConfigResp string.\r
\r
- @retval EFI_SUCCESS Question is reset to default value.\r
+ @retval point to the offset where is for this question.\r
\r
**/\r
-EFI_STATUS\r
-GetDefaultValueFromAltCfg (\r
- IN FORM_BROWSER_FORMSET *FormSet,\r
- IN OUT FORM_BROWSER_STATEMENT *Question,\r
- IN UINT16 DefaultId\r
+CHAR16 *\r
+GetOffsetFromConfigResp (\r
+ IN FORM_BROWSER_STATEMENT *Question,\r
+ IN CHAR16 *ConfigResp\r
)\r
{\r
- BOOLEAN IsBufferStorage;\r
- BOOLEAN IsString; \r
- UINTN Length;\r
- BROWSER_STORAGE *Storage;\r
- CHAR16 *ConfigRequest;\r
- CHAR16 *Progress;\r
- CHAR16 *Result;\r
- CHAR16 *ConfigResp;\r
- CHAR16 *Value;\r
- CHAR16 *StringPtr;\r
- UINTN LengthStr;\r
- UINT8 *Dst;\r
- CHAR16 TemStr[5];\r
- UINTN Index;\r
- UINT8 DigitUint8;\r
- EFI_STATUS Status;\r
+ CHAR16 *RequestElement;\r
+ CHAR16 *BlockData;\r
\r
- Status = EFI_NOT_FOUND;\r
- Length = 0;\r
- Dst = NULL;\r
- ConfigRequest = NULL;\r
- Result = NULL;\r
- ConfigResp = NULL;\r
- Value = NULL;\r
- Storage = Question->Storage;\r
+ //\r
+ // Type is EFI_HII_VARSTORE_NAME_VALUE.\r
+ //\r
+ if (Question->Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
+ RequestElement = StrStr (ConfigResp, Question->VariableName);\r
+ if (RequestElement != NULL) {\r
+ //\r
+ // Skip the "VariableName=" field.\r
+ //\r
+ RequestElement += StrLen (Question->VariableName) + 1;\r
+ }\r
\r
- if ((Storage == NULL) || (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE)) {\r
- return Status;\r
+ return RequestElement;\r
}\r
\r
//\r
- // Question Value is provided by Buffer Storage or NameValue Storage\r
+ // Type is EFI_HII_VARSTORE_EFI_VARIABLE or EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER\r
//\r
- if (Question->BufferValue != NULL) {\r
- //\r
- // This Question is password or orderedlist\r
- //\r
- Dst = Question->BufferValue;\r
- } else {\r
+\r
+ //\r
+ // Convert all hex digits in ConfigResp to lower case before searching.\r
+ //\r
+ HiiToLower (ConfigResp);\r
+\r
+ //\r
+ // 1. Directly use Question->BlockName to find.\r
+ //\r
+ RequestElement = StrStr (ConfigResp, Question->BlockName);\r
+ if (RequestElement != NULL) {\r
//\r
- // Other type of Questions\r
+ // Skip the "Question->BlockName&VALUE=" field.\r
//\r
- Dst = (UINT8 *) &Question->HiiValue.Value;\r
+ RequestElement += StrLen (Question->BlockName) + StrLen (L"&VALUE=");\r
+ return RequestElement;\r
}\r
\r
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {\r
- IsBufferStorage = TRUE;\r
- } else {\r
- IsBufferStorage = FALSE;\r
- }\r
- IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE);\r
-\r
//\r
- // <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||\r
- // <ConfigHdr> + "&" + <VariableName>\r
+ // 2. Change all hex digits in Question->BlockName to lower and compare again.\r
//\r
- if (IsBufferStorage) {\r
- Length = StrLen (Storage->ConfigHdr);\r
- Length += StrLen (Question->BlockName);\r
- } else {\r
- Length = StrLen (Storage->ConfigHdr);\r
- Length += StrLen (Question->VariableName) + 1;\r
- }\r
- ConfigRequest = AllocateZeroPool ((Length + 1) * sizeof (CHAR16));\r
- ASSERT (ConfigRequest != NULL);\r
+ BlockData = AllocateCopyPool (StrSize(Question->BlockName), Question->BlockName);\r
+ ASSERT (BlockData != NULL);\r
+ HiiToLower (BlockData);\r
+ RequestElement = StrStr (ConfigResp, BlockData);\r
+ FreePool (BlockData);\r
\r
- StrCpy (ConfigRequest, Storage->ConfigHdr);\r
- if (IsBufferStorage) {\r
- StrCat (ConfigRequest, Question->BlockName);\r
- } else {\r
- StrCat (ConfigRequest, L"&");\r
- StrCat (ConfigRequest, Question->VariableName);\r
+ if (RequestElement != NULL) {\r
+ //\r
+ // Skip the "Question->BlockName&VALUE=" field.\r
+ //\r
+ RequestElement += StrLen (Question->BlockName) + StrLen (L"&VALUE=");\r
}\r
\r
- Status = mHiiConfigRouting->ExtractConfig (\r
- mHiiConfigRouting,\r
- ConfigRequest,\r
- &Progress,\r
- &Result\r
- );\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
+ return RequestElement;\r
+}\r
\r
- //\r
- // Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)\r
- // Get the default configuration string according to the default ID.\r
- //\r
- Status = mHiiConfigRouting->GetAltConfig (\r
- mHiiConfigRouting,\r
- Result,\r
- &Storage->Guid,\r
- Storage->Name,\r
- NULL,\r
- &DefaultId, // it can be NULL to get the current setting.\r
- &ConfigResp\r
- );\r
- \r
- //\r
- // The required setting can't be found. So, it is not required to be validated and set.\r
- //\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
+/**\r
+ Get Question default value from AltCfg string.\r
\r
- if (ConfigResp == NULL) {\r
- Status = EFI_NOT_FOUND;\r
- goto Done;\r
- }\r
+ @param FormSet The form set.\r
+ @param Form The form\r
+ @param Question The question.\r
\r
- //\r
- // Skip <ConfigRequest>\r
- //\r
- if (IsBufferStorage) {\r
- Value = StrStr (ConfigResp, L"&VALUE");\r
- ASSERT (Value != NULL);\r
- //\r
- // Skip "&VALUE"\r
- //\r
- Value = Value + 6;\r
- } else {\r
- Value = StrStr (ConfigResp, Question->VariableName);\r
- ASSERT (Value != NULL);\r
+ @retval EFI_SUCCESS Question is reset to default value.\r
\r
- Value = Value + StrLen (Question->VariableName);\r
- }\r
- if (*Value != '=') {\r
- Status = EFI_NOT_FOUND;\r
- goto Done;\r
+**/\r
+EFI_STATUS\r
+GetDefaultValueFromAltCfg (\r
+ IN FORM_BROWSER_FORMSET *FormSet,\r
+ IN FORM_BROWSER_FORM *Form,\r
+ IN OUT FORM_BROWSER_STATEMENT *Question\r
+ )\r
+{\r
+ BROWSER_STORAGE *Storage;\r
+ FORMSET_STORAGE *FormSetStorage;\r
+ CHAR16 *ConfigResp;\r
+ CHAR16 *Value;\r
+ LIST_ENTRY *Link;\r
+ FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;\r
+\r
+ Storage = Question->Storage;\r
+ if ((Storage == NULL) || (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE)) {\r
+ return EFI_NOT_FOUND;\r
}\r
- //\r
- // Skip '=', point to value\r
- //\r
- Value = Value + 1;\r
\r
//\r
- // Suppress <AltResp> if any\r
+ // Try to get AltCfg string from form. If not found it, then\r
+ // try to get it from formset.\r
//\r
- StringPtr = Value;\r
- while (*StringPtr != L'\0' && *StringPtr != L'&') {\r
- StringPtr++;\r
- }\r
- *StringPtr = L'\0';\r
+ ConfigResp = NULL;\r
+ Link = GetFirstNode (&Form->ConfigRequestHead);\r
+ while (!IsNull (&Form->ConfigRequestHead, Link)) {\r
+ ConfigInfo = FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link);\r
+ Link = GetNextNode (&Form->ConfigRequestHead, Link);\r
\r
- LengthStr = StrLen (Value);\r
- if (!IsBufferStorage && IsString) {\r
- StringPtr = (CHAR16 *) Dst;\r
- ZeroMem (TemStr, sizeof (TemStr));\r
- for (Index = 0; Index < LengthStr; Index += 4) {\r
- StrnCpy (TemStr, Value + Index, 4);\r
- StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr);\r
+ if (Storage == ConfigInfo->Storage) {\r
+ ConfigResp = ConfigInfo->ConfigAltResp;\r
+ break;\r
}\r
- //\r
- // Add tailing L'\0' character\r
- //\r
- StringPtr[Index/4] = L'\0';\r
- } else {\r
- ZeroMem (TemStr, sizeof (TemStr));\r
- for (Index = 0; Index < LengthStr; Index ++) {\r
- TemStr[0] = Value[LengthStr - Index - 1];\r
- DigitUint8 = (UINT8) StrHexToUint64 (TemStr);\r
- if ((Index & 1) == 0) {\r
- Dst [Index/2] = DigitUint8;\r
- } else {\r
- Dst [Index/2] = (UINT8) ((DigitUint8 << 4) + Dst [Index/2]);\r
+ }\r
+\r
+ if (ConfigResp == NULL) {\r
+ Link = GetFirstNode (&FormSet->StorageListHead);\r
+ while (!IsNull (&FormSet->StorageListHead, Link)) {\r
+ FormSetStorage = FORMSET_STORAGE_FROM_LINK (Link);\r
+ Link = GetNextNode (&FormSet->StorageListHead, Link);\r
+\r
+ if (Storage == FormSetStorage->BrowserStorage) {\r
+ ConfigResp = FormSetStorage->ConfigAltResp;\r
+ break;\r
}\r
}\r
}\r
\r
-Done:\r
- if (ConfigRequest != NULL){\r
- FreePool (ConfigRequest);\r
+ if (ConfigResp == NULL) {\r
+ return EFI_NOT_FOUND;\r
}\r
\r
- if (ConfigResp != NULL) {\r
- FreePool (ConfigResp);\r
- }\r
- \r
- if (Result != NULL) {\r
- FreePool (Result);\r
+ Value = GetOffsetFromConfigResp (Question, ConfigResp);\r
+ if (Value == NULL) {\r
+ return EFI_NOT_FOUND;\r
}\r
\r
- return Status;\r
+ return BufferToValue (Question, Value);\r
}\r
\r
/**\r
GetDefaultIdForCallBack (\r
UINTN DefaultId\r
)\r
-{ \r
+{\r
if (DefaultId == EFI_HII_DEFAULT_CLASS_STANDARD) {\r
return EFI_BROWSER_ACTION_DEFAULT_STANDARD;\r
} else if (DefaultId == EFI_HII_DEFAULT_CLASS_MANUFACTURING) {\r
EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
INTN Action;\r
CHAR16 *NewString;\r
+ EFI_IFR_TYPE_VALUE *TypeValue;\r
+ UINT16 OriginalDefaultId;\r
+ FORMSET_DEFAULTSTORE *DefaultStore;\r
+ LIST_ENTRY *DefaultLink;\r
\r
Status = EFI_NOT_FOUND;\r
StrValue = NULL;\r
+ OriginalDefaultId = DefaultId;\r
+ DefaultLink = GetFirstNode (&FormSet->DefaultStoreListHead);\r
\r
//\r
// Statement don't have storage, skip them\r
// There are Five ways to specify default value for a Question:\r
// 1, use call back function (highest priority)\r
// 2, use ExtractConfig function\r
- // 3, use nested EFI_IFR_DEFAULT \r
+ // 3, use nested EFI_IFR_DEFAULT\r
// 4, set flags of EFI_ONE_OF_OPTION (provide Standard and Manufacturing default)\r
// 5, set flags of EFI_IFR_CHECKBOX (provide Standard and Manufacturing default) (lowest priority)\r
//\r
+ReGetDefault:\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
\r
ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth);\r
if (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth) {\r
+ ZeroMem (Question->BufferValue, Question->StorageWidth);\r
CopyMem (Question->BufferValue, NewString, StrSize (NewString));\r
} else {\r
CopyMem (Question->BufferValue, NewString, Question->StorageWidth);\r
//\r
// Get default value from altcfg string.\r
//\r
- if (ConfigAccess != NULL) { \r
- Status = GetDefaultValueFromAltCfg(FormSet, Question, DefaultId);\r
+ if (ConfigAccess != NULL) {\r
+ Status = GetDefaultValueFromAltCfg(FormSet, Form, Question);\r
if (!EFI_ERROR (Status)) {\r
return Status;\r
}\r
FreePool (Default->ValueExpression->Result.Buffer);\r
}\r
HiiValue->Type = Default->ValueExpression->Result.Type;\r
- CopyMem (&HiiValue->Value, &Default->ValueExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE)); \r
+ CopyMem (&HiiValue->Value, &Default->ValueExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE));\r
} else {\r
//\r
// Default value is embedded in EFI_IFR_DEFAULT\r
//\r
- CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE));\r
+ if (Default->Value.Type == EFI_IFR_TYPE_BUFFER) {\r
+ ASSERT (HiiValue->Buffer != NULL);\r
+ CopyMem (HiiValue->Buffer, Default->Value.Buffer, Default->Value.BufferLen);\r
+ } else {\r
+ CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE));\r
+ }\r
}\r
\r
if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
return EFI_NOT_FOUND;\r
}\r
if (Question->StorageWidth > StrSize (StrValue)) {\r
+ ZeroMem (Question->BufferValue, Question->StorageWidth);\r
CopyMem (Question->BufferValue, StrValue, StrSize (StrValue));\r
} else {\r
CopyMem (Question->BufferValue, StrValue, Question->StorageWidth);\r
((DefaultId == EFI_HII_DEFAULT_CLASS_MANUFACTURING) && ((Question->Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG) != 0))\r
) {\r
HiiValue->Value.b = TRUE;\r
- } else {\r
- HiiValue->Value.b = FALSE;\r
}\r
\r
- return EFI_SUCCESS;\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ //\r
+ // For question without default value for current default Id, we try to re-get the default value form other default id in the DefaultStoreList.\r
+ // If get, will exit the function, if not, will choose next default id in the DefaultStoreList.\r
+ // The default id in DefaultStoreList are in ascending order to make sure choose the smallest default id every time.\r
+ //\r
+ while (!IsNull(&FormSet->DefaultStoreListHead, DefaultLink)) {\r
+ DefaultStore = FORMSET_DEFAULTSTORE_FROM_LINK(DefaultLink);\r
+ DefaultLink = GetNextNode (&FormSet->DefaultStoreListHead,DefaultLink);\r
+ DefaultId = DefaultStore->DefaultId;\r
+ if (DefaultId == OriginalDefaultId) {\r
+ continue;\r
+ }\r
+ goto ReGetDefault;\r
+ }\r
+\r
+ //\r
+ // For Questions without default value for all the default id in the DefaultStoreList.\r
+ //\r
+ Status = EFI_NOT_FOUND;\r
+ switch (Question->Operand) {\r
+ case EFI_IFR_CHECKBOX_OP:\r
+ HiiValue->Value.b = FALSE;\r
+ Status = EFI_SUCCESS;\r
+ break;\r
+\r
+ case EFI_IFR_NUMERIC_OP:\r
+ //\r
+ // Take minimum value as numeric default value\r
+ //\r
+ if ((Question->Flags & EFI_IFR_DISPLAY) == 0) {\r
+ //\r
+ // In EFI_IFR_DISPLAY_INT_DEC type, should check value with int* type.\r
+ //\r
+ switch (Question->Flags & EFI_IFR_NUMERIC_SIZE) {\r
+ case EFI_IFR_NUMERIC_SIZE_1:\r
+ if (((INT8) HiiValue->Value.u8 < (INT8) Question->Minimum) || ((INT8) HiiValue->Value.u8 > (INT8) Question->Maximum)) {\r
+ HiiValue->Value.u8 = (UINT8) Question->Minimum;\r
+ Status = EFI_SUCCESS;\r
+ }\r
+ break;\r
+ case EFI_IFR_NUMERIC_SIZE_2:\r
+ if (((INT16) HiiValue->Value.u16 < (INT16) Question->Minimum) || ((INT16) HiiValue->Value.u16 > (INT16) Question->Maximum)) {\r
+ HiiValue->Value.u16 = (UINT16) Question->Minimum;\r
+ Status = EFI_SUCCESS;\r
+ }\r
+ break;\r
+ case EFI_IFR_NUMERIC_SIZE_4:\r
+ if (((INT32) HiiValue->Value.u32 < (INT32) Question->Minimum) || ((INT32) HiiValue->Value.u32 > (INT32) Question->Maximum)) {\r
+ HiiValue->Value.u32 = (UINT32) Question->Minimum;\r
+ Status = EFI_SUCCESS;\r
+ }\r
+ break;\r
+ case EFI_IFR_NUMERIC_SIZE_8:\r
+ if (((INT64) HiiValue->Value.u64 < (INT64) Question->Minimum) || ((INT64) HiiValue->Value.u64 > (INT64) Question->Maximum)) {\r
+ HiiValue->Value.u64 = Question->Minimum;\r
+ Status = EFI_SUCCESS;\r
+ }\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ } else {\r
+ if ((HiiValue->Value.u64 < Question->Minimum) || (HiiValue->Value.u64 > Question->Maximum)) {\r
+ HiiValue->Value.u64 = Question->Minimum;\r
+ Status = EFI_SUCCESS;\r
+ }\r
+ }\r
+ break;\r
+\r
+ case EFI_IFR_ONE_OF_OP:\r
+ //\r
+ // Take first oneof option as oneof's default value\r
+ //\r
+ if (ValueToOption (Question, HiiValue) == NULL) {\r
+ Link = GetFirstNode (&Question->OptionListHead);\r
+ while (!IsNull (&Question->OptionListHead, Link)) {\r
+ Option = QUESTION_OPTION_FROM_LINK (Link);\r
+ Link = GetNextNode (&Question->OptionListHead, Link);\r
+\r
+ if ((Option->SuppressExpression != NULL) &&\r
+ EvaluateExpressionList(Option->SuppressExpression, FALSE, NULL, NULL) != ExpressFalse) {\r
+ continue;\r
+ }\r
+\r
+ CopyMem (HiiValue, &Option->Value, sizeof (EFI_HII_VALUE));\r
+ Status = EFI_SUCCESS;\r
+ break;\r
+ }\r
+ }\r
+ break;\r
+\r
+ case EFI_IFR_ORDERED_LIST_OP:\r
+ //\r
+ // Take option sequence in IFR as ordered list's default value\r
+ //\r
+ Index = 0;\r
+ Link = GetFirstNode (&Question->OptionListHead);\r
+ while (!IsNull (&Question->OptionListHead, Link)) {\r
+ Status = EFI_SUCCESS;\r
+ Option = QUESTION_OPTION_FROM_LINK (Link);\r
+ Link = GetNextNode (&Question->OptionListHead, Link);\r
+\r
+ if ((Option->SuppressExpression != NULL) &&\r
+ EvaluateExpressionList(Option->SuppressExpression, FALSE, NULL, NULL) != ExpressFalse) {\r
+ continue;\r
+ }\r
+\r
+ SetArrayData (Question->BufferValue, Question->ValueType, Index, Option->Value.Value.u64);\r
+\r
+ Index++;\r
+ if (Index >= Question->MaxContainers) {\r
+ break;\r
+ }\r
+ }\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Get AltCfg string for current form.\r
+\r
+ @param FormSet Form data structure.\r
+ @param Form Form data structure.\r
+ @param DefaultId The Class of the default.\r
+ @param BrowserStorage The input request storage for the questions.\r
+\r
+**/\r
+VOID\r
+ExtractAltCfgForForm (\r
+ IN FORM_BROWSER_FORMSET *FormSet,\r
+ IN FORM_BROWSER_FORM *Form,\r
+ IN UINT16 DefaultId,\r
+ IN BROWSER_STORAGE *BrowserStorage\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ LIST_ENTRY *Link;\r
+ CHAR16 *ConfigResp;\r
+ CHAR16 *Progress;\r
+ CHAR16 *Result;\r
+ BROWSER_STORAGE *Storage;\r
+ FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;\r
+ FORMSET_STORAGE *FormSetStorage;\r
+\r
+ //\r
+ // Check whether has get AltCfg string for this formset.\r
+ // If yes, no need to get AltCfg for form.\r
+ //\r
+ Link = GetFirstNode (&FormSet->StorageListHead);\r
+ while (!IsNull (&FormSet->StorageListHead, Link)) {\r
+ FormSetStorage = FORMSET_STORAGE_FROM_LINK (Link);\r
+ Storage = FormSetStorage->BrowserStorage;\r
+ Link = GetNextNode (&FormSet->StorageListHead, Link);\r
+ if (BrowserStorage != NULL && BrowserStorage != Storage) {\r
+ continue;\r
+ }\r
+\r
+ if (Storage->Type != EFI_HII_VARSTORE_EFI_VARIABLE &&\r
+ FormSetStorage->ElementCount != 0 &&\r
+ FormSetStorage->HasCallAltCfg) {\r
+ return;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Get AltCfg string for each form.\r
+ //\r
+ Link = GetFirstNode (&Form->ConfigRequestHead);\r
+ while (!IsNull (&Form->ConfigRequestHead, Link)) {\r
+ ConfigInfo = FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link);\r
+ Link = GetNextNode (&Form->ConfigRequestHead, Link);\r
+\r
+ Storage = ConfigInfo->Storage;\r
+ if (BrowserStorage != NULL && BrowserStorage != Storage) {\r
+ continue;\r
+ }\r
+\r
+ if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {\r
+ continue;\r
+ }\r
+\r
+ //\r
+ // 1. Skip if there is no RequestElement\r
+ //\r
+ if (ConfigInfo->ElementCount == 0) {\r
+ continue;\r
+ }\r
+\r
+ //\r
+ // 2. Get value through hii config routine protocol.\r
+ //\r
+ Status = mHiiConfigRouting->ExtractConfig (\r
+ mHiiConfigRouting,\r
+ ConfigInfo->ConfigRequest,\r
+ &Progress,\r
+ &Result\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
+ }\r
+\r
+ //\r
+ // 3. Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)\r
+ // Get the default configuration string according to the default ID.\r
+ //\r
+ Status = mHiiConfigRouting->GetAltConfig (\r
+ mHiiConfigRouting,\r
+ Result,\r
+ &Storage->Guid,\r
+ Storage->Name,\r
+ NULL,\r
+ &DefaultId, // it can be NULL to get the current setting.\r
+ &ConfigResp\r
+ );\r
+ FreePool (Result);\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
+ }\r
+\r
+ ConfigInfo->ConfigAltResp = ConfigResp;\r
+ }\r
+}\r
+\r
+/**\r
+ Clean AltCfg string for current form.\r
+\r
+ @param Form Form data structure.\r
+\r
+**/\r
+VOID\r
+CleanAltCfgForForm (\r
+ IN FORM_BROWSER_FORM *Form\r
+ )\r
+{\r
+ LIST_ENTRY *Link;\r
+ FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;\r
+\r
+ Link = GetFirstNode (&Form->ConfigRequestHead);\r
+ while (!IsNull (&Form->ConfigRequestHead, Link)) {\r
+ ConfigInfo = FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link);\r
+ Link = GetNextNode (&Form->ConfigRequestHead, Link);\r
+\r
+ if (ConfigInfo->ConfigAltResp != NULL) {\r
+ FreePool (ConfigInfo->ConfigAltResp);\r
+ ConfigInfo->ConfigAltResp = NULL;\r
+ }\r
+ }\r
+}\r
+\r
+/**\r
+ Get AltCfg string for current formset.\r
+\r
+ @param FormSet Form data structure.\r
+ @param DefaultId The Class of the default.\r
+ @param BrowserStorage The input request storage for the questions.\r
+\r
+**/\r
+VOID\r
+ExtractAltCfgForFormSet (\r
+ IN FORM_BROWSER_FORMSET *FormSet,\r
+ IN UINT16 DefaultId,\r
+ IN BROWSER_STORAGE *BrowserStorage\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ LIST_ENTRY *Link;\r
+ CHAR16 *ConfigResp;\r
+ CHAR16 *Progress;\r
+ CHAR16 *Result;\r
+ BROWSER_STORAGE *Storage;\r
+ FORMSET_STORAGE *FormSetStorage;\r
+\r
+ Link = GetFirstNode (&FormSet->StorageListHead);\r
+ while (!IsNull (&FormSet->StorageListHead, Link)) {\r
+ FormSetStorage = FORMSET_STORAGE_FROM_LINK (Link);\r
+ Storage = FormSetStorage->BrowserStorage;\r
+ Link = GetNextNode (&FormSet->StorageListHead, Link);\r
+\r
+ if (BrowserStorage != NULL && BrowserStorage != Storage) {\r
+ continue;\r
}\r
- }\r
\r
- //\r
- // For Questions without default\r
- //\r
- Status = EFI_NOT_FOUND;\r
- switch (Question->Operand) {\r
- case EFI_IFR_NUMERIC_OP:\r
- //\r
- // Take minimum value as numeric default value\r
- //\r
- if ((HiiValue->Value.u64 < Question->Minimum) || (HiiValue->Value.u64 > Question->Maximum)) {\r
- HiiValue->Value.u64 = Question->Minimum;\r
- Status = EFI_SUCCESS;\r
+ if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {\r
+ continue;\r
}\r
- break;\r
\r
- case EFI_IFR_ONE_OF_OP:\r
//\r
- // Take first oneof option as oneof's default value\r
+ // 1. Skip if there is no RequestElement\r
//\r
- if (ValueToOption (Question, HiiValue) == NULL) {\r
- Link = GetFirstNode (&Question->OptionListHead);\r
- while (!IsNull (&Question->OptionListHead, Link)) {\r
- Option = QUESTION_OPTION_FROM_LINK (Link);\r
- Link = GetNextNode (&Question->OptionListHead, Link);\r
+ if (FormSetStorage->ElementCount == 0) {\r
+ continue;\r
+ }\r
\r
- if ((Option->SuppressExpression != NULL) &&\r
- EvaluateExpressionList(Option->SuppressExpression, FALSE, NULL, NULL) != ExpressFalse) {\r
- continue;\r
- }\r
+ FormSetStorage->HasCallAltCfg = TRUE;\r
\r
- CopyMem (HiiValue, &Option->Value, sizeof (EFI_HII_VALUE));\r
- Status = EFI_SUCCESS;\r
- break;\r
- }\r
+ //\r
+ // 2. Get value through hii config routine protocol.\r
+ //\r
+ Status = mHiiConfigRouting->ExtractConfig (\r
+ mHiiConfigRouting,\r
+ FormSetStorage->ConfigRequest,\r
+ &Progress,\r
+ &Result\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
}\r
- break;\r
\r
- case EFI_IFR_ORDERED_LIST_OP:\r
//\r
- // Take option sequence in IFR as ordered list's default value\r
+ // 3. Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)\r
+ // Get the default configuration string according to the default ID.\r
//\r
- Index = 0;\r
- Link = GetFirstNode (&Question->OptionListHead);\r
- while (!IsNull (&Question->OptionListHead, Link)) {\r
- Status = EFI_SUCCESS;\r
- Option = QUESTION_OPTION_FROM_LINK (Link);\r
- Link = GetNextNode (&Question->OptionListHead, Link);\r
-\r
- if ((Option->SuppressExpression != NULL) &&\r
- EvaluateExpressionList(Option->SuppressExpression, FALSE, NULL, NULL) != ExpressFalse) {\r
- continue;\r
- }\r
-\r
- SetArrayData (Question->BufferValue, Question->ValueType, Index, Option->Value.Value.u64);\r
+ Status = mHiiConfigRouting->GetAltConfig (\r
+ mHiiConfigRouting,\r
+ Result,\r
+ &Storage->Guid,\r
+ Storage->Name,\r
+ NULL,\r
+ &DefaultId, // it can be NULL to get the current setting.\r
+ &ConfigResp\r
+ );\r
\r
- Index++;\r
- if (Index >= Question->MaxContainers) {\r
- break;\r
- }\r
+ FreePool (Result);\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
}\r
- break;\r
\r
- default:\r
- break;\r
+ FormSetStorage->ConfigAltResp = ConfigResp;\r
}\r
\r
- return Status;\r
}\r
\r
+/**\r
+ Clean AltCfg string for current formset.\r
+\r
+ @param FormSet Form data structure.\r
+\r
+**/\r
+VOID\r
+CleanAltCfgForFormSet (\r
+ IN FORM_BROWSER_FORMSET *FormSet\r
+ )\r
+{\r
+ LIST_ENTRY *Link;\r
+ FORMSET_STORAGE *FormSetStorage;\r
+\r
+ Link = GetFirstNode (&FormSet->StorageListHead);\r
+ while (!IsNull (&FormSet->StorageListHead, Link)) {\r
+ FormSetStorage = FORMSET_STORAGE_FROM_LINK (Link);\r
+ Link = GetNextNode (&FormSet->StorageListHead, Link);\r
+\r
+ if (FormSetStorage->ConfigAltResp != NULL) {\r
+ FreePool (FormSetStorage->ConfigAltResp);\r
+ FormSetStorage->ConfigAltResp = NULL;\r
+ }\r
+\r
+ FormSetStorage->HasCallAltCfg = FALSE;\r
+ }\r
+}\r
\r
/**\r
Reset Questions to their initial value or default value in a Form, Formset or System.\r
\r
- GetDefaultValueScope parameter decides which questions will reset \r
+ GetDefaultValueScope parameter decides which questions will reset\r
to its default value.\r
\r
@param FormSet FormSet data structure.\r
@param RetrieveValueFirst Whether call the retrieve call back to\r
get the initial value before get default\r
value.\r
+ @param SkipGetAltCfg Whether skip the get altcfg string process.\r
\r
@retval EFI_SUCCESS The function completed successfully.\r
@retval EFI_UNSUPPORTED Unsupport SettingScope.\r
IN BROWSER_SETTING_SCOPE SettingScope,\r
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,\r
IN BROWSER_STORAGE *Storage OPTIONAL,\r
- IN BOOLEAN RetrieveValueFirst\r
+ IN BOOLEAN RetrieveValueFirst,\r
+ IN BOOLEAN SkipGetAltCfg\r
)\r
{\r
EFI_STATUS Status;\r
if (GetDefaultValueScope == GetDefaultForStorage && Storage == NULL) {\r
return EFI_UNSUPPORTED;\r
}\r
- \r
+\r
if (SettingScope == FormLevel) {\r
+ //\r
+ // Prepare the AltCfg String for form.\r
+ //\r
+ if (!SkipGetAltCfg && (GetDefaultValueScope != GetDefaultForNoStorage)) {\r
+ ExtractAltCfgForForm (FormSet, Form, DefaultId, Storage);\r
+ }\r
+\r
//\r
// Extract Form default\r
//\r
SetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);\r
}\r
}\r
+\r
+ //\r
+ // Clean the AltCfg String.\r
+ //\r
+ if (!SkipGetAltCfg && (GetDefaultValueScope != GetDefaultForNoStorage)) {\r
+ CleanAltCfgForForm(Form);\r
+ }\r
} else if (SettingScope == FormSetLevel) {\r
+ //\r
+ // Prepare the AltCfg String for formset.\r
+ //\r
+ if (!SkipGetAltCfg && (GetDefaultValueScope != GetDefaultForNoStorage)) {\r
+ ExtractAltCfgForFormSet (FormSet, DefaultId, Storage);\r
+ }\r
+\r
FormLink = GetFirstNode (&FormSet->FormListHead);\r
while (!IsNull (&FormSet->FormListHead, FormLink)) {\r
Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);\r
- ExtractDefault (FormSet, Form, DefaultId, FormLevel, GetDefaultValueScope, Storage, RetrieveValueFirst);\r
+ ExtractDefault (FormSet, Form, DefaultId, FormLevel, GetDefaultValueScope, Storage, RetrieveValueFirst, SkipGetAltCfg);\r
FormLink = GetNextNode (&FormSet->FormListHead, FormLink);\r
}\r
+\r
+ //\r
+ // Clean the AltCfg String.\r
+ //\r
+ if (!SkipGetAltCfg && (GetDefaultValueScope != GetDefaultForNoStorage)) {\r
+ CleanAltCfgForFormSet (FormSet);\r
+ }\r
} else if (SettingScope == SystemLevel) {\r
//\r
// Preload all Hii formset.\r
\r
mSystemLevelFormSet = LocalFormSet;\r
\r
- ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage, RetrieveValueFirst);\r
+ ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage, RetrieveValueFirst, SkipGetAltCfg);\r
}\r
\r
mSystemLevelFormSet = OldFormSet;\r
/**\r
Initialize Question's Edit copy from Storage.\r
\r
- @param Selection Selection contains the information about \r
+ @param Selection Selection contains the information about\r
the Selection, form and formset to be displayed.\r
Selection action may be updated in retrieve callback.\r
If Selection is NULL, only initialize Question value.\r
EFI_STATUS Status;\r
LIST_ENTRY *Link;\r
FORM_BROWSER_STATEMENT *Question;\r
- \r
+\r
Link = GetFirstNode (&Form->StatementListHead);\r
while (!IsNull (&Form->StatementListHead, Link)) {\r
Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);\r
/**\r
Initialize Question's Edit copy from Storage for the whole Formset.\r
\r
- @param Selection Selection contains the information about \r
+ @param Selection Selection contains the information about\r
the Selection, form and formset to be displayed.\r
Selection action may be updated in retrieve callback.\r
If Selection is NULL, only initialize Question value.\r
\r
//\r
// Finished question initialization.\r
- // \r
+ //\r
FormSet->QuestionInited = TRUE;\r
\r
return EFI_SUCCESS;\r
DestStr = NewStr;\r
NewStr += StrLen (RequestElement);\r
CopyMem (DestStr, NewStr, StrSize (NewStr));\r
- \r
- Storage->SpareStrLen += StrLen (RequestElement); \r
+\r
+ Storage->SpareStrLen += StrLen (RequestElement);\r
}\r
\r
/**\r
Adjust config request in storage, remove the request elements existed in the input ConfigRequest.\r
\r
- @param Storage Pointer to the browser storage.\r
+ @param Storage Pointer to the formset storage.\r
@param ConfigRequest The pointer to the Request element.\r
\r
**/\r
VOID\r
RemoveConfigRequest (\r
- BROWSER_STORAGE *Storage,\r
+ FORMSET_STORAGE *Storage,\r
CHAR16 *ConfigRequest\r
)\r
{\r
return;\r
}\r
\r
- if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
//\r
// "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage\r
//\r
//\r
// Find SearchKey storage\r
//\r
- if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
RequestElement = StrStr (ConfigRequest, L"PATH");\r
ASSERT (RequestElement != NULL);\r
- RequestElement = StrStr (RequestElement, SearchKey); \r
+ RequestElement = StrStr (RequestElement, SearchKey);\r
} else {\r
RequestElement = StrStr (ConfigRequest, SearchKey);\r
}\r
*NextRequestElement = L'\0';\r
}\r
\r
- RemoveElement (Storage, RequestElement);\r
+ RemoveElement (Storage->BrowserStorage, RequestElement);\r
\r
if (NextRequestElement != NULL) {\r
//\r
//\r
// If no request element remain, just remove the ConfigRequest string.\r
//\r
- if (StrCmp (Storage->ConfigRequest, Storage->ConfigHdr) == 0) {\r
- FreePool (Storage->ConfigRequest);\r
- Storage->ConfigRequest = NULL;\r
- Storage->SpareStrLen = 0;\r
+ if (StrCmp (Storage->BrowserStorage->ConfigRequest, Storage->ConfigHdr) == 0) {\r
+ FreePool (Storage->BrowserStorage->ConfigRequest);\r
+ Storage->BrowserStorage->ConfigRequest = NULL;\r
+ Storage->BrowserStorage->SpareStrLen = 0;\r
}\r
}\r
\r
continue;\r
}\r
\r
- RemoveConfigRequest (Storage->BrowserStorage, Storage->ConfigRequest);\r
+ RemoveConfigRequest (Storage, Storage->ConfigRequest);\r
} else if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||\r
Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
- if (Storage->BrowserStorage->ConfigRequest != NULL) { \r
+ if (Storage->BrowserStorage->ConfigRequest != NULL) {\r
FreePool (Storage->BrowserStorage->ConfigRequest);\r
Storage->BrowserStorage->ConfigRequest = NULL;\r
}\r
@retval FALSE The Element not in the configReqeust String.\r
\r
**/\r
-BOOLEAN \r
+BOOLEAN\r
ElementValidation (\r
BROWSER_STORAGE *BrowserStorage,\r
CHAR16 *RequestElement\r
CHAR16 *NewStr;\r
UINTN StringSize;\r
UINTN StrLength;\r
+ UINTN MaxLen;\r
\r
StrLength = StrLen (RequestElement);\r
+ StringSize = (*ConfigRequest != NULL) ? StrSize (*ConfigRequest) : sizeof (CHAR16);\r
+ MaxLen = StringSize / sizeof (CHAR16) + *SpareStrLen;\r
\r
//\r
// Append <RequestElement> to <ConfigRequest>\r
//\r
// Old String buffer is not sufficient for RequestElement, allocate a new one\r
//\r
- StringSize = (*ConfigRequest != NULL) ? StrSize (*ConfigRequest) : sizeof (CHAR16);\r
- NewStr = AllocateZeroPool (StringSize + CONFIG_REQUEST_STRING_INCREMENTAL * sizeof (CHAR16));\r
+ MaxLen = StringSize / sizeof (CHAR16) + CONFIG_REQUEST_STRING_INCREMENTAL;\r
+ NewStr = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
ASSERT (NewStr != NULL);\r
\r
if (*ConfigRequest != NULL) {\r
*SpareStrLen = CONFIG_REQUEST_STRING_INCREMENTAL;\r
}\r
\r
- StrCat (*ConfigRequest, RequestElement);\r
+ StrCatS (*ConfigRequest, MaxLen, RequestElement);\r
*SpareStrLen -= StrLength;\r
}\r
\r
@retval FALSE All elements covered by current used elements.\r
\r
**/\r
-BOOLEAN \r
+BOOLEAN\r
ConfigRequestAdjust (\r
IN BROWSER_STORAGE *Storage,\r
IN CHAR16 *Request,\r
CHAR16 *RequestElement;\r
CHAR16 *NextRequestElement;\r
CHAR16 *NextElementBakup;\r
- UINTN SpareBufLen;\r
CHAR16 *SearchKey;\r
CHAR16 *ValueKey;\r
BOOLEAN RetVal;\r
CHAR16 *ConfigRequest;\r
\r
- SpareBufLen = 0;\r
RetVal = FALSE;\r
NextElementBakup = NULL;\r
ValueKey = NULL;\r
if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
RequestElement = StrStr (ConfigRequest, L"PATH");\r
ASSERT (RequestElement != NULL);\r
- RequestElement = StrStr (RequestElement, SearchKey); \r
+ RequestElement = StrStr (RequestElement, SearchKey);\r
} else {\r
RequestElement = StrStr (ConfigRequest, SearchKey);\r
}\r
*NextRequestElement = L'\0';\r
}\r
}\r
- \r
+\r
if (!ElementValidation (Storage, RequestElement)) {\r
//\r
// Add this element to the Storage->BrowserStorage->AllRequestElement.\r
return RetVal;\r
}\r
\r
-/**\r
-\r
- Base on ConfigRequest info to get default value for current formset. \r
-\r
- ConfigRequest info include the info about which questions in current formset need to \r
- get default value. This function only get these questions default value.\r
- \r
- @param FormSet FormSet data structure.\r
- @param Storage Storage need to update value.\r
- @param ConfigRequest The config request string.\r
-\r
-**/\r
-VOID\r
-GetDefaultForFormset (\r
- IN FORM_BROWSER_FORMSET *FormSet,\r
- IN BROWSER_STORAGE *Storage,\r
- IN CHAR16 *ConfigRequest\r
- )\r
-{\r
- UINT8 *BackUpBuf;\r
- UINTN BufferSize;\r
- LIST_ENTRY BackUpList;\r
- NAME_VALUE_NODE *Node;\r
- LIST_ENTRY *Link;\r
- LIST_ENTRY *NodeLink;\r
- NAME_VALUE_NODE *TmpNode;\r
- EFI_STATUS Status;\r
- EFI_STRING Progress;\r
- EFI_STRING Result;\r
-\r
- BackUpBuf = NULL;\r
- InitializeListHead(&BackUpList);\r
-\r
- //\r
- // Back update the edit buffer.\r
- // \r
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER || \r
- (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {\r
- BackUpBuf = AllocateCopyPool (Storage->Size, Storage->EditBuffer);\r
- ASSERT (BackUpBuf != NULL);\r
- } else if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
- Link = GetFirstNode (&Storage->NameValueListHead);\r
- while (!IsNull (&Storage->NameValueListHead, Link)) {\r
- Node = NAME_VALUE_NODE_FROM_LINK (Link);\r
- Link = GetNextNode (&Storage->NameValueListHead, Link);\r
-\r
- //\r
- // Only back Node belong to this formset.\r
- //\r
- if (StrStr (Storage->ConfigRequest, Node->Name) == NULL) {\r
- continue;\r
- }\r
-\r
- TmpNode = AllocateCopyPool (sizeof (NAME_VALUE_NODE), Node);\r
- ASSERT (TmpNode != NULL);\r
- TmpNode->Name = AllocateCopyPool (StrSize(Node->Name) * sizeof (CHAR16), Node->Name);\r
- ASSERT (TmpNode->Name != NULL);\r
- TmpNode->EditValue = AllocateCopyPool (StrSize(Node->EditValue) * sizeof (CHAR16), Node->EditValue);\r
- ASSERT (TmpNode->EditValue != NULL);\r
-\r
- InsertTailList(&BackUpList, &TmpNode->Link);\r
- }\r
- }\r
-\r
- //\r
- // Get default value.\r
- //\r
- ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage, TRUE);\r
-\r
- //\r
- // Update the question value based on the input ConfigRequest.\r
- //\r
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER || \r
- (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {\r
- ASSERT (BackUpBuf != NULL);\r
- BufferSize = Storage->Size;\r
- Status = mHiiConfigRouting->BlockToConfig(\r
- mHiiConfigRouting,\r
- ConfigRequest,\r
- Storage->EditBuffer,\r
- BufferSize,\r
- &Result,\r
- &Progress\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- \r
- Status = mHiiConfigRouting->ConfigToBlock (\r
- mHiiConfigRouting,\r
- Result,\r
- BackUpBuf,\r
- &BufferSize,\r
- &Progress\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- if (Result != NULL) {\r
- FreePool (Result);\r
- }\r
- \r
- CopyMem (Storage->EditBuffer, BackUpBuf, Storage->Size);\r
- FreePool (BackUpBuf);\r
- } else if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
- //\r
- // Update question value, only element in ConfigReqeust will be update.\r
- //\r
- Link = GetFirstNode (&BackUpList);\r
- while (!IsNull (&BackUpList, Link)) {\r
- Node = NAME_VALUE_NODE_FROM_LINK (Link);\r
- Link = GetNextNode (&BackUpList, Link);\r
-\r
- if (StrStr (ConfigRequest, Node->Name) != NULL) {\r
- continue;\r
- }\r
-\r
- NodeLink = GetFirstNode (&Storage->NameValueListHead);\r
- while (!IsNull (&Storage->NameValueListHead, NodeLink)) {\r
- TmpNode = NAME_VALUE_NODE_FROM_LINK (NodeLink);\r
- NodeLink = GetNextNode (&Storage->NameValueListHead, NodeLink);\r
- \r
- if (StrCmp (Node->Name, TmpNode->Name) != 0) {\r
- continue;\r
- }\r
-\r
- FreePool (TmpNode->EditValue);\r
- TmpNode->EditValue = AllocateCopyPool (StrSize(Node->EditValue) * sizeof (CHAR16), Node->EditValue);\r
-\r
- RemoveEntryList (&Node->Link);\r
- FreePool (Node->EditValue);\r
- FreePool (Node->Name);\r
- FreePool (Node);\r
- }\r
- }\r
-\r
- //\r
- // Restore the Name/Value node.\r
- // \r
- Link = GetFirstNode (&BackUpList);\r
- while (!IsNull (&BackUpList, Link)) {\r
- Node = NAME_VALUE_NODE_FROM_LINK (Link);\r
- Link = GetNextNode (&BackUpList, Link);\r
- \r
- //\r
- // Free this node.\r
- //\r
- RemoveEntryList (&Node->Link);\r
- FreePool (Node->EditValue);\r
- FreePool (Node->Name);\r
- FreePool (Node);\r
- }\r
- }\r
-}\r
-\r
/**\r
Fill storage's edit copy with settings requested from Configuration Driver.\r
\r
}\r
\r
//\r
- // Just update the ConfigRequest, if storage already initialized. \r
+ // Just update the ConfigRequest, if storage already initialized.\r
//\r
if (Storage->BrowserStorage->Initialized) {\r
ConfigRequestAdjust(Storage->BrowserStorage, Storage->ConfigRequest, FALSE);\r
// Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
// followed by "&OFFSET=0&WIDTH=WWWW"followed by a Null-terminator\r
//\r
- StrLen = StrSize (Storage->BrowserStorage->ConfigHdr) + 20 * sizeof (CHAR16);\r
+ StrLen = StrSize (Storage->ConfigHdr) + 20 * sizeof (CHAR16);\r
ConfigRequest = AllocateZeroPool (StrLen);\r
ASSERT (ConfigRequest != NULL);\r
UnicodeSPrint (\r
- ConfigRequest, \r
- StrLen, \r
- L"%s&OFFSET=0&WIDTH=%04x", \r
- Storage->BrowserStorage->ConfigHdr,\r
+ ConfigRequest,\r
+ StrLen,\r
+ L"%s&OFFSET=0&WIDTH=%04x",\r
+ Storage->ConfigHdr,\r
Storage->BrowserStorage->Size);\r
} else {\r
ConfigRequest = Storage->ConfigRequest;\r
// If get value fail, extract default from IFR binary\r
//\r
if (EFI_ERROR (Status)) {\r
- ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE);\r
+ ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE, TRUE);\r
} else {\r
//\r
// Convert Result from <ConfigAltResp> to <ConfigResp>\r
if (StrPtr != NULL) {\r
*StrPtr = L'\0';\r
}\r
- \r
+\r
Status = ConfigRespToStorage (Storage->BrowserStorage, Result);\r
FreePool (Result);\r
}\r
Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest);\r
\r
//\r
- // Input NULL for ConfigRequest field means sync all fields from editbuffer to buffer. \r
+ // Input NULL for ConfigRequest field means sync all fields from editbuffer to buffer.\r
//\r
SynchronizeStorage(Storage->BrowserStorage, NULL, TRUE);\r
\r
\r
//\r
// Extract default from IFR binary for no storage questions.\r
- // \r
- ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForNoStorage, NULL, TRUE);\r
+ //\r
+ ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForNoStorage, NULL, TRUE, FALSE);\r
\r
//\r
// Request current settings from Configuration Driver\r
//\r
// Try to compare against formset GUID\r
//\r
- if (CompareGuid (FormSetGuid, &gZeroGuid) || \r
+ if (IsZeroGuid (ComparingGuid) ||\r
CompareGuid (ComparingGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {\r
break;\r
}\r
\r
\r
/**\r
- Save globals used by previous call to SendForm(). SendForm() may be called from \r
+ Save globals used by previous call to SendForm(). SendForm() may be called from\r
HiiConfigAccess.Callback(), this will cause SendForm() be reentried.\r
So, save globals of previous call to SendForm() and restore them upon exit.\r
\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
// Save FormBrowser context\r
//\r
Context->Selection = gCurrentSelection;\r
- Context->ResetRequired = gResetRequired;\r
+ Context->ResetRequired = gResetRequiredFormLevel;\r
+ Context->FlagReconnect = gFlagReconnect;\r
+ Context->CallbackReconnect = gCallbackReconnect;\r
Context->ExitRequired = gExitRequired;\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
// Restore FormBrowser context\r
//\r
gCurrentSelection = Context->Selection;\r
- gResetRequired = Context->ResetRequired;\r
+ gResetRequiredFormLevel = Context->ResetRequired;\r
+ gFlagReconnect = Context->FlagReconnect;\r
+ gCallbackReconnect = Context->CallbackReconnect;\r
gExitRequired = Context->ExitRequired;\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
\r
/**\r
Find the matched FormSet context in the backup maintain list based on HiiHandle.\r
- \r
+\r
@param Handle The Hii Handle.\r
- \r
+\r
@return the found FormSet context. If no found, NULL will return.\r
\r
**/\r
-FORM_BROWSER_FORMSET * \r
+FORM_BROWSER_FORMSET *\r
GetFormSetFromHiiHandle (\r
EFI_HII_HANDLE Handle\r
)\r
return FormSet;\r
}\r
}\r
- \r
+\r
return NULL;\r
}\r
\r
/**\r
Check whether the input HII handle is the FormSet that is being used.\r
- \r
+\r
@param Handle The Hii Handle.\r
- \r
+\r
@retval TRUE HII handle is being used.\r
@retval FALSE HII handle is not being used.\r
\r
}\r
Link = GetNextNode (&gBrowserContextList, Link);\r
}\r
- \r
+\r
return FALSE;\r
}\r
\r
/**\r
- Perform Password check. \r
+ Perform Password check.\r
Passwork may be encrypted by driver that requires the specific check.\r
- \r
+\r
@param Form Form where Password Statement is in.\r
@param Statement Password statement\r
@param PasswordString Password string to be checked. It may be NULL.\r
NULL means to restore password.\r
"" string can be used to checked whether old password does exist.\r
- \r
+\r
@return Status Status of Password check.\r
**/\r
EFI_STATUS\r
return EFI_UNSUPPORTED;\r
}\r
} else {\r
- if (PasswordString == NULL) {\r
- return EFI_SUCCESS;\r
- } \r
-\r
- //\r
- // Check whether has preexisted password.\r
- //\r
- if (PasswordString[0] == 0) {\r
- if (*((CHAR16 *) Question->BufferValue) == 0) {\r
- return EFI_SUCCESS;\r
- } else {\r
- return EFI_NOT_READY;\r
- }\r
- }\r
-\r
//\r
- // Check whether the input password is same as preexisted password.\r
+ // If a password doesn't have the CALLBACK flag, browser will not handle it.\r
//\r
- if (StrnCmp (PasswordString, (CHAR16 *) Question->BufferValue, Question->StorageWidth/sizeof (CHAR16)) == 0) {\r
- return EFI_SUCCESS;\r
- } else {\r
- return EFI_NOT_READY;\r
- }\r
+ return EFI_UNSUPPORTED;\r
}\r
- \r
+\r
//\r
// Prepare password string in HII database\r
//\r
\r
/**\r
Find the registered HotKey based on KeyData.\r
- \r
+\r
@param[in] KeyData A pointer to a buffer that describes the keystroke\r
information for the hot key.\r
\r
}\r
Link = GetNextNode (&gBrowserHotKeyList, Link);\r
}\r
- \r
+\r
return NULL;\r
}\r
\r
All hot keys have the same scope. The mixed hot keys with the different level are not supported.\r
If no scope is set, the default scope will be FormSet level.\r
After all registered hot keys are removed, previous Scope can reset to another level.\r
- \r
- @param[in] Scope Scope level to be set. \r
- \r
+\r
+ @param[in] Scope Scope level to be set.\r
+\r
@retval EFI_SUCCESS Scope is set correctly.\r
- @retval EFI_INVALID_PARAMETER Scope is not the valid value specified in BROWSER_SETTING_SCOPE. \r
+ @retval EFI_INVALID_PARAMETER Scope is not the valid value specified in BROWSER_SETTING_SCOPE.\r
@retval EFI_UNSPPORTED Scope level is different from current one that the registered hot keys have.\r
\r
**/\r
Only support hot key that is not printable character (control key, function key, etc.).\r
If the action value is zero, the hot key will be unregistered if it has been registered.\r
If the same hot key has been registered, the new action and help string will override the previous ones.\r
- \r
+\r
@param[in] KeyData A pointer to a buffer that describes the keystroke\r
- information for the hot key. Its type is EFI_INPUT_KEY to \r
+ information for the hot key. Its type is EFI_INPUT_KEY to\r
be supported by all ConsoleIn devices.\r
- @param[in] Action Action value that describes what action will be trigged when the hot key is pressed. \r
+ @param[in] Action Action value that describes what action will be trigged when the hot key is pressed.\r
@param[in] DefaultId Specifies the type of defaults to retrieve, which is only for DEFAULT action.\r
@param[in] HelpString Help string that describes the hot key information.\r
Its value may be NULL for the unregistered hot key.\r
- \r
+\r
@retval EFI_SUCCESS Hot key is registered or unregistered.\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
//\r
// Check input parameters.\r
//\r
- if (KeyData == NULL || KeyData->UnicodeChar != CHAR_NULL || \r
+ if (KeyData == NULL || KeyData->UnicodeChar != CHAR_NULL ||\r
(Action != BROWSER_ACTION_UNREGISTER && HelpString == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
// Check whether the input KeyData is in BrowserHotKeyList.\r
//\r
HotKey = GetHotKeyFromRegisterList (KeyData);\r
- \r
+\r
//\r
// Unregister HotKey\r
//\r
if (Action == BROWSER_ACTION_UNREGISTER) {\r
if (HotKey != NULL) {\r
//\r
- // The registered HotKey is found. \r
+ // The registered HotKey is found.\r
// Remove it from List, and free its resource.\r
//\r
RemoveEntryList (&HotKey->Link);\r
return EFI_SUCCESS;\r
} else {\r
//\r
- // The registered HotKey is not found. \r
+ // The registered HotKey is not found.\r
//\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
}\r
\r
/**\r
- Register Exit handler function. \r
- When more than one handler function is registered, the latter one will override the previous one. \r
- When NULL handler is specified, the previous Exit handler will be unregistered. \r
- \r
- @param[in] Handler Pointer to handler function. \r
+ Register Exit handler function.\r
+ When more than one handler function is registered, the latter one will override the previous one.\r
+ When NULL handler is specified, the previous Exit handler will be unregistered.\r
+\r
+ @param[in] Handler Pointer to handler function.\r
\r
**/\r
VOID\r
@retval EFI_INVALID_PARAMETER The input action value is invalid.\r
\r
**/\r
-EFI_STATUS \r
+EFI_STATUS\r
EFIAPI\r
ExecuteAction (\r
IN UINT32 Action,\r
Form = NULL;\r
if (gBrowserSettingScope < SystemLevel) {\r
FormSet = gCurrentSelection->FormSet;\r
- Form = gCurrentSelection->Form; \r
+ Form = gCurrentSelection->Form;\r
}\r
\r
//\r
// Executet the difault action.\r
//\r
if ((Action & BROWSER_ACTION_DEFAULT) != 0) {\r
- Status = ExtractDefault (FormSet, Form, DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL, FALSE);\r
+ Status = ExtractDefault (FormSet, Form, DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL, FALSE, FALSE);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
// Executet the reset action.\r
//\r
if ((Action & BROWSER_ACTION_RESET) != 0) {\r
- gResetRequired = TRUE;\r
+ gResetRequiredFormLevel = TRUE;\r
+ gResetRequiredSystemLevel = TRUE;\r
}\r
\r
//\r
break;\r
}\r
}\r
- \r
+\r
//\r
- // No data is changed. No save is required. \r
+ // No data is changed. No save is required.\r
//\r
if (!IsDataChanged) {\r
return DataSavedAction;\r
}\r
- \r
+\r
//\r
- // If data is changed, prompt user to save or discard it. \r
+ // If data is changed, prompt user to save or discard it.\r
//\r
do {\r
ConfirmRet = (UINT32) mFormDisplay->ConfirmDataChange();\r
VOID\r
)\r
{\r
- return gResetRequired;\r
+ return gResetRequiredSystemLevel;\r
}\r
\r