bios: Initialise the bios attributes from bios-settings-manager
The bios-settings-manager is persisting the current value for the PLDM
BIOS attributes. The PLDM daemon will lookup the bios-settings-manager
for the current value and create the BIOS attribute value table.
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Change-Id: I6a7a9ff9c3766189e6a64ab88c5c5e438881151f
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index 5497ac6..b61b3b6 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -476,13 +476,51 @@
return;
}
+ BaseBIOSTable biosTable{};
+ constexpr auto biosObjPath = "/xyz/openbmc_project/bios_config/manager";
+ constexpr auto biosInterface = "xyz.openbmc_project.BIOSConfig.Manager";
+
+ try
+ {
+ auto& bus = dbusHandler->getBus();
+ auto service = dbusHandler->getService(biosObjPath, biosInterface);
+ auto method =
+ bus.new_method_call(service.c_str(), biosObjPath,
+ "org.freedesktop.DBus.Properties", "Get");
+ method.append(biosInterface, "BaseBIOSTable");
+ auto reply = bus.call(method);
+ std::variant<BaseBIOSTable> varBiosTable{};
+ reply.read(varBiosTable);
+ biosTable = std::get<BaseBIOSTable>(varBiosTable);
+ }
+ // Failed to read the BaseBIOSTable, so update the BaseBIOSTable with the
+ // default values populated from the BIOS JSONs to keep PLDM and
+ // bios-settings-manager in sync
+ catch (const std::exception& e)
+ {
+ std::cerr << "Failed to read BaseBIOSTable property, ERROR=" << e.what()
+ << "\n";
+ }
+
Table attrTable, attrValueTable;
for (auto& attr : biosAttributes)
{
try
{
- attr->constructEntry(biosStringTable, attrTable, attrValueTable);
+ auto iter = biosTable.find(attr->name);
+ if (iter == biosTable.end())
+ {
+ attr->constructEntry(biosStringTable, attrTable, attrValueTable,
+ std::nullopt);
+ }
+ else
+ {
+ attr->constructEntry(
+ biosStringTable, attrTable, attrValueTable,
+ std::get<static_cast<uint8_t>(Index::currentValue)>(
+ iter->second));
+ }
}
catch (const std::exception& e)
{