John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "bios_attribute.hpp" |
| 4 | #include "bios_table.hpp" |
Andrew Jeffery | 2abbce7 | 2023-10-18 10:17:35 +1030 | [diff] [blame] | 5 | #include "common/instance_id.hpp" |
Sagar Srinivas | 11ce8d2 | 2022-07-28 11:32:34 -0500 | [diff] [blame] | 6 | #include "oem_handler.hpp" |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 7 | #include "platform_config.hpp" |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 8 | #include "requester/handler.hpp" |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 9 | |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 10 | #include <libpldm/bios_table.h> |
| 11 | |
George Liu | 6492f52 | 2020-06-16 10:34:05 +0800 | [diff] [blame] | 12 | #include <nlohmann/json.hpp> |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 13 | #include <phosphor-logging/lg2.hpp> |
George Liu | 6492f52 | 2020-06-16 10:34:05 +0800 | [diff] [blame] | 14 | |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 15 | #include <functional> |
| 16 | #include <iostream> |
| 17 | #include <memory> |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 18 | #include <optional> |
| 19 | #include <set> |
| 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 23 | PHOSPHOR_LOG2_USING; |
| 24 | |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 25 | namespace pldm |
| 26 | { |
| 27 | namespace responder |
| 28 | { |
| 29 | namespace bios |
| 30 | { |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 31 | enum class BoundType |
| 32 | { |
| 33 | LowerBound, |
| 34 | UpperBound, |
| 35 | ScalarIncrement, |
| 36 | MinStringLength, |
| 37 | MaxStringLength, |
| 38 | OneOf |
| 39 | }; |
| 40 | |
| 41 | using AttributeName = std::string; |
| 42 | using AttributeType = std::string; |
| 43 | using ReadonlyStatus = bool; |
| 44 | using DisplayName = std::string; |
| 45 | using Description = std::string; |
| 46 | using MenuPath = std::string; |
| 47 | using CurrentValue = std::variant<int64_t, std::string>; |
| 48 | using DefaultValue = std::variant<int64_t, std::string>; |
| 49 | using OptionString = std::string; |
| 50 | using OptionValue = std::variant<int64_t, std::string>; |
Sagar Srinivas | 7927f90 | 2023-10-09 07:53:00 -0500 | [diff] [blame] | 51 | using ValueDisplayName = std::string; |
| 52 | using Option = |
| 53 | std::vector<std::tuple<OptionString, OptionValue, ValueDisplayName>>; |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 54 | using BIOSTableObj = |
| 55 | std::tuple<AttributeType, ReadonlyStatus, DisplayName, Description, |
| 56 | MenuPath, CurrentValue, DefaultValue, Option>; |
| 57 | using BaseBIOSTable = std::map<AttributeName, BIOSTableObj>; |
| 58 | |
George Liu | 1244acf | 2020-08-14 09:11:11 +0800 | [diff] [blame] | 59 | using PendingObj = std::tuple<AttributeType, CurrentValue>; |
| 60 | using PendingAttributes = std::map<AttributeName, PendingObj>; |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 61 | using Callback = std::function<void()>; |
George Liu | 1244acf | 2020-08-14 09:11:11 +0800 | [diff] [blame] | 62 | |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 63 | /** @class BIOSConfig |
| 64 | * @brief Manager BIOS Attributes |
| 65 | */ |
| 66 | class BIOSConfig |
| 67 | { |
| 68 | public: |
| 69 | BIOSConfig() = delete; |
| 70 | BIOSConfig(const BIOSConfig&) = delete; |
| 71 | BIOSConfig(BIOSConfig&&) = delete; |
| 72 | BIOSConfig& operator=(const BIOSConfig&) = delete; |
| 73 | BIOSConfig& operator=(BIOSConfig&&) = delete; |
| 74 | ~BIOSConfig() = default; |
| 75 | |
| 76 | /** @brief Construct BIOSConfig |
| 77 | * @param[in] jsonDir - The directory where json file exists |
| 78 | * @param[in] tableDir - The directory where the persistent table is placed |
| 79 | * @param[in] dbusHandler - Dbus Handler |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 80 | * @param[in] fd - socket descriptor to communicate to host |
| 81 | * @param[in] eid - MCTP EID of host firmware |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 82 | * @param[in] instanceIdDb - pointer to an InstanceIdDb object |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 83 | * @param[in] handler - PLDM request handler |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 84 | * @param[in] platformConfigHandler - pointer to platform config Handler |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 85 | * @param[in] requestPLDMServiceName - Callback for claiming the PLDM |
| 86 | * service name Called only after building BIOS tables. |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 87 | */ |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 88 | explicit BIOSConfig( |
| 89 | const char* jsonDir, const char* tableDir, |
Brad Bishop | 5079ac4 | 2021-08-19 18:35:06 -0400 | [diff] [blame] | 90 | pldm::utils::DBusHandler* const dbusHandler, int fd, uint8_t eid, |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 91 | pldm::InstanceIdDb* instanceIdDb, |
Sagar Srinivas | 11ce8d2 | 2022-07-28 11:32:34 -0500 | [diff] [blame] | 92 | pldm::requester::Handler<pldm::requester::Request>* handler, |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 93 | pldm::responder::platform_config::Handler* platformConfigHandler, |
| 94 | pldm::responder::bios::Callback requestPLDMServiceName); |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 95 | |
| 96 | /** @brief Set attribute value on dbus and attribute value table |
| 97 | * @param[in] entry - attribute value entry |
| 98 | * @param[in] size - size of the attribute value entry |
Sagar Srinivas | cac0ebb | 2021-11-23 07:50:28 -0600 | [diff] [blame] | 99 | * @param[in] isBMC - indicates if the attribute is set by BMC |
George Liu | 6d6d1e8 | 2021-02-16 11:08:55 +0800 | [diff] [blame] | 100 | * @param[in] updateDBus - update Attr value D-Bus property |
| 101 | * if this is set to true |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 102 | * @param[in] updateBaseBIOSTable - update BaseBIOSTable D-Bus property |
| 103 | * if this is set to true |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 104 | * @return pldm_completion_codes |
| 105 | */ |
Sagar Srinivas | cac0ebb | 2021-11-23 07:50:28 -0600 | [diff] [blame] | 106 | int setAttrValue(const void* entry, size_t size, bool isBMC, |
| 107 | bool updateDBus = true, bool updateBaseBIOSTable = true); |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 108 | |
| 109 | /** @brief Remove the persistent tables */ |
| 110 | void removeTables(); |
| 111 | |
| 112 | /** @brief Build bios tables(string,attribute,attribute value table)*/ |
| 113 | void buildTables(); |
| 114 | |
| 115 | /** @brief Get BIOS table of specified type |
| 116 | * @param[in] tableType - The table type |
| 117 | * @return The bios table, std::nullopt if the table is unaviliable |
| 118 | */ |
| 119 | std::optional<Table> getBIOSTable(pldm_bios_table_types tableType); |
| 120 | |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 121 | /** @brief set BIOS table |
| 122 | * @param[in] tableType - Indicates what table is being transferred |
| 123 | * {BIOSStringTable=0x0, BIOSAttributeTable=0x1, |
| 124 | * BIOSAttributeValueTable=0x2} |
| 125 | * @param[in] table - table data |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 126 | * @param[in] updateBaseBIOSTable - update BaseBIOSTable D-Bus property |
| 127 | * if this is set to true |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 128 | * @return pldm_completion_codes |
| 129 | */ |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 130 | int setBIOSTable(uint8_t tableType, const Table& table, |
| 131 | bool updateBaseBIOSTable = true); |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 132 | |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 133 | /** @brief Construct the BIOS Attributes and build the tables |
| 134 | * after receiving system type from entity manager. |
Archana Kakani | 46f352e | 2024-03-17 08:21:08 -0500 | [diff] [blame] | 135 | * Also register the Service Name only if |
| 136 | * System specific Bios attributes are supported |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 137 | * @param[in] String - System Type |
Archana Kakani | 46f352e | 2024-03-17 08:21:08 -0500 | [diff] [blame] | 138 | * @param[in] bool - flag to register service name |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 139 | * @return void |
| 140 | */ |
Archana Kakani | 46f352e | 2024-03-17 08:21:08 -0500 | [diff] [blame] | 141 | void initBIOSAttributes(const std::string& sysType, bool registerService); |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 142 | |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 143 | private: |
Tom Joseph | ca7b252 | 2020-11-18 12:27:11 +0530 | [diff] [blame] | 144 | /** @enum Index into the fields in the BaseBIOSTable |
| 145 | */ |
| 146 | enum class Index : uint8_t |
| 147 | { |
| 148 | attributeType = 0, |
| 149 | readOnly, |
| 150 | displayName, |
| 151 | description, |
| 152 | menuPath, |
| 153 | currentValue, |
| 154 | defaultValue, |
| 155 | options, |
| 156 | }; |
| 157 | |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 158 | const fs::path jsonDir; |
| 159 | const fs::path tableDir; |
Brad Bishop | 5079ac4 | 2021-08-19 18:35:06 -0400 | [diff] [blame] | 160 | pldm::utils::DBusHandler* const dbusHandler; |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 161 | BaseBIOSTable baseBIOSTableMaps; |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 162 | |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 163 | /** @brief MCTP EID of host firmware */ |
| 164 | uint8_t eid; |
| 165 | |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 166 | /** @brief pointer to an Instance ID database object, used to obtain PLDM |
| 167 | * instance IDs. |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 168 | */ |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 169 | pldm::InstanceIdDb* instanceIdDb; |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 170 | |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 171 | /** @brief PLDM request handler */ |
| 172 | pldm::requester::Handler<pldm::requester::Request>* handler; |
| 173 | |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 174 | /** @brief platform config Handler*/ |
| 175 | pldm::responder::platform_config::Handler* platformConfigHandler; |
Sagar Srinivas | 11ce8d2 | 2022-07-28 11:32:34 -0500 | [diff] [blame] | 176 | |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 177 | /** @brief Callback for registering the PLDM service name */ |
| 178 | pldm::responder::bios::Callback requestPLDMServiceName; |
| 179 | |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 180 | // vector persists all attributes |
| 181 | using BIOSAttributes = std::vector<std::unique_ptr<BIOSAttribute>>; |
| 182 | BIOSAttributes biosAttributes; |
| 183 | |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 184 | using propName = std::string; |
Brad Bishop | 5079ac4 | 2021-08-19 18:35:06 -0400 | [diff] [blame] | 185 | using DbusChObjProperties = std::map<propName, pldm::utils::PropertyValue>; |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 186 | |
Matt Spinler | d987c94 | 2023-03-24 10:18:19 -0500 | [diff] [blame] | 187 | using ifaceName = std::string; |
| 188 | using DbusIfacesAdded = std::map<ifaceName, DbusChObjProperties>; |
| 189 | |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 190 | // vector to catch the D-Bus property change signals for BIOS attributes |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 191 | std::vector<std::unique_ptr<sdbusplus::bus::match_t>> biosAttrMatch; |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 192 | |
Sagar Srinivas | 11ce8d2 | 2022-07-28 11:32:34 -0500 | [diff] [blame] | 193 | /** @brief system type/model */ |
| 194 | std::string sysType; |
| 195 | |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 196 | /** @brief Method to update a BIOS attribute when the corresponding Dbus |
| 197 | * property is changed |
| 198 | * @param[in] chProperties - list of properties which have changed |
| 199 | * @param[in] biosAttrIndex - Index of BIOSAttribute pointer in |
| 200 | * biosAttributes |
| 201 | * @return - none |
| 202 | */ |
| 203 | void processBiosAttrChangeNotification( |
| 204 | const DbusChObjProperties& chProperties, uint32_t biosAttrIndex); |
| 205 | |
Archana Kakani | 46f352e | 2024-03-17 08:21:08 -0500 | [diff] [blame] | 206 | /** @brief Method is used to initiate bios attributes only if system type |
| 207 | * is already populated by entity manager. |
| 208 | * Register the callback if system type is yet to be populated by Entity |
| 209 | * manager |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 210 | */ |
Archana Kakani | 46f352e | 2024-03-17 08:21:08 -0500 | [diff] [blame] | 211 | void checkSystemTypeAvailability(); |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 212 | |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 213 | /** @brief Construct an attribute and persist it |
| 214 | * @tparam T - attribute type |
| 215 | * @param[in] entry - json entry |
| 216 | */ |
| 217 | template <typename T> |
| 218 | void constructAttribute(const Json& entry) |
| 219 | { |
| 220 | try |
| 221 | { |
| 222 | biosAttributes.push_back(std::make_unique<T>(entry, dbusHandler)); |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 223 | auto biosAttrIndex = biosAttributes.size() - 1; |
| 224 | auto dBusMap = biosAttributes[biosAttrIndex]->getDBusMap(); |
| 225 | |
| 226 | if (dBusMap.has_value()) |
| 227 | { |
| 228 | using namespace sdbusplus::bus::match::rules; |
| 229 | biosAttrMatch.push_back( |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 230 | std::make_unique<sdbusplus::bus::match_t>( |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 231 | pldm::utils::DBusHandler::getBus(), |
| 232 | propertiesChanged(dBusMap->objectPath, |
| 233 | dBusMap->interface), |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 234 | [this, biosAttrIndex](sdbusplus::message_t& msg) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 235 | DbusChObjProperties props; |
| 236 | std::string iface; |
| 237 | msg.read(iface, props); |
| 238 | processBiosAttrChangeNotification(props, |
| 239 | biosAttrIndex); |
| 240 | })); |
Matt Spinler | d987c94 | 2023-03-24 10:18:19 -0500 | [diff] [blame] | 241 | |
| 242 | biosAttrMatch.push_back( |
Patrick Williams | b90fb7f | 2023-04-12 02:31:38 -0500 | [diff] [blame] | 243 | std::make_unique<sdbusplus::bus::match_t>( |
Matt Spinler | d987c94 | 2023-03-24 10:18:19 -0500 | [diff] [blame] | 244 | pldm::utils::DBusHandler::getBus(), |
| 245 | interfacesAdded() + argNpath(0, dBusMap->objectPath), |
| 246 | [this, biosAttrIndex, interface = dBusMap->interface]( |
Patrick Williams | b90fb7f | 2023-04-12 02:31:38 -0500 | [diff] [blame] | 247 | sdbusplus::message_t& msg) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 248 | sdbusplus::message::object_path path; |
| 249 | DbusIfacesAdded interfaces; |
Matt Spinler | d987c94 | 2023-03-24 10:18:19 -0500 | [diff] [blame] | 250 | |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 251 | msg.read(path, interfaces); |
| 252 | auto ifaceIt = interfaces.find(interface); |
| 253 | if (ifaceIt != interfaces.end()) |
| 254 | { |
| 255 | processBiosAttrChangeNotification( |
| 256 | ifaceIt->second, biosAttrIndex); |
| 257 | } |
| 258 | })); |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 259 | } |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 260 | } |
| 261 | catch (const std::exception& e) |
| 262 | { |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 263 | error("Failed to construct an attribute, error - {ERROR}", "ERROR", |
| 264 | e); |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 265 | } |
| 266 | } |
| 267 | |
| 268 | /** Construct attributes and persist them */ |
| 269 | void constructAttributes(); |
| 270 | |
| 271 | using ParseHandler = std::function<void(const Json& entry)>; |
| 272 | |
| 273 | /** @brief Helper function to parse json |
| 274 | * @param[in] filePath - Path of json file |
| 275 | * @param[in] handler - Handler to process each entry in the json |
| 276 | */ |
| 277 | void load(const fs::path& filePath, ParseHandler handler); |
| 278 | |
| 279 | /** @brief Build String Table and persist it |
| 280 | * @return The built string table, std::nullopt if it fails. |
| 281 | */ |
| 282 | std::optional<Table> buildAndStoreStringTable(); |
| 283 | |
Tom Joseph | ca7b252 | 2020-11-18 12:27:11 +0530 | [diff] [blame] | 284 | /** @brief Build attribute table and attribute value table and persist them |
| 285 | * Read the BaseBIOSTable from the bios-settings-manager and update |
| 286 | * attribute table and attribute value table. |
| 287 | * |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 288 | * @param[in] stringTable - The string Table |
| 289 | */ |
| 290 | void buildAndStoreAttrTables(const Table& stringTable); |
| 291 | |
| 292 | /** @brief Persist the table |
| 293 | * @param[in] path - Path to persist the table |
| 294 | * @param[in] table - The table |
| 295 | */ |
| 296 | void storeTable(const fs::path& path, const Table& table); |
| 297 | |
| 298 | /** @brief Load bios table to ram |
| 299 | * @param[in] path - Path of the table |
| 300 | * @return The table, std::nullopt if loading fails |
| 301 | */ |
| 302 | std::optional<Table> loadTable(const fs::path& path); |
John Wang | 8241b34 | 2020-06-05 10:49:17 +0800 | [diff] [blame] | 303 | |
Sagar Srinivas | cac0ebb | 2021-11-23 07:50:28 -0600 | [diff] [blame] | 304 | /** @brief Method to decode the attribute name from the string handle |
| 305 | * |
| 306 | * @param[in] stringEntry - string entry from string table |
| 307 | * @return the decoded string |
| 308 | */ |
| 309 | std::string decodeStringFromStringEntry( |
| 310 | const pldm_bios_string_table_entry* stringEntry); |
| 311 | |
| 312 | /** @brief Method to print the string Handle by passing the attribute Handle |
| 313 | * of the bios attribute that got updated |
| 314 | * |
| 315 | * @param[in] handle - the Attribute handle of the bios attribute |
| 316 | * @param[in] index - index to the possible value handles |
| 317 | * @param[in] attrTable - the attribute table |
| 318 | * @param[in] stringTable - the string table |
| 319 | * @return string handle from the string table and decoded string to the |
| 320 | * name handle |
| 321 | */ |
| 322 | std::string displayStringHandle(uint16_t handle, uint8_t index, |
| 323 | const std::optional<Table>& attrTable, |
| 324 | const std::optional<Table>& stringTable); |
| 325 | |
| 326 | /** @brief Method to trace the bios attribute which got changed |
| 327 | * |
| 328 | * @param[in] attrValueEntry - The attribute value entry to update |
| 329 | * @param[in] attrEntry - The attribute table entry |
| 330 | * @param[in] isBMC - indicates if the attribute is set by BMC |
| 331 | */ |
| 332 | void traceBIOSUpdate(const pldm_bios_attr_val_table_entry* attrValueEntry, |
| 333 | const pldm_bios_attr_table_entry* attrEntry, |
| 334 | bool isBMC); |
| 335 | |
John Wang | 8241b34 | 2020-06-05 10:49:17 +0800 | [diff] [blame] | 336 | /** @brief Check the attribute value to update |
| 337 | * @param[in] attrValueEntry - The attribute value entry to update |
| 338 | * @param[in] attrEntry - The attribute table entry |
| 339 | * @param[in] stringTable - The string table |
| 340 | * @return pldm_completion_codes |
| 341 | */ |
| 342 | int checkAttrValueToUpdate( |
| 343 | const pldm_bios_attr_val_table_entry* attrValueEntry, |
| 344 | const pldm_bios_attr_table_entry* attrEntry, Table& stringTable); |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 345 | |
| 346 | /** @brief Check the attribute table |
| 347 | * @param[in] table - The table |
| 348 | * @return pldm_completion_codes |
| 349 | */ |
| 350 | int checkAttributeTable(const Table& table); |
| 351 | |
| 352 | /** @brief Check the attribute value table |
| 353 | * @param[in] table - The table |
| 354 | * @return pldm_completion_codes |
| 355 | */ |
| 356 | int checkAttributeValueTable(const Table& table); |
| 357 | |
| 358 | /** @brief Update the BaseBIOSTable property of the D-Bus interface |
| 359 | */ |
| 360 | void updateBaseBIOSTableProperty(); |
George Liu | 1244acf | 2020-08-14 09:11:11 +0800 | [diff] [blame] | 361 | |
| 362 | /** @brief Listen the PendingAttributes property of the D-Bus interface and |
| 363 | * update BaseBIOSTable |
| 364 | */ |
| 365 | void listenPendingAttributes(); |
| 366 | |
| 367 | /** @brief Find attribute handle from bios attribute table |
| 368 | * @param[in] attrName - attribute name |
| 369 | * @return attribute handle |
| 370 | */ |
| 371 | uint16_t findAttrHandle(const std::string& attrName); |
| 372 | |
| 373 | /** @brief Listen the PendingAttributes property of the D-Bus interface |
| 374 | * and update BaseBIOSTable |
| 375 | * @param[in] msg - Data associated with subscribed signal |
| 376 | */ |
| 377 | void constructPendingAttribute(const PendingAttributes& pendingAttributes); |
John Wang | d965934 | 2020-02-27 16:46:05 +0800 | [diff] [blame] | 378 | }; |
| 379 | |
| 380 | } // namespace bios |
| 381 | } // namespace responder |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 382 | } // namespace pldm |