RedfishPkg/RedfishPlatformConfigDxe: Fix string assert issue

When calling SetValue() with string type input, there is
assertion of providing zero string ID to HII string function.
Fix this issue by creating string ID for input string buffer.
Fix Unicode and Ascii code convert issue together.
Add text op-code support

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
This commit is contained in:
Nickle Wang
2023-05-08 18:22:42 +08:00
committed by mergify[bot]
parent ba2300f97b
commit 5258c4186f
4 changed files with 169 additions and 27 deletions

View File

@@ -143,6 +143,34 @@ DumpFormsetList (
return EFI_SUCCESS;
}
/**
Delete a string from HII Package List by given HiiHandle.
@param[in] StringId Id of the string in HII database.
@param[in] HiiHandle The HII package list handle.
@retval EFI_SUCCESS The string was deleted successfully.
@retval EFI_INVALID_PARAMETER StringId is zero.
**/
EFI_STATUS
HiiDeleteString (
IN EFI_STRING_ID StringId,
IN EFI_HII_HANDLE HiiHandle
)
{
CHAR16 NullChar;
if (StringId == 0x00) {
return EFI_INVALID_PARAMETER;
}
NullChar = CHAR_NULL;
HiiSetString (HiiHandle, StringId, &NullChar, NULL);
return EFI_SUCCESS;
}
/**
Retrieves a unicode string from a string package in a given language. The
returned string is allocated using AllocatePool(). The caller is responsible
@@ -259,7 +287,6 @@ HiiGetRedfishAsciiString (
)
{
EFI_STRING HiiString;
UINTN StringSize;
CHAR8 *AsciiString;
HiiString = HiiGetRedfishString (HiiHandle, Language, StringId);
@@ -268,15 +295,9 @@ HiiGetRedfishAsciiString (
return NULL;
}
StringSize = (StrLen (HiiString) + 1) * sizeof (CHAR8);
AsciiString = AllocatePool (StringSize);
if (AsciiString == NULL) {
return NULL;
}
UnicodeStrToAsciiStrS (HiiString, AsciiString, StringSize);
AsciiString = StrToAsciiStr (HiiString);
FreePool (HiiString);
return AsciiString;
}
@@ -322,7 +343,6 @@ HiiGetEnglishAsciiString (
)
{
EFI_STRING HiiString;
UINTN StringSize;
CHAR8 *AsciiString;
HiiString = HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, StringId);
@@ -331,15 +351,9 @@ HiiGetEnglishAsciiString (
return NULL;
}
StringSize = (StrLen (HiiString) + 1) * sizeof (CHAR8);
AsciiString = AllocatePool (StringSize);
if (AsciiString == NULL) {
return NULL;
}
UnicodeStrToAsciiStrS (HiiString, AsciiString, StringSize);
AsciiString = StrToAsciiStr (HiiString);
FreePool (HiiString);
return AsciiString;
}