Update the browser logic, make the storage as browser level instead of form set level.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14280 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ydong10 2013-04-16 10:53:22 +00:00
parent d9a1844ed3
commit 94f3aae730
3 changed files with 327 additions and 342 deletions

View File

@ -18,6 +18,7 @@ UINT16 mStatementIndex;
UINT16 mExpressionOpCodeIndex;
BOOLEAN mInScopeSubtitle;
extern LIST_ENTRY gBrowserStorageList;
/**
Initialize Statement header members.
@ -179,6 +180,7 @@ CreateQuestion (
FORMSET_STORAGE *Storage;
NAME_VALUE_NODE *NameValueNode;
EFI_STATUS Status;
BOOLEAN Find;
Statement = CreateStatement (OpCodeData, FormSet, Form);
if (Statement == NULL) {
@ -220,7 +222,7 @@ CreateQuestion (
Storage = FORMSET_STORAGE_FROM_LINK (Link);
if (Storage->VarStoreId == Statement->VarStoreId) {
Statement->Storage = Storage;
Statement->Storage = Storage->BrowserStorage;
break;
}
@ -238,19 +240,39 @@ CreateQuestion (
if (Statement->Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
//
// Insert to Name/Value varstore list
// Check whether old string node already exist.
//
NameValueNode = AllocateZeroPool (sizeof (NAME_VALUE_NODE));
ASSERT (NameValueNode != NULL);
NameValueNode->Signature = NAME_VALUE_NODE_SIGNATURE;
NameValueNode->Name = AllocateCopyPool (StrSize (Statement->VariableName), Statement->VariableName);
ASSERT (NameValueNode->Name != NULL);
NameValueNode->Value = AllocateZeroPool (0x10);
ASSERT (NameValueNode->Value != NULL);
NameValueNode->EditValue = AllocateZeroPool (0x10);
ASSERT (NameValueNode->EditValue != NULL);
Find = FALSE;
if (!IsListEmpty(&Statement->Storage->NameValueListHead)) {
Link = GetFirstNode (&Statement->Storage->NameValueListHead);
while (!IsNull (&Statement->Storage->NameValueListHead, Link)) {
NameValueNode = NAME_VALUE_NODE_FROM_LINK (Link);
InsertTailList (&Statement->Storage->NameValueListHead, &NameValueNode->Link);
if (StrCmp (Statement->VariableName, NameValueNode->Name) == 0) {
Find = TRUE;
break;
}
Link = GetNextNode (&Statement->Storage->NameValueListHead, Link);
}
}
if (!Find) {
//
// Insert to Name/Value varstore list
//
NameValueNode = AllocateZeroPool (sizeof (NAME_VALUE_NODE));
ASSERT (NameValueNode != NULL);
NameValueNode->Signature = NAME_VALUE_NODE_SIGNATURE;
NameValueNode->Name = AllocateCopyPool (StrSize (Statement->VariableName), Statement->VariableName);
ASSERT (NameValueNode->Name != NULL);
NameValueNode->Value = AllocateZeroPool (0x10);
ASSERT (NameValueNode->Value != NULL);
NameValueNode->EditValue = AllocateZeroPool (0x10);
ASSERT (NameValueNode->EditValue != NULL);
InsertTailList (&Statement->Storage->NameValueListHead, &NameValueNode->Link);
}
}
}
@ -281,32 +303,6 @@ CreateExpression (
return Expression;
}
/**
Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
@param FormSet Pointer of the current FormSet
@return Pointer to a FORMSET_STORAGE data structure.
**/
FORMSET_STORAGE *
CreateStorage (
IN FORM_BROWSER_FORMSET *FormSet
)
{
FORMSET_STORAGE *Storage;
Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE));
ASSERT (Storage != NULL);
Storage->Signature = FORMSET_STORAGE_SIGNATURE;
InitializeListHead (&Storage->NameValueListHead);
InsertTailList (&FormSet->StorageListHead, &Storage->Link);
return Storage;
}
/**
Create ConfigHdr string for a storage.
@ -319,7 +315,7 @@ CreateStorage (
EFI_STATUS
InitializeConfigHdr (
IN FORM_BROWSER_FORMSET *FormSet,
IN OUT FORMSET_STORAGE *Storage
IN OUT BROWSER_STORAGE *Storage
)
{
CHAR16 *Name;
@ -341,12 +337,185 @@ InitializeConfigHdr (
return EFI_NOT_FOUND;
}
Storage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigHdr), Storage->ConfigHdr);
Storage->SpareStrLen = 0;
return EFI_SUCCESS;
}
/**
Find the global storage link base on the input storate type, name and guid.
@param StorageType Storage type.
@param StorageGuid Storage guid.
@param StorageName Storage Name.
@return Pointer to a GLOBAL_STORAGE data structure.
**/
BROWSER_STORAGE *
FindStorageInList (
IN UINT8 StorageType,
IN EFI_GUID *StorageGuid,
IN CHAR16 *StorageName
)
{
LIST_ENTRY *Link;
BROWSER_STORAGE *BrowserStorage;
Link = GetFirstNode (&gBrowserStorageList);
while (!IsNull (&gBrowserStorageList, Link)) {
BrowserStorage = BROWSER_STORAGE_FROM_LINK (Link);
if ((BrowserStorage->Type == StorageType) && CompareGuid (&BrowserStorage->Guid, StorageGuid)) {
if (StorageType == EFI_HII_VARSTORE_NAME_VALUE) {
return BrowserStorage;
}
if (StrCmp (BrowserStorage->Name, StorageName) == 0) {
return BrowserStorage;
}
}
//
// Get Next Storage.
//
Link = GetNextNode (&gBrowserStorageList, Link);
}
return NULL;
}
/**
Intialize the Global Storage.
@param BrowserStorage Pointer to the global storage.
@param StorageType Storage type.
@param OpCodeData Binary data for this opcode.
**/
VOID
IntializeBrowserStorage (
IN BROWSER_STORAGE *BrowserStorage,
IN UINT8 StorageType,
IN UINT8 *OpCodeData
)
{
switch (StorageType) {
case EFI_HII_VARSTORE_BUFFER:
CopyMem (&BrowserStorage->Guid, &((EFI_IFR_VARSTORE *) OpCodeData)->Guid, sizeof (EFI_GUID));
CopyMem (&BrowserStorage->Size, &((EFI_IFR_VARSTORE *) OpCodeData)->Size, sizeof (UINT16));
BrowserStorage->Buffer = AllocateZeroPool (BrowserStorage->Size);
BrowserStorage->EditBuffer = AllocateZeroPool (BrowserStorage->Size);
break;
case EFI_HII_VARSTORE_EFI_VARIABLE:
case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
CopyMem (&BrowserStorage->Guid, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid, sizeof (EFI_GUID));
CopyMem (&BrowserStorage->Attributes, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Attributes, sizeof (UINT32));
CopyMem (&BrowserStorage->Size, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Size, sizeof (UINT16));
if (StorageType == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
BrowserStorage->Buffer = AllocateZeroPool (BrowserStorage->Size);
BrowserStorage->EditBuffer = AllocateZeroPool (BrowserStorage->Size);
}
break;
case EFI_HII_VARSTORE_NAME_VALUE:
CopyMem (&BrowserStorage->Guid, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->Guid, sizeof (EFI_GUID));
InitializeListHead (&BrowserStorage->NameValueListHead);
break;
default:
break;
}
}
/**
Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
@param FormSet Pointer of the current FormSet
@param StorageType Storage type.
@param OpCodeData Binary data for this opcode.
@return Pointer to a FORMSET_STORAGE data structure.
**/
FORMSET_STORAGE *
CreateStorage (
IN FORM_BROWSER_FORMSET *FormSet,
IN UINT8 StorageType,
IN UINT8 *OpCodeData
)
{
FORMSET_STORAGE *Storage;
CHAR16 *UnicodeString;
UINT16 Index;
BROWSER_STORAGE *BrowserStorage;
EFI_GUID *StorageGuid;
CHAR8 *StorageName;
UnicodeString = NULL;
StorageName = NULL;
switch (StorageType) {
case EFI_HII_VARSTORE_BUFFER:
StorageGuid = (EFI_GUID *) (CHAR8*) &((EFI_IFR_VARSTORE *) OpCodeData)->Guid;
StorageName = (CHAR8 *) ((EFI_IFR_VARSTORE *) OpCodeData)->Name;
break;
case EFI_HII_VARSTORE_EFI_VARIABLE:
case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
StorageGuid = (EFI_GUID *) (CHAR8*) &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid;
StorageName = (CHAR8 *) ((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Name;
break;
default:
ASSERT (StorageType == EFI_HII_VARSTORE_NAME_VALUE);
StorageGuid = &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->Guid;
break;
}
if (StorageType != EFI_HII_VARSTORE_NAME_VALUE) {
ASSERT (StorageName != NULL);
UnicodeString = AllocateZeroPool (AsciiStrSize (StorageName) * 2);
ASSERT (UnicodeString != NULL);
for (Index = 0; StorageName[Index] != 0; Index++) {
UnicodeString[Index] = (CHAR16) StorageName[Index];
}
}
Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE));
ASSERT (Storage != NULL);
Storage->Signature = FORMSET_STORAGE_SIGNATURE;
InsertTailList (&FormSet->StorageListHead, &Storage->Link);
BrowserStorage = FindStorageInList(StorageType, StorageGuid, UnicodeString);
if (BrowserStorage == NULL) {
BrowserStorage = AllocateZeroPool (sizeof (BROWSER_STORAGE));
ASSERT (BrowserStorage != NULL);
BrowserStorage->Signature = BROWSER_STORAGE_SIGNATURE;
InsertTailList (&gBrowserStorageList, &BrowserStorage->Link);
IntializeBrowserStorage (BrowserStorage, StorageType, OpCodeData);
BrowserStorage->Type = StorageType;
if (StorageType != EFI_HII_VARSTORE_NAME_VALUE) {
BrowserStorage->Name = UnicodeString;
}
InitializeConfigHdr (FormSet, BrowserStorage);
}
//
// Add count because one formset storage use this global storage.
//
BrowserStorage->ReferenceCount++;
Storage->BrowserStorage = BrowserStorage;
Storage->ConfigRequest = AllocateCopyPool (StrSize (BrowserStorage->ConfigHdr), BrowserStorage->ConfigHdr);
Storage->SpareStrLen = 0;
return Storage;
}
/**
Initialize Request Element of a Question. <RequestElement> ::= '&'<BlockName> | '&'<Label>
@ -366,7 +535,8 @@ InitializeRequestElement (
IN OUT FORM_BROWSER_FORM *Form
)
{
FORMSET_STORAGE *Storage;
BROWSER_STORAGE *Storage;
FORMSET_STORAGE *FormsetStorage;
UINTN StrLen;
UINTN StringSize;
CHAR16 *NewStr;
@ -413,27 +583,43 @@ InitializeRequestElement (
return EFI_SUCCESS;
}
//
// Find Formset Storage for this Question
//
FormsetStorage = NULL;
Link = GetFirstNode (&FormSet->StorageListHead);
while (!IsNull (&FormSet->StorageListHead, Link)) {
FormsetStorage = FORMSET_STORAGE_FROM_LINK (Link);
if (FormsetStorage->VarStoreId == Question->VarStoreId) {
break;
}
Link = GetNextNode (&FormSet->StorageListHead, Link);
}
ASSERT (FormsetStorage != NULL);
//
// Append <RequestElement> to <ConfigRequest>
//
if (StrLen > Storage->SpareStrLen) {
if (StrLen > FormsetStorage->SpareStrLen) {
//
// Old String buffer is not sufficient for RequestElement, allocate a new one
//
StringSize = (Storage->ConfigRequest != NULL) ? StrSize (Storage->ConfigRequest) : sizeof (CHAR16);
StringSize = (FormsetStorage->ConfigRequest != NULL) ? StrSize (FormsetStorage->ConfigRequest) : sizeof (CHAR16);
NewStr = AllocateZeroPool (StringSize + CONFIG_REQUEST_STRING_INCREMENTAL * sizeof (CHAR16));
ASSERT (NewStr != NULL);
if (Storage->ConfigRequest != NULL) {
CopyMem (NewStr, Storage->ConfigRequest, StringSize);
FreePool (Storage->ConfigRequest);
if (FormsetStorage->ConfigRequest != NULL) {
CopyMem (NewStr, FormsetStorage->ConfigRequest, StringSize);
FreePool (FormsetStorage->ConfigRequest);
}
Storage->ConfigRequest = NewStr;
Storage->SpareStrLen = CONFIG_REQUEST_STRING_INCREMENTAL;
FormsetStorage->ConfigRequest = NewStr;
FormsetStorage->SpareStrLen = CONFIG_REQUEST_STRING_INCREMENTAL;
}
StrCat (Storage->ConfigRequest, RequestElement);
Storage->ElementCount++;
Storage->SpareStrLen -= StrLen;
StrCat (FormsetStorage->ConfigRequest, RequestElement);
FormsetStorage->ElementCount++;
FormsetStorage->SpareStrLen -= StrLen;
//
// Update the Config Request info saved in the form.
@ -444,7 +630,7 @@ InitializeRequestElement (
while (!IsNull (&Form->ConfigRequestHead, Link)) {
ConfigInfo = FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link);
if (ConfigInfo != NULL && ConfigInfo->Storage->VarStoreId == Storage->VarStoreId) {
if (ConfigInfo != NULL && ConfigInfo->Storage == Storage) {
Find = TRUE;
break;
}
@ -532,7 +718,6 @@ DestroyExpression (
FreePool (Expression);
}
/**
Free resources of a storage.
@ -544,47 +729,20 @@ DestroyStorage (
IN FORMSET_STORAGE *Storage
)
{
LIST_ENTRY *Link;
NAME_VALUE_NODE *NameValueNode;
if (Storage == NULL) {
return;
}
if (Storage->Name != NULL) {
FreePool (Storage->Name);
}
if (Storage->Buffer != NULL) {
FreePool (Storage->Buffer);
}
if (Storage->EditBuffer != NULL) {
FreePool (Storage->EditBuffer);
}
while (!IsListEmpty (&Storage->NameValueListHead)) {
Link = GetFirstNode (&Storage->NameValueListHead);
NameValueNode = NAME_VALUE_NODE_FROM_LINK (Link);
RemoveEntryList (&NameValueNode->Link);
if (NameValueNode->Name != NULL) {
FreePool (NameValueNode->Name);
}
if (NameValueNode->Value != NULL) {
FreePool (NameValueNode->Value);
}
if (NameValueNode->EditValue != NULL) {
FreePool (NameValueNode->EditValue);
}
FreePool (NameValueNode);
}
if (Storage->ConfigHdr != NULL) {
FreePool (Storage->ConfigHdr);
}
if (Storage->ConfigRequest != NULL) {
FreePool (Storage->ConfigRequest);
}
//
// Minus the reference to the global storage.
//
ASSERT (Storage->BrowserStorage->ReferenceCount > 0);
Storage->BrowserStorage->ReferenceCount--;
FreePool (Storage);
}
@ -915,7 +1073,6 @@ ParseOpCodes (
)
{
EFI_STATUS Status;
UINT16 Index;
FORM_BROWSER_FORM *CurrentForm;
FORM_BROWSER_STATEMENT *CurrentStatement;
EXPRESSION_OPCODE *ExpressionOpCode;
@ -931,7 +1088,6 @@ ParseOpCodes (
QUESTION_DEFAULT *CurrentDefault;
QUESTION_OPTION *CurrentOption;
UINT8 Width;
CHAR8 *AsciiString;
UINT16 NumberOfStatement;
UINT16 NumberOfExpression;
EFI_IMAGE_ID *ImageId;
@ -1104,7 +1260,7 @@ ParseOpCodes (
while (!IsNull (&FormSet->StorageListHead, Link)) {
VarStorage = FORMSET_STORAGE_FROM_LINK (Link);
if (VarStorage->VarStoreId == ((EFI_IFR_GET *) OpCodeData)->VarStoreId) {
ExpressionOpCode->VarStorage = VarStorage;
ExpressionOpCode->VarStorage = VarStorage->BrowserStorage;
break;
}
Link = GetNextNode (&FormSet->StorageListHead, Link);
@ -1448,76 +1604,28 @@ ParseOpCodes (
//
// Create a buffer Storage for this FormSet
//
Storage = CreateStorage (FormSet);
Storage->Type = EFI_HII_VARSTORE_BUFFER;
Storage = CreateStorage (FormSet, EFI_HII_VARSTORE_BUFFER, OpCodeData);
CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE *) OpCodeData)->Guid, sizeof (EFI_GUID));
CopyMem (&Storage->Size, &((EFI_IFR_VARSTORE *) OpCodeData)->Size, sizeof (UINT16));
Storage->Buffer = AllocateZeroPool (Storage->Size);
Storage->EditBuffer = AllocateZeroPool (Storage->Size);
AsciiString = (CHAR8 *) ((EFI_IFR_VARSTORE *) OpCodeData)->Name;
Storage->Name = AllocateZeroPool (AsciiStrSize (AsciiString) * 2);
ASSERT (Storage->Name != NULL);
for (Index = 0; AsciiString[Index] != 0; Index++) {
Storage->Name[Index] = (CHAR16) AsciiString[Index];
}
//
// Initialize <ConfigHdr>
//
InitializeConfigHdr (FormSet, Storage);
break;
case EFI_IFR_VARSTORE_NAME_VALUE_OP:
//
// Create a name/value Storage for this FormSet
//
Storage = CreateStorage (FormSet);
Storage->Type = EFI_HII_VARSTORE_NAME_VALUE;
Storage = CreateStorage (FormSet, EFI_HII_VARSTORE_NAME_VALUE, OpCodeData);
CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->Guid, sizeof (EFI_GUID));
//
// Initialize <ConfigHdr>
//
InitializeConfigHdr (FormSet, Storage);
break;
case EFI_IFR_VARSTORE_EFI_OP:
//
// Create a EFI variable Storage for this FormSet
//
Storage = CreateStorage (FormSet);
CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid, sizeof (EFI_GUID));
CopyMem (&Storage->Attributes, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Attributes, sizeof (UINT32));
CopyMem (&Storage->Size, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Size, sizeof (UINT16));
if (OpCodeLength < sizeof (EFI_IFR_VARSTORE_EFI)) {
Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE;
break;
}
Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER;
Storage->Buffer = AllocateZeroPool (Storage->Size);
Storage->EditBuffer = AllocateZeroPool (Storage->Size);
AsciiString = (CHAR8 *) ((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Name;
Storage->Name = AllocateZeroPool (AsciiStrSize (AsciiString) * 2);
ASSERT (Storage->Name != NULL);
for (Index = 0; AsciiString[Index] != 0; Index++) {
Storage->Name[Index] = (CHAR16) AsciiString[Index];
Storage = CreateStorage (FormSet, EFI_HII_VARSTORE_EFI_VARIABLE, OpCodeData);
} else {
Storage = CreateStorage (FormSet, EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER, OpCodeData);
}
//
// Initialize <ConfigHdr>
//
InitializeConfigHdr (FormSet, Storage);
CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
break;
//

View File

@ -38,6 +38,7 @@ UINTN gBrowserContextCount = 0;
LIST_ENTRY gBrowserContextList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserContextList);
LIST_ENTRY gBrowserFormSetList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserFormSetList);
LIST_ENTRY gBrowserHotKeyList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserHotKeyList);
LIST_ENTRY gBrowserStorageList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserStorageList);
BANNER_DATA *gBannerData;
EFI_HII_HANDLE gFrontPageHandle;
@ -475,9 +476,9 @@ BrowserCallback (
Storage = FORMSET_STORAGE_FROM_LINK (Link);
Link = GetNextNode (&FormSet->StorageListHead, Link);
if (CompareGuid (&Storage->Guid, (EFI_GUID *) VariableGuid)) {
if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||
Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
if (CompareGuid (&Storage->BrowserStorage->Guid, (EFI_GUID *) VariableGuid)) {
if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||
Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
//
// Buffer storage require both GUID and Name
//
@ -485,7 +486,7 @@ BrowserCallback (
return EFI_NOT_FOUND;
}
if (StrCmp (Storage->Name, (CHAR16 *) VariableName) != 0) {
if (StrCmp (Storage->BrowserStorage->Name, (CHAR16 *) VariableName) != 0) {
continue;
}
}
@ -515,7 +516,7 @@ BrowserCallback (
//
// Generate <ConfigResp>
//
Status = StorageToConfigResp (Storage, &ConfigResp, FALSE);
Status = StorageToConfigResp (Storage->BrowserStorage, &ConfigResp, Storage->ConfigRequest);
if (EFI_ERROR (Status)) {
return Status;
}
@ -523,7 +524,7 @@ BrowserCallback (
//
// Skip <ConfigHdr> and '&' to point to <ConfigBody>
//
StrPtr = ConfigResp + StrLen (Storage->ConfigHdr) + 1;
StrPtr = ConfigResp + StrLen (Storage->BrowserStorage->ConfigHdr) + 1;
BufferSize = StrSize (StrPtr);
if (*ResultsDataSize < BufferSize) {
@ -542,18 +543,18 @@ BrowserCallback (
// Prepare <ConfigResp>
//
TmpSize = StrLen (ResultsData);
BufferSize = (TmpSize + StrLen (Storage->ConfigHdr) + 2) * sizeof (CHAR16);
BufferSize = (TmpSize + StrLen (Storage->BrowserStorage->ConfigHdr) + 2) * sizeof (CHAR16);
ConfigResp = AllocateZeroPool (BufferSize);
ASSERT (ConfigResp != NULL);
StrCpy (ConfigResp, Storage->ConfigHdr);
StrCpy (ConfigResp, Storage->BrowserStorage->ConfigHdr);
StrCat (ConfigResp, L"&");
StrCat (ConfigResp, ResultsData);
//
// Update Browser uncommited data
//
Status = ConfigRespToStorage (Storage, ConfigResp);
Status = ConfigRespToStorage (Storage->BrowserStorage, ConfigResp);
if (EFI_ERROR (Status)) {
return Status;
}
@ -826,7 +827,7 @@ NewStringCat (
**/
VOID
SynchronizeStorage (
IN FORMSET_STORAGE *Storage,
IN BROWSER_STORAGE *Storage,
IN BOOLEAN SyncOrRestore
)
{
@ -879,7 +880,7 @@ SynchronizeStorage (
**/
EFI_STATUS
GetValueByName (
IN FORMSET_STORAGE *Storage,
IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN OUT CHAR16 **Value,
IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
@ -928,7 +929,7 @@ GetValueByName (
**/
EFI_STATUS
SetValueByName (
IN FORMSET_STORAGE *Storage,
IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN CHAR16 *Value,
IN GET_SET_QUESTION_VALUE_WITH SetValueTo
@ -975,9 +976,9 @@ SetValueByName (
/**
Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
@param Buffer The Storage to be conveted.
@param Storage The Storage to be conveted.
@param ConfigResp The returned <ConfigResp>.
@param SingleForm Whether update data for single form or formset level.
@param ConfigRequest The ConfigRequest string.
@retval EFI_SUCCESS Convert success.
@retval EFI_INVALID_PARAMETER Incorrect storage type.
@ -985,28 +986,17 @@ SetValueByName (
**/
EFI_STATUS
StorageToConfigResp (
IN VOID *Buffer,
IN BROWSER_STORAGE *Storage,
IN CHAR16 **ConfigResp,
IN BOOLEAN SingleForm
IN CHAR16 *ConfigRequest
)
{
EFI_STATUS Status;
EFI_STRING Progress;
EFI_STATUS Status;
EFI_STRING Progress;
LIST_ENTRY *Link;
NAME_VALUE_NODE *Node;
CHAR16 *ConfigRequest;
FORMSET_STORAGE *Storage;
FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;
Status = EFI_SUCCESS;
if (SingleForm) {
ConfigInfo = (FORM_BROWSER_CONFIG_REQUEST *) Buffer;
Storage = ConfigInfo->Storage;
ConfigRequest = ConfigInfo->ConfigRequest;
} else {
Storage = (FORMSET_STORAGE *) Buffer;
ConfigRequest = Storage->ConfigRequest;
}
switch (Storage->Type) {
case EFI_HII_VARSTORE_BUFFER:
@ -1061,7 +1051,7 @@ StorageToConfigResp (
**/
EFI_STATUS
ConfigRespToStorage (
IN FORMSET_STORAGE *Storage,
IN BROWSER_STORAGE *Storage,
IN CHAR16 *ConfigResp
)
{
@ -1153,7 +1143,7 @@ GetQuestionValue (
UINT8 *Dst;
UINTN StorageWidth;
EFI_TIME EfiTime;
FORMSET_STORAGE *Storage;
BROWSER_STORAGE *Storage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigRequest;
CHAR16 *Progress;
@ -1578,7 +1568,7 @@ SetQuestionValue (
EFI_TIME EfiTime;
UINTN BufferLen;
UINTN StorageWidth;
FORMSET_STORAGE *Storage;
BROWSER_STORAGE *Storage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigResp;
CHAR16 *Progress;
@ -2304,7 +2294,7 @@ DiscardForm (
Storage = FORMSET_STORAGE_FROM_LINK (Link);
Link = GetNextNode (&FormSet->StorageListHead, Link);
if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
continue;
}
@ -2315,7 +2305,7 @@ DiscardForm (
continue;
}
SynchronizeStorage(Storage, FALSE);
SynchronizeStorage(Storage->BrowserStorage, FALSE);
}
Link = GetFirstNode (&FormSet->FormListHead);
@ -2381,7 +2371,8 @@ SubmitForm (
LIST_ENTRY *Link;
EFI_STRING ConfigResp;
EFI_STRING Progress;
FORMSET_STORAGE *Storage;
BROWSER_STORAGE *Storage;
FORMSET_STORAGE *FormSetStorage;
UINTN BufferSize;
UINT8 *TmpBuf;
FORM_BROWSER_FORMSET *LocalFormSet;
@ -2429,7 +2420,7 @@ SubmitForm (
//
// 1. Prepare <ConfigResp>
//
Status = StorageToConfigResp (ConfigInfo, &ConfigResp, TRUE);
Status = StorageToConfigResp (ConfigInfo->Storage, &ConfigResp, ConfigInfo->ConfigRequest);
if (EFI_ERROR (Status)) {
return Status;
}
@ -2518,7 +2509,8 @@ SubmitForm (
//
Link = GetFirstNode (&FormSet->StorageListHead);
while (!IsNull (&FormSet->StorageListHead, Link)) {
Storage = FORMSET_STORAGE_FROM_LINK (Link);
FormSetStorage = (FORMSET_STORAGE_FROM_LINK (Link));
Storage = FormSetStorage->BrowserStorage;
Link = GetNextNode (&FormSet->StorageListHead, Link);
if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
@ -2528,14 +2520,14 @@ SubmitForm (
//
// Skip if there is no RequestElement
//
if (Storage->ElementCount == 0) {
if (FormSetStorage->ElementCount == 0) {
continue;
}
//
// 1. Prepare <ConfigResp>
//
Status = StorageToConfigResp (Storage, &ConfigResp, FALSE);
Status = StorageToConfigResp (Storage, &ConfigResp, FormSetStorage->ConfigRequest);
if (EFI_ERROR (Status)) {
return Status;
}
@ -2663,7 +2655,7 @@ GetDefaultValueFromAltCfg (
BOOLEAN IsBufferStorage;
BOOLEAN IsString;
UINTN Length;
FORMSET_STORAGE *Storage;
BROWSER_STORAGE *Storage;
CHAR16 *ConfigRequest;
CHAR16 *Progress;
CHAR16 *Result;
@ -3151,7 +3143,7 @@ ExtractDefault (
IN UINT16 DefaultId,
IN BROWSER_SETTING_SCOPE SettingScope,
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
IN FORMSET_STORAGE *Storage OPTIONAL,
IN BROWSER_STORAGE *Storage OPTIONAL,
IN BOOLEAN RetrieveValueFirst
)
{
@ -3464,17 +3456,17 @@ LoadStorage (
EFI_STRING Result;
CHAR16 *StrPtr;
if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
return EFI_SUCCESS;
}
if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
Status = gRT->GetVariable (
Storage->Name,
&Storage->Guid,
Storage->BrowserStorage->Name,
&Storage->BrowserStorage->Guid,
NULL,
(UINTN*)&Storage->Size,
Storage->EditBuffer
(UINTN*)&Storage->BrowserStorage->Size,
Storage->BrowserStorage->EditBuffer
);
return Status;
}
@ -3511,136 +3503,11 @@ LoadStorage (
*StrPtr = L'\0';
}
Status = ConfigRespToStorage (Storage, Result);
Status = ConfigRespToStorage (Storage->BrowserStorage, Result);
FreePool (Result);
return Status;
}
/**
Copy uncommitted data from source Storage to destination Storage.
@param Dst Target Storage for uncommitted data.
@param Src Source Storage for uncommitted data.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Source and destination Storage is not the same type.
**/
EFI_STATUS
CopyStorage (
IN OUT FORMSET_STORAGE *Dst,
IN FORMSET_STORAGE *Src
)
{
LIST_ENTRY *Link;
NAME_VALUE_NODE *Node;
if ((Dst->Type != Src->Type) || (Dst->Size != Src->Size)) {
return EFI_INVALID_PARAMETER;
}
switch (Src->Type) {
case EFI_HII_VARSTORE_BUFFER:
case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
CopyMem (Dst->EditBuffer, Src->EditBuffer, Src->Size);
CopyMem (Dst->Buffer, Src->Buffer, Src->Size);
break;
case EFI_HII_VARSTORE_NAME_VALUE:
Link = GetFirstNode (&Src->NameValueListHead);
while (!IsNull (&Src->NameValueListHead, Link)) {
Node = NAME_VALUE_NODE_FROM_LINK (Link);
SetValueByName (Dst, Node->Name, Node->EditValue, GetSetValueWithEditBuffer);
SetValueByName (Dst, Node->Name, Node->Value, GetSetValueWithBuffer);
Link = GetNextNode (&Src->NameValueListHead, Link);
}
break;
case EFI_HII_VARSTORE_EFI_VARIABLE:
default:
break;
}
return EFI_SUCCESS;
}
/**
Get old question value from the saved formset.
@param Statement The question which need to get old question value.
@param OldFormSet FormSet data structure saved in the list.
**/
VOID
GetOldQuestionValue (
IN OUT FORM_BROWSER_STATEMENT *Statement,
IN FORM_BROWSER_FORMSET *OldFormSet
)
{
LIST_ENTRY *FormLink;
LIST_ENTRY *Link;
FORM_BROWSER_STATEMENT *Question;
FORM_BROWSER_FORM *Form;
FormLink = GetFirstNode (&OldFormSet->FormListHead);
while (!IsNull (&OldFormSet->FormListHead, FormLink)) {
Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);
FormLink = GetNextNode (&OldFormSet->FormListHead, FormLink);
Link = GetFirstNode (&Form->StatementListHead);
while (!IsNull (&Form->StatementListHead, Link)) {
Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
Link = GetNextNode (&Form->StatementListHead, Link);
if (Question->QuestionId != Statement->QuestionId) {
continue;
}
CopyMem (&Statement->HiiValue, &Question->HiiValue, sizeof (EFI_HII_VALUE));
return;
}
}
}
/**
Get old question value from the saved formset, all these questions not have
storage.
@param FormSet FormSet data structure which is used now.
@param OldFormSet FormSet data structure saved in the list.
**/
VOID
CopyOldValueForNoStorageQst (
IN OUT FORM_BROWSER_FORMSET *FormSet,
IN FORM_BROWSER_FORMSET *OldFormSet
)
{
LIST_ENTRY *FormLink;
LIST_ENTRY *Link;
FORM_BROWSER_STATEMENT *Question;
FORM_BROWSER_FORM *Form;
FormLink = GetFirstNode (&FormSet->FormListHead);
while (!IsNull (&FormSet->FormListHead, FormLink)) {
Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);
FormLink = GetNextNode (&FormSet->FormListHead, FormLink);
Link = GetFirstNode (&Form->StatementListHead);
while (!IsNull (&Form->StatementListHead, Link)) {
Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
Link = GetNextNode (&Form->StatementListHead, Link);
if (Question->Storage == NULL) {
GetOldQuestionValue (Question, OldFormSet);
}
}
}
}
/**
Get current setting of Questions.
@ -3693,17 +3560,18 @@ InitializeCurrentSetting (
}
}
if (OldStorage == NULL) {
//
// Storage is not found in backup formset, request it from ConfigDriver
//
//
// Storage is not found in backup formset and current global storage not has other driver used,
// request it from ConfigDriver
//
if (OldStorage == NULL && Storage->BrowserStorage->ReferenceCount == 1) {
Status = LoadStorage (FormSet, Storage);
if (EFI_ERROR (Status)) {
//
// If get last time changed value failed, extract default from IFR binary
//
ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage, TRUE);
ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE);
//
// ExtractDefault will set the NV flag to TRUE, so need this function to clean the flag
// in current situation.
@ -3715,12 +3583,7 @@ InitializeCurrentSetting (
// Now Edit Buffer is filled with default values(lower priority) or current
// settings(higher priority), sychronize it to shadow Buffer
//
SynchronizeStorage (Storage, TRUE);
} else {
//
// Storage found in backup formset, use it
//
Status = CopyStorage (Storage, OldStorage);
SynchronizeStorage (Storage->BrowserStorage, TRUE);
}
Link = GetNextNode (&FormSet->StorageListHead, Link);

View File

@ -216,7 +216,7 @@ typedef struct {
#define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
#define FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'G')
#define BROWSER_STORAGE_SIGNATURE SIGNATURE_32 ('B', 'S', 'T', 'G')
typedef struct {
UINTN Signature;
@ -224,7 +224,6 @@ typedef struct {
UINT8 Type; // Storage type
UINT16 VarStoreId;
EFI_GUID Guid;
CHAR16 *Name; // For EFI_IFR_VARSTORE
@ -237,6 +236,21 @@ typedef struct {
UINT32 Attributes; // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute
CHAR16 *ConfigHdr; // <ConfigHdr>
UINT8 ReferenceCount; // How many form set storage refrence this storage.
} BROWSER_STORAGE;
#define BROWSER_STORAGE_FROM_LINK(a) CR (a, BROWSER_STORAGE, Link, BROWSER_STORAGE_SIGNATURE)
#define FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'G')
typedef struct {
UINTN Signature;
LIST_ENTRY Link;
UINT16 VarStoreId;
BROWSER_STORAGE *BrowserStorage;
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
@ -272,7 +286,7 @@ typedef struct {
EFI_STRING_ID DevicePath; // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3
EFI_GUID Guid;
FORMSET_STORAGE *VarStorage; // For EFI_IFR_SET, EFI_IFR_GET
BROWSER_STORAGE *VarStorage; // For EFI_IFR_SET, EFI_IFR_GET
VAR_STORE_INFO VarStoreInfo;// For EFI_IFR_SET, EFI_IFR_GET
UINT8 ValueType; // For EFI_IFR_SET, EFI_IFR_GET
UINT8 ValueWidth; // For EFI_IFR_SET, EFI_IFR_GET
@ -372,7 +386,7 @@ typedef struct {
//
EFI_QUESTION_ID QuestionId; // The value of zero is reserved
EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no variable storage
FORMSET_STORAGE *Storage;
BROWSER_STORAGE *Storage;
VAR_STORE_INFO VarStoreInfo;
UINT16 StorageWidth;
UINT8 QuestionFlags;
@ -430,7 +444,7 @@ typedef struct {
UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
UINTN SpareStrLen;
FORMSET_STORAGE *Storage;
BROWSER_STORAGE *Storage;
} FORM_BROWSER_CONFIG_REQUEST;
#define FORM_BROWSER_CONFIG_REQUEST_FROM_LINK(a) CR (a, FORM_BROWSER_CONFIG_REQUEST, Link, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)
@ -909,7 +923,7 @@ CreateDialog (
**/
EFI_STATUS
GetValueByName (
IN FORMSET_STORAGE *Storage,
IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN OUT CHAR16 **Value,
IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
@ -929,7 +943,7 @@ GetValueByName (
**/
EFI_STATUS
SetValueByName (
IN FORMSET_STORAGE *Storage,
IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN CHAR16 *Value,
IN GET_SET_QUESTION_VALUE_WITH SetValueTo
@ -1111,7 +1125,7 @@ ExtractDefault (
IN UINT16 DefaultId,
IN BROWSER_SETTING_SCOPE SettingScope,
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
IN FORMSET_STORAGE *Storage,
IN BROWSER_STORAGE *Storage,
IN BOOLEAN RetrieveValueFirst
);
@ -1156,9 +1170,9 @@ LoadFormSetConfig (
/**
Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
@param Buffer The Storage to be conveted.
@param Storage The Storage to be conveted.
@param ConfigResp The returned <ConfigResp>.
@param SingleForm Whether update data for single form or formset level.
@param ConfigRequest The ConfigRequest string.
@retval EFI_SUCCESS Convert success.
@retval EFI_INVALID_PARAMETER Incorrect storage type.
@ -1166,9 +1180,9 @@ LoadFormSetConfig (
**/
EFI_STATUS
StorageToConfigResp (
IN VOID *Buffer,
IN BROWSER_STORAGE *Storage,
IN CHAR16 **ConfigResp,
IN BOOLEAN SingleForm
IN CHAR16 *ConfigRequest
);
/**
@ -1183,7 +1197,7 @@ StorageToConfigResp (
**/
EFI_STATUS
ConfigRespToStorage (
IN FORMSET_STORAGE *Storage,
IN BROWSER_STORAGE *Storage,
IN CHAR16 *ConfigResp
);