]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/NewHiiLib/HiiLib.c
Update NewHii library
[mirror_edk2.git] / MdeModulePkg / Library / NewHiiLib / HiiLib.c
index 02aa80664123d0a2a56a816079ccb969ac5d792f..099ef5441204568c05a54fe3cb9bf4d1e182c505 100644 (file)
@@ -868,6 +868,7 @@ InternalHiiBlockToConfig (
   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
@@ -876,32 +877,16 @@ InternalHiiBlockToConfig (
 UINT8 *\r
 EFIAPI\r
 InternalHiiConfigToBlock (\r
-  IN CONST EFI_STRING  ConfigResp\r
+  IN  EFI_STRING  ConfigResp,\r
+  IN  UINTN       BlockSize\r
   )\r
 {\r
   EFI_STATUS  Status;\r
-  UINTN       BlockSize;\r
-  UINT8       TempBlock;\r
   CHAR16      *Progress;\r
   UINT8       *Block;\r
 \r
   ASSERT (ConfigResp != NULL);\r
 \r
-  //\r
-  // Get the size of the buffer required for <ConfigResp> conversion\r
-  //\r
-  BlockSize = 0;\r
-  Status = gHiiConfigRouting->ConfigToBlock (\r
-                                gHiiConfigRouting,\r
-                                ConfigResp,\r
-                                &TempBlock,\r
-                                &BlockSize,\r
-                                &Progress\r
-                                );\r
-  if (Status != EFI_BUFFER_TOO_SMALL) {\r
-    return NULL;\r
-  }\r
-\r
   //\r
   // Allocate a buffer to hold the <ConfigResp> conversion\r
   //\r
@@ -1583,6 +1568,7 @@ HiiIsConfigHdrMatch (
                             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
 \r
   @retval NULL   The uncommitted data could not be retrieved.\r
   @retval Other  A pointer to a buffer containing the uncommitted data.\r
@@ -1592,7 +1578,8 @@ UINT8 *
 EFIAPI\r
 HiiGetBrowserData (\r
   IN CONST EFI_GUID  *VariableGuid,  OPTIONAL\r
-  IN CONST CHAR16    *VariableName   OPTIONAL\r
+  IN CONST CHAR16    *VariableName,  OPTIONAL\r
+  IN UINTN           BlockSize\r
   )\r
 {\r
   EFI_STRING  ResultsData;\r
@@ -1614,8 +1601,10 @@ HiiGetBrowserData (
   Size = (StrLen (mConfigHdrTemplate) + 1 + StrLen (ResultsData) + 1) * sizeof (CHAR16);\r
   ConfigResp = AllocateZeroPool (Size);\r
   UnicodeSPrint (ConfigResp, Size, L"%s&%s", mConfigHdrTemplate, ResultsData);\r
-\r
-\r
+  \r
+  //\r
+  // Free the allocated buffer\r
+  //\r
   FreePool (ResultsData);\r
   if (ConfigResp == NULL) {\r
     return NULL;\r
@@ -1624,12 +1613,9 @@ HiiGetBrowserData (
   //\r
   // Convert <ConfigResp> to a buffer\r
   //\r
-  Block = InternalHiiConfigToBlock (ConfigResp);\r
+  Block = InternalHiiConfigToBlock (ConfigResp, BlockSize);\r
   FreePool (ConfigResp);\r
 \r
-  //\r
-  // Return converted buffer\r
-  //\r
   return Block;\r
 }\r
 \r
@@ -2665,12 +2651,6 @@ InternalHiiUpdateFormPackageData (
             //\r
             if ((UpdateIfrOpHdr->Length == IfrOpHdr->Length) && \\r
                 (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0)) {\r
-              //\r
-              // Keep the End opcode flag\r
-              //\r
-              CopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);\r
-              BufferPos           += IfrOpHdr->Length;\r
-              UpdatePackageLength += IfrOpHdr->Length;\r
               break;\r
             }\r
             //\r
@@ -2701,6 +2681,15 @@ InternalHiiUpdateFormPackageData (
           AddOpCode = (EFI_IFR_OP_HEADER *) ((UINT8 *) (AddOpCode) + AddOpCode->Length);\r
           AddSize += AddOpCode->Length;          \r
         }\r
+\r
+        if (OpCodeBufferEnd != NULL) {\r
+          //\r
+          // Add the end opcode\r
+          //\r
+          CopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);\r
+          BufferPos           += IfrOpHdr->Length;\r
+          UpdatePackageLength += IfrOpHdr->Length;\r
+        }\r
         //\r
         // Set update flag\r
         //\r