/** @file\r
Entry and initialization module for the browser.\r
\r
-Copyright (c) 2007 - 2015, 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
// 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
ASSERT (BrowserStorage != NULL);\r
TmpSize = StrLen (*ResultsData);\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, BrowserStorage->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
&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
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
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
+ if (Question->Storage->Type == EFI_HII_VARSTORE_BUFFER ||\r
Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {\r
IsBufferStorage = TRUE;\r
} else {\r
//\r
// Other type of Questions\r
//\r
- Dst = (UINT8 *) &Question->HiiValue.Value;\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
*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
- Length = Question->StorageWidth + sizeof (CHAR16);\r
- if (Length < ((LengthStr / 4 + 1) * 2)) {\r
- Status = EFI_BUFFER_TOO_SMALL;\r
- } else {\r
- DstBuf = (CHAR16 *) Dst;\r
- ZeroMem (TemStr, sizeof (TemStr));\r
- for (Index = 0; Index < LengthStr; Index += 4) {\r
- StrnCpy (TemStr, 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
+ 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
- if (Question->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
+ 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
CHAR16 *Value;\r
UINTN Length;\r
BOOLEAN IsBufferStorage;\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
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
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, FormsetStorage->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
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
}\r
FormsetStorage = GetFstStgFromVarId(FormSet, Question->VarStoreId);\r
ASSERT (FormsetStorage != NULL);\r
- ConfigResp = AllocateZeroPool ((StrLen (FormsetStorage->ConfigHdr) + Length + 1) * sizeof (CHAR16));\r
+ MaxLen = StrLen (FormsetStorage->ConfigHdr) + Length + 1;\r
+ ConfigResp = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
ASSERT (ConfigResp != NULL);\r
\r
- StrCpy (ConfigResp, FormsetStorage->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
+/**\r
+ When submit the question value, call the callback function with Submitted type\r
+ to inform the hii driver.\r
+\r
+ @param FormSet FormSet data structure.\r
+ @param Form Form data structure.\r
+\r
+**/\r
+VOID\r
+SubmitCallbackForForm (\r
+ IN FORM_BROWSER_FORMSET *FormSet,\r
+ IN FORM_BROWSER_FORM *Form\r
+ )\r
+{\r
+ LIST_ENTRY *Link;\r
+ FORM_BROWSER_STATEMENT *Question;\r
+ EFI_IFR_TYPE_VALUE *TypeValue;\r
+ EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
+\r
+ if (FormSet->ConfigAccess == NULL) {\r
+ return;\r
+ }\r
+\r
+ Link = GetFirstNode (&Form->StatementListHead);\r
+ while (!IsNull (&Form->StatementListHead, Link)) {\r
+ Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);\r
+ Link = GetNextNode (&Form->StatementListHead, Link);\r
+\r
+ if (Question->Storage == NULL || Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {\r
+ continue;\r
+ }\r
+\r
+ if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) {\r
+ continue;\r
+ }\r
+\r
+ if (Question->Operand == EFI_IFR_PASSWORD_OP) {\r
+ continue;\r
+ }\r
+\r
+ if (Question->HiiValue.Type == EFI_IFR_TYPE_BUFFER) {\r
+ TypeValue = (EFI_IFR_TYPE_VALUE *) Question->BufferValue;\r
+ } else {\r
+ TypeValue = &Question->HiiValue.Value;\r
+ }\r
+\r
+ ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
+ FormSet->ConfigAccess->Callback (\r
+ FormSet->ConfigAccess,\r
+ EFI_BROWSER_ACTION_SUBMITTED,\r
+ Question->QuestionId,\r
+ Question->HiiValue.Type,\r
+ TypeValue,\r
+ &ActionRequest\r
+ );\r
+ }\r
+}\r
+\r
+/**\r
+ When value set Success, call the submit callback function.\r
+\r
+ @param FormSet FormSet data structure.\r
+ @param Form Form data structure.\r
+\r
+**/\r
+VOID\r
+SubmitCallback (\r
+ IN FORM_BROWSER_FORMSET *FormSet,\r
+ IN FORM_BROWSER_FORM *Form\r
+ )\r
+{\r
+ FORM_BROWSER_FORM *CurrentForm;\r
+ LIST_ENTRY *Link;\r
+\r
+ if (Form != NULL) {\r
+ SubmitCallbackForForm(FormSet, Form);\r
+ return;\r
+ }\r
+\r
+ Link = GetFirstNode (&FormSet->FormListHead);\r
+ while (!IsNull (&FormSet->FormListHead, Link)) {\r
+ CurrentForm = FORM_BROWSER_FORM_FROM_LINK (Link);\r
+ Link = GetNextNode (&FormSet->FormListHead, Link);\r
+\r
+ SubmitCallbackForForm(FormSet, CurrentForm);\r
+ }\r
+}\r
+\r
/**\r
Validate the HiiHandle.\r
\r
//\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
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
FORMSET_STORAGE *FormSetStorage;\r
FORM_BROWSER_FORM *Form;\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
while (!IsNull (&LocalFormSet->SaveFailStorageListHead, StorageLink)) {\r
FormSetStorage = FORMSET_STORAGE_FROM_SAVE_FAIL_LINK (StorageLink);\r
StorageLink = GetNextNode (&LocalFormSet->SaveFailStorageListHead, StorageLink);\r
-\r
- SynchronizeStorage(FormSetStorage->BrowserStorage, FormSetStorage->ConfigRequest, FALSE);\r
+ //\r
+ // Process the submit fail question, base on the RestoreConfigRequest to restore the EditBuffer\r
+ // base on the SyncConfigRequest to Sync the buffer.\r
+ //\r
+ SynchronizeStorage (FormSetStorage->BrowserStorage, FormSetStorage->RestoreConfigRequest, FALSE);\r
+ FreePool (FormSetStorage->RestoreConfigRequest);\r
+ FormSetStorage->RestoreConfigRequest = NULL;\r
+ if ( FormSetStorage->SyncConfigRequest != NULL) {\r
+ SynchronizeStorage (FormSetStorage->BrowserStorage, FormSetStorage->SyncConfigRequest, TRUE);\r
+ FreePool (FormSetStorage->SyncConfigRequest);\r
+ FormSetStorage->SyncConfigRequest = NULL;\r
+ }\r
}\r
}\r
\r
+ 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
// Type is EFI_HII_VARSTORE_EFI_VARIABLE or EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER\r
//\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 += StrLen (Question->BlockName) + StrLen (L"&VALUE=");\r
return RequestElement;\r
}\r
- \r
+\r
//\r
// 2. Change all hex digits in Question->BlockName to lower and compare again.\r
//\r
IN FORM_BROWSER_FORM *Form,\r
IN OUT FORM_BROWSER_STATEMENT *Question\r
)\r
-{ \r
+{\r
BROWSER_STORAGE *Storage;\r
FORMSET_STORAGE *FormSetStorage;\r
CHAR16 *ConfigResp;\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
+ if (ConfigAccess != NULL) {\r
Status = GetDefaultValueFromAltCfg(FormSet, Form, Question);\r
if (!EFI_ERROR (Status)) {\r
return Status;\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
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
}\r
\r
//\r
- // For Questions without default\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 ((HiiValue->Value.u64 < Question->Minimum) || (HiiValue->Value.u64 > Question->Maximum)) {\r
- HiiValue->Value.u64 = Question->Minimum;\r
- Status = EFI_SUCCESS;\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
/**\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
/**\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
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
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
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
}\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
ConfigRequest = AllocateZeroPool (StrLen);\r
ASSERT (ConfigRequest != NULL);\r
UnicodeSPrint (\r
- ConfigRequest, \r
- StrLen, \r
- L"%s&OFFSET=0&WIDTH=%04x", \r
+ ConfigRequest,\r
+ StrLen,\r
+ L"%s&OFFSET=0&WIDTH=%04x",\r
Storage->ConfigHdr,\r
Storage->BrowserStorage->Size);\r
} else {\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
+ //\r
ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForNoStorage, NULL, TRUE, FALSE);\r
\r
//\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 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