Revision: 16764
http://sourceforge.net/p/edk2/code/16764
Author: vanjeff
Date: 2015-02-05 06:00:42 +0000 (Thu, 05 Feb 2015)
Log Message:
-----------
Move ConfigHdr from browser_storage to Formset_storage, avoid device path lost
for drivers.
(Sync patch r16680 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/16680
Modified Paths:
--------------
branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
Modified: branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
===================================================================
--- branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
2015-02-05 05:37:10 UTC (rev 16763)
+++ branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
2015-02-05 06:00:42 UTC (rev 16764)
@@ -1,7 +1,7 @@
/** @file
Parser for IFR binary encoding.
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD
License
which accompanies this distribution. The full text of the license may be
found at
@@ -320,20 +320,20 @@
EFI_STATUS
InitializeConfigHdr (
IN FORM_BROWSER_FORMSET *FormSet,
- IN OUT BROWSER_STORAGE *Storage
+ IN OUT FORMSET_STORAGE *Storage
)
{
CHAR16 *Name;
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||
- Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
- Name = Storage->Name;
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||
+ Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
+ Name = Storage->BrowserStorage->Name;
} else {
Name = NULL;
}
Storage->ConfigHdr = HiiConstructConfigHdr (
- &Storage->Guid,
+ &Storage->BrowserStorage->Guid,
Name,
FormSet->DriverHandle
);
@@ -559,30 +559,109 @@
}
BrowserStorage->HiiHandle = FormSet->HiiHandle;
- InitializeConfigHdr (FormSet, BrowserStorage);
BrowserStorage->Initialized = FALSE;
- } else {
- if ((StorageType == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) &&
- (FormSet->DriverHandle != NULL) &&
- (!IsDevicePathExist (BrowserStorage->ConfigHdr))) {
- //
- // If this storage not has device path info but new formset has,
- // update the device path info.
- //
- FreePool (BrowserStorage->ConfigHdr);
- InitializeConfigHdr (FormSet, BrowserStorage);
- }
}
Storage->BrowserStorage = BrowserStorage;
- Storage->ConfigRequest = AllocateCopyPool (StrSize
(BrowserStorage->ConfigHdr), BrowserStorage->ConfigHdr);
+ InitializeConfigHdr (FormSet, Storage);
+ Storage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigHdr),
Storage->ConfigHdr);
Storage->SpareStrLen = 0;
return Storage;
}
/**
+ Get Formset_storage base on the input varstoreid info.
+
+ @param FormSet Pointer of the current FormSet.
+ @param VarStoreId Varstore ID info.
+
+ @return Pointer to a FORMSET_STORAGE data structure.
+
+**/
+FORMSET_STORAGE *
+GetFstStgFromVarId (
+ IN FORM_BROWSER_FORMSET *FormSet,
+ IN EFI_VARSTORE_ID VarStoreId
+ )
+{
+ FORMSET_STORAGE *FormsetStorage;
+ LIST_ENTRY *Link;
+ BOOLEAN Found;
+
+ Found = FALSE;
+ FormsetStorage = NULL;
+ //
+ // Find Formset Storage for this Question
+ //
+ Link = GetFirstNode (&FormSet->StorageListHead);
+ while (!IsNull (&FormSet->StorageListHead, Link)) {
+ FormsetStorage = FORMSET_STORAGE_FROM_LINK (Link);
+
+ if (FormsetStorage->VarStoreId == VarStoreId) {
+ Found = TRUE;
+ break;
+ }
+
+ Link = GetNextNode (&FormSet->StorageListHead, Link);
+ }
+
+ return Found ? FormsetStorage : NULL;
+}
+
+/**
+ Get Formset_storage base on the input browser storage.
+
+ More than one formsets may share the same browser storage,
+ this function just get the first formset storage which
+ share the browser storage.
+
+ @param Storage browser storage info.
+
+ @return Pointer to a FORMSET_STORAGE data structure.
+
+
+**/
+FORMSET_STORAGE *
+GetFstStgFromBrsStg (
+ IN BROWSER_STORAGE *Storage
+ )
+{
+ FORMSET_STORAGE *FormsetStorage;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *FormsetLink;
+ FORM_BROWSER_FORMSET *FormSet;
+ BOOLEAN Found;
+
+ Found = FALSE;
+ FormsetStorage = NULL;
+
+ FormsetLink = GetFirstNode (&gBrowserFormSetList);
+ while (!IsNull (&gBrowserFormSetList, FormsetLink)) {
+ FormSet = FORM_BROWSER_FORMSET_FROM_LINK (FormsetLink);
+ FormsetLink = GetNextNode (&gBrowserFormSetList, FormsetLink);
+
+ Link = GetFirstNode (&FormSet->StorageListHead);
+ while (!IsNull (&FormSet->StorageListHead, Link)) {
+ FormsetStorage = FORMSET_STORAGE_FROM_LINK (Link);
+ Link = GetNextNode (&FormSet->StorageListHead, Link);
+
+ if (FormsetStorage->BrowserStorage == Storage) {
+ Found = TRUE;
+ break;
+ }
+ }
+
+ if (Found) {
+ break;
+ }
+ }
+
+ return Found ? FormsetStorage : NULL;
+}
+
+/**
Initialize Request Element of a Question. <RequestElement> ::=
'&'<BlockName> | '&'<Label>
@param FormSet Pointer of the current FormSet.
@@ -651,17 +730,7 @@
//
// 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);
- }
+ FormsetStorage = GetFstStgFromVarId(FormSet, Question->VarStoreId);
ASSERT (FormsetStorage != NULL);
//
@@ -695,7 +764,7 @@
while (!IsNull (&Form->ConfigRequestHead, Link)) {
ConfigInfo = FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link);
- if (ConfigInfo != NULL && ConfigInfo->Storage == Storage) {
+ if (ConfigInfo != NULL && ConfigInfo->Storage ==
FormsetStorage->BrowserStorage) {
Find = TRUE;
break;
}
@@ -707,10 +776,10 @@
ConfigInfo = AllocateZeroPool(sizeof (FORM_BROWSER_CONFIG_REQUEST));
ASSERT (ConfigInfo != NULL);
ConfigInfo->Signature = FORM_BROWSER_CONFIG_REQUEST_SIGNATURE;
- ConfigInfo->ConfigRequest = AllocateCopyPool (StrSize
(Storage->ConfigHdr), Storage->ConfigHdr);
+ ConfigInfo->ConfigRequest = AllocateCopyPool (StrSize
(FormsetStorage->ConfigHdr), FormsetStorage->ConfigHdr);
ASSERT (ConfigInfo->ConfigRequest != NULL);
ConfigInfo->SpareStrLen = 0;
- ConfigInfo->Storage = Storage;
+ ConfigInfo->Storage = FormsetStorage->BrowserStorage;
InsertTailList(&Form->ConfigRequestHead, &ConfigInfo->Link);
}
Modified: branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
===================================================================
--- branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
2015-02-05 05:37:10 UTC (rev 16763)
+++ branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
2015-02-05 06:00:42 UTC (rev 16764)
@@ -1,7 +1,7 @@
/** @file
Entry and initialization module for the browser.
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD
License
which accompanies this distribution. The full text of the license may be
found at
@@ -621,6 +621,7 @@
CHAR16 *StrPtr;
UINTN BufferSize;
UINTN TmpSize;
+ FORMSET_STORAGE *BrowserStorage;
if (RetrieveData) {
//
@@ -635,10 +636,12 @@
// Skip <ConfigHdr> and '&' to point to <ConfigBody> when first copy the
configbody.
// Also need to consider add "\0" at first time.
//
- StrPtr = ConfigResp + StrLen (Storage->ConfigHdr) + 1;
+ StrPtr = StrStr (ConfigResp, L"PATH");
+ ASSERT (StrPtr != NULL);
+ StrPtr = StrStr (StrPtr, L"&");
+ StrPtr += 1;
BufferSize = StrSize (StrPtr);
-
//
// Copy the data if the input buffer is bigger enough.
//
@@ -652,12 +655,14 @@
//
// Prepare <ConfigResp>
//
+ BrowserStorage = GetFstStgFromBrsStg (Storage);
+ ASSERT (BrowserStorage != NULL);
TmpSize = StrLen (*ResultsData);
- BufferSize = (TmpSize + StrLen (Storage->ConfigHdr) + 2) * sizeof (CHAR16);
+ BufferSize = (TmpSize + StrLen (BrowserStorage->ConfigHdr) + 2) * sizeof
(CHAR16);
ConfigResp = AllocateZeroPool (BufferSize);
ASSERT (ConfigResp != NULL);
- StrCpy (ConfigResp, Storage->ConfigHdr);
+ StrCpy (ConfigResp, BrowserStorage->ConfigHdr);
StrCat (ConfigResp, L"&");
StrCat (ConfigResp, *ResultsData);
@@ -1219,6 +1224,7 @@
LIST_ENTRY *Link;
NAME_VALUE_NODE *Node;
UINT8 *SourceBuf;
+ FORMSET_STORAGE *FormsetStorage;
Status = EFI_SUCCESS;
@@ -1238,7 +1244,9 @@
case EFI_HII_VARSTORE_NAME_VALUE:
*ConfigResp = NULL;
- NewStringCat (ConfigResp, Storage->ConfigHdr);
+ FormsetStorage = GetFstStgFromBrsStg(Storage);
+ ASSERT (FormsetStorage != NULL);
+ NewStringCat (ConfigResp, FormsetStorage->ConfigHdr);
Link = GetFirstNode (&Storage->NameValueListHead);
while (!IsNull (&Storage->NameValueListHead, Link)) {
@@ -1373,6 +1381,7 @@
UINTN StorageWidth;
EFI_TIME EfiTime;
BROWSER_STORAGE *Storage;
+ FORMSET_STORAGE *FormsetStorage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigRequest;
CHAR16 *Progress;
@@ -1602,21 +1611,23 @@
FreePool (Value);
}
} else {
+ FormsetStorage = GetFstStgFromVarId(FormSet, Question->VarStoreId);
+ ASSERT (FormsetStorage != NULL);
//
// <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||
// <ConfigHdr> + "&" + <VariableName>
//
if (IsBufferStorage) {
- Length = StrLen (Storage->ConfigHdr);
+ Length = StrLen (FormsetStorage->ConfigHdr);
Length += StrLen (Question->BlockName);
} else {
- Length = StrLen (Storage->ConfigHdr);
+ Length = StrLen (FormsetStorage->ConfigHdr);
Length += StrLen (Question->VariableName) + 1;
}
ConfigRequest = AllocateZeroPool ((Length + 1) * sizeof (CHAR16));
ASSERT (ConfigRequest != NULL);
- StrCpy (ConfigRequest, Storage->ConfigHdr);
+ StrCpy (ConfigRequest, FormsetStorage->ConfigHdr);
if (IsBufferStorage) {
StrCat (ConfigRequest, Question->BlockName);
} else {
@@ -1761,6 +1772,7 @@
UINTN BufferLen;
UINTN StorageWidth;
BROWSER_STORAGE *Storage;
+ FORMSET_STORAGE *FormsetStorage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigResp;
CHAR16 *Progress;
@@ -1955,10 +1967,12 @@
} else {
Length += (StorageWidth * 2);
}
- ConfigResp = AllocateZeroPool ((StrLen (Storage->ConfigHdr) + Length + 1)
* sizeof (CHAR16));
+ FormsetStorage = GetFstStgFromVarId(FormSet, Question->VarStoreId);
+ ASSERT (FormsetStorage != NULL);
+ ConfigResp = AllocateZeroPool ((StrLen (FormsetStorage->ConfigHdr) +
Length + 1) * sizeof (CHAR16));
ASSERT (ConfigResp != NULL);
- StrCpy (ConfigResp, Storage->ConfigHdr);
+ StrCpy (ConfigResp, FormsetStorage->ConfigHdr);
if (IsBufferStorage) {
StrCat (ConfigResp, Question->BlockName);
StrCat (ConfigResp, L"&VALUE=");
@@ -2671,6 +2685,11 @@
*RetQuestion = Statement;
break;
}
+
+ if (Statement->VariableName != NULL && StrStr
(Statement->VariableName, Progress) != NULL) {
+ *RetQuestion = Statement;
+ break;
+ }
}
}
@@ -3393,6 +3412,7 @@
BOOLEAN IsString;
UINTN Length;
BROWSER_STORAGE *Storage;
+ FORMSET_STORAGE *FormsetStorage;
CHAR16 *ConfigRequest;
CHAR16 *Progress;
CHAR16 *Result;
@@ -3445,17 +3465,19 @@
// <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||
// <ConfigHdr> + "&" + <VariableName>
//
+ FormsetStorage = GetFstStgFromVarId (FormSet, Question->VarStoreId);
+ ASSERT (FormsetStorage != NULL);
+ Length = StrLen (FormsetStorage->ConfigHdr);
+
if (IsBufferStorage) {
- Length = StrLen (Storage->ConfigHdr);
Length += StrLen (Question->BlockName);
} else {
- Length = StrLen (Storage->ConfigHdr);
Length += StrLen (Question->VariableName) + 1;
}
ConfigRequest = AllocateZeroPool ((Length + 1) * sizeof (CHAR16));
ASSERT (ConfigRequest != NULL);
- StrCpy (ConfigRequest, Storage->ConfigHdr);
+ StrCpy (ConfigRequest, FormsetStorage->ConfigHdr);
if (IsBufferStorage) {
StrCat (ConfigRequest, Question->BlockName);
} else {
@@ -4399,13 +4421,13 @@
/**
Adjust config request in storage, remove the request elements existed in the
input ConfigRequest.
- @param Storage Pointer to the browser storage.
+ @param Storage Pointer to the formset storage.
@param ConfigRequest The pointer to the Request element.
**/
VOID
RemoveConfigRequest (
- BROWSER_STORAGE *Storage,
+ FORMSET_STORAGE *Storage,
CHAR16 *ConfigRequest
)
{
@@ -4420,7 +4442,7 @@
return;
}
- if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
//
// "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage
//
@@ -4435,7 +4457,7 @@
//
// Find SearchKey storage
//
- if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
RequestElement = StrStr (ConfigRequest, L"PATH");
ASSERT (RequestElement != NULL);
RequestElement = StrStr (RequestElement, SearchKey);
@@ -4459,7 +4481,7 @@
*NextRequestElement = L'\0';
}
- RemoveElement (Storage, RequestElement);
+ RemoveElement (Storage->BrowserStorage, RequestElement);
if (NextRequestElement != NULL) {
//
@@ -4474,10 +4496,10 @@
//
// If no request element remain, just remove the ConfigRequest string.
//
- if (StrCmp (Storage->ConfigRequest, Storage->ConfigHdr) == 0) {
- FreePool (Storage->ConfigRequest);
- Storage->ConfigRequest = NULL;
- Storage->SpareStrLen = 0;
+ if (StrCmp (Storage->BrowserStorage->ConfigRequest, Storage->ConfigHdr) ==
0) {
+ FreePool (Storage->BrowserStorage->ConfigRequest);
+ Storage->BrowserStorage->ConfigRequest = NULL;
+ Storage->BrowserStorage->SpareStrLen = 0;
}
}
@@ -4505,7 +4527,7 @@
continue;
}
- RemoveConfigRequest (Storage->BrowserStorage, Storage->ConfigRequest);
+ RemoveConfigRequest (Storage, Storage->ConfigRequest);
} else if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||
Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
if (Storage->BrowserStorage->ConfigRequest != NULL) {
@@ -4919,14 +4941,14 @@
// Allocate and fill a buffer large enough to hold the <ConfigHdr> template
// followed by "&OFFSET=0&WIDTH=WWWW"followed by a Null-terminator
//
- StrLen = StrSize (Storage->BrowserStorage->ConfigHdr) + 20 * sizeof
(CHAR16);
+ StrLen = StrSize (Storage->ConfigHdr) + 20 * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (StrLen);
ASSERT (ConfigRequest != NULL);
UnicodeSPrint (
ConfigRequest,
StrLen,
L"%s&OFFSET=0&WIDTH=%04x",
- Storage->BrowserStorage->ConfigHdr,
+ Storage->ConfigHdr,
Storage->BrowserStorage->Size);
} else {
ConfigRequest = Storage->ConfigRequest;
Modified: branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
===================================================================
--- branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
2015-02-05 05:37:10 UTC (rev 16763)
+++ branches/UDK2014.SP1/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
2015-02-05 06:00:42 UTC (rev 16764)
@@ -1,7 +1,7 @@
/** @file
Private MACRO, structure and function definitions for Setup Browser module.
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD
License
which accompanies this distribution. The full text of the license may be
found at
@@ -150,7 +150,6 @@
UINT32 Attributes; // For EFI_IFR_VARSTORE_EFI: EFI Variable
attribute
- CHAR16 *ConfigHdr; // <ConfigHdr>
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> +
<RequestElement>
// <RequestElement> includes all fields
which is used by current form sets.
UINTN SpareStrLen; // Spare length of ConfigRequest string
buffer
@@ -170,6 +169,8 @@
BROWSER_STORAGE *BrowserStorage;
+ CHAR16 *ConfigHdr; // <ConfigHdr>
+
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> +
<RequestElement>
UINTN ElementCount; // Number of <RequestElement> in the
<ConfigRequest>
UINTN SpareStrLen; // Spare length of ConfigRequest string
buffer
@@ -1790,4 +1791,37 @@
IN EFI_HII_VALUE *Result
);
+/**
+ Get Formset_storage base on the input varstoreid info.
+
+ @param FormSet Pointer of the current FormSet.
+ @param VarStoreId Varstore ID info.
+
+ @return Pointer to a FORMSET_STORAGE data structure.
+
+**/
+FORMSET_STORAGE *
+GetFstStgFromVarId (
+ IN FORM_BROWSER_FORMSET *FormSet,
+ IN EFI_VARSTORE_ID VarStoreId
+ );
+
+/**
+ Get Formset_storage base on the input browser storage.
+
+ More than one formsets may share the same browser storage,
+ this function just get the first formset storage which
+ share the browser storage.
+
+ @param Storage browser storage info.
+
+ @return Pointer to a FORMSET_STORAGE data structure.
+
+
+**/
+FORMSET_STORAGE *
+GetFstStgFromBrsStg (
+ IN BROWSER_STORAGE *Storage
+ );
+
#endif
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits