diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-04-27 04:55:02 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-04-27 04:55:02 +0000 |
commit | 1d451ff9cf3427c5dc4ba1650d33b1b5aad76d7f (patch) | |
tree | edf9ee8479d2d2ccec62abf26013db9eea4936b2 /MdeModulePkg | |
parent | 7059dad90457cda5074783411fbe9b513c7c9ae3 (diff) | |
download | edk2-platforms-1d451ff9cf3427c5dc4ba1650d33b1b5aad76d7f.tar.xz |
Update HiiGetBrowserData API
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8176 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
6 files changed, 52 insertions, 99 deletions
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 @@ -447,63 +447,6 @@ InternalHiiBlockToConfig ( }
/**
- 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
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 <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;
}
/**
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;
}
|