bios: Add support for enum value display names
This commits adds changes to add support for the value
display names for the Enum BIOS attributes.
GET on
/redfish/v1/Registries/BiosAttributeRegistry/BiosAttributeRegistry/
shows list of Attributes under RegistryEntries. Each
attribute corresponds to a knob in BIOS.
If knob in BIOS is of type Enumeration, it will have
'option' with 'text' and 'value'. This text should be
mapped to attribute->Value->ValueDisplayName.
This change only applies to ENUM type of BIOS attributes
and does not make sense for Integer and String attributes.
Hence, we are sending attribute name in place of the
value display name field for these attributes.
The corresponding bios-setting-mgr change which mandated
this change in PLDM is at-
[1] https://github.com/openbmc/bios-settings-mgr/commit/1a448ad88fdaec7e082b4a1c437f7f3c990402cd
Signed-off-by: Sagar Srinivas <sagar.srinivas@ibm.com>
Change-Id: Ib2882c93e81a70332e4897b196ae812b63cf6184
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index aea24a0..1514664 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -249,6 +249,8 @@
MenuPath menuPath{};
CurrentValue currentValue{};
DefaultValue defaultValue{};
+ std::vector<ValueDisplayName> valueDisplayNames;
+ std::map<uint16_t, std::vector<std::string>> valueDisplayNamesMap;
Option options{};
auto attrValueHandle =
@@ -291,6 +293,9 @@
biosAttributes[attrHandle % biosAttributes.size()]->helpText;
displayName =
biosAttributes[attrHandle % biosAttributes.size()]->displayName;
+ valueDisplayNamesMap =
+ biosAttributes[attrHandle % biosAttributes.size()]
+ ->valueDisplayNamesMap;
}
switch (attrType)
@@ -298,6 +303,13 @@
case PLDM_BIOS_ENUMERATION:
case PLDM_BIOS_ENUMERATION_READ_ONLY:
{
+ if (valueDisplayNamesMap.contains(attrHandle))
+ {
+ const std::vector<ValueDisplayName>& vdn =
+ valueDisplayNamesMap[attrHandle];
+ valueDisplayNames.insert(valueDisplayNames.end(),
+ vdn.begin(), vdn.end());
+ }
auto getValue = [](uint16_t handle,
const Table& table) -> std::string {
auto stringEntry = pldm_bios_table_string_find_by_handle(
@@ -334,7 +346,8 @@
options.push_back(
std::make_tuple("xyz.openbmc_project.BIOSConfig."
"Manager.BoundType.OneOf",
- getValue(pvHandls[i], *stringTable)));
+ getValue(pvHandls[i], *stringTable),
+ valueDisplayNames[i]));
}
auto count =
@@ -380,18 +393,18 @@
uint32_t scalar;
pldm_bios_table_attr_entry_integer_decode(
attrEntry, &lower, &upper, &scalar, &def);
- options.push_back(
- std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
- "BoundType.LowerBound",
- static_cast<int64_t>(lower)));
- options.push_back(
- std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
- "BoundType.UpperBound",
- static_cast<int64_t>(upper)));
- options.push_back(
- std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
- "BoundType.ScalarIncrement",
- static_cast<int64_t>(scalar)));
+ options.push_back(std::make_tuple(
+ "xyz.openbmc_project.BIOSConfig.Manager."
+ "BoundType.LowerBound",
+ static_cast<int64_t>(lower), attributeName));
+ options.push_back(std::make_tuple(
+ "xyz.openbmc_project.BIOSConfig.Manager."
+ "BoundType.UpperBound",
+ static_cast<int64_t>(upper), attributeName));
+ options.push_back(std::make_tuple(
+ "xyz.openbmc_project.BIOSConfig.Manager."
+ "BoundType.ScalarIncrement",
+ static_cast<int64_t>(scalar), attributeName));
defaultValue = static_cast<int64_t>(def);
break;
}
@@ -420,11 +433,11 @@
options.push_back(
std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
"BoundType.MinStringLength",
- static_cast<int64_t>(min)));
+ static_cast<int64_t>(min), attributeName));
options.push_back(
std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
"BoundType.MaxStringLength",
- static_cast<int64_t>(max)));
+ static_cast<int64_t>(max), attributeName));
defaultValue = defString.data();
break;
}