mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 07:34:06 +02:00
Refine the load form sets process for BrowserCallback function.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Liming, Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15434 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
ad43bc6b2e
commit
9d34cac819
@ -608,14 +608,6 @@ BrowserCallback (
|
|||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
//
|
|
||||||
// If set browser data, pre load all hii formset to avoid set the varstore which is not
|
|
||||||
// saved in browser.
|
|
||||||
//
|
|
||||||
if (!RetrieveData && (gBrowserSettingScope == SystemLevel)) {
|
|
||||||
LoadAllHiiFormset();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VariableGuid != NULL) {
|
if (VariableGuid != NULL) {
|
||||||
//
|
//
|
||||||
// Try to find target storage in the current formset.
|
// Try to find target storage in the current formset.
|
||||||
@ -661,6 +653,10 @@ BrowserCallback (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
|
||||||
|
ConfigRequestAdjust (Storage, ResultsData, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Different formsets may have same varstore, so here just set the flag
|
// Different formsets may have same varstore, so here just set the flag
|
||||||
// not exit the circle.
|
// not exit the circle.
|
||||||
@ -3707,7 +3703,6 @@ CleanBrowserStorage (
|
|||||||
{
|
{
|
||||||
LIST_ENTRY *Link;
|
LIST_ENTRY *Link;
|
||||||
FORMSET_STORAGE *Storage;
|
FORMSET_STORAGE *Storage;
|
||||||
CHAR16 *ConfigRequest;
|
|
||||||
|
|
||||||
Link = GetFirstNode (&FormSet->StorageListHead);
|
Link = GetFirstNode (&FormSet->StorageListHead);
|
||||||
while (!IsNull (&FormSet->StorageListHead, Link)) {
|
while (!IsNull (&FormSet->StorageListHead, Link)) {
|
||||||
@ -3719,8 +3714,7 @@ CleanBrowserStorage (
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigRequest = FormSet->QuestionInited ? Storage->ConfigRequest : Storage->ConfigElements;
|
RemoveConfigRequest (Storage->BrowserStorage, Storage->ConfigRequest);
|
||||||
RemoveConfigRequest (Storage->BrowserStorage, ConfigRequest);
|
|
||||||
} else if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||
|
} else if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||
|
||||||
Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
||||||
if (Storage->BrowserStorage->ConfigRequest != NULL) {
|
if (Storage->BrowserStorage->ConfigRequest != NULL) {
|
||||||
@ -3799,6 +3793,8 @@ AppendConfigRequest (
|
|||||||
Adjust the config request info, remove the request elements which already in AllConfigRequest string.
|
Adjust the config request info, remove the request elements which already in AllConfigRequest string.
|
||||||
|
|
||||||
@param Storage Form set Storage.
|
@param Storage Form set Storage.
|
||||||
|
@param Request The input request string.
|
||||||
|
@param RespString Whether the input is ConfigRequest or ConfigResp format.
|
||||||
|
|
||||||
@retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig
|
@retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig
|
||||||
@retval FALSE All elements covered by current used elements.
|
@retval FALSE All elements covered by current used elements.
|
||||||
@ -3806,30 +3802,37 @@ AppendConfigRequest (
|
|||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
ConfigRequestAdjust (
|
ConfigRequestAdjust (
|
||||||
IN FORMSET_STORAGE *Storage
|
IN BROWSER_STORAGE *Storage,
|
||||||
|
IN CHAR16 *Request,
|
||||||
|
IN BOOLEAN RespString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CHAR16 *RequestElement;
|
CHAR16 *RequestElement;
|
||||||
CHAR16 *NextRequestElement;
|
CHAR16 *NextRequestElement;
|
||||||
CHAR16 *RetBuf;
|
CHAR16 *NextElementBakup;
|
||||||
UINTN SpareBufLen;
|
UINTN SpareBufLen;
|
||||||
CHAR16 *SearchKey;
|
CHAR16 *SearchKey;
|
||||||
|
CHAR16 *ValueKey;
|
||||||
BOOLEAN RetVal;
|
BOOLEAN RetVal;
|
||||||
|
CHAR16 *ConfigRequest;
|
||||||
|
|
||||||
SpareBufLen = 0;
|
SpareBufLen = 0;
|
||||||
RetBuf = NULL;
|
|
||||||
RetVal = FALSE;
|
RetVal = FALSE;
|
||||||
|
NextElementBakup = NULL;
|
||||||
|
ValueKey = NULL;
|
||||||
|
|
||||||
if (Storage->BrowserStorage->ConfigRequest == NULL) {
|
if (Request != NULL) {
|
||||||
Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest);
|
ConfigRequest = Request;
|
||||||
if (Storage->ConfigElements != NULL) {
|
} else {
|
||||||
FreePool (Storage->ConfigElements);
|
ConfigRequest = Storage->ConfigRequest;
|
||||||
}
|
}
|
||||||
Storage->ConfigElements = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest);
|
|
||||||
|
if (Storage->ConfigRequest == NULL) {
|
||||||
|
Storage->ConfigRequest = AllocateCopyPool (StrSize (ConfigRequest), ConfigRequest);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
||||||
//
|
//
|
||||||
// "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage
|
// "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage
|
||||||
//
|
//
|
||||||
@ -3839,26 +3842,22 @@ ConfigRequestAdjust (
|
|||||||
// "&OFFSET=####&WIDTH=####" section for EFI_HII_VARSTORE_BUFFER storage
|
// "&OFFSET=####&WIDTH=####" section for EFI_HII_VARSTORE_BUFFER storage
|
||||||
//
|
//
|
||||||
SearchKey = L"&OFFSET";
|
SearchKey = L"&OFFSET";
|
||||||
|
ValueKey = L"&VALUE";
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare the config header.
|
|
||||||
//
|
|
||||||
RetBuf = AllocateCopyPool(StrSize (Storage->BrowserStorage->ConfigHdr), Storage->BrowserStorage->ConfigHdr);
|
|
||||||
ASSERT (RetBuf != NULL);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find SearchKey storage
|
// Find SearchKey storage
|
||||||
//
|
//
|
||||||
if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
||||||
RequestElement = StrStr (Storage->ConfigRequest, L"PATH");
|
RequestElement = StrStr (ConfigRequest, L"PATH");
|
||||||
ASSERT (RequestElement != NULL);
|
ASSERT (RequestElement != NULL);
|
||||||
RequestElement = StrStr (RequestElement, SearchKey);
|
RequestElement = StrStr (RequestElement, SearchKey);
|
||||||
} else {
|
} else {
|
||||||
RequestElement = StrStr (Storage->ConfigRequest, SearchKey);
|
RequestElement = StrStr (ConfigRequest, SearchKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (RequestElement != NULL) {
|
while (RequestElement != NULL) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// +1 to avoid find header itself.
|
// +1 to avoid find header itself.
|
||||||
//
|
//
|
||||||
@ -3868,18 +3867,30 @@ ConfigRequestAdjust (
|
|||||||
// The last Request element in configRequest string.
|
// The last Request element in configRequest string.
|
||||||
//
|
//
|
||||||
if (NextRequestElement != NULL) {
|
if (NextRequestElement != NULL) {
|
||||||
|
if (RespString && (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {
|
||||||
|
NextElementBakup = NextRequestElement;
|
||||||
|
NextRequestElement = StrStr (RequestElement, ValueKey);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Replace "&" with '\0'.
|
// Replace "&" with '\0'.
|
||||||
//
|
//
|
||||||
*NextRequestElement = L'\0';
|
*NextRequestElement = L'\0';
|
||||||
|
} else {
|
||||||
|
if (RespString && (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {
|
||||||
|
NextElementBakup = NextRequestElement;
|
||||||
|
NextRequestElement = StrStr (RequestElement, ValueKey);
|
||||||
|
//
|
||||||
|
// Replace "&" with '\0'.
|
||||||
|
//
|
||||||
|
*NextRequestElement = L'\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ElementValidation (Storage->BrowserStorage, RequestElement)) {
|
if (!ElementValidation (Storage, RequestElement)) {
|
||||||
//
|
//
|
||||||
// Add this element to the Storage->BrowserStorage->AllRequestElement.
|
// Add this element to the Storage->BrowserStorage->AllRequestElement.
|
||||||
//
|
//
|
||||||
AppendConfigRequest(&Storage->BrowserStorage->ConfigRequest, &Storage->BrowserStorage->SpareStrLen, RequestElement);
|
AppendConfigRequest(&Storage->ConfigRequest, &Storage->SpareStrLen, RequestElement);
|
||||||
AppendConfigRequest (&RetBuf, &SpareBufLen, RequestElement);
|
|
||||||
RetVal = TRUE;
|
RetVal = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3890,16 +3901,11 @@ ConfigRequestAdjust (
|
|||||||
*NextRequestElement = L'&';
|
*NextRequestElement = L'&';
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestElement = NextRequestElement;
|
if (RespString && (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {
|
||||||
}
|
RequestElement = NextElementBakup;
|
||||||
|
} else {
|
||||||
if (RetVal) {
|
RequestElement = NextRequestElement;
|
||||||
if (Storage->ConfigElements != NULL) {
|
|
||||||
FreePool (Storage->ConfigElements);
|
|
||||||
}
|
}
|
||||||
Storage->ConfigElements = RetBuf;
|
|
||||||
} else {
|
|
||||||
FreePool (RetBuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return RetVal;
|
return RetVal;
|
||||||
@ -4082,7 +4088,7 @@ LoadStorage (
|
|||||||
|
|
||||||
case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
|
case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
|
||||||
if (Storage->BrowserStorage->ConfigRequest != NULL) {
|
if (Storage->BrowserStorage->ConfigRequest != NULL) {
|
||||||
ConfigRequestAdjust(Storage);
|
ConfigRequestAdjust(Storage->BrowserStorage, Storage->ConfigRequest, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4100,7 +4106,7 @@ LoadStorage (
|
|||||||
// Just update the ConfigRequest, if storage already initialized.
|
// Just update the ConfigRequest, if storage already initialized.
|
||||||
//
|
//
|
||||||
if (Storage->BrowserStorage->Initialized) {
|
if (Storage->BrowserStorage->Initialized) {
|
||||||
ConfigRequestAdjust(Storage);
|
ConfigRequestAdjust(Storage->BrowserStorage, Storage->ConfigRequest, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,6 @@ typedef struct {
|
|||||||
BROWSER_STORAGE *BrowserStorage;
|
BROWSER_STORAGE *BrowserStorage;
|
||||||
|
|
||||||
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
|
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
|
||||||
CHAR16 *ConfigElements;// Elements need to load initial data.
|
|
||||||
UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
|
UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
|
||||||
UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
|
UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
|
||||||
} FORMSET_STORAGE;
|
} FORMSET_STORAGE;
|
||||||
@ -1657,4 +1656,22 @@ DevicePathToHiiHandle (
|
|||||||
IN EFI_GUID *FormsetGuid
|
IN EFI_GUID *FormsetGuid
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Adjust the config request info, remove the request elements which already in AllConfigRequest string.
|
||||||
|
|
||||||
|
@param Storage Form set Storage.
|
||||||
|
@param Request The input request string.
|
||||||
|
@param RespString Whether the input is ConfigRequest or ConfigResp format.
|
||||||
|
|
||||||
|
@retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig
|
||||||
|
@retval FALSE All elements covered by current used elements.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
ConfigRequestAdjust (
|
||||||
|
IN BROWSER_STORAGE *Storage,
|
||||||
|
IN CHAR16 *Request,
|
||||||
|
IN BOOLEAN RespString
|
||||||
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user