]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiHiiLib/HiiLib.c
Retire original HII APIs: IfrLibExtractDefault and ConstructConfigAltResp, which...
[mirror_edk2.git] / MdeModulePkg / Library / UefiHiiLib / HiiLib.c
index b9323706a6f24f95462bb2101224e818d4381f29..06c345b128aef3cd23318d3fc1325ba07767fe2f 100644 (file)
@@ -1843,11 +1843,20 @@ InternalHiiIfrValueAction (
                                   (ActionType == ACTION_SET_DEFAUTL_VALUE) ? &DefaultName:NULL,  // it can be NULL to get the current setting.\r
                                   &ConfigResp\r
                                 );\r
-\r
+    \r
+    //\r
+    // The required setting can't be found. So, it is not required to be validated and set.\r
+    //\r
     if (EFI_ERROR (Status)) {\r
       Status = EFI_SUCCESS;\r
       goto NextConfigAltResp;\r
     }\r
+    //\r
+    // Only the ConfigHdr is found. Not any block data is found. No data is required to be validated and set.\r
+    //\r
+    if (StrStr (ConfigResp, L"&OFFSET=") == NULL) {\r
+      goto NextConfigAltResp;\r
+    }\r
     \r
     //\r
     // 4. Set the default configuration information or Validate current setting by parse IFR code.\r
@@ -1878,10 +1887,10 @@ NextConfigAltResp:
       HiiPackageList = NULL;\r
     }\r
     \r
-       if (ConfigResp != NULL) {\r
-         FreePool (ConfigResp);\r
-         ConfigResp = NULL;\r
-       }\r
+       if (ConfigResp != NULL) {\r
+         FreePool (ConfigResp);\r
+         ConfigResp = NULL;\r
+       }\r
 \r
     //\r
     // Free the allocated buffer.\r
@@ -2035,299 +2044,6 @@ HiiSetToDefaults (
   return InternalHiiIfrValueAction (Request, DefaultId, ACTION_SET_DEFAUTL_VALUE);\r
 }\r
 \r
