From 300c1f0d354bbb4ec1c7a97bf508c656983f6eec Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Thu, 11 Dec 2014 08:03:19 +0000 Subject: [PATCH] MdeModulePkg: Update the device path info for the storage when former drivers not provide it. 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@16499 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/SetupBrowserDxe/IfrParse.c | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index d3b1186427..e9cdea0e8b 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -451,6 +451,42 @@ IntializeBrowserStorage ( } } +/** + Check whether exist device path info in the ConfigHdr string. + + @param String UEFI configuration string + + @retval TRUE Device Path exist. + @retval FALSE Not exist device path info. + +**/ +BOOLEAN +IsDevicePathExist ( + IN EFI_STRING String + ) +{ + UINTN Length; + EFI_STRING PathHdr; + + for (; (*String != 0 && StrnCmp (String, L"PATH=", StrLen (L"PATH=")) != 0); String++); + if (*String == 0) { + return FALSE; + } + + String += StrLen (L"PATH="); + if (*String == 0) { + return FALSE; + } + PathHdr = String; + + for (Length = 0; *String != 0 && *String != L'&'; String++, Length++); + if (((Length + 1) / 2) < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { + return FALSE; + } + + return TRUE; +} + /** Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List. @@ -528,6 +564,17 @@ CreateStorage ( 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; -- 2.39.2