From a35ecb7584677b84b65028b7865243f76e7ecf0c Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Fri, 30 Jan 2015 05:35:30 +0000 Subject: [PATCH] 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 Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16680 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/SetupBrowserDxe/IfrParse.c | 135 +++++++++++++----- .../Universal/SetupBrowserDxe/Setup.c | 65 ++++++--- .../Universal/SetupBrowserDxe/Setup.h | 38 ++++- 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.
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
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,29 +559,108 @@ 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. ::= '&' | '&'