-/**\r
-  Allocates and returns a Null-terminated Unicode <ConfigAltResp> string.\r
-\r
-  If Guid is NULL, then ASSERT().\r
-  If Name is NULL, then ASSERT().\r
-  If BlockNameArray is NULL, then ASSERT().\r
-\r
-  @param[in] Guid               GUID of the buffer storage.\r
-  @param[in] Name               Name of the buffer storage.\r
-  @param[in] DriverHandle       The DriverHandle that support a Device Path\r
-                                Protocol.    \r
-  @param[in] BufferStorage      Content of the buffer storage.\r
-  @param[in] BufferStorageSize  Length in bytes of the buffer storage.\r
-  @param[in] BlockNameArray     Array generated by VFR compiler.  This array\r
-                                contains a UINT32 value that is the length\r
-                                of BlockNameArray in bytes, followed by pairs\r
-                                of 16-bit values that are the offset and length\r
-                                values used to contruct a <ConfigRequest> string.\r
-  @param[in]  ...               A variable argument list that contains pairs of 16-bit\r
-                                ALTCFG identifiers and pointers to DefaultValueArrays.\r
-                                The variable argument list is terminated by a NULL \r
-                                DefaultValueArray pointer.  A DefaultValueArray \r
-                                contains a UINT32 value that is the length, in bytes,\r
-                                of the DefaultValueArray.  The UINT32 length value \r
-                                is followed by a series of records that contain\r
-                                a 16-bit WIDTH value followed by a byte array with \r
-                                WIDTH entries.  The records must be parsed from\r
-                                beginning to end until the UINT32 length limit\r
-                                is reached.  \r
-\r
-  @retval NULL          There are not enough resources to process the request.\r
-  @retval NULL          A <ConfigResp> could not be retrieved from the Config \r
-                        Routing Protocol.\r
-  @retval Other         A pointer to the Null-terminate Unicode <ConfigAltResp>\r
-                        string.\r
-\r
-**/\r
-EFI_STRING\r
-EFIAPI\r
-HiiConstructConfigAltResp (\r
-  IN CONST EFI_GUID  *Guid,\r
-  IN CONST CHAR16    *Name,\r
-  IN EFI_HANDLE      DriverHandle,\r
-  IN CONST VOID      *BufferStorage,\r
-  IN UINTN           BufferStorageSize,\r
-  IN CONST VOID      *BlockNameArray, \r
-  ...\r
-  )\r
-{\r
-  UINTN         Length;\r
-  CHAR16        *String;\r
-  CHAR16        *ConfigHdr;\r
-  UINT8         *Buffer;\r
-  UINT8         *BufferEnd;\r
-  CHAR16        *ConfigRequest;\r
-  EFI_STRING    ConfigResp;\r
-  EFI_STRING    ConfigAltResp;\r
-  VA_LIST       Args;\r
-  UINTN         AltCfgId;\r
-  UINT16        Width;\r
-  UINT16        OffsetValue;\r
-  UINT16        WidthValue;\r
-\r
-  ASSERT (Guid != NULL);\r
-  ASSERT (Name != NULL);\r
-  ASSERT (BlockNameArray != NULL);\r
-\r
-  //\r
-  // Initialize local variables\r
-  //\r
-  ConfigHdr     = NULL;\r
-  ConfigRequest = NULL; \r
-  ConfigResp    = NULL;\r
-\r
-  //\r
-  // Construct <ConfigHdr> : "GUID=...&NAME=...&PATH=..."\r
-  //\r
-  ConfigHdr = HiiConstructConfigHdr (Guid, Name, DriverHandle);\r
-  if (ConfigHdr == NULL) {\r
-    goto Exit;\r
-  }\r
-\r
-  //\r
-  // Compute the length of the entire request starting with <ConfigHdr> and a \r
-  // Null-terminator\r
-  //\r
-  Length = StrLen (ConfigHdr) + 1;\r
-\r
-  //\r
-  // Determine the size <BlockName> Offset/Width pairs\r
-  //\r
-  Buffer = (UINT8 *)BlockNameArray;\r
-  BufferEnd = Buffer + ReadUnaligned32 ((UINT32 *)Buffer);\r
-  Buffer += sizeof (UINT32);\r
-\r
-  //\r
-  // Add <BlockName> length that is composed of one or more Offset/Width pairs\r
-  //\r
-  // <BlockName> ::= &OFFSET=1234&WIDTH=1234\r
-  //                 |  8   | 4 |   7  | 4 |\r
-  //\r
-  Length += (((BufferEnd - Buffer) / (sizeof (UINT16) + sizeof (UINT16))) * (8 + 4 + 7 + 4));\r
-\r
-  //\r
-  // Allocate buffer for the entire <ConfigRequest>\r
-  //\r
-  ConfigRequest = AllocateZeroPool (Length * sizeof (CHAR16));\r
-  if (ConfigRequest == NULL) {\r
-    goto Exit;\r
-  }\r
-  String = ConfigRequest;\r
-\r
-  //\r
-  // Start with <ConfigHdr>\r
-  //\r
-  StrCpy (String, ConfigHdr);\r
-  String += StrLen (String);\r
-\r
-  //\r
-  // Loop through all the Offset/Width pairs and append them to ConfigRequest\r
-  //\r
-  while (Buffer < BufferEnd) {\r
-    //\r
-    // Append &OFFSET=XXXX&WIDTH=YYYY\r
-    //\r
-    OffsetValue = ReadUnaligned16 ((UINT16 *)Buffer);\r
-    WidthValue  = ReadUnaligned16 ((UINT16 *)(Buffer + sizeof (UINT16)));\r
-    UnicodeSPrint (\r
-      String, \r
-      (8 + 4 + 7 + 4) * sizeof (CHAR16), \r
-      L"&OFFSET=%04X&WIDTH=%04X", \r
-      OffsetValue, \r
-      WidthValue\r
-    );\r
-\r
-    String += StrLen (String);\r
-    Buffer += (sizeof (UINT16) + sizeof (UINT16));\r
-  }\r
-\r
-  //\r
-  // Get the <ConfigResp>\r
-  //\r
-  ConfigResp = InternalHiiBlockToConfig (ConfigRequest, BufferStorage, BufferStorageSize);\r
-  if (ConfigResp == NULL) {\r
-    goto Exit;\r
-  }\r
-\r
-  //\r
-  // Compute the length of the entire response starting with <ConfigResp> and a \r
-  // Null-terminator\r
-  //\r
-  Length = StrLen (ConfigResp) + 1;\r
-\r
-  //\r
-  // Add the length associated with each pair of variable argument parameters\r
-  //\r
-  VA_START (Args, BlockNameArray);\r
-  while (TRUE) {\r
-    AltCfgId = VA_ARG (Args, UINTN);\r
-    Buffer   = VA_ARG (Args, UINT8 *);\r
-    if (Buffer == NULL) {\r
-      break;\r
-    }\r
-\r
-    //\r
-    // Add length for "&<ConfigHdr>&ALTCFG=XXXX"\r
-    //                |1| StrLen (ConfigHdr) | 8 | 4 |\r
-    //\r
-    Length += (1 + StrLen (ConfigHdr) + 8 + 4);\r
-\r
-    BufferEnd = Buffer + ReadUnaligned32 ((UINT32 *)Buffer);\r
-    Buffer += sizeof (UINT32);\r
-    while (Buffer < BufferEnd) {\r
-      //\r
-      // Extract Width field\r
-      //\r
-      Width = ReadUnaligned16 ((UINT16 *)(Buffer + sizeof (UINT16)));\r
-\r
-      //\r
-      // Add length for "&OFFSET=XXXX&WIDTH=YYYY&VALUE=zzzzzzzzzzzz"\r
-      //                |    8  | 4 |   7  | 4 |   7  | Width * 2 |\r
-      //\r
-      Length += (8 + 4 + 7 + 4 + 7 + Width * 2);\r
-\r
-      //\r
-      // Update Buffer to the next record\r
-      //\r
-      Buffer += (sizeof (UINT16) + sizeof (UINT16) + Width);\r
-    }\r
-  }\r
-  VA_END (Args);\r
-\r
-  //\r
-  // Allocate a buffer for the entire response\r
-  //\r
-  ConfigAltResp = AllocateZeroPool (Length * sizeof (CHAR16));\r
-  if (ConfigAltResp == NULL) {\r
-    goto Exit;\r
-  }\r
-  String = ConfigAltResp;\r
-\r
-  //\r
-  // Add <ConfigResp>\r
-  //\r
-  StrCpy (String, ConfigResp);\r
-  String += StrLen (String);\r
-\r
-  //\r
-  // Add <AltResp> for each pair of variable argument parameters\r
-  //\r
-  VA_START (Args, BlockNameArray);\r
-  while (TRUE) {\r
-    AltCfgId = VA_ARG (Args, UINTN);\r
-    Buffer   = VA_ARG (Args, UINT8 *);\r
-    if (Buffer == NULL) {\r
-      break;\r
-    }\r
-\r
-    //\r
-    // Add <AltConfigHdr> of the form "&<ConfigHdr>&ALTCFG=XXXX"\r
-    //                                |1| StrLen (ConfigHdr) | 8 | 4 |\r
-    //\r
-    UnicodeSPrint (\r
-      String, \r
-      (1 + StrLen (ConfigHdr) + 8 + 4) * sizeof (CHAR16), \r
-      L"&%s&ALTCFG=%04X", \r
-      ConfigHdr, \r
-      AltCfgId\r
-      );\r
-    String += StrLen (String);\r
-\r
-    //\r
-    // Add <ConfigBody> ::= <ConfigElement>*\r
-    //\r
-    BufferEnd = Buffer + ReadUnaligned32 ((UINT32 *)Buffer);\r
-    Buffer += sizeof (UINT32);\r
-    while (Buffer < BufferEnd) {\r
-      //\r
-      // Extract Width field\r
-      //\r
-      Width = ReadUnaligned16 ((UINT16 *)(Buffer + sizeof (UINT16)));\r
-\r
-      //\r
-      // Add <BlockConfig>\r
-      //\r
-      UnicodeSPrint (\r
-        String, \r
-        (8 + 4 + 7 + 4 + 7 + Width * 2) * sizeof (CHAR16),\r
-        L"&OFFSET=%04X&WIDTH=%04X&VALUE=", \r
-        ReadUnaligned16 ((UINT16 *)Buffer), \r
-        Width\r
-        );\r
-      String += StrLen (String);\r
-\r
-      //\r
-      // Update Buffer to point to the value in the current record\r
-      //\r
-      Buffer += (sizeof (UINT16) + sizeof (UINT16));\r
-\r
-      //\r
-      // Convert Value to a hex string in "%x" format\r
-      //   NOTE: This is in the opposite byte that GUID and PATH use\r
-      //\r
-      for (; Width > 0; Width--) {\r
-        String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, Buffer[Width - 1], 2);\r
-      }\r
-      //\r
-      // Update Buffer to the next record\r
-      //\r
-      Buffer += Width;\r
-    }\r
-  }\r
-  VA_END (Args);\r
-\r
-  //\r
-  // Convert all hex digits in range [A-F] in the configuration header to [a-f]\r
-  //\r
-  return InternalHiiLowerConfigString (ConfigAltResp);\r
-\r
-Exit:\r
-  if (ConfigHdr != NULL) {\r
-    FreePool (ConfigHdr);\r
-  }\r
-  if (ConfigRequest != NULL) {\r
-    FreePool (ConfigRequest);\r
-  }\r
-  if (ConfigResp != NULL) {\r
-    FreePool (ConfigResp);\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
 /**\r
   Determines if two values in config strings match.\r
 \r
@@ -3859,78 +3575,3 @@ Finish:
 \r
   return Status; \r
 }\r
-\r
-/**\r
-  Configure the buffer accrording to ConfigBody strings in the format of\r
-  <Length:4 bytes>, <Offset: 2 bytes>, <Width:2 bytes>, <Data:n bytes>.\r
-  This ConfigBody strings is generated by UEFI VfrCompiler for the default\r
-  values in a Form Set. The name of the ConfigBody strings is VfrMyIfrNVDataDefault0000\r
-  constructed following this rule: \r
-   "Vfr" + varstore.name + "Default" + defaultstore.attributes.\r
-  Check the generated C file in Output for details.\r
-\r
-  @param  Buffer                 The start address of buffer.\r
-  @param  BufferSize             The size of buffer.\r
-  @param  Number                 The number of the strings.\r
-  @param  ...                    Variable argument list for default value in <AltResp> format \r
-                                 generated by the tool.\r
-\r
-  @retval EFI_BUFFER_TOO_SMALL   the BufferSize is too small to operate.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL or BufferSize is 0.\r
-  @retval EFI_SUCCESS            Operation successful.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HiiIfrLibExtractDefault(\r
-  IN VOID                         *Buffer,\r
-  IN UINTN                        *BufferSize,\r
-  UINTN                           Number,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST                         Args;\r
-  UINTN                           Index;\r
-  UINT32                          TotalLen;\r
-  UINT8                           *BufCfgArray;\r
-  UINT8                           *BufferPos;\r
-  UINT16                          Offset;\r
-  UINT16                          Width;\r
-  UINT8                           *Value;\r
-\r
-  if ((Buffer == NULL) || (BufferSize == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Offset = 0;\r
-  Width  = 0;\r
-  Value  = NULL;\r
-\r
-  VA_START (Args, Number);\r
-  for (Index = 0; Index < Number; Index++) {\r
-    BufCfgArray = (UINT8 *) VA_ARG (Args, VOID *);\r
-    TotalLen = ReadUnaligned32 ((UINT32 *)BufCfgArray);\r
-    BufferPos = BufCfgArray + sizeof (UINT32);\r
-\r
-    while ((UINT32)(BufferPos - BufCfgArray) < TotalLen) {\r
-      Offset = ReadUnaligned16 ((UINT16 *)BufferPos);\r
-      BufferPos += sizeof (UINT16);\r
-      Width = ReadUnaligned16 ((UINT16 *)BufferPos);\r
-      BufferPos += sizeof (UINT16);\r
-      Value = BufferPos;\r
-      BufferPos += Width;\r
-\r
-      if ((UINTN)(Offset + Width) > *BufferSize) {\r
-        return EFI_BUFFER_TOO_SMALL;\r
-      }\r
-\r
-      CopyMem ((UINT8 *)Buffer + Offset, Value, Width);\r
-    }\r
-  }\r
-  VA_END (Args);\r
-\r
-  *BufferSize = (UINTN)Offset;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r