summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorEric Dong <eric.dong@intel.com>2015-01-30 05:35:30 +0000
committerydong10 <ydong10@Edk2>2015-01-30 05:35:30 +0000
commita35ecb7584677b84b65028b7865243f76e7ecf0c (patch)
tree200f10cf62833e7d2c2aa229f7cdbb6682ba06a1 /MdeModulePkg
parent49a228ca6980b197bb854dc88c909d712959cb47 (diff)
downloadedk2-a35ecb7584677b84b65028b7865243f76e7ecf0c.tar.gz
edk2-a35ecb7584677b84b65028b7865243f76e7ecf0c.tar.bz2
edk2-a35ecb7584677b84b65028b7865243f76e7ecf0c.zip
Move ConfigHdr from browser_storage to Formset_storage, avoid device path lost for drivers.
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@16680 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c135
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.c65
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.h38
3 files changed, 180 insertions, 58 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index d82e08ed91..0e9c82363d 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -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 @@ CreateExpression (
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 @@ CreateStorage (
}
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 @@ InitializeRequestElement (
//
// 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 @@ InitializeRequestElement (
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 @@ InitializeRequestElement (
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);
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index fb88956a24..964682399c 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -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 @@ ProcessStorage (
CHAR16 *StrPtr;
UINTN BufferSize;
UINTN TmpSize;
+ FORMSET_STORAGE *BrowserStorage;
if (RetrieveData) {
//
@@ -635,10 +636,12 @@ ProcessStorage (
// 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 @@ ProcessStorage (
//
// 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);
@@ -1217,6 +1222,7 @@ StorageToConfigResp (
LIST_ENTRY *Link;
NAME_VALUE_NODE *Node;
UINT8 *SourceBuf;
+ FORMSET_STORAGE *FormsetStorage;
Status = EFI_SUCCESS;
@@ -1236,7 +1242,9 @@ StorageToConfigResp (
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)) {
@@ -1475,6 +1483,7 @@ GetQuestionValue (
UINTN StorageWidth;
EFI_TIME EfiTime;
BROWSER_STORAGE *Storage;
+ FORMSET_STORAGE *FormsetStorage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigRequest;
CHAR16 *Progress;
@@ -1659,21 +1668,23 @@ GetQuestionValue (
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 {
@@ -1771,6 +1782,7 @@ SetQuestionValue (
UINTN BufferLen;
UINTN StorageWidth;
BROWSER_STORAGE *Storage;
+ FORMSET_STORAGE *FormsetStorage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigResp;
CHAR16 *Progress;
@@ -1965,10 +1977,12 @@ SetQuestionValue (
} 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=");
@@ -2681,6 +2695,11 @@ FindQuestionFromProgress (
*RetQuestion = Statement;
break;
}
+
+ if (Statement->VariableName != NULL && StrStr (Statement->VariableName, Progress) != NULL) {
+ *RetQuestion = Statement;
+ break;
+ }
}
}
@@ -4645,13 +4664,13 @@ RemoveElement (
/**
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
)
{
@@ -4666,7 +4685,7 @@ RemoveConfigRequest (
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
//
@@ -4681,7 +4700,7 @@ RemoveConfigRequest (
//
// 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);
@@ -4705,7 +4724,7 @@ RemoveConfigRequest (
*NextRequestElement = L'\0';
}
- RemoveElement (Storage, RequestElement);
+ RemoveElement (Storage->BrowserStorage, RequestElement);
if (NextRequestElement != NULL) {
//
@@ -4720,10 +4739,10 @@ RemoveConfigRequest (
//
// 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;
}
}
@@ -4751,7 +4770,7 @@ CleanBrowserStorage (
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) {
@@ -5011,14 +5030,14 @@ LoadStorage (
// 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;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
index f431bb0f36..9a300fa966 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
@@ -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 @@ typedef struct {
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 @@ typedef struct {
BROWSER_STORAGE *BrowserStorage;
+ CHAR16 *ConfigHdr; // <ConfigHdr>
+
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
CHAR16 *ConfigAltResp; // Alt config response string for this ConfigRequest.
BOOLEAN HasCallAltCfg; // Flag to show whether browser has call ExtractConfig to get Altcfg string.
@@ -1795,4 +1796,37 @@ IsTrue (
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