Skip to content

Commit a35ecb7

Browse files
ydong10ydong10
authored and
ydong10
committed
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 <[email protected]> Reviewed-by: Liming Gao <[email protected]> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16680 6f19259b-4bc3-4df7-8a09-765794883524
1 parent 49a228c commit a35ecb7

File tree

3 files changed

+180
-58
lines changed

3 files changed

+180
-58
lines changed

MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c

Lines changed: 102 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @file
22
Parser for IFR binary encoding.
33
4-
Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
4+
Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
55
This program and the accompanying materials
66
are licensed and made available under the terms and conditions of the BSD License
77
which accompanies this distribution. The full text of the license may be found at
@@ -320,20 +320,20 @@ CreateExpression (
320320
EFI_STATUS
321321
InitializeConfigHdr (
322322
IN FORM_BROWSER_FORMSET *FormSet,
323-
IN OUT BROWSER_STORAGE *Storage
323+
IN OUT FORMSET_STORAGE *Storage
324324
)
325325
{
326326
CHAR16 *Name;
327327

328-
if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||
329-
Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
330-
Name = Storage->Name;
328+
if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||
329+
Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
330+
Name = Storage->BrowserStorage->Name;
331331
} else {
332332
Name = NULL;
333333
}
334334

335335
Storage->ConfigHdr = HiiConstructConfigHdr (
336-
&Storage->Guid,
336+
&Storage->BrowserStorage->Guid,
337337
Name,
338338
FormSet->DriverHandle
339339
);
@@ -559,29 +559,108 @@ CreateStorage (
559559
}
560560

561561
BrowserStorage->HiiHandle = FormSet->HiiHandle;
562-
InitializeConfigHdr (FormSet, BrowserStorage);
563562

564563
BrowserStorage->Initialized = FALSE;
565-
} else {
566-
if ((StorageType == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) &&
567-
(FormSet->DriverHandle != NULL) &&
568-
(!IsDevicePathExist (BrowserStorage->ConfigHdr))) {
569-
//
570-
// If this storage not has device path info but new formset has,
571-
// update the device path info.
572-
//
573-
FreePool (BrowserStorage->ConfigHdr);
574-
InitializeConfigHdr (FormSet, BrowserStorage);
575-
}
576564
}
577565

578566
Storage->BrowserStorage = BrowserStorage;
579-
Storage->ConfigRequest = AllocateCopyPool (StrSize (BrowserStorage->ConfigHdr), BrowserStorage->ConfigHdr);
567+
InitializeConfigHdr (FormSet, Storage);
568+
Storage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigHdr), Storage->ConfigHdr);
580569
Storage->SpareStrLen = 0;
581570

582571
return Storage;
583572
}
584573

574+
/**
575+
Get Formset_storage base on the input varstoreid info.
576+
577+
@param FormSet Pointer of the current FormSet.
578+
@param VarStoreId Varstore ID info.
579+
580+
@return Pointer to a FORMSET_STORAGE data structure.
581+
582+
**/
583+
FORMSET_STORAGE *
584+
GetFstStgFromVarId (
585+
IN FORM_BROWSER_FORMSET *FormSet,
586+
IN EFI_VARSTORE_ID VarStoreId
587+
)
588+
{
589+
FORMSET_STORAGE *FormsetStorage;
590+
LIST_ENTRY *Link;
591+
BOOLEAN Found;
592+
593+
Found = FALSE;
594+
FormsetStorage = NULL;
595+
//
596+
// Find Formset Storage for this Question
597+
//
598+
Link = GetFirstNode (&FormSet->StorageListHead);
599+
while (!IsNull (&FormSet->StorageListHead, Link)) {
600+
FormsetStorage = FORMSET_STORAGE_FROM_LINK (Link);
601+
602+
if (FormsetStorage->VarStoreId == VarStoreId) {
603+
Found = TRUE;
604+
break;
605+
}
606+
607+
Link = GetNextNode (&FormSet->StorageListHead, Link);
608+
}
609+
610+
return Found ? FormsetStorage : NULL;
611+
}
612+
613+
/**
614+
Get Formset_storage base on the input browser storage.
615+
616+
More than one formsets may share the same browser storage,
617+
this function just get the first formset storage which
618+
share the browser storage.
619+
620+
@param Storage browser storage info.
621+
622+
@return Pointer to a FORMSET_STORAGE data structure.
623+
624+
625+
**/
626+
FORMSET_STORAGE *
627+
GetFstStgFromBrsStg (
628+
IN BROWSER_STORAGE *Storage
629+
)
630+
{
631+
FORMSET_STORAGE *FormsetStorage;
632+
LIST_ENTRY *Link;
633+
LIST_ENTRY *FormsetLink;
634+
FORM_BROWSER_FORMSET *FormSet;
635+
BOOLEAN Found;
636+
637+
Found = FALSE;
638+
FormsetStorage = NULL;
639+
640+
FormsetLink = GetFirstNode (&gBrowserFormSetList);
641+
while (!IsNull (&gBrowserFormSetList, FormsetLink)) {
642+
FormSet = FORM_BROWSER_FORMSET_FROM_LINK (FormsetLink);
643+
FormsetLink = GetNextNode (&gBrowserFormSetList, FormsetLink);
644+
645+
Link = GetFirstNode (&FormSet->StorageListHead);
646+
while (!IsNull (&FormSet->StorageListHead, Link)) {
647+
FormsetStorage = FORMSET_STORAGE_FROM_LINK (Link);
648+
Link = GetNextNode (&FormSet->StorageListHead, Link);
649+
650+
if (FormsetStorage->BrowserStorage == Storage) {
651+
Found = TRUE;
652+
break;
653+
}
654+
}
655+
656+
if (Found) {
657+
break;
658+
}
659+
}
660+
661+
return Found ? FormsetStorage : NULL;
662+
}
663+
585664
/**
586665
Initialize Request Element of a Question. <RequestElement> ::= '&'<BlockName> | '&'<Label>
587666
@@ -651,17 +730,7 @@ InitializeRequestElement (
651730
//
652731
// Find Formset Storage for this Question
653732
//
654-
FormsetStorage = NULL;
655-
Link = GetFirstNode (&FormSet->StorageListHead);
656-
while (!IsNull (&FormSet->StorageListHead, Link)) {
657-
FormsetStorage = FORMSET_STORAGE_FROM_LINK (Link);
658-
659-
if (FormsetStorage->VarStoreId == Question->VarStoreId) {
660-
break;
661-
}
662-
663-
Link = GetNextNode (&FormSet->StorageListHead, Link);
664-
}
733+
FormsetStorage = GetFstStgFromVarId(FormSet, Question->VarStoreId);
665734
ASSERT (FormsetStorage != NULL);
666735

667736
//
@@ -695,7 +764,7 @@ InitializeRequestElement (
695764
while (!IsNull (&Form->ConfigRequestHead, Link)) {
696765
ConfigInfo = FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link);
697766

698-
if (ConfigInfo != NULL && ConfigInfo->Storage == Storage) {
767+
if (ConfigInfo != NULL && ConfigInfo->Storage == FormsetStorage->BrowserStorage) {
699768
Find = TRUE;
700769
break;
701770
}
@@ -707,10 +776,10 @@ InitializeRequestElement (
707776
ConfigInfo = AllocateZeroPool(sizeof (FORM_BROWSER_CONFIG_REQUEST));
708777
ASSERT (ConfigInfo != NULL);
709778
ConfigInfo->Signature = FORM_BROWSER_CONFIG_REQUEST_SIGNATURE;
710-
ConfigInfo->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigHdr), Storage->ConfigHdr);
779+
ConfigInfo->ConfigRequest = AllocateCopyPool (StrSize (FormsetStorage->ConfigHdr), FormsetStorage->ConfigHdr);
711780
ASSERT (ConfigInfo->ConfigRequest != NULL);
712781
ConfigInfo->SpareStrLen = 0;
713-
ConfigInfo->Storage = Storage;
782+
ConfigInfo->Storage = FormsetStorage->BrowserStorage;
714783
InsertTailList(&Form->ConfigRequestHead, &ConfigInfo->Link);
715784
}
716785

0 commit comments

Comments
 (0)