Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 1 | #include "bios.hpp" |
| 2 | |
Deepak Kodihalli | d130e1a | 2020-06-17 05:55:32 -0500 | [diff] [blame] | 3 | #include "common/utils.hpp" |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 4 | |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 5 | #include <time.h> |
| 6 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 7 | #include <array> |
| 8 | #include <chrono> |
| 9 | #include <ctime> |
Sampa Misra | aa8ae72 | 2019-12-12 03:20:40 -0600 | [diff] [blame] | 10 | #include <iostream> |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 11 | #include <stdexcept> |
| 12 | #include <string> |
| 13 | #include <variant> |
| 14 | #include <vector> |
| 15 | |
Brad Bishop | 5079ac4 | 2021-08-19 18:35:06 -0400 | [diff] [blame] | 16 | using namespace pldm::utils; |
| 17 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 18 | namespace pldm |
| 19 | { |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 20 | namespace responder |
| 21 | { |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 22 | namespace utils |
| 23 | { |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 24 | void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes, |
| 25 | uint8_t& hours, uint8_t& day, uint8_t& month, |
| 26 | uint16_t& year) |
| 27 | { |
| 28 | auto t = time_t(timeSec); |
| 29 | auto time = localtime(&t); |
| 30 | |
George Liu | 8340957 | 2019-12-24 18:42:54 +0800 | [diff] [blame] | 31 | seconds = pldm::utils::decimalToBcd(time->tm_sec); |
| 32 | minutes = pldm::utils::decimalToBcd(time->tm_min); |
| 33 | hours = pldm::utils::decimalToBcd(time->tm_hour); |
| 34 | day = pldm::utils::decimalToBcd(time->tm_mday); |
| 35 | month = pldm::utils::decimalToBcd(time->tm_mon + |
| 36 | 1); // The number of months in the range |
| 37 | // 0 to 11.PLDM expects range 1 to 12 |
| 38 | year = pldm::utils::decimalToBcd(time->tm_year + |
| 39 | 1900); // The number of years since 1900 |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 40 | } |
| 41 | |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 42 | std::time_t timeToEpoch(uint8_t seconds, uint8_t minutes, uint8_t hours, |
| 43 | uint8_t day, uint8_t month, uint16_t year) |
| 44 | { |
| 45 | struct std::tm stm; |
| 46 | |
| 47 | stm.tm_year = year - 1900; |
| 48 | stm.tm_mon = month - 1; |
| 49 | stm.tm_mday = day; |
| 50 | stm.tm_hour = hours; |
| 51 | stm.tm_min = minutes; |
| 52 | stm.tm_sec = seconds; |
| 53 | stm.tm_isdst = -1; |
| 54 | |
| 55 | // It will get the time in seconds since |
| 56 | // Epoch, 1970.1.1 00:00:00 +0000,UTC. |
| 57 | return timegm(&stm); |
| 58 | } |
| 59 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 60 | } // namespace utils |
| 61 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 62 | namespace bios |
| 63 | { |
John Wang | 6080aae | 2020-02-14 09:34:25 +0800 | [diff] [blame] | 64 | using EpochTimeUS = uint64_t; |
| 65 | |
| 66 | DBusHandler dbusHandler; |
| 67 | |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 68 | Handler::Handler(int fd, uint8_t eid, dbus_api::Requester* requester, |
| 69 | pldm::requester::Handler<pldm::requester::Request>* handler) : |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 70 | biosConfig(BIOS_JSONS_DIR, BIOS_TABLES_DIR, &dbusHandler, fd, eid, |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 71 | requester, handler) |
Deepak Kodihalli | d9fb152 | 2019-11-28 10:06:34 -0600 | [diff] [blame] | 72 | { |
John Wang | 6080aae | 2020-02-14 09:34:25 +0800 | [diff] [blame] | 73 | biosConfig.removeTables(); |
| 74 | biosConfig.buildTables(); |
| 75 | |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 76 | handlers.emplace(PLDM_SET_DATE_TIME, |
| 77 | [this](const pldm_msg* request, size_t payloadLength) { |
| 78 | return this->setDateTime(request, payloadLength); |
| 79 | }); |
Deepak Kodihalli | d9fb152 | 2019-11-28 10:06:34 -0600 | [diff] [blame] | 80 | handlers.emplace(PLDM_GET_DATE_TIME, |
| 81 | [this](const pldm_msg* request, size_t payloadLength) { |
| 82 | return this->getDateTime(request, payloadLength); |
| 83 | }); |
| 84 | handlers.emplace(PLDM_GET_BIOS_TABLE, |
| 85 | [this](const pldm_msg* request, size_t payloadLength) { |
| 86 | return this->getBIOSTable(request, payloadLength); |
| 87 | }); |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 88 | handlers.emplace(PLDM_SET_BIOS_TABLE, |
| 89 | [this](const pldm_msg* request, size_t payloadLength) { |
| 90 | return this->setBIOSTable(request, payloadLength); |
| 91 | }); |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 92 | handlers.emplace(PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE, |
| 93 | [this](const pldm_msg* request, size_t payloadLength) { |
| 94 | return this->getBIOSAttributeCurrentValueByHandle( |
| 95 | request, payloadLength); |
| 96 | }); |
John Wang | 4217488 | 2019-12-20 14:56:59 +0800 | [diff] [blame] | 97 | handlers.emplace(PLDM_SET_BIOS_ATTRIBUTE_CURRENT_VALUE, |
| 98 | [this](const pldm_msg* request, size_t payloadLength) { |
| 99 | return this->setBIOSAttributeCurrentValue( |
| 100 | request, payloadLength); |
| 101 | }); |
Deepak Kodihalli | d9fb152 | 2019-11-28 10:06:34 -0600 | [diff] [blame] | 102 | } |
| 103 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 104 | Response Handler::getDateTime(const pldm_msg* request, size_t /*payloadLength*/) |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 105 | { |
| 106 | uint8_t seconds = 0; |
| 107 | uint8_t minutes = 0; |
| 108 | uint8_t hours = 0; |
| 109 | uint8_t day = 0; |
| 110 | uint8_t month = 0; |
| 111 | uint16_t year = 0; |
| 112 | |
| 113 | constexpr auto timeInterface = "xyz.openbmc_project.Time.EpochTime"; |
George Liu | fd97264 | 2020-04-12 12:08:23 +0800 | [diff] [blame] | 114 | constexpr auto bmcTimePath = "/xyz/openbmc_project/time/bmc"; |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 115 | Response response(sizeof(pldm_msg_hdr) + PLDM_GET_DATE_TIME_RESP_BYTES, 0); |
| 116 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
George Liu | 782d37f | 2020-01-24 09:02:17 +0800 | [diff] [blame] | 117 | EpochTimeUS timeUsec; |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 118 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 119 | try |
| 120 | { |
George Liu | 782d37f | 2020-01-24 09:02:17 +0800 | [diff] [blame] | 121 | timeUsec = pldm::utils::DBusHandler().getDbusProperty<EpochTimeUS>( |
George Liu | fd97264 | 2020-04-12 12:08:23 +0800 | [diff] [blame] | 122 | bmcTimePath, "Elapsed", timeInterface); |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 123 | } |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 124 | catch (const sdbusplus::exception_t& e) |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 125 | { |
George Liu | fd97264 | 2020-04-12 12:08:23 +0800 | [diff] [blame] | 126 | std::cerr << "Error getting time, PATH=" << bmcTimePath |
Sampa Misra | aa8ae72 | 2019-12-12 03:20:40 -0600 | [diff] [blame] | 127 | << " TIME INTERACE=" << timeInterface << "\n"; |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 128 | |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 129 | return CmdHandler::ccOnlyResponse(request, PLDM_ERROR); |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 130 | } |
| 131 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 132 | uint64_t timeSec = std::chrono::duration_cast<std::chrono::seconds>( |
| 133 | std::chrono::microseconds(timeUsec)) |
| 134 | .count(); |
| 135 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 136 | pldm::responder::utils::epochToBCDTime(timeSec, seconds, minutes, hours, |
| 137 | day, month, year); |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 138 | |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 139 | auto rc = encode_get_date_time_resp(request->hdr.instance_id, PLDM_SUCCESS, |
| 140 | seconds, minutes, hours, day, month, |
| 141 | year, responsePtr); |
| 142 | if (rc != PLDM_SUCCESS) |
| 143 | { |
| 144 | return ccOnlyResponse(request, rc); |
| 145 | } |
| 146 | |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 147 | return response; |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 148 | } |
| 149 | |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 150 | Response Handler::setDateTime(const pldm_msg* request, size_t payloadLength) |
| 151 | { |
| 152 | uint8_t seconds = 0; |
| 153 | uint8_t minutes = 0; |
| 154 | uint8_t hours = 0; |
| 155 | uint8_t day = 0; |
| 156 | uint8_t month = 0; |
| 157 | uint16_t year = 0; |
| 158 | std::time_t timeSec; |
| 159 | |
Pavithra Barithaya | 297720a | 2022-09-12 05:50:38 -0500 | [diff] [blame] | 160 | constexpr auto timeSyncPath = "/xyz/openbmc_project/time/sync_method"; |
| 161 | constexpr auto timeSyncInterface = |
| 162 | "xyz.openbmc_project.Time.Synchronization"; |
| 163 | constexpr auto timeSyncProperty = "TimeSyncMethod"; |
| 164 | |
| 165 | // The time is correct on BMC when in NTP mode, so we do not want to |
| 166 | // try and set the time again and cause potential time drifts. |
| 167 | try |
| 168 | { |
| 169 | auto propVal = pldm::utils::DBusHandler().getDbusPropertyVariant( |
| 170 | timeSyncPath, timeSyncProperty, timeSyncInterface); |
| 171 | const auto& mode = std::get<std::string>(propVal); |
| 172 | |
| 173 | if (mode == "xyz.openbmc_project.Time.Synchronization.Method.NTP") |
| 174 | { |
| 175 | return ccOnlyResponse(request, PLDM_SUCCESS); |
| 176 | } |
| 177 | } |
| 178 | catch (const std::exception& e) |
| 179 | { |
| 180 | std::cerr << "Error getting the time sync property, PATH=" |
| 181 | << timeSyncPath << "INTERFACE=" << timeSyncInterface |
| 182 | << "PROPERTY=" << timeSyncProperty << "ERROR=" << e.what() |
| 183 | << "\n"; |
| 184 | } |
| 185 | |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 186 | constexpr auto setTimeInterface = "xyz.openbmc_project.Time.EpochTime"; |
George Liu | fd97264 | 2020-04-12 12:08:23 +0800 | [diff] [blame] | 187 | constexpr auto setTimePath = "/xyz/openbmc_project/time/bmc"; |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 188 | constexpr auto timeSetPro = "Elapsed"; |
| 189 | |
| 190 | auto rc = decode_set_date_time_req(request, payloadLength, &seconds, |
| 191 | &minutes, &hours, &day, &month, &year); |
| 192 | if (rc != PLDM_SUCCESS) |
| 193 | { |
| 194 | return ccOnlyResponse(request, rc); |
| 195 | } |
| 196 | timeSec = pldm::responder::utils::timeToEpoch(seconds, minutes, hours, day, |
| 197 | month, year); |
| 198 | uint64_t timeUsec = std::chrono::duration_cast<std::chrono::microseconds>( |
| 199 | std::chrono::seconds(timeSec)) |
| 200 | .count(); |
George Liu | 1e44c73 | 2020-02-28 20:20:06 +0800 | [diff] [blame] | 201 | PropertyValue value{timeUsec}; |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 202 | try |
| 203 | { |
George Liu | 1e44c73 | 2020-02-28 20:20:06 +0800 | [diff] [blame] | 204 | DBusMapping dbusMapping{setTimePath, setTimeInterface, timeSetPro, |
| 205 | "uint64_t"}; |
| 206 | pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value); |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 207 | } |
Patrick Williams | 5133058 | 2021-10-06 12:48:56 -0500 | [diff] [blame] | 208 | catch (const std::exception& e) |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 209 | { |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 210 | std::cerr << "Error Setting time,PATH=" << setTimePath |
| 211 | << "TIME INTERFACE=" << setTimeInterface |
| 212 | << "ERROR=" << e.what() << "\n"; |
| 213 | |
| 214 | return ccOnlyResponse(request, PLDM_ERROR); |
| 215 | } |
| 216 | |
| 217 | return ccOnlyResponse(request, PLDM_SUCCESS); |
| 218 | } |
| 219 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 220 | Response Handler::getBIOSTable(const pldm_msg* request, size_t payloadLength) |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 221 | { |
John Wang | 6080aae | 2020-02-14 09:34:25 +0800 | [diff] [blame] | 222 | uint32_t transferHandle{}; |
| 223 | uint8_t transferOpFlag{}; |
| 224 | uint8_t tableType{}; |
| 225 | |
| 226 | auto rc = decode_get_bios_table_req(request, payloadLength, &transferHandle, |
| 227 | &transferOpFlag, &tableType); |
| 228 | if (rc != PLDM_SUCCESS) |
| 229 | { |
| 230 | return ccOnlyResponse(request, rc); |
| 231 | } |
| 232 | |
| 233 | auto table = |
| 234 | biosConfig.getBIOSTable(static_cast<pldm_bios_table_types>(tableType)); |
| 235 | if (!table) |
| 236 | { |
| 237 | return ccOnlyResponse(request, PLDM_BIOS_TABLE_UNAVAILABLE); |
| 238 | } |
| 239 | |
| 240 | Response response(sizeof(pldm_msg_hdr) + |
| 241 | PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES + table->size()); |
| 242 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 243 | |
| 244 | rc = encode_get_bios_table_resp( |
| 245 | request->hdr.instance_id, PLDM_SUCCESS, 0 /* nxtTransferHandle */, |
| 246 | PLDM_START_AND_END, table->data(), response.size(), responsePtr); |
| 247 | if (rc != PLDM_SUCCESS) |
| 248 | { |
| 249 | return ccOnlyResponse(request, rc); |
| 250 | } |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 251 | |
| 252 | return response; |
| 253 | } |
| 254 | |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 255 | Response Handler::setBIOSTable(const pldm_msg* request, size_t payloadLength) |
| 256 | { |
| 257 | uint32_t transferHandle{}; |
| 258 | uint8_t transferOpFlag{}; |
| 259 | uint8_t tableType{}; |
| 260 | struct variable_field field; |
| 261 | |
| 262 | auto rc = decode_set_bios_table_req(request, payloadLength, &transferHandle, |
| 263 | &transferOpFlag, &tableType, &field); |
| 264 | if (rc != PLDM_SUCCESS) |
| 265 | { |
| 266 | return ccOnlyResponse(request, rc); |
| 267 | } |
| 268 | |
| 269 | Table table(field.ptr, field.ptr + field.length); |
| 270 | rc = biosConfig.setBIOSTable(tableType, table); |
| 271 | if (rc != PLDM_SUCCESS) |
| 272 | { |
| 273 | return ccOnlyResponse(request, rc); |
| 274 | } |
| 275 | |
| 276 | Response response(sizeof(pldm_msg_hdr) + PLDM_SET_BIOS_TABLE_RESP_BYTES); |
| 277 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 278 | |
| 279 | rc = encode_set_bios_table_resp(request->hdr.instance_id, PLDM_SUCCESS, |
| 280 | 0 /* nxtTransferHandle */, responsePtr); |
| 281 | if (rc != PLDM_SUCCESS) |
| 282 | { |
| 283 | return ccOnlyResponse(request, rc); |
| 284 | } |
| 285 | |
| 286 | return response; |
| 287 | } |
| 288 | |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 289 | Response Handler::getBIOSAttributeCurrentValueByHandle(const pldm_msg* request, |
| 290 | size_t payloadLength) |
| 291 | { |
| 292 | uint32_t transferHandle; |
| 293 | uint8_t transferOpFlag; |
| 294 | uint16_t attributeHandle; |
| 295 | |
| 296 | auto rc = decode_get_bios_attribute_current_value_by_handle_req( |
| 297 | request, payloadLength, &transferHandle, &transferOpFlag, |
| 298 | &attributeHandle); |
| 299 | if (rc != PLDM_SUCCESS) |
| 300 | { |
| 301 | return ccOnlyResponse(request, rc); |
| 302 | } |
| 303 | |
John Wang | 6080aae | 2020-02-14 09:34:25 +0800 | [diff] [blame] | 304 | auto table = biosConfig.getBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE); |
| 305 | if (!table) |
Deepak Kodihalli | 4976a68 | 2020-01-07 05:48:29 -0600 | [diff] [blame] | 306 | { |
| 307 | return ccOnlyResponse(request, PLDM_BIOS_TABLE_UNAVAILABLE); |
| 308 | } |
| 309 | |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 310 | auto entry = pldm_bios_table_attr_value_find_by_handle( |
John Wang | 6080aae | 2020-02-14 09:34:25 +0800 | [diff] [blame] | 311 | table->data(), table->size(), attributeHandle); |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 312 | if (entry == nullptr) |
| 313 | { |
| 314 | return ccOnlyResponse(request, PLDM_INVALID_BIOS_ATTR_HANDLE); |
| 315 | } |
| 316 | |
John Wang | 8e877e0 | 2020-02-03 16:06:55 +0800 | [diff] [blame] | 317 | auto entryLength = pldm_bios_table_attr_value_entry_length(entry); |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 318 | Response response(sizeof(pldm_msg_hdr) + |
| 319 | PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_MIN_RESP_BYTES + |
John Wang | 8e877e0 | 2020-02-03 16:06:55 +0800 | [diff] [blame] | 320 | entryLength, |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 321 | 0); |
| 322 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 323 | rc = encode_get_bios_current_value_by_handle_resp( |
John Wang | 8e877e0 | 2020-02-03 16:06:55 +0800 | [diff] [blame] | 324 | request->hdr.instance_id, PLDM_SUCCESS, 0, PLDM_START_AND_END, |
| 325 | reinterpret_cast<const uint8_t*>(entry), entryLength, responsePtr); |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 326 | if (rc != PLDM_SUCCESS) |
| 327 | { |
| 328 | return ccOnlyResponse(request, rc); |
| 329 | } |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 330 | |
| 331 | return response; |
| 332 | } |
| 333 | |
John Wang | 4217488 | 2019-12-20 14:56:59 +0800 | [diff] [blame] | 334 | Response Handler::setBIOSAttributeCurrentValue(const pldm_msg* request, |
| 335 | size_t payloadLength) |
| 336 | { |
| 337 | uint32_t transferHandle; |
| 338 | uint8_t transferOpFlag; |
| 339 | variable_field attributeField; |
| 340 | |
| 341 | auto rc = decode_set_bios_attribute_current_value_req( |
| 342 | request, payloadLength, &transferHandle, &transferOpFlag, |
| 343 | &attributeField); |
| 344 | if (rc != PLDM_SUCCESS) |
| 345 | { |
| 346 | return ccOnlyResponse(request, rc); |
| 347 | } |
| 348 | |
Sagar Srinivas | cac0ebb | 2021-11-23 07:50:28 -0600 | [diff] [blame] | 349 | rc = biosConfig.setAttrValue(attributeField.ptr, attributeField.length, |
| 350 | false); |
John Wang | 4217488 | 2019-12-20 14:56:59 +0800 | [diff] [blame] | 351 | |
Xiaochao Ma | 7a0d072 | 2020-05-29 09:07:33 +0800 | [diff] [blame] | 352 | Response response( |
| 353 | sizeof(pldm_msg_hdr) + PLDM_SET_BIOS_ATTR_CURR_VAL_RESP_BYTES, 0); |
| 354 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 355 | |
| 356 | encode_set_bios_attribute_current_value_resp(request->hdr.instance_id, rc, |
| 357 | 0, responsePtr); |
| 358 | |
| 359 | return response; |
John Wang | 4217488 | 2019-12-20 14:56:59 +0800 | [diff] [blame] | 360 | } |
| 361 | |
John Wang | f719f3b | 2020-01-17 08:46:22 +0800 | [diff] [blame] | 362 | } // namespace bios |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 363 | } // namespace responder |
| 364 | } // namespace pldm |