Update HiiGetBrowserData API

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8176 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2009-04-27 04:55:02 +00:00
parent 7059dad904
commit 1d451ff9cf
8 changed files with 55 additions and 125 deletions

View File

@ -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;
}

View File

@ -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) {
//

View File

@ -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
);
/**

View File

@ -446,63 +446,6 @@ InternalHiiBlockToConfig (
return ConfigResp;
}
/**
Uses the ConfigToBlock() service of the Config Routing Protocol to
convert <ConfigResp> 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 <ConfigResp> conversion
//
Block = AllocateZeroPool (BlockSize);
if (Block == NULL) {
return NULL;
}
//
// Convert <ConfigResp> 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 <ConfigResp> 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;
}
/**

View File

@ -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

View File

@ -61,7 +61,7 @@
[Protocols]
gEfiHiiStringProtocolGuid ## CONSUMES
gEfiHiiConfigRoutingProtocolGuid ## CONSUMES
gEfiHiiConfigAccessProtocolGuid ## CONSUMES
gEfiHiiConfigAccessProtocolGuid ## PRODUCES
gEfiFormBrowser2ProtocolGuid ## CONSUMES
gEfiHiiDatabaseProtocolGuid ## CONSUMES

View File

@ -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;
}

View File

@ -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;
}