From 1d451ff9cf3427c5dc4ba1650d33b1b5aad76d7f Mon Sep 17 00:00:00 2001 From: lgao4 Date: Mon, 27 Apr 2009 04:55:02 +0000 Subject: 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 ++- .../Universal/DriverSampleDxe/DriverSampleDxe.inf | 2 +- .../Universal/Network/IScsiDxe/IScsiConfig.c | 6 +- .../PlatformDriOverrideDxe/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 1e8e593..da5611d 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 366aced..2cde6e0 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 3f0e096..7c561a6 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 ea3c223..c8ef091 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -447,63 +447,6 @@ InternalHiiBlockToConfig ( } /** - 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 allocated using AllocatePool(). The caller is then responsible for freeing @@ -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 8a46972..0e8efd1 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 657d0ca..ff8b49a 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 0025f24..62fd606 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 47921cd..2c1d9d9 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; } -- cgit v1.1