]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update HiiGetBrowserData API
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 27 Apr 2009 04:55:02 +0000 (04:55 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 27 Apr 2009 04:55:02 +0000 (04:55 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8176 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FileExplorer.c
MdeModulePkg/Include/Library/HiiLib.h
MdeModulePkg/Library/UefiHiiLib/HiiLib.c
MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c

index 1e8e59305910524b19242d853dd441b84e761175..da5611d2de9deb80c8b3e0b69536321d67566709 100644 (file)
@@ -271,18 +271,8 @@ BootMaintCallback (
   //\r
   // Retrive uncommitted data from Form Browser\r
   //\r
-  CurrentFakeNVMap = (BMM_FAKE_NV_DATA *) HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA));\r
-  DisMap = (UINT8 *) CurrentFakeNVMap;\r
-  for (Index = 0; Index < sizeof (BMM_FAKE_NV_DATA); Index ++) {\r
-    if (DisMap [Index] != 0) {\r
-      break;\r
-    }\r
-  }\r
-  \r
-  if (Index == sizeof (BMM_FAKE_NV_DATA)) {\r
-    FreePool (CurrentFakeNVMap);\r
-    CurrentFakeNVMap = &Private->BmmFakeNvData;\r
-  }\r
+  CurrentFakeNVMap = &Private->BmmFakeNvData;\r
+  HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap);\r
 \r
   //\r
   // need to be subtituded.\r
@@ -595,14 +585,6 @@ BootMaintCallback (
   //\r
   Status = HiiSetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap, NULL);\r
 \r
-  //\r
-  // Update local settting.\r
-  //\r
-  if (CurrentFakeNVMap != &Private->BmmFakeNvData) {\r
-    CopyMem (&Private->BmmFakeNvData, CurrentFakeNVMap, sizeof (BMM_FAKE_NV_DATA));\r
-    FreePool (CurrentFakeNVMap);\r
-  }\r
-\r
   return Status;\r
 }\r
 \r
index 366aceda18849a6636f982a35b39b0ba28e725c3..2cde6e0d0f95832c7e31b7025e1cdd3c3864785c 100644 (file)
@@ -260,13 +260,8 @@ FileExplorerCallback (
   //\r
   // Retrieve uncommitted data from Form Browser\r
   //\r
-  NvRamMap = (FILE_EXPLORER_NV_DATA *) HiiGetBrowserData (&mFileExplorerGuid, mFileExplorerStorageName, sizeof (FILE_EXPLORER_NV_DATA));\r
-  if (NvRamMap == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  CopyMem (&Private->FeFakeNvData, NvRamMap, sizeof (FILE_EXPLORER_NV_DATA));\r
-  FreePool (NvRamMap);\r
   NvRamMap = &Private->FeFakeNvData;\r
+  HiiGetBrowserData (&mFileExplorerGuid, mFileExplorerStorageName, sizeof (FILE_EXPLORER_NV_DATA), (UINT8 *) NvRamMap);\r
 \r
   if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_BOOT || QuestionId == KEY_VALUE_SAVE_AND_EXIT_DRIVER) {\r
     //\r
index 3f0e096fbace2476ce7929c8c2bcbabeeb3ba280..7c561a69db10faea66e90b2b3fe447b4f7938379 100644 (file)
@@ -357,25 +357,26 @@ HiiIsConfigHdrMatch (
 \r
 /**\r
   Retrieves uncommited data from the Form Browser and converts it to a binary\r
-  buffer.  The returned buffer is allocated using AllocatePool().  The caller\r
-  is responsible for freeing the returned buffer using FreePool().\r
+  buffer.\r
 \r
   @param[in]  VariableName  Pointer to a Null-terminated Unicode string.  This \r
                             is an optional parameter that may be NULL.\r
   @param[in]  VariableGuid  Pointer to an EFI_GUID structure.  This is an optional \r
                             parameter that may be NULL.\r
   @param[in]  BufferSize    Length in bytes of buffer to hold retrived data. \r
+  @param[out] Block         Buffer of data to be updated.\r
 \r
-  @retval NULL   The uncommitted data could not be retrieved.\r
-  @retval Other  A pointer to a buffer containing the uncommitted data.\r
+  @retval FALSE  The uncommitted data could not be retrieved.\r
+  @retval TRUE   The uncommitted data was retrieved.\r
 \r
 **/\r
-UINT8 *\r
+BOOLEAN\r
 EFIAPI\r
 HiiGetBrowserData (\r
   IN CONST EFI_GUID  *VariableGuid,  OPTIONAL\r
   IN CONST CHAR16    *VariableName,  OPTIONAL\r
-  IN UINTN           BlockSize\r
+  IN UINTN           BlockSize,\r
+  OUT UINT8          *Block\r
   );\r
 \r
 /**\r
index ea3c22348e3438daa5ceee5cb0c472e8934606be..c8ef091ff7802d3324708d7ee733e80dda58b5a8 100644 (file)
@@ -446,63 +446,6 @@ InternalHiiBlockToConfig (
   return ConfigResp;\r
 }\r
 \r
-/**\r
-  Uses the ConfigToBlock() service of the Config Routing Protocol to \r
-  convert <ConfigResp> to a block.  The block is allocated using\r
-  AllocatePool().  The caller is responsible for freeing the block\r
-  using FreePool().\r
-\r
-  If ConfigResp is NULL, then ASSERT().\r
-\r
-  @param[in] ConfigResp  Pointer to a Null-terminated Unicode string.\r
-  @param[in] BufferSize  Length in bytes of buffer to hold retrived data. \r
-\r
-  @retval NULL   The block could not be generated..\r
-  @retval Other  Pointer to the allocated block.\r
-\r
-**/\r
-UINT8 *\r
-EFIAPI\r
-InternalHiiConfigToBlock (\r
-  IN  EFI_STRING  ConfigResp,\r
-  IN  UINTN       BlockSize\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  CHAR16      *Progress;\r
-  UINT8       *Block;\r
-\r
-  ASSERT (ConfigResp != NULL);\r
-\r
-  //\r
-  // Allocate a buffer to hold the <ConfigResp> conversion\r
-  //\r
-  Block = AllocateZeroPool (BlockSize);\r
-  if (Block == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Convert <ConfigResp> to a buffer\r
-  //\r
-  Status = gHiiConfigRouting->ConfigToBlock (\r
-                                gHiiConfigRouting,\r
-                                ConfigResp,\r
-                                Block,\r
-                                &BlockSize,\r
-                                &Progress\r
-                                );\r
-  if (EFI_ERROR (Status)) {\r
-    FreePool (Block);\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Return converted buffer\r
-  //\r
-  return Block;\r
-}\r
-\r
 /**\r
   Uses the BrowserCallback() service of the Form Browser Protocol to retrieve \r
   or set uncommitted data.  If sata i being retrieved, then the buffer is \r
@@ -1164,38 +1107,40 @@ HiiIsConfigHdrMatch (
 \r
 /**\r
   Retrieves uncommited data from the Form Browser and converts it to a binary\r
-  buffer.  The returned buffer is allocated using AllocatePool().  The caller\r
-  is responsible for freeing the returned buffer using FreePool().\r
+  buffer.\r
 \r
-  @param[in]  VariableGuid  Pointer to an EFI_GUID structure.  This is an optional \r
-                            parameter that may be NULL.\r
   @param[in]  VariableName  Pointer to a Null-terminated Unicode string.  This \r
                             is an optional parameter that may be NULL.\r
+  @param[in]  VariableGuid  Pointer to an EFI_GUID structure.  This is an optional \r
+                            parameter that may be NULL.\r
   @param[in]  BufferSize    Length in bytes of buffer to hold retrived data. \r
+  @param[out] Block         Buffer of data to be updated.\r
 \r
-  @retval NULL   The uncommitted data could not be retrieved.\r
-  @retval Other  A pointer to a buffer containing the uncommitted data.\r
+  @retval FALSE  The uncommitted data could not be retrieved.\r
+  @retval TRUE   The uncommitted data was retrieved.\r
 \r
 **/\r
-UINT8 *\r
+BOOLEAN\r
 EFIAPI\r
 HiiGetBrowserData (\r
   IN CONST EFI_GUID  *VariableGuid,  OPTIONAL\r
   IN CONST CHAR16    *VariableName,  OPTIONAL\r
-  IN UINTN           BlockSize\r
+  IN UINTN           BlockSize,\r
+  OUT UINT8          *Block\r
   )\r
 {\r
   EFI_STRING  ResultsData;\r
   UINTN       Size;\r
   EFI_STRING  ConfigResp;\r
-  UINT8       *Block;\r
+  EFI_STATUS  Status;\r
+  CHAR16      *Progress;\r
 \r
   //\r
   // Retrieve the results data from the Browser Callback\r
   //\r
   ResultsData = InternalHiiBrowserCallback (VariableGuid, VariableName, NULL);\r
   if (ResultsData == NULL) {\r
-    return NULL;\r
+    return FALSE;\r
   }\r
 \r
   //\r
@@ -1211,16 +1156,29 @@ HiiGetBrowserData (
   //\r
   FreePool (ResultsData);\r
   if (ConfigResp == NULL) {\r
-    return NULL;\r
+    return FALSE;\r
   }\r
 \r
   //\r
   // Convert <ConfigResp> to a buffer\r
   //\r
-  Block = InternalHiiConfigToBlock (ConfigResp, BlockSize);\r
+  Status = gHiiConfigRouting->ConfigToBlock (\r
+                                gHiiConfigRouting,\r
+                                ConfigResp,\r
+                                Block,\r
+                                &BlockSize,\r
+                                &Progress\r
+                                );\r
+  //\r
+  // Free the allocated buffer\r
+  //\r
   FreePool (ConfigResp);\r
 \r
-  return Block;\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
 }\r
 \r
 /**\r
index 8a46972f7d232dc8317104b9fbb8e7cd4cebc01a..0e8efd18d07eb17f6b821e0154d96d54887493fd 100644 (file)
@@ -260,8 +260,9 @@ SetPassword (
   //\r
   // Retrive uncommitted data from Browser\r
   //\r
-  Configuration = (DRIVER_SAMPLE_CONFIGURATION *) HiiGetBrowserData (&mFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION));\r
-  if (Configuration != NULL) {\r
+  Configuration = AllocateZeroPool (sizeof (DRIVER_SAMPLE_CONFIGURATION));\r
+  ASSERT (Configuration != NULL);\r
+  if (HiiGetBrowserData (&mFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION), (UINT8 *) Configuration)) {\r
     //\r
     // Update password's clear text in the screen\r
     //\r
@@ -277,10 +278,13 @@ SetPassword (
        (UINT8 *) Configuration,\r
        NULL\r
        );\r
-    \r
-    FreePool (Configuration);\r
   }\r
 \r
+  //\r
+  // Free Configuration Buffer\r
+  //\r
+  FreePool (Configuration);\r
+\r
 \r
   //\r
   // Set password\r
index 657d0ca78e11042e03fc58e11da12ac18e124422..ff8b49a51d36adf56e324a80ca0a9ebc8619babd 100644 (file)
@@ -61,7 +61,7 @@
 [Protocols]\r
   gEfiHiiStringProtocolGuid                     ## CONSUMES\r
   gEfiHiiConfigRoutingProtocolGuid              ## CONSUMES\r
-  gEfiHiiConfigAccessProtocolGuid               ## CONSUMES\r
+  gEfiHiiConfigAccessProtocolGuid               ## PRODUCES\r
   gEfiFormBrowser2ProtocolGuid                  ## CONSUMES\r
   gEfiHiiDatabaseProtocolGuid                   ## CONSUMES\r
 \r
index 0025f24bc1c9703947f2c6ab2bea9c66b55f0aa0..62fd606aff09bce2346da183d7f12fde20195017 100644 (file)
@@ -505,8 +505,10 @@ IScsiFormCallback (
   //\r
   // Retrive uncommitted data from Browser\r
   //\r
-  IfrNvData = (ISCSI_CONFIG_IFR_NVDATA *) HiiGetBrowserData (&mVendorGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA));\r
-  if (IfrNvData == NULL) {\r
+  IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA));\r
+  ASSERT (IfrNvData != NULL);\r
+  if (!HiiGetBrowserData (&mVendorGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA), (UINT8 *) IfrNvData)) {\r
+    FreePool (IfrNvData);\r
     return EFI_NOT_FOUND;\r
   }\r
   \r
index 47921cd43befba29df33634160c6566edcf5e905..2c1d9d96c5a4634de4885ef13d60e2025e78afe8 100644 (file)
@@ -1211,8 +1211,8 @@ PlatOverMngrRouteConfig (
   PLAT_OVER_MNGR_DATA                       *FakeNvData;\r
 \r
   Private    = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-  FakeNvData = (PLAT_OVER_MNGR_DATA *) HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA));\r
-  if (FakeNvData == NULL) {\r
+  FakeNvData = &Private->FakeNvData;\r
+  if (HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData)) {\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
@@ -1233,10 +1233,6 @@ PlatOverMngrRouteConfig (
     CommintChanges (Private, KeyValue, FakeNvData);\r
   }\r
 \r
-  if (FakeNvData != NULL) {\r
-    FreePool (FakeNvData);\r
-  }\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -1279,8 +1275,8 @@ PlatOverMngrCallback (
   PLAT_OVER_MNGR_DATA                       *FakeNvData;\r
   \r
   Private = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-  FakeNvData = (PLAT_OVER_MNGR_DATA *) HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA));\r
-  if (FakeNvData == NULL) {\r
+  FakeNvData = &Private->FakeNvData;\r
+  if (HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData)) {\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
@@ -1344,14 +1340,6 @@ PlatOverMngrCallback (
   // Pass changed uncommitted data back to Form Browser\r
   //\r
   HiiSetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData, NULL);\r
-  \r
-  //\r
-  // Update local configuration buffer.\r
-  //\r
-  CopyMem (&Private->FakeNvData, FakeNvData, sizeof (PLAT_OVER_MNGR_DATA));\r
-  if (FakeNvData != NULL) {\r
-    FreePool (FakeNvData);\r
-  }\r
 \r
   return EFI_SUCCESS;\r
 }\r