blob: 69a98f4d55357e81e2f631fe188f9344fdeac8af [file] [log] [blame]
John Wangd9659342020-02-27 16:46:05 +08001#include "bios_config.hpp"
2
John Wang3be70852020-02-13 15:59:04 +08003#include "bios_enum_attribute.hpp"
John Wang95e6b3c2020-02-13 09:43:24 +08004#include "bios_integer_attribute.hpp"
John Wangd9659342020-02-27 16:46:05 +08005#include "bios_string_attribute.hpp"
Sampa Misra46ece062020-03-18 07:17:44 -05006#include "bios_table.hpp"
George Liu1b180d82020-07-23 14:01:58 +08007#include "common/bios_utils.hpp"
John Wangd9659342020-02-27 16:46:05 +08008
Riya Dixit49cfb132023-03-02 04:26:53 -06009#include <phosphor-logging/lg2.hpp>
George Liu1244acf2020-08-14 09:11:11 +080010#include <xyz/openbmc_project/BIOSConfig/Manager/server.hpp>
11
John Wangd9659342020-02-27 16:46:05 +080012#include <fstream>
13#include <iostream>
14
Tom Joseph7f839f92020-09-21 10:20:44 +053015#ifdef OEM_IBM
16#include "oem/ibm/libpldmresponder/platform_oem_ibm.hpp"
17#endif
18
Riya Dixit49cfb132023-03-02 04:26:53 -060019PHOSPHOR_LOG2_USING;
20
Brad Bishop5079ac42021-08-19 18:35:06 -040021using namespace pldm::utils;
22
John Wangd9659342020-02-27 16:46:05 +080023namespace pldm
24{
25namespace responder
26{
27namespace bios
28{
29namespace
30{
George Liu1244acf2020-08-14 09:11:11 +080031using BIOSConfigManager =
32 sdbusplus::xyz::openbmc_project::BIOSConfig::server::Manager;
33
John Wangd9659342020-02-27 16:46:05 +080034constexpr auto enumJsonFile = "enum_attrs.json";
35constexpr auto stringJsonFile = "string_attrs.json";
36constexpr auto integerJsonFile = "integer_attrs.json";
37
38constexpr auto stringTableFile = "stringTable";
39constexpr auto attrTableFile = "attributeTable";
40constexpr auto attrValueTableFile = "attributeValueTable";
41
42} // namespace
43
Sampa Misrac0c79482021-06-02 08:01:54 -050044BIOSConfig::BIOSConfig(
45 const char* jsonDir, const char* tableDir, DBusHandler* const dbusHandler,
Andrew Jefferya330b2f2023-05-04 14:55:37 +093046 int fd, uint8_t eid, pldm::InstanceIdDb* instanceIdDb,
Sampa Misrac0c79482021-06-02 08:01:54 -050047 pldm::requester::Handler<pldm::requester::Request>* handler) :
John Wangd9659342020-02-27 16:46:05 +080048 jsonDir(jsonDir),
Tom Joseph7f839f92020-09-21 10:20:44 +053049 tableDir(tableDir), dbusHandler(dbusHandler), fd(fd), eid(eid),
Andrew Jefferya330b2f2023-05-04 14:55:37 +093050 instanceIdDb(instanceIdDb), handler(handler)
Tom Joseph7f839f92020-09-21 10:20:44 +053051
John Wangd9659342020-02-27 16:46:05 +080052{
George Liu9d8921e2020-05-14 15:41:50 +080053 fs::create_directories(tableDir);
John Wangd9659342020-02-27 16:46:05 +080054 constructAttributes();
George Liu1244acf2020-08-14 09:11:11 +080055 listenPendingAttributes();
John Wangd9659342020-02-27 16:46:05 +080056}
57
58void BIOSConfig::buildTables()
59{
John Wangd9659342020-02-27 16:46:05 +080060 auto stringTable = buildAndStoreStringTable();
61 if (stringTable)
62 {
63 buildAndStoreAttrTables(*stringTable);
64 }
65}
66
67std::optional<Table> BIOSConfig::getBIOSTable(pldm_bios_table_types tableType)
68{
69 fs::path tablePath;
70 switch (tableType)
71 {
72 case PLDM_BIOS_STRING_TABLE:
73 tablePath = tableDir / stringTableFile;
74 break;
75 case PLDM_BIOS_ATTR_TABLE:
76 tablePath = tableDir / attrTableFile;
77 break;
78 case PLDM_BIOS_ATTR_VAL_TABLE:
79 tablePath = tableDir / attrValueTableFile;
80 break;
81 }
82 return loadTable(tablePath);
83}
84
Tom Joseph7f839f92020-09-21 10:20:44 +053085int BIOSConfig::setBIOSTable(uint8_t tableType, const Table& table,
86 bool updateBaseBIOSTable)
George Liu1b180d82020-07-23 14:01:58 +080087{
88 fs::path stringTablePath(tableDir / stringTableFile);
89 fs::path attrTablePath(tableDir / attrTableFile);
90 fs::path attrValueTablePath(tableDir / attrValueTableFile);
91
92 if (!pldm_bios_table_checksum(table.data(), table.size()))
93 {
94 return PLDM_INVALID_BIOS_TABLE_DATA_INTEGRITY_CHECK;
95 }
96
97 if (tableType == PLDM_BIOS_STRING_TABLE)
98 {
99 storeTable(stringTablePath, table);
100 }
101 else if (tableType == PLDM_BIOS_ATTR_TABLE)
102 {
103 BIOSTable biosStringTable(stringTablePath.c_str());
104 if (biosStringTable.isEmpty())
105 {
106 return PLDM_INVALID_BIOS_TABLE_TYPE;
107 }
108
109 auto rc = checkAttributeTable(table);
110 if (rc != PLDM_SUCCESS)
111 {
112 return rc;
113 }
114
115 storeTable(attrTablePath, table);
116 }
117 else if (tableType == PLDM_BIOS_ATTR_VAL_TABLE)
118 {
119 BIOSTable biosStringTable(stringTablePath.c_str());
120 BIOSTable biosStringValueTable(attrTablePath.c_str());
121 if (biosStringTable.isEmpty() || biosStringValueTable.isEmpty())
122 {
123 return PLDM_INVALID_BIOS_TABLE_TYPE;
124 }
125
126 auto rc = checkAttributeValueTable(table);
127 if (rc != PLDM_SUCCESS)
128 {
129 return rc;
130 }
131
132 storeTable(attrValueTablePath, table);
George Liu1b180d82020-07-23 14:01:58 +0800133 }
134 else
135 {
136 return PLDM_INVALID_BIOS_TABLE_TYPE;
137 }
138
Tom Joseph7f839f92020-09-21 10:20:44 +0530139 if ((tableType == PLDM_BIOS_ATTR_VAL_TABLE) && updateBaseBIOSTable)
George Liu1b180d82020-07-23 14:01:58 +0800140 {
George Liu1b180d82020-07-23 14:01:58 +0800141 updateBaseBIOSTableProperty();
142 }
143
144 return PLDM_SUCCESS;
145}
146
147int BIOSConfig::checkAttributeTable(const Table& table)
148{
149 using namespace pldm::bios::utils;
150 auto stringTable = getBIOSTable(PLDM_BIOS_STRING_TABLE);
151 for (auto entry :
152 BIOSTableIter<PLDM_BIOS_ATTR_TABLE>(table.data(), table.size()))
153 {
154 auto attrNameHandle =
155 pldm_bios_table_attr_entry_decode_string_handle(entry);
156
157 auto stringEnty = pldm_bios_table_string_find_by_handle(
158 stringTable->data(), stringTable->size(), attrNameHandle);
159 if (stringEnty == nullptr)
160 {
161 return PLDM_INVALID_BIOS_ATTR_HANDLE;
162 }
163
164 auto attrType = static_cast<pldm_bios_attribute_type>(
165 pldm_bios_table_attr_entry_decode_attribute_type(entry));
166
167 switch (attrType)
168 {
169 case PLDM_BIOS_ENUMERATION:
170 case PLDM_BIOS_ENUMERATION_READ_ONLY:
171 {
172 auto pvNum =
173 pldm_bios_table_attr_entry_enum_decode_pv_num(entry);
174 std::vector<uint16_t> pvHandls(pvNum);
175 pldm_bios_table_attr_entry_enum_decode_pv_hdls(
176 entry, pvHandls.data(), pvHandls.size());
177 auto defNum =
178 pldm_bios_table_attr_entry_enum_decode_def_num(entry);
179 std::vector<uint8_t> defIndices(defNum);
180 pldm_bios_table_attr_entry_enum_decode_def_indices(
181 entry, defIndices.data(), defIndices.size());
182
183 for (size_t i = 0; i < pvHandls.size(); i++)
184 {
185 auto stringEntry = pldm_bios_table_string_find_by_handle(
186 stringTable->data(), stringTable->size(), pvHandls[i]);
187 if (stringEntry == nullptr)
188 {
189 return PLDM_INVALID_BIOS_ATTR_HANDLE;
190 }
191 }
192
193 for (size_t i = 0; i < defIndices.size(); i++)
194 {
195 auto stringEntry = pldm_bios_table_string_find_by_handle(
196 stringTable->data(), stringTable->size(),
197 pvHandls[defIndices[i]]);
198 if (stringEntry == nullptr)
199 {
200 return PLDM_INVALID_BIOS_ATTR_HANDLE;
201 }
202 }
203 break;
204 }
205 case PLDM_BIOS_INTEGER:
206 case PLDM_BIOS_INTEGER_READ_ONLY:
207 case PLDM_BIOS_STRING:
208 case PLDM_BIOS_STRING_READ_ONLY:
209 case PLDM_BIOS_PASSWORD:
210 case PLDM_BIOS_PASSWORD_READ_ONLY:
211 break;
212 default:
213 return PLDM_INVALID_BIOS_ATTR_HANDLE;
214 }
215 }
216
217 return PLDM_SUCCESS;
218}
219
220int BIOSConfig::checkAttributeValueTable(const Table& table)
221{
222 using namespace pldm::bios::utils;
223 auto stringTable = getBIOSTable(PLDM_BIOS_STRING_TABLE);
224 auto attrTable = getBIOSTable(PLDM_BIOS_ATTR_TABLE);
225
226 baseBIOSTableMaps.clear();
227
228 for (auto tableEntry :
229 BIOSTableIter<PLDM_BIOS_ATTR_VAL_TABLE>(table.data(), table.size()))
230 {
231 AttributeName attributeName{};
232 AttributeType attributeType{};
233 ReadonlyStatus readonlyStatus{};
234 DisplayName displayName{};
235 Description description{};
236 MenuPath menuPath{};
237 CurrentValue currentValue{};
238 DefaultValue defaultValue{};
239 Option options{};
240
241 auto attrValueHandle =
242 pldm_bios_table_attr_value_entry_decode_attribute_handle(
243 tableEntry);
244 auto attrType = static_cast<pldm_bios_attribute_type>(
245 pldm_bios_table_attr_value_entry_decode_attribute_type(tableEntry));
246
247 auto attrEntry = pldm_bios_table_attr_find_by_handle(
248 attrTable->data(), attrTable->size(), attrValueHandle);
249 if (attrEntry == nullptr)
250 {
251 return PLDM_INVALID_BIOS_ATTR_HANDLE;
252 }
253 auto attrHandle =
254 pldm_bios_table_attr_entry_decode_attribute_handle(attrEntry);
255 auto attrNameHandle =
256 pldm_bios_table_attr_entry_decode_string_handle(attrEntry);
257
258 auto stringEntry = pldm_bios_table_string_find_by_handle(
259 stringTable->data(), stringTable->size(), attrNameHandle);
260 if (stringEntry == nullptr)
261 {
262 return PLDM_INVALID_BIOS_ATTR_HANDLE;
263 }
264 auto strLength =
265 pldm_bios_table_string_entry_decode_string_length(stringEntry);
266 std::vector<char> buffer(strLength + 1 /* sizeof '\0' */);
267 pldm_bios_table_string_entry_decode_string(stringEntry, buffer.data(),
268 buffer.size());
269 attributeName = std::string(buffer.data(), buffer.data() + strLength);
270
271 if (!biosAttributes.empty())
272 {
273 readonlyStatus =
George Liub1fbeec2020-09-04 09:59:46 +0800274 biosAttributes[attrHandle % biosAttributes.size()]->readOnly;
George Liu92bb4022020-09-03 14:58:24 +0800275 description =
276 biosAttributes[attrHandle % biosAttributes.size()]->helpText;
277 displayName =
278 biosAttributes[attrHandle % biosAttributes.size()]->displayName;
George Liu1b180d82020-07-23 14:01:58 +0800279 }
280
281 switch (attrType)
282 {
283 case PLDM_BIOS_ENUMERATION:
284 case PLDM_BIOS_ENUMERATION_READ_ONLY:
285 {
286 auto getValue = [](uint16_t handle,
287 const Table& table) -> std::string {
288 auto stringEntry = pldm_bios_table_string_find_by_handle(
289 table.data(), table.size(), handle);
290
291 auto strLength =
292 pldm_bios_table_string_entry_decode_string_length(
293 stringEntry);
294 std::vector<char> buffer(strLength + 1 /* sizeof '\0' */);
295 pldm_bios_table_string_entry_decode_string(
296 stringEntry, buffer.data(), buffer.size());
297
298 return std::string(buffer.data(),
299 buffer.data() + strLength);
300 };
301
302 attributeType = "xyz.openbmc_project.BIOSConfig.Manager."
303 "AttributeType.Enumeration";
304
305 auto pvNum =
306 pldm_bios_table_attr_entry_enum_decode_pv_num(attrEntry);
307 std::vector<uint16_t> pvHandls(pvNum);
308 pldm_bios_table_attr_entry_enum_decode_pv_hdls(
309 attrEntry, pvHandls.data(), pvHandls.size());
310
311 // get possible_value
312 for (size_t i = 0; i < pvHandls.size(); i++)
313 {
314 options.push_back(
315 std::make_tuple("xyz.openbmc_project.BIOSConfig."
316 "Manager.BoundType.OneOf",
317 getValue(pvHandls[i], *stringTable)));
318 }
319
320 auto count =
321 pldm_bios_table_attr_value_entry_enum_decode_number(
322 tableEntry);
323 std::vector<uint8_t> handles(count);
324 pldm_bios_table_attr_value_entry_enum_decode_handles(
325 tableEntry, handles.data(), handles.size());
326
327 // get current_value
328 for (size_t i = 0; i < handles.size(); i++)
329 {
330 currentValue = getValue(pvHandls[handles[i]], *stringTable);
331 }
332
333 auto defNum =
334 pldm_bios_table_attr_entry_enum_decode_def_num(attrEntry);
335 std::vector<uint8_t> defIndices(defNum);
336 pldm_bios_table_attr_entry_enum_decode_def_indices(
337 attrEntry, defIndices.data(), defIndices.size());
338
339 // get default_value
340 for (size_t i = 0; i < defIndices.size(); i++)
341 {
Patrick Williams6da4f912023-05-10 07:50:53 -0500342 defaultValue = getValue(pvHandls[defIndices[i]],
343 *stringTable);
George Liu1b180d82020-07-23 14:01:58 +0800344 }
345
346 break;
347 }
348 case PLDM_BIOS_INTEGER:
349 case PLDM_BIOS_INTEGER_READ_ONLY:
350 {
351 attributeType = "xyz.openbmc_project.BIOSConfig.Manager."
352 "AttributeType.Integer";
353 currentValue = static_cast<int64_t>(
354 pldm_bios_table_attr_value_entry_integer_decode_cv(
355 tableEntry));
356
357 uint64_t lower, upper, def;
358 uint32_t scalar;
359 pldm_bios_table_attr_entry_integer_decode(
360 attrEntry, &lower, &upper, &scalar, &def);
361 options.push_back(
362 std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
363 "BoundType.LowerBound",
364 static_cast<int64_t>(lower)));
365 options.push_back(
366 std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
367 "BoundType.UpperBound",
368 static_cast<int64_t>(upper)));
369 options.push_back(
370 std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
371 "BoundType.ScalarIncrement",
372 static_cast<int64_t>(scalar)));
373 defaultValue = static_cast<int64_t>(def);
374 break;
375 }
376 case PLDM_BIOS_STRING:
377 case PLDM_BIOS_STRING_READ_ONLY:
378 {
379 attributeType = "xyz.openbmc_project.BIOSConfig.Manager."
380 "AttributeType.String";
381 variable_field currentString;
382 pldm_bios_table_attr_value_entry_string_decode_string(
383 tableEntry, &currentString);
384 currentValue = std::string(
385 reinterpret_cast<const char*>(currentString.ptr),
386 currentString.length);
387 auto min = pldm_bios_table_attr_entry_string_decode_min_length(
388 attrEntry);
389 auto max = pldm_bios_table_attr_entry_string_decode_max_length(
390 attrEntry);
391 auto def =
392 pldm_bios_table_attr_entry_string_decode_def_string_length(
393 attrEntry);
394 std::vector<char> defString(def + 1);
395 pldm_bios_table_attr_entry_string_decode_def_string(
396 attrEntry, defString.data(), defString.size());
397 options.push_back(
398 std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
399 "BoundType.MinStringLength",
400 static_cast<int64_t>(min)));
401 options.push_back(
402 std::make_tuple("xyz.openbmc_project.BIOSConfig.Manager."
403 "BoundType.MaxStringLength",
404 static_cast<int64_t>(max)));
405 defaultValue = defString.data();
406 break;
407 }
408 case PLDM_BIOS_PASSWORD:
409 case PLDM_BIOS_PASSWORD_READ_ONLY:
410 {
411 attributeType = "xyz.openbmc_project.BIOSConfig.Manager."
412 "AttributeType.Password";
413 break;
414 }
415 default:
416 return PLDM_INVALID_BIOS_ATTR_HANDLE;
417 }
418 baseBIOSTableMaps.emplace(
419 std::move(attributeName),
420 std::make_tuple(attributeType, readonlyStatus, displayName,
421 description, menuPath, currentValue, defaultValue,
422 std::move(options)));
423 }
424
425 return PLDM_SUCCESS;
426}
427
428void BIOSConfig::updateBaseBIOSTableProperty()
429{
430 constexpr static auto biosConfigPath =
431 "/xyz/openbmc_project/bios_config/manager";
432 constexpr static auto biosConfigInterface =
433 "xyz.openbmc_project.BIOSConfig.Manager";
434 constexpr static auto biosConfigPropertyName = "BaseBIOSTable";
435 constexpr static auto dbusProperties = "org.freedesktop.DBus.Properties";
436
437 if (baseBIOSTableMaps.empty())
438 {
439 return;
440 }
441
442 try
443 {
444 auto& bus = dbusHandler->getBus();
Patrick Williams6da4f912023-05-10 07:50:53 -0500445 auto service = dbusHandler->getService(biosConfigPath,
446 biosConfigInterface);
George Liu1b180d82020-07-23 14:01:58 +0800447 auto method = bus.new_method_call(service.c_str(), biosConfigPath,
448 dbusProperties, "Set");
449 std::variant<BaseBIOSTable> value = baseBIOSTableMaps;
450 method.append(biosConfigInterface, biosConfigPropertyName, value);
451 bus.call_noreply(method);
452 }
453 catch (const std::exception& e)
454 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600455 error("failed to update BaseBIOSTable property, ERROR={ERR_EXCEP}",
456 "ERR_EXCEP", e.what());
George Liu1b180d82020-07-23 14:01:58 +0800457 }
458}
459
John Wangd9659342020-02-27 16:46:05 +0800460void BIOSConfig::constructAttributes()
461{
462 load(jsonDir / stringJsonFile, [this](const Json& entry) {
463 constructAttribute<BIOSStringAttribute>(entry);
464 });
John Wang3be70852020-02-13 15:59:04 +0800465 load(jsonDir / integerJsonFile, [this](const Json& entry) {
John Wang95e6b3c2020-02-13 09:43:24 +0800466 constructAttribute<BIOSIntegerAttribute>(entry);
467 });
John Wang3be70852020-02-13 15:59:04 +0800468 load(jsonDir / enumJsonFile, [this](const Json& entry) {
469 constructAttribute<BIOSEnumAttribute>(entry);
470 });
John Wangd9659342020-02-27 16:46:05 +0800471}
472
473void BIOSConfig::buildAndStoreAttrTables(const Table& stringTable)
474{
475 BIOSStringTable biosStringTable(stringTable);
476
477 if (biosAttributes.empty())
478 {
479 return;
480 }
481
Tom Josephca7b2522020-11-18 12:27:11 +0530482 BaseBIOSTable biosTable{};
483 constexpr auto biosObjPath = "/xyz/openbmc_project/bios_config/manager";
484 constexpr auto biosInterface = "xyz.openbmc_project.BIOSConfig.Manager";
485
486 try
487 {
488 auto& bus = dbusHandler->getBus();
489 auto service = dbusHandler->getService(biosObjPath, biosInterface);
Patrick Williams6da4f912023-05-10 07:50:53 -0500490 auto method = bus.new_method_call(service.c_str(), biosObjPath,
491 "org.freedesktop.DBus.Properties",
492 "Get");
Tom Josephca7b2522020-11-18 12:27:11 +0530493 method.append(biosInterface, "BaseBIOSTable");
494 auto reply = bus.call(method);
495 std::variant<BaseBIOSTable> varBiosTable{};
496 reply.read(varBiosTable);
497 biosTable = std::get<BaseBIOSTable>(varBiosTable);
498 }
499 // Failed to read the BaseBIOSTable, so update the BaseBIOSTable with the
500 // default values populated from the BIOS JSONs to keep PLDM and
501 // bios-settings-manager in sync
502 catch (const std::exception& e)
503 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600504 error("Failed to read BaseBIOSTable property, ERROR={ERR_EXCEP}",
505 "ERR_EXCEP", e.what());
Tom Josephca7b2522020-11-18 12:27:11 +0530506 }
507
John Wangd9659342020-02-27 16:46:05 +0800508 Table attrTable, attrValueTable;
509
510 for (auto& attr : biosAttributes)
511 {
512 try
513 {
Tom Josephca7b2522020-11-18 12:27:11 +0530514 auto iter = biosTable.find(attr->name);
515 if (iter == biosTable.end())
516 {
517 attr->constructEntry(biosStringTable, attrTable, attrValueTable,
518 std::nullopt);
519 }
520 else
521 {
522 attr->constructEntry(
523 biosStringTable, attrTable, attrValueTable,
524 std::get<static_cast<uint8_t>(Index::currentValue)>(
525 iter->second));
526 }
John Wangd9659342020-02-27 16:46:05 +0800527 }
528 catch (const std::exception& e)
529 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600530 error("Construct Table Entry Error, AttributeName = {ATTR_NAME}",
531 "ATTR_NAME", attr->name);
John Wangd9659342020-02-27 16:46:05 +0800532 }
533 }
534
535 table::appendPadAndChecksum(attrTable);
536 table::appendPadAndChecksum(attrValueTable);
George Liu1b180d82020-07-23 14:01:58 +0800537 setBIOSTable(PLDM_BIOS_ATTR_TABLE, attrTable);
538 setBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE, attrValueTable);
John Wangd9659342020-02-27 16:46:05 +0800539}
540
541std::optional<Table> BIOSConfig::buildAndStoreStringTable()
542{
543 std::set<std::string> strings;
544 auto handler = [&strings](const Json& entry) {
545 strings.emplace(entry.at("attribute_name"));
546 };
547
548 load(jsonDir / stringJsonFile, handler);
549 load(jsonDir / integerJsonFile, handler);
550 load(jsonDir / enumJsonFile, [&strings](const Json& entry) {
551 strings.emplace(entry.at("attribute_name"));
552 auto possibleValues = entry.at("possible_values");
553 for (auto& pv : possibleValues)
554 {
555 strings.emplace(pv);
556 }
557 });
558
559 if (strings.empty())
560 {
561 return std::nullopt;
562 }
563
564 Table table;
565 for (const auto& elem : strings)
566 {
567 table::string::constructEntry(table, elem);
568 }
569
570 table::appendPadAndChecksum(table);
George Liu1b180d82020-07-23 14:01:58 +0800571 setBIOSTable(PLDM_BIOS_STRING_TABLE, table);
John Wangd9659342020-02-27 16:46:05 +0800572 return table;
573}
574
575void BIOSConfig::storeTable(const fs::path& path, const Table& table)
576{
577 BIOSTable biosTable(path.c_str());
578 biosTable.store(table);
579}
580
581std::optional<Table> BIOSConfig::loadTable(const fs::path& path)
582{
583 BIOSTable biosTable(path.c_str());
584 if (biosTable.isEmpty())
585 {
586 return std::nullopt;
587 }
588
589 Table table;
590 biosTable.load(table);
591 return table;
592}
593
594void BIOSConfig::load(const fs::path& filePath, ParseHandler handler)
595{
596 std::ifstream file;
597 Json jsonConf;
598 if (fs::exists(filePath))
599 {
600 try
601 {
602 file.open(filePath);
603 jsonConf = Json::parse(file);
604 auto entries = jsonConf.at("entries");
605 for (auto& entry : entries)
606 {
607 try
608 {
609 handler(entry);
610 }
611 catch (const std::exception& e)
612 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600613 error(
614 "Failed to parse JSON config file(entry handler) : {JSON_PATH}, {ERR_EXCEP}",
615 "JSON_PATH", filePath.c_str(), "ERR_EXCEP", e.what());
John Wangd9659342020-02-27 16:46:05 +0800616 }
617 }
618 }
619 catch (const std::exception& e)
620 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600621 error("Failed to parse JSON config file : {JSON_PATH}", "JSON_PATH",
622 filePath.c_str());
John Wangd9659342020-02-27 16:46:05 +0800623 }
624 }
625}
626
Sagar Srinivascac0ebb2021-11-23 07:50:28 -0600627std::string BIOSConfig::decodeStringFromStringEntry(
628 const pldm_bios_string_table_entry* stringEntry)
629{
630 auto strLength =
631 pldm_bios_table_string_entry_decode_string_length(stringEntry);
632 std::vector<char> buffer(strLength + 1 /* sizeof '\0' */);
633 pldm_bios_table_string_entry_decode_string(stringEntry, buffer.data(),
634 buffer.size());
635 return std::string(buffer.data(), buffer.data() + strLength);
636}
637
638std::string
639 BIOSConfig::displayStringHandle(uint16_t handle, uint8_t index,
640 const std::optional<Table>& attrTable,
641 const std::optional<Table>& stringTable)
642{
643 auto attrEntry = pldm_bios_table_attr_find_by_handle(
644 attrTable->data(), attrTable->size(), handle);
645 auto pvNum = pldm_bios_table_attr_entry_enum_decode_pv_num(attrEntry);
646 std::vector<uint16_t> pvHandls(pvNum);
647 pldm_bios_table_attr_entry_enum_decode_pv_hdls(attrEntry, pvHandls.data(),
648 pvHandls.size());
649
650 std::string displayString = std::to_string(pvHandls[index]);
651
652 auto stringEntry = pldm_bios_table_string_find_by_handle(
653 stringTable->data(), stringTable->size(), pvHandls[index]);
654
655 auto decodedStr = decodeStringFromStringEntry(stringEntry);
656
657 return decodedStr + "(" + displayString + ")";
658}
659
660void BIOSConfig::traceBIOSUpdate(
661 const pldm_bios_attr_val_table_entry* attrValueEntry,
662 const pldm_bios_attr_table_entry* attrEntry, bool isBMC)
663{
664 auto stringTable = getBIOSTable(PLDM_BIOS_STRING_TABLE);
665 auto attrTable = getBIOSTable(PLDM_BIOS_ATTR_TABLE);
666
Patrick Williams6da4f912023-05-10 07:50:53 -0500667 auto [attrHandle,
668 attrType] = table::attribute_value::decodeHeader(attrValueEntry);
Sagar Srinivascac0ebb2021-11-23 07:50:28 -0600669
670 auto attrHeader = table::attribute::decodeHeader(attrEntry);
671 BIOSStringTable biosStringTable(*stringTable);
672 auto attrName = biosStringTable.findString(attrHeader.stringHandle);
673
674 switch (attrType)
675 {
676 case PLDM_BIOS_ENUMERATION:
677 case PLDM_BIOS_ENUMERATION_READ_ONLY:
678 {
679 auto count = pldm_bios_table_attr_value_entry_enum_decode_number(
680 attrValueEntry);
681 std::vector<uint8_t> handles(count);
682 pldm_bios_table_attr_value_entry_enum_decode_handles(
683 attrValueEntry, handles.data(), handles.size());
684
685 for (uint8_t handle : handles)
686 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600687 auto nwVal = displayStringHandle(attrHandle, handle, attrTable,
688 stringTable);
689 auto chkBMC = isBMC ? "true" : "false";
690 info(
691 "BIOS:{ATTR_NAME}, updated to value: {NEW_VAL}, by BMC: {CHK_BMC} ",
692 "ATTR_NAME", attrName, "NEW_VAL", nwVal, "CHK_BMC", chkBMC);
Sagar Srinivascac0ebb2021-11-23 07:50:28 -0600693 }
694 break;
695 }
696 case PLDM_BIOS_INTEGER:
697 case PLDM_BIOS_INTEGER_READ_ONLY:
698 {
699 auto value =
700 table::attribute_value::decodeIntegerEntry(attrValueEntry);
Riya Dixit49cfb132023-03-02 04:26:53 -0600701 auto chkBMC = isBMC ? "true" : "false";
702 info(
703 "BIOS: {ATTR_NAME}, updated to value: {UPDATED_VAL}, by BMC: {CHK_BMC}",
704 "ATTR_NAME", attrName, "UPDATED_VAL", value, "CHK_BMC", chkBMC);
Sagar Srinivascac0ebb2021-11-23 07:50:28 -0600705 break;
706 }
707 case PLDM_BIOS_STRING:
708 case PLDM_BIOS_STRING_READ_ONLY:
709 {
710 auto value =
711 table::attribute_value::decodeStringEntry(attrValueEntry);
Riya Dixit49cfb132023-03-02 04:26:53 -0600712 auto chkBMC = isBMC ? "true" : "false";
713 info(
714 "BIOS: {ATTR_NAME}, updated to value: {UPDATED_VAL}, by BMC: {CHK_BMC}",
715 "ATTR_NAME", attrName, "UPDATED_VAL", value, "CHK_BMC", chkBMC);
Sagar Srinivascac0ebb2021-11-23 07:50:28 -0600716 break;
717 }
718 default:
719 break;
720 };
721}
722
John Wang8241b342020-06-05 10:49:17 +0800723int BIOSConfig::checkAttrValueToUpdate(
724 const pldm_bios_attr_val_table_entry* attrValueEntry,
725 const pldm_bios_attr_table_entry* attrEntry, Table&)
726
727{
Patrick Williams6da4f912023-05-10 07:50:53 -0500728 auto [attrHandle,
729 attrType] = table::attribute_value::decodeHeader(attrValueEntry);
John Wang8241b342020-06-05 10:49:17 +0800730
731 switch (attrType)
732 {
733 case PLDM_BIOS_ENUMERATION:
George Liu5bb9edb2021-08-05 20:10:32 +0800734 case PLDM_BIOS_ENUMERATION_READ_ONLY:
John Wang8241b342020-06-05 10:49:17 +0800735 {
736 auto value =
737 table::attribute_value::decodeEnumEntry(attrValueEntry);
Patrick Williams6da4f912023-05-10 07:50:53 -0500738 auto [pvHdls,
739 defIndex] = table::attribute::decodeEnumEntry(attrEntry);
Varsha Kaverappa6a4d1cf2021-11-24 21:15:42 -0600740 if (!(value.size() == 1))
741 {
742 return PLDM_ERROR_INVALID_LENGTH;
743 }
John Wang8241b342020-06-05 10:49:17 +0800744 if (value[0] >= pvHdls.size())
745 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600746 error("Enum: Illgeal index, Index = {ATTR_INDEX}", "ATTR_INDEX",
747 (int)value[0]);
John Wang8241b342020-06-05 10:49:17 +0800748 return PLDM_ERROR_INVALID_DATA;
749 }
John Wang8241b342020-06-05 10:49:17 +0800750 return PLDM_SUCCESS;
751 }
752 case PLDM_BIOS_INTEGER:
George Liu5bb9edb2021-08-05 20:10:32 +0800753 case PLDM_BIOS_INTEGER_READ_ONLY:
John Wang8241b342020-06-05 10:49:17 +0800754 {
755 auto value =
756 table::attribute_value::decodeIntegerEntry(attrValueEntry);
Patrick Williams6da4f912023-05-10 07:50:53 -0500757 auto [lower, upper, scalar,
758 def] = table::attribute::decodeIntegerEntry(attrEntry);
John Wang8241b342020-06-05 10:49:17 +0800759
760 if (value < lower || value > upper)
761 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600762 error("Integer: out of bound, value = {ATTR_VALUE}",
763 "ATTR_VALUE", value);
John Wang8241b342020-06-05 10:49:17 +0800764 return PLDM_ERROR_INVALID_DATA;
765 }
766 return PLDM_SUCCESS;
767 }
768 case PLDM_BIOS_STRING:
George Liu5bb9edb2021-08-05 20:10:32 +0800769 case PLDM_BIOS_STRING_READ_ONLY:
John Wang8241b342020-06-05 10:49:17 +0800770 {
771 auto stringConf = table::attribute::decodeStringEntry(attrEntry);
772 auto value =
773 table::attribute_value::decodeStringEntry(attrValueEntry);
774 if (value.size() < stringConf.minLength ||
775 value.size() > stringConf.maxLength)
776 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600777 error(
778 "String: Length error, string = {ATTR_VALUE} length {LEN}",
779 "ATTR_VALUE", value, "LEN", value.size());
John Wang8241b342020-06-05 10:49:17 +0800780 return PLDM_ERROR_INVALID_LENGTH;
781 }
782 return PLDM_SUCCESS;
783 }
784 default:
Riya Dixit49cfb132023-03-02 04:26:53 -0600785 error("ReadOnly or Unspported type, type = {ATTR_TYPE}",
786 "ATTR_TYPE", attrType);
John Wang8241b342020-06-05 10:49:17 +0800787 return PLDM_ERROR;
788 };
789}
790
Sagar Srinivascac0ebb2021-11-23 07:50:28 -0600791int BIOSConfig::setAttrValue(const void* entry, size_t size, bool isBMC,
792 bool updateDBus, bool updateBaseBIOSTable)
John Wangd9659342020-02-27 16:46:05 +0800793{
794 auto attrValueTable = getBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE);
795 auto attrTable = getBIOSTable(PLDM_BIOS_ATTR_TABLE);
796 auto stringTable = getBIOSTable(PLDM_BIOS_STRING_TABLE);
797 if (!attrValueTable || !attrTable || !stringTable)
798 {
799 return PLDM_BIOS_TABLE_UNAVAILABLE;
800 }
801
John Wangd9659342020-02-27 16:46:05 +0800802 auto attrValueEntry =
803 reinterpret_cast<const pldm_bios_attr_val_table_entry*>(entry);
804
805 auto attrValHeader = table::attribute_value::decodeHeader(attrValueEntry);
806
Patrick Williams6da4f912023-05-10 07:50:53 -0500807 auto attrEntry = table::attribute::findByHandle(*attrTable,
808 attrValHeader.attrHandle);
John Wangd9659342020-02-27 16:46:05 +0800809 if (!attrEntry)
810 {
811 return PLDM_ERROR;
812 }
813
John Wang8241b342020-06-05 10:49:17 +0800814 auto rc = checkAttrValueToUpdate(attrValueEntry, attrEntry, *stringTable);
815 if (rc != PLDM_SUCCESS)
816 {
817 return rc;
818 }
819
Patrick Williams6da4f912023-05-10 07:50:53 -0500820 auto destTable = table::attribute_value::updateTable(*attrValueTable, entry,
821 size);
John Wang8241b342020-06-05 10:49:17 +0800822
823 if (!destTable)
824 {
825 return PLDM_ERROR;
826 }
827
John Wangd9659342020-02-27 16:46:05 +0800828 try
829 {
830 auto attrHeader = table::attribute::decodeHeader(attrEntry);
831
832 BIOSStringTable biosStringTable(*stringTable);
833 auto attrName = biosStringTable.findString(attrHeader.stringHandle);
Patrick Williams6da4f912023-05-10 07:50:53 -0500834 auto iter = std::find_if(biosAttributes.begin(), biosAttributes.end(),
835 [&attrName](const auto& attr) {
836 return attr->name == attrName;
837 });
John Wangd9659342020-02-27 16:46:05 +0800838
839 if (iter == biosAttributes.end())
840 {
841 return PLDM_ERROR;
842 }
George Liu6d6d1e82021-02-16 11:08:55 +0800843 if (updateDBus)
844 {
845 (*iter)->setAttrValueOnDbus(attrValueEntry, attrEntry,
846 biosStringTable);
847 }
John Wangd9659342020-02-27 16:46:05 +0800848 }
849 catch (const std::exception& e)
850 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600851 error("Set attribute value error: {ERR_EXCEP}", "ERR_EXCEP", e.what());
John Wangd9659342020-02-27 16:46:05 +0800852 return PLDM_ERROR;
853 }
854
Tom Joseph7f839f92020-09-21 10:20:44 +0530855 setBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE, *destTable, updateBaseBIOSTable);
George Liu5c3192b2020-08-13 17:35:43 +0800856
Sagar Srinivascac0ebb2021-11-23 07:50:28 -0600857 traceBIOSUpdate(attrValueEntry, attrEntry, isBMC);
858
John Wangd9659342020-02-27 16:46:05 +0800859 return PLDM_SUCCESS;
860}
861
862void BIOSConfig::removeTables()
863{
864 try
865 {
866 fs::remove(tableDir / stringTableFile);
867 fs::remove(tableDir / attrTableFile);
868 fs::remove(tableDir / attrValueTableFile);
869 }
870 catch (const std::exception& e)
871 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600872 error("Remove the tables error: {ERR_EXCEP}", "ERR_EXCEP", e.what());
John Wangd9659342020-02-27 16:46:05 +0800873 }
874}
875
Sampa Misra46ece062020-03-18 07:17:44 -0500876void BIOSConfig::processBiosAttrChangeNotification(
877 const DbusChObjProperties& chProperties, uint32_t biosAttrIndex)
878{
879 const auto& dBusMap = biosAttributes[biosAttrIndex]->getDBusMap();
880 const auto& propertyName = dBusMap->propertyName;
881 const auto& attrName = biosAttributes[biosAttrIndex]->name;
882
883 const auto it = chProperties.find(propertyName);
884 if (it == chProperties.end())
885 {
886 return;
887 }
888
889 PropertyValue newPropVal = it->second;
890 auto stringTable = getBIOSTable(PLDM_BIOS_STRING_TABLE);
891 if (!stringTable.has_value())
892 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600893 error("BIOS string table unavailable");
Sampa Misra46ece062020-03-18 07:17:44 -0500894 return;
895 }
896 BIOSStringTable biosStringTable(*stringTable);
897 uint16_t attrNameHdl{};
898 try
899 {
900 attrNameHdl = biosStringTable.findHandle(attrName);
901 }
Patrick Williams51330582021-10-06 12:48:56 -0500902 catch (const std::invalid_argument& e)
Sampa Misra46ece062020-03-18 07:17:44 -0500903 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600904 error("Could not find handle for BIOS string, ATTRIBUTE={ATTR_NAME}",
905 "ATTR_NAME", attrName.c_str());
Sampa Misra46ece062020-03-18 07:17:44 -0500906 return;
907 }
908
909 auto attrTable = getBIOSTable(PLDM_BIOS_ATTR_TABLE);
910 if (!attrTable.has_value())
911 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600912 error("Attribute table not present");
Sampa Misra46ece062020-03-18 07:17:44 -0500913 return;
914 }
915 const struct pldm_bios_attr_table_entry* tableEntry =
916 table::attribute::findByStringHandle(*attrTable, attrNameHdl);
917 if (tableEntry == nullptr)
918 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600919 error(
920 "Attribute not found in attribute table, name= {ATTR_NAME} name handle={ATTR_HANDLE}",
921 "ATTR_NAME", attrName.c_str(), "ATTR_HANDLE", attrNameHdl);
Sampa Misra46ece062020-03-18 07:17:44 -0500922 return;
923 }
924
Patrick Williams6da4f912023-05-10 07:50:53 -0500925 auto [attrHdl, attrType,
926 stringHdl] = table::attribute::decodeHeader(tableEntry);
Sampa Misra46ece062020-03-18 07:17:44 -0500927
928 auto attrValueSrcTable = getBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE);
929
930 if (!attrValueSrcTable.has_value())
931 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600932 error("Attribute value table not present");
Sampa Misra46ece062020-03-18 07:17:44 -0500933 return;
934 }
935
936 Table newValue;
937 auto rc = biosAttributes[biosAttrIndex]->updateAttrVal(
938 newValue, attrHdl, attrType, newPropVal);
939 if (rc != PLDM_SUCCESS)
940 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600941 error(
942 "Could not update the attribute value table for attribute handle={ATTR_HANDLE} and type={ATTR_TYPE}",
943 "ATTR_HANDLE", attrHdl, "ATTR_TYPE", (uint32_t)attrType);
Sampa Misra46ece062020-03-18 07:17:44 -0500944 return;
945 }
946 auto destTable = table::attribute_value::updateTable(
947 *attrValueSrcTable, newValue.data(), newValue.size());
948 if (destTable.has_value())
949 {
950 storeTable(tableDir / attrValueTableFile, *destTable);
951 }
Sampa Misra0f262332021-02-15 00:13:51 -0600952
Sagar Srinivascac0ebb2021-11-23 07:50:28 -0600953 rc = setAttrValue(newValue.data(), newValue.size(), true, false);
Sampa Misra0f262332021-02-15 00:13:51 -0600954 if (rc != PLDM_SUCCESS)
955 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600956 error("could not setAttrValue on base bios table and dbus, rc = {RC}",
957 "RC", rc);
Sampa Misra0f262332021-02-15 00:13:51 -0600958 }
Sampa Misra46ece062020-03-18 07:17:44 -0500959}
960
George Liu1244acf2020-08-14 09:11:11 +0800961uint16_t BIOSConfig::findAttrHandle(const std::string& attrName)
962{
963 auto stringTable = getBIOSTable(PLDM_BIOS_STRING_TABLE);
964 auto attrTable = getBIOSTable(PLDM_BIOS_ATTR_TABLE);
965
966 BIOSStringTable biosStringTable(*stringTable);
967 pldm::bios::utils::BIOSTableIter<PLDM_BIOS_ATTR_TABLE> attrTableIter(
968 attrTable->data(), attrTable->size());
969 auto stringHandle = biosStringTable.findHandle(attrName);
970
971 for (auto entry : pldm::bios::utils::BIOSTableIter<PLDM_BIOS_ATTR_TABLE>(
972 attrTable->data(), attrTable->size()))
973 {
974 auto header = table::attribute::decodeHeader(entry);
975 if (header.stringHandle == stringHandle)
976 {
977 return header.attrHandle;
978 }
979 }
980
981 throw std::invalid_argument("Unknow attribute Name");
982}
983
984void BIOSConfig::constructPendingAttribute(
985 const PendingAttributes& pendingAttributes)
986{
Tom Joseph7f839f92020-09-21 10:20:44 +0530987 std::vector<uint16_t> listOfHandles{};
988
George Liu1244acf2020-08-14 09:11:11 +0800989 for (auto& attribute : pendingAttributes)
990 {
991 std::string attributeName = attribute.first;
992 auto& [attributeType, attributevalue] = attribute.second;
993
994 auto iter = std::find_if(biosAttributes.begin(), biosAttributes.end(),
995 [&attributeName](const auto& attr) {
Patrick Williams6da4f912023-05-10 07:50:53 -0500996 return attr->name == attributeName;
997 });
George Liu1244acf2020-08-14 09:11:11 +0800998
999 if (iter == biosAttributes.end())
1000 {
Riya Dixit49cfb132023-03-02 04:26:53 -06001001 error("Wrong attribute name, attributeName = {ATTR_NAME}",
1002 "ATTR_NAME", attributeName);
George Liu1244acf2020-08-14 09:11:11 +08001003 continue;
1004 }
1005
1006 Table attrValueEntry(sizeof(pldm_bios_attr_val_table_entry), 0);
1007 auto entry = reinterpret_cast<pldm_bios_attr_val_table_entry*>(
1008 attrValueEntry.data());
1009
1010 auto handler = findAttrHandle(attributeName);
1011 auto type =
1012 BIOSConfigManager::convertAttributeTypeFromString(attributeType);
1013
1014 if (type != BIOSConfigManager::AttributeType::Enumeration &&
1015 type != BIOSConfigManager::AttributeType::String &&
1016 type != BIOSConfigManager::AttributeType::Integer)
1017 {
Riya Dixit49cfb132023-03-02 04:26:53 -06001018 error("Attribute type not supported, attributeType = {ATTR_TYPE}",
1019 "ATTR_TYPE", attributeType);
George Liu1244acf2020-08-14 09:11:11 +08001020 continue;
1021 }
1022
George Liu4876c542022-06-08 15:59:54 +08001023 const auto [attrType, readonlyStatus, displayName, description,
Patrick Williams6da4f912023-05-10 07:50:53 -05001024 menuPath, currentValue, defaultValue,
1025 option] = baseBIOSTableMaps.at(attributeName);
George Liu4876c542022-06-08 15:59:54 +08001026
George Liu1244acf2020-08-14 09:11:11 +08001027 entry->attr_handle = htole16(handler);
George Liu4876c542022-06-08 15:59:54 +08001028
1029 // Need to verify that the current value has really changed
1030 if (attributeType == attrType && attributevalue != currentValue)
1031 {
1032 listOfHandles.emplace_back(htole16(handler));
1033 }
Tom Joseph7f839f92020-09-21 10:20:44 +05301034
George Liu1244acf2020-08-14 09:11:11 +08001035 (*iter)->generateAttributeEntry(attributevalue, attrValueEntry);
1036
Sagar Srinivascac0ebb2021-11-23 07:50:28 -06001037 setAttrValue(attrValueEntry.data(), attrValueEntry.size(), true);
Tom Joseph7f839f92020-09-21 10:20:44 +05301038 }
1039
1040 if (listOfHandles.size())
1041 {
1042#ifdef OEM_IBM
1043 auto rc = pldm::responder::platform::sendBiosAttributeUpdateEvent(
Andrew Jefferya330b2f2023-05-04 14:55:37 +09301044 eid, instanceIdDb, listOfHandles, handler);
Tom Joseph7f839f92020-09-21 10:20:44 +05301045 if (rc != PLDM_SUCCESS)
1046 {
1047 return;
1048 }
1049#endif
George Liu1244acf2020-08-14 09:11:11 +08001050 }
1051}
1052
1053void BIOSConfig::listenPendingAttributes()
1054{
1055 constexpr auto objPath = "/xyz/openbmc_project/bios_config/manager";
1056 constexpr auto objInterface = "xyz.openbmc_project.BIOSConfig.Manager";
1057
1058 using namespace sdbusplus::bus::match::rules;
Patrick Williams84b790c2022-07-22 19:26:56 -05001059 auto updateBIOSMatch = std::make_unique<sdbusplus::bus::match_t>(
George Liu1244acf2020-08-14 09:11:11 +08001060 pldm::utils::DBusHandler::getBus(),
1061 propertiesChanged(objPath, objInterface),
Patrick Williams84b790c2022-07-22 19:26:56 -05001062 [this](sdbusplus::message_t& msg) {
Patrick Williams6da4f912023-05-10 07:50:53 -05001063 constexpr auto propertyName = "PendingAttributes";
George Liu1244acf2020-08-14 09:11:11 +08001064
Patrick Williams6da4f912023-05-10 07:50:53 -05001065 using Value =
1066 std::variant<std::string, PendingAttributes, BaseBIOSTable>;
1067 using Properties = std::map<DbusProp, Value>;
George Liu1244acf2020-08-14 09:11:11 +08001068
Patrick Williams6da4f912023-05-10 07:50:53 -05001069 Properties props{};
1070 std::string intf;
1071 msg.read(intf, props);
George Liu1244acf2020-08-14 09:11:11 +08001072
Patrick Williams6da4f912023-05-10 07:50:53 -05001073 auto valPropMap = props.find(propertyName);
1074 if (valPropMap == props.end())
1075 {
1076 return;
1077 }
George Liu1244acf2020-08-14 09:11:11 +08001078
Patrick Williams6da4f912023-05-10 07:50:53 -05001079 PendingAttributes pendingAttributes =
1080 std::get<PendingAttributes>(valPropMap->second);
1081 this->constructPendingAttribute(pendingAttributes);
George Liu1244acf2020-08-14 09:11:11 +08001082 });
1083
1084 biosAttrMatch.emplace_back(std::move(updateBIOSMatch));
1085}
1086
John Wangd9659342020-02-27 16:46:05 +08001087} // namespace bios
1088} // namespace responder
1089} // namespace pldm