From 1d451ff9cf3427c5dc4ba1650d33b1b5aad76d7f Mon Sep 17 00:00:00 2001 From: lgao4 Date: Mon, 27 Apr 2009 04:55:02 +0000 Subject: [PATCH] Update HiiGetBrowserData API git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8176 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/BdsDxe/BootMaint/BootMaint.c | 22 +---- .../Universal/BdsDxe/BootMaint/FileExplorer.c | 7 +- MdeModulePkg/Include/Library/HiiLib.h | 13 +-- MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 98 ++++++------------- .../Universal/DriverSampleDxe/DriverSample.c | 12 ++- .../DriverSampleDxe/DriverSampleDxe.inf | 2 +- .../Universal/Network/IScsiDxe/IScsiConfig.c | 6 +- .../PlatDriOverrideDxe.c | 20 +--- 8 files changed, 55 insertions(+), 125 deletions(-) diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c index 1e8e593059..da5611d2de 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c @@ -271,18 +271,8 @@ BootMaintCallback ( // // Retrive uncommitted data from Form Browser // - CurrentFakeNVMap = (BMM_FAKE_NV_DATA *) HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA)); - DisMap = (UINT8 *) CurrentFakeNVMap; - for (Index = 0; Index < sizeof (BMM_FAKE_NV_DATA); Index ++) { - if (DisMap [Index] != 0) { - break; - } - } - - if (Index == sizeof (BMM_FAKE_NV_DATA)) { - FreePool (CurrentFakeNVMap); - CurrentFakeNVMap = &Private->BmmFakeNvData; - } + CurrentFakeNVMap = &Private->BmmFakeNvData; + HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap); // // need to be subtituded. @@ -595,14 +585,6 @@ BootMaintCallback ( // Status = HiiSetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap, NULL); - // - // Update local settting. - // - if (CurrentFakeNVMap != &Private->BmmFakeNvData) { - CopyMem (&Private->BmmFakeNvData, CurrentFakeNVMap, sizeof (BMM_FAKE_NV_DATA)); - FreePool (CurrentFakeNVMap); - } - return Status; } diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FileExplorer.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FileExplorer.c index 366aceda18..2cde6e0d0f 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FileExplorer.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FileExplorer.c @@ -260,13 +260,8 @@ FileExplorerCallback ( // // Retrieve uncommitted data from Form Browser // - NvRamMap = (FILE_EXPLORER_NV_DATA *) HiiGetBrowserData (&mFileExplorerGuid, mFileExplorerStorageName, sizeof (FILE_EXPLORER_NV_DATA)); - if (NvRamMap == NULL) { - return EFI_NOT_FOUND; - } - CopyMem (&Private->FeFakeNvData, NvRamMap, sizeof (FILE_EXPLORER_NV_DATA)); - FreePool (NvRamMap); NvRamMap = &Private->FeFakeNvData; + HiiGetBrowserData (&mFileExplorerGuid, mFileExplorerStorageName, sizeof (FILE_EXPLORER_NV_DATA), (UINT8 *) NvRamMap); if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_BOOT || QuestionId == KEY_VALUE_SAVE_AND_EXIT_DRIVER) { // diff --git a/MdeModulePkg/Include/Library/HiiLib.h b/MdeModulePkg/Include/Library/HiiLib.h index 3f0e096fba..7c561a69db 100644 --- a/MdeModulePkg/Include/Library/HiiLib.h +++ b/MdeModulePkg/Include/Library/HiiLib.h @@ -357,25 +357,26 @@ HiiIsConfigHdrMatch ( /** Retrieves uncommited data from the Form Browser and converts it to a binary - buffer. The returned buffer is allocated using AllocatePool(). The caller - is responsible for freeing the returned buffer using FreePool(). + buffer. @param[in] VariableName Pointer to a Null-terminated Unicode string. This is an optional parameter that may be NULL. @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional parameter that may be NULL. @param[in] BufferSize Length in bytes of buffer to hold retrived data. + @param[out] Block Buffer of data to be updated. - @retval NULL The uncommitted data could not be retrieved. - @retval Other A pointer to a buffer containing the uncommitted data. + @retval FALSE The uncommitted data could not be retrieved. + @retval TRUE The uncommitted data was retrieved. **/ -UINT8 * +BOOLEAN EFIAPI HiiGetBrowserData ( IN CONST EFI_GUID *VariableGuid, OPTIONAL IN CONST CHAR16 *VariableName, OPTIONAL - IN UINTN BlockSize + IN UINTN BlockSize, + OUT UINT8 *Block ); /** diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c index ea3c22348e..c8ef091ff7 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -446,63 +446,6 @@ InternalHiiBlockToConfig ( return ConfigResp; } -/** - Uses the ConfigToBlock() service of the Config Routing Protocol to - convert to a block. The block is allocated using - AllocatePool(). The caller is responsible for freeing the block - using FreePool(). - - If ConfigResp is NULL, then ASSERT(). - - @param[in] ConfigResp Pointer to a Null-terminated Unicode string. - @param[in] BufferSize Length in bytes of buffer to hold retrived data. - - @retval NULL The block could not be generated.. - @retval Other Pointer to the allocated block. - -**/ -UINT8 * -EFIAPI -InternalHiiConfigToBlock ( - IN EFI_STRING ConfigResp, - IN UINTN BlockSize - ) -{ - EFI_STATUS Status; - CHAR16 *Progress; - UINT8 *Block; - - ASSERT (ConfigResp != NULL); - - // - // Allocate a buffer to hold the conversion - // - Block = AllocateZeroPool (BlockSize); - if (Block == NULL) { - return NULL; - } - - // - // Convert to a buffer - // - Status = gHiiConfigRouting->ConfigToBlock ( - gHiiConfigRouting, - ConfigResp, - Block, - &BlockSize, - &Progress - ); - if (EFI_ERROR (Status)) { - FreePool (Block); - return NULL; - } - - // - // Return converted buffer - // - return Block; -} - /** Uses the BrowserCallback() service of the Form Browser Protocol to retrieve or set uncommitted data. If sata i being retrieved, then the buffer is @@ -1164,38 +1107,40 @@ HiiIsConfigHdrMatch ( /** Retrieves uncommited data from the Form Browser and converts it to a binary - buffer. The returned buffer is allocated using AllocatePool(). The caller - is responsible for freeing the returned buffer using FreePool(). + buffer. - @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional - parameter that may be NULL. @param[in] VariableName Pointer to a Null-terminated Unicode string. This is an optional parameter that may be NULL. + @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional + parameter that may be NULL. @param[in] BufferSize Length in bytes of buffer to hold retrived data. + @param[out] Block Buffer of data to be updated. - @retval NULL The uncommitted data could not be retrieved. - @retval Other A pointer to a buffer containing the uncommitted data. + @retval FALSE The uncommitted data could not be retrieved. + @retval TRUE The uncommitted data was retrieved. **/ -UINT8 * +BOOLEAN EFIAPI HiiGetBrowserData ( IN CONST EFI_GUID *VariableGuid, OPTIONAL IN CONST CHAR16 *VariableName, OPTIONAL - IN UINTN BlockSize + IN UINTN BlockSize, + OUT UINT8 *Block ) { EFI_STRING ResultsData; UINTN Size; EFI_STRING ConfigResp; - UINT8 *Block; + EFI_STATUS Status; + CHAR16 *Progress; // // Retrieve the results data from the Browser Callback // ResultsData = InternalHiiBrowserCallback (VariableGuid, VariableName, NULL); if (ResultsData == NULL) { - return NULL; + return FALSE; } // @@ -1211,16 +1156,29 @@ HiiGetBrowserData ( // FreePool (ResultsData); if (ConfigResp == NULL) { - return NULL; + return FALSE; } // // Convert to a buffer // - Block = InternalHiiConfigToBlock (ConfigResp, BlockSize); + Status = gHiiConfigRouting->ConfigToBlock ( + gHiiConfigRouting, + ConfigResp, + Block, + &BlockSize, + &Progress + ); + // + // Free the allocated buffer + // FreePool (ConfigResp); - return Block; + if (EFI_ERROR (Status)) { + return FALSE; + } + + return TRUE; } /** diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index 8a46972f7d..0e8efd18d0 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -260,8 +260,9 @@ SetPassword ( // // Retrive uncommitted data from Browser // - Configuration = (DRIVER_SAMPLE_CONFIGURATION *) HiiGetBrowserData (&mFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION)); - if (Configuration != NULL) { + Configuration = AllocateZeroPool (sizeof (DRIVER_SAMPLE_CONFIGURATION)); + ASSERT (Configuration != NULL); + if (HiiGetBrowserData (&mFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION), (UINT8 *) Configuration)) { // // Update password's clear text in the screen // @@ -277,10 +278,13 @@ SetPassword ( (UINT8 *) Configuration, NULL ); - - FreePool (Configuration); } + // + // Free Configuration Buffer + // + FreePool (Configuration); + // // Set password diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf index 657d0ca78e..ff8b49a51d 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf @@ -61,7 +61,7 @@ [Protocols] gEfiHiiStringProtocolGuid ## CONSUMES gEfiHiiConfigRoutingProtocolGuid ## CONSUMES - gEfiHiiConfigAccessProtocolGuid ## CONSUMES + gEfiHiiConfigAccessProtocolGuid ## PRODUCES gEfiFormBrowser2ProtocolGuid ## CONSUMES gEfiHiiDatabaseProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c index 0025f24bc1..62fd606aff 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c @@ -505,8 +505,10 @@ IScsiFormCallback ( // // Retrive uncommitted data from Browser // - IfrNvData = (ISCSI_CONFIG_IFR_NVDATA *) HiiGetBrowserData (&mVendorGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA)); - if (IfrNvData == NULL) { + IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA)); + ASSERT (IfrNvData != NULL); + if (!HiiGetBrowserData (&mVendorGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA), (UINT8 *) IfrNvData)) { + FreePool (IfrNvData); return EFI_NOT_FOUND; } diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c index 47921cd43b..2c1d9d96c5 100644 --- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c @@ -1211,8 +1211,8 @@ PlatOverMngrRouteConfig ( PLAT_OVER_MNGR_DATA *FakeNvData; Private = EFI_CALLBACK_INFO_FROM_THIS (This); - FakeNvData = (PLAT_OVER_MNGR_DATA *) HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA)); - if (FakeNvData == NULL) { + FakeNvData = &Private->FakeNvData; + if (HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData)) { return EFI_NOT_FOUND; } @@ -1233,10 +1233,6 @@ PlatOverMngrRouteConfig ( CommintChanges (Private, KeyValue, FakeNvData); } - if (FakeNvData != NULL) { - FreePool (FakeNvData); - } - return EFI_SUCCESS; } @@ -1279,8 +1275,8 @@ PlatOverMngrCallback ( PLAT_OVER_MNGR_DATA *FakeNvData; Private = EFI_CALLBACK_INFO_FROM_THIS (This); - FakeNvData = (PLAT_OVER_MNGR_DATA *) HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA)); - if (FakeNvData == NULL) { + FakeNvData = &Private->FakeNvData; + if (HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData)) { return EFI_NOT_FOUND; } @@ -1344,14 +1340,6 @@ PlatOverMngrCallback ( // Pass changed uncommitted data back to Form Browser // HiiSetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData, NULL); - - // - // Update local configuration buffer. - // - CopyMem (&Private->FakeNvData, FakeNvData, sizeof (PLAT_OVER_MNGR_DATA)); - if (FakeNvData != NULL) { - FreePool (FakeNvData); - } return EFI_SUCCESS; } -- 2.39.5