Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 Intel Corporation. |
| 3 | * Copyright (c) 2018-present Facebook. |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include "xyz/openbmc_project/Common/error.hpp" |
| 19 | #include <ipmid/api.h> |
| 20 | |
| 21 | #include <array> |
| 22 | #include <commandutils.hpp> |
| 23 | #include <cstring> |
| 24 | #include <iostream> |
| 25 | #include <oemcommands.hpp> |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 26 | #include <ipmid/utils.hpp> |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 27 | #include <phosphor-logging/log.hpp> |
| 28 | #include <sdbusplus/bus.hpp> |
| 29 | #include <string> |
| 30 | #include <vector> |
| 31 | |
| 32 | #define SIZE_IANA_ID 3 |
| 33 | |
| 34 | namespace ipmi |
| 35 | { |
| 36 | static void registerOEMFunctions() __attribute__((constructor)); |
| 37 | sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection()); // from ipmid/api.h |
| 38 | static constexpr size_t maxFRUStringLength = 0x3F; |
| 39 | |
| 40 | ipmi_ret_t plat_udbg_get_post_desc(uint8_t, uint8_t *, uint8_t, uint8_t *, |
| 41 | uint8_t *, uint8_t *); |
| 42 | ipmi_ret_t plat_udbg_get_frame_data(uint8_t, uint8_t, uint8_t *, uint8_t *, |
| 43 | uint8_t *); |
| 44 | ipmi_ret_t plat_udbg_control_panel(uint8_t, uint8_t, uint8_t, uint8_t *, |
| 45 | uint8_t *); |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 46 | namespace variant_ns = sdbusplus::message::variant_ns; |
| 47 | |
| 48 | enum class LanParam : uint8_t |
| 49 | { |
| 50 | INPROGRESS = 0, |
| 51 | AUTHSUPPORT = 1, |
| 52 | AUTHENABLES = 2, |
| 53 | IP = 3, |
| 54 | IPSRC = 4, |
| 55 | MAC = 5, |
| 56 | SUBNET = 6, |
| 57 | GATEWAY = 12, |
| 58 | VLAN = 20, |
| 59 | CIPHER_SUITE_COUNT = 22, |
| 60 | CIPHER_SUITE_ENTRIES = 23, |
| 61 | IPV6 = 59, |
| 62 | }; |
| 63 | |
| 64 | ipmi_ret_t getNetworkData(uint8_t lan_param, char *data) |
| 65 | { |
| 66 | ipmi_ret_t rc = IPMI_CC_OK; |
| 67 | sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection()); |
| 68 | |
| 69 | const std::string ethdevice = "eth0"; |
| 70 | |
| 71 | switch (static_cast<LanParam>(lan_param)) |
| 72 | { |
| 73 | case LanParam::IP: |
| 74 | { |
| 75 | auto ethIP = ethdevice + "/" + ipmi::network::IP_TYPE; |
| 76 | std::string ipaddress; |
| 77 | auto ipObjectInfo = ipmi::getIPObject( |
| 78 | bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP); |
| 79 | |
| 80 | auto properties = ipmi::getAllDbusProperties( |
| 81 | bus, ipObjectInfo.second, ipObjectInfo.first, |
| 82 | ipmi::network::IP_INTERFACE); |
| 83 | |
| 84 | ipaddress = variant_ns::get<std::string>(properties["Address"]); |
| 85 | |
| 86 | std::strcpy(data, ipaddress.c_str()); |
| 87 | } |
| 88 | break; |
| 89 | |
| 90 | case LanParam::IPV6: |
| 91 | { |
| 92 | auto ethIP = ethdevice + "/ipv6"; |
| 93 | std::string ipaddress; |
| 94 | auto ipObjectInfo = ipmi::getIPObject( |
| 95 | bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP); |
| 96 | |
| 97 | auto properties = ipmi::getAllDbusProperties( |
| 98 | bus, ipObjectInfo.second, ipObjectInfo.first, |
| 99 | ipmi::network::IP_INTERFACE); |
| 100 | |
| 101 | ipaddress = variant_ns::get<std::string>(properties["Address"]); |
| 102 | |
| 103 | std::strcpy(data, ipaddress.c_str()); |
| 104 | } |
| 105 | break; |
| 106 | |
| 107 | case LanParam::MAC: |
| 108 | { |
| 109 | std::string macAddress; |
| 110 | auto macObjectInfo = |
| 111 | ipmi::getDbusObject(bus, ipmi::network::MAC_INTERFACE, |
| 112 | ipmi::network::ROOT, ethdevice); |
| 113 | |
| 114 | auto variant = ipmi::getDbusProperty( |
| 115 | bus, macObjectInfo.second, macObjectInfo.first, |
| 116 | ipmi::network::MAC_INTERFACE, "MACAddress"); |
| 117 | |
| 118 | macAddress = variant_ns::get<std::string>(variant); |
| 119 | |
| 120 | sscanf(macAddress.c_str(), ipmi::network::MAC_ADDRESS_FORMAT, |
| 121 | (data), (data + 1), (data + 2), (data + 3), (data + 4), |
| 122 | (data + 5)); |
| 123 | std::strcpy(data, macAddress.c_str()); |
| 124 | } |
| 125 | break; |
| 126 | |
| 127 | default: |
| 128 | rc = IPMI_CC_PARM_OUT_OF_RANGE; |
| 129 | } |
| 130 | return rc; |
| 131 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 132 | |
| 133 | // return code: 0 successful |
| 134 | int8_t getFruData(std::string &data, std::string &name) |
| 135 | { |
| 136 | std::string objpath = "/xyz/openbmc_project/FruDevice"; |
| 137 | std::string intf = "xyz.openbmc_project.FruDeviceManager"; |
| 138 | std::string service = getService(dbus, intf, objpath); |
| 139 | ObjectValueTree valueTree = getManagedObjects(dbus, service, "/"); |
| 140 | if (valueTree.empty()) |
| 141 | { |
| 142 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 143 | "No object implements interface", |
| 144 | phosphor::logging::entry("INTF=%s", intf.c_str())); |
| 145 | return -1; |
| 146 | } |
| 147 | |
| 148 | for (const auto &item : valueTree) |
| 149 | { |
| 150 | auto interface = item.second.find("xyz.openbmc_project.FruDevice"); |
| 151 | if (interface == item.second.end()) |
| 152 | { |
| 153 | continue; |
| 154 | } |
| 155 | |
| 156 | auto property = interface->second.find(name.c_str()); |
| 157 | if (property == interface->second.end()) |
| 158 | { |
| 159 | continue; |
| 160 | } |
| 161 | |
| 162 | try |
| 163 | { |
| 164 | Value variant = property->second; |
| 165 | std::string &result = |
| 166 | sdbusplus::message::variant_ns::get<std::string>(variant); |
| 167 | if (result.size() > maxFRUStringLength) |
| 168 | { |
| 169 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 170 | "FRU serial number exceed maximum length"); |
| 171 | return -1; |
| 172 | } |
| 173 | data = result; |
| 174 | return 0; |
| 175 | } |
| 176 | catch (sdbusplus::message::variant_ns::bad_variant_access &e) |
| 177 | { |
| 178 | phosphor::logging::log<phosphor::logging::level::ERR>(e.what()); |
| 179 | return -1; |
| 180 | } |
| 181 | } |
| 182 | return -1; |
| 183 | } |
| 184 | |
| 185 | typedef struct |
| 186 | { |
| 187 | uint8_t cur_power_state; |
| 188 | uint8_t last_power_event; |
| 189 | uint8_t misc_power_state; |
| 190 | uint8_t front_panel_button_cap_status; |
| 191 | } ipmi_get_chassis_status_t; |
| 192 | |
| 193 | // Todo: Needs to update this as per power policy when integrated |
| 194 | //---------------------------------------------------------------------- |
| 195 | // Get Chassis Status commands |
| 196 | //---------------------------------------------------------------------- |
| 197 | ipmi_ret_t ipmiGetChassisStatus(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 198 | ipmi_request_t request, |
| 199 | ipmi_response_t response, |
| 200 | ipmi_data_len_t data_len, |
| 201 | ipmi_context_t context) |
| 202 | { |
| 203 | ipmi_get_chassis_status_t chassis_status; |
| 204 | uint8_t s = 2; |
| 205 | |
| 206 | *data_len = 4; |
| 207 | |
| 208 | // Current Power State |
| 209 | // [7] reserved |
| 210 | // [6..5] power restore policy |
| 211 | // 00b = chassis stays powered off after AC/mains returns |
| 212 | // 01b = after AC returns, power is restored to the state that was |
| 213 | // in effect when AC/mains was lost. |
| 214 | // 10b = chassis always powers up after AC/mains returns |
| 215 | // 11b = unknow |
| 216 | // Set to 00b, by observing the hardware behavior. |
| 217 | // Do we need to define a dbus property to identify the restore |
| 218 | // policy? |
| 219 | |
| 220 | // [4] power control fault |
| 221 | // 1b = controller attempted to turn system power on or off, but |
| 222 | // system did not enter desired state. |
| 223 | // Set to 0b, since We don't support it.. |
| 224 | |
| 225 | // [3] power fault |
| 226 | // 1b = fault detected in main power subsystem. |
| 227 | // set to 0b. for we don't support it. |
| 228 | |
| 229 | // [2] 1b = interlock (chassis is presently shut down because a chassis |
| 230 | // panel interlock switch is active). (IPMI 1.5) |
| 231 | // set to 0b, for we don't support it. |
| 232 | |
| 233 | // [1] power overload |
| 234 | // 1b = system shutdown because of power overload condition. |
| 235 | // set to 0b, for we don't support it. |
| 236 | |
| 237 | // [0] power is on |
| 238 | // 1b = system power is on |
| 239 | // 0b = system power is off(soft-off S4/S5, or mechanical off) |
| 240 | |
| 241 | chassis_status.cur_power_state = ((s & 0x3) << 5) | (1 & 0x1); |
| 242 | |
| 243 | // Last Power Event |
| 244 | // [7..5] – reserved |
| 245 | // [4] – 1b = last ‘Power is on’ state was entered via IPMI command |
| 246 | // [3] – 1b = last power down caused by power fault |
| 247 | // [2] – 1b = last power down caused by a power interlock being activated |
| 248 | // [1] – 1b = last power down caused by a Power overload |
| 249 | // [0] – 1b = AC failed |
| 250 | // set to 0x0, for we don't support these fields. |
| 251 | |
| 252 | chassis_status.last_power_event = 0; |
| 253 | |
| 254 | // Misc. Chassis State |
| 255 | // [7] – reserved |
| 256 | // [6] – 1b = Chassis Identify command and state info supported (Optional) |
| 257 | // 0b = Chassis Identify command support unspecified via this command. |
| 258 | // (The Get Command Support command , if implemented, would still |
| 259 | // indicate support for the Chassis Identify command) |
| 260 | // [5..4] – Chassis Identify State. Mandatory when bit[6] =1b, reserved |
| 261 | // (return |
| 262 | // as 00b) otherwise. Returns the present chassis identify state. |
| 263 | // Refer to the Chassis Identify command for more info. |
| 264 | // 00b = chassis identify state = Off |
| 265 | // 01b = chassis identify state = Temporary(timed) On |
| 266 | // 10b = chassis identify state = Indefinite On |
| 267 | // 11b = reserved |
| 268 | // [3] – 1b = Cooling/fan fault detected |
| 269 | // [2] – 1b = Drive Fault |
| 270 | // [1] – 1b = Front Panel Lockout active (power off and reset via chassis |
| 271 | // push-buttons disabled.) |
| 272 | // [0] – 1b = Chassis Intrusion active |
| 273 | // set to 0, for we don't support them. |
| 274 | chassis_status.misc_power_state = 0x40; |
| 275 | |
| 276 | // Front Panel Button Capabilities and disable/enable status(Optional) |
| 277 | // set to 0, for we don't support them. |
| 278 | chassis_status.front_panel_button_cap_status = 0; |
| 279 | |
| 280 | // Pack the actual response |
| 281 | std::memcpy(response, &chassis_status, *data_len); |
| 282 | |
| 283 | return IPMI_CC_OK; |
| 284 | } |
| 285 | |
| 286 | //---------------------------------------------------------------------- |
| 287 | // Get Debug Frame Info |
| 288 | //---------------------------------------------------------------------- |
| 289 | ipmi_ret_t ipmiOemDbgGetFrameInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 290 | ipmi_request_t request, |
| 291 | ipmi_response_t response, |
| 292 | ipmi_data_len_t data_len, |
| 293 | ipmi_context_t context) |
| 294 | { |
| 295 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 296 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 297 | uint8_t num_frames = 3; |
| 298 | |
| 299 | std::memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 300 | res[SIZE_IANA_ID] = num_frames; |
| 301 | *data_len = SIZE_IANA_ID + 1; |
| 302 | |
| 303 | return IPMI_CC_OK; |
| 304 | } |
| 305 | |
| 306 | //---------------------------------------------------------------------- |
| 307 | // Get Debug Updated Frames |
| 308 | //---------------------------------------------------------------------- |
| 309 | ipmi_ret_t ipmiOemDbgGetUpdFrames(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 310 | ipmi_request_t request, |
| 311 | ipmi_response_t response, |
| 312 | ipmi_data_len_t data_len, |
| 313 | ipmi_context_t context) |
| 314 | { |
| 315 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 316 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 317 | uint8_t num_updates = 3; |
| 318 | *data_len = 4; |
| 319 | |
| 320 | std::memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 321 | res[SIZE_IANA_ID] = num_updates; |
| 322 | *data_len = SIZE_IANA_ID + num_updates + 1; |
| 323 | res[SIZE_IANA_ID + 1] = 1; // info page update |
| 324 | res[SIZE_IANA_ID + 2] = 2; // cri sel update |
| 325 | res[SIZE_IANA_ID + 3] = 3; // cri sensor update |
| 326 | |
| 327 | return IPMI_CC_OK; |
| 328 | } |
| 329 | |
| 330 | //---------------------------------------------------------------------- |
| 331 | // Get Debug POST Description |
| 332 | //---------------------------------------------------------------------- |
| 333 | ipmi_ret_t ipmiOemDbgGetPostDesc(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 334 | ipmi_request_t request, |
| 335 | ipmi_response_t response, |
| 336 | ipmi_data_len_t data_len, |
| 337 | ipmi_context_t context) |
| 338 | { |
| 339 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 340 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 341 | uint8_t index = 0; |
| 342 | uint8_t next = 0; |
| 343 | uint8_t end = 0; |
| 344 | uint8_t phase = 0; |
| 345 | uint8_t count = 0; |
| 346 | int ret; |
| 347 | |
| 348 | index = req[3]; |
| 349 | phase = req[4]; |
| 350 | |
| 351 | phosphor::logging::log<phosphor::logging::level::INFO>( |
| 352 | "Get POST Description Event"); |
| 353 | |
| 354 | ret = plat_udbg_get_post_desc(index, &next, phase, &end, &count, &res[8]); |
| 355 | if (ret) |
| 356 | { |
| 357 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 358 | *data_len = SIZE_IANA_ID; |
| 359 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 360 | } |
| 361 | |
| 362 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 363 | res[3] = index; |
| 364 | res[4] = next; |
| 365 | res[5] = phase; |
| 366 | res[6] = end; |
| 367 | res[7] = count; |
| 368 | *data_len = SIZE_IANA_ID + 5 + count; |
| 369 | |
| 370 | return IPMI_CC_OK; |
| 371 | } |
| 372 | |
| 373 | //---------------------------------------------------------------------- |
| 374 | // Get Debug GPIO Description |
| 375 | //---------------------------------------------------------------------- |
| 376 | ipmi_ret_t ipmiOemDbgGetGpioDesc(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 377 | ipmi_request_t request, |
| 378 | ipmi_response_t response, |
| 379 | ipmi_data_len_t data_len, |
| 380 | ipmi_context_t context) |
| 381 | { |
| 382 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 383 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 384 | |
| 385 | phosphor::logging::log<phosphor::logging::level::INFO>( |
| 386 | "Get GPIO Description Event"); |
| 387 | |
| 388 | std::memcpy(res, req, SIZE_IANA_ID + 1); // IANA ID |
| 389 | *data_len = SIZE_IANA_ID + 1; |
| 390 | |
| 391 | return IPMI_CC_OK; |
| 392 | } |
| 393 | |
| 394 | //---------------------------------------------------------------------- |
| 395 | // Get Debug Frame Data |
| 396 | //---------------------------------------------------------------------- |
| 397 | ipmi_ret_t ipmiOemDbgGetFrameData(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 398 | ipmi_request_t request, |
| 399 | ipmi_response_t response, |
| 400 | ipmi_data_len_t data_len, |
| 401 | ipmi_context_t context) |
| 402 | { |
| 403 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 404 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 405 | uint8_t frame; |
| 406 | uint8_t page; |
| 407 | uint8_t next; |
| 408 | uint8_t count; |
| 409 | int ret; |
| 410 | |
| 411 | frame = req[3]; |
| 412 | page = req[4]; |
| 413 | int fr = frame; |
| 414 | int pg = page; |
| 415 | |
| 416 | ret = plat_udbg_get_frame_data(frame, page, &next, &count, &res[7]); |
| 417 | if (ret) |
| 418 | { |
| 419 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 420 | *data_len = SIZE_IANA_ID; |
| 421 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 422 | } |
| 423 | |
| 424 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 425 | res[3] = frame; |
| 426 | res[4] = page; |
| 427 | res[5] = next; |
| 428 | res[6] = count; |
| 429 | *data_len = SIZE_IANA_ID + 4 + count; |
| 430 | |
| 431 | return IPMI_CC_OK; |
| 432 | } |
| 433 | |
| 434 | //---------------------------------------------------------------------- |
| 435 | // Get Debug Control Panel |
| 436 | //---------------------------------------------------------------------- |
| 437 | ipmi_ret_t ipmiOemDbgGetCtrlPanel(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 438 | ipmi_request_t request, |
| 439 | ipmi_response_t response, |
| 440 | ipmi_data_len_t data_len, |
| 441 | ipmi_context_t context) |
| 442 | { |
| 443 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 444 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 445 | |
| 446 | uint8_t panel; |
| 447 | uint8_t operation; |
| 448 | uint8_t item; |
| 449 | uint8_t count; |
| 450 | ipmi_ret_t ret; |
| 451 | |
| 452 | panel = req[3]; |
| 453 | operation = req[4]; |
| 454 | item = req[5]; |
| 455 | |
| 456 | ret = plat_udbg_control_panel(panel, operation, item, &count, &res[3]); |
| 457 | |
| 458 | std::memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 459 | *data_len = SIZE_IANA_ID + count; |
| 460 | |
| 461 | return ret; |
| 462 | } |
| 463 | |
| 464 | // Todo: Need to implement all below functions for oem commands |
| 465 | //---------------------------------------------------------------------- |
| 466 | // Set Dimm Info (CMD_OEM_SET_DIMM_INFO) |
| 467 | //---------------------------------------------------------------------- |
| 468 | ipmi_ret_t ipmiOemSetDimmInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 469 | ipmi_request_t request, ipmi_response_t response, |
| 470 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 471 | { |
| 472 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 473 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 474 | |
| 475 | std::memcpy(res, req, SIZE_IANA_ID + 1); // IANA ID |
| 476 | *data_len = SIZE_IANA_ID + 1; |
| 477 | *data_len = 0; |
| 478 | |
| 479 | return IPMI_CC_OK; |
| 480 | } |
| 481 | |
| 482 | //---------------------------------------------------------------------- |
| 483 | // Get Boot Order (CMD_OEM_GET_BOOT_ORDER) |
| 484 | //---------------------------------------------------------------------- |
| 485 | ipmi_ret_t ipmiOemGetBootOrder(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 486 | ipmi_request_t request, ipmi_response_t response, |
| 487 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 488 | { |
| 489 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 490 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 491 | |
| 492 | *res++ = 0x01; |
| 493 | *res++ = 0x00; |
| 494 | *res++ = 0x09; |
| 495 | *res++ = 0x02; |
| 496 | *res++ = 0x03; |
| 497 | *res++ = 0xff; |
| 498 | *data_len = 6; |
| 499 | |
| 500 | return IPMI_CC_OK; |
| 501 | } |
| 502 | |
| 503 | //---------------------------------------------------------------------- |
| 504 | // Set Machine Config Info (CMD_OEM_SET_MACHINE_CONFIG_INFO) |
| 505 | //---------------------------------------------------------------------- |
| 506 | ipmi_ret_t ipmiOemSetMachineCfgInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 507 | ipmi_request_t request, |
| 508 | ipmi_response_t response, |
| 509 | ipmi_data_len_t data_len, |
| 510 | ipmi_context_t context) |
| 511 | { |
| 512 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 513 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 514 | |
| 515 | *data_len = 0; |
| 516 | |
| 517 | return IPMI_CC_OK; |
| 518 | } |
| 519 | |
| 520 | //---------------------------------------------------------------------- |
| 521 | // Set POST start (CMD_OEM_SET_POST_START) |
| 522 | //---------------------------------------------------------------------- |
| 523 | ipmi_ret_t ipmiOemSetPostStart(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 524 | ipmi_request_t request, ipmi_response_t response, |
| 525 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 526 | { |
| 527 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 528 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 529 | |
| 530 | phosphor::logging::log<phosphor::logging::level::INFO>("POST Start Event"); |
| 531 | |
| 532 | *data_len = 0; |
| 533 | return IPMI_CC_OK; |
| 534 | } |
| 535 | |
| 536 | //---------------------------------------------------------------------- |
| 537 | // Set POST End (CMD_OEM_SET_POST_END) |
| 538 | //---------------------------------------------------------------------- |
| 539 | ipmi_ret_t ipmiOemSetPostEnd(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 540 | ipmi_request_t request, ipmi_response_t response, |
| 541 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 542 | { |
| 543 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 544 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 545 | |
| 546 | phosphor::logging::log<phosphor::logging::level::INFO>("POST End Event"); |
| 547 | |
| 548 | *data_len = 0; |
| 549 | return IPMI_CC_OK; |
| 550 | } |
| 551 | |
| 552 | //---------------------------------------------------------------------- |
| 553 | // Set Bios Flash Info (CMD_OEM_SET_BIOS_FLASH_INFO) |
| 554 | //---------------------------------------------------------------------- |
| 555 | ipmi_ret_t ipmiOemSetBiosFlashInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 556 | ipmi_request_t request, |
| 557 | ipmi_response_t response, |
| 558 | ipmi_data_len_t data_len, |
| 559 | ipmi_context_t context) |
| 560 | { |
| 561 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 562 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 563 | |
| 564 | *data_len = 0; |
| 565 | return IPMI_CC_OK; |
| 566 | } |
| 567 | |
| 568 | //---------------------------------------------------------------------- |
| 569 | // Set PPR (CMD_OEM_SET_PPR) |
| 570 | //---------------------------------------------------------------------- |
| 571 | ipmi_ret_t ipmiOemSetPpr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 572 | ipmi_request_t request, ipmi_response_t response, |
| 573 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 574 | { |
| 575 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 576 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 577 | |
| 578 | *data_len = 0; |
| 579 | return IPMI_CC_OK; |
| 580 | } |
| 581 | |
| 582 | //---------------------------------------------------------------------- |
| 583 | // Get PPR (CMD_OEM_GET_PPR) |
| 584 | //---------------------------------------------------------------------- |
| 585 | ipmi_ret_t ipmiOemGetPpr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 586 | ipmi_request_t request, ipmi_response_t response, |
| 587 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 588 | { |
| 589 | uint8_t *req = reinterpret_cast<uint8_t *>(request); |
| 590 | uint8_t *res = reinterpret_cast<uint8_t *>(response); |
| 591 | |
| 592 | res[0] = 0x00; |
| 593 | *data_len = 1; |
| 594 | |
| 595 | return IPMI_CC_OK; |
| 596 | } |
| 597 | |
| 598 | static void registerOEMFunctions(void) |
| 599 | { |
| 600 | phosphor::logging::log<phosphor::logging::level::INFO>( |
| 601 | "Registering OEM commands"); |
| 602 | ipmiPrintAndRegister(NETFUN_CHASSIS, 1, NULL, ipmiGetChassisStatus, |
| 603 | PRIVILEGE_USER); // get chassis status |
| 604 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_INFO, |
| 605 | NULL, ipmiOemDbgGetFrameInfo, |
| 606 | PRIVILEGE_USER); // get debug frame info |
| 607 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, |
| 608 | CMD_OEM_USB_DBG_GET_UPDATED_FRAMES, NULL, |
| 609 | ipmiOemDbgGetUpdFrames, |
| 610 | PRIVILEGE_USER); // get debug updated frames |
| 611 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_POST_DESC, |
| 612 | NULL, ipmiOemDbgGetPostDesc, |
| 613 | PRIVILEGE_USER); // get debug post description |
| 614 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_GPIO_DESC, |
| 615 | NULL, ipmiOemDbgGetGpioDesc, |
| 616 | PRIVILEGE_USER); // get debug gpio description |
| 617 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_DATA, |
| 618 | NULL, ipmiOemDbgGetFrameData, |
| 619 | PRIVILEGE_USER); // get debug frame data |
| 620 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_CTRL_PANEL, |
| 621 | NULL, ipmiOemDbgGetCtrlPanel, |
| 622 | PRIVILEGE_USER); // get debug control panel |
| 623 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_DIMM_INFO, NULL, |
| 624 | ipmiOemSetDimmInfo, |
| 625 | PRIVILEGE_USER); // Set Dimm Info |
| 626 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_BOOT_ORDER, NULL, |
| 627 | ipmiOemGetBootOrder, |
| 628 | PRIVILEGE_USER); // Get Boot Order |
| 629 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_MACHINE_CONFIG_INFO, NULL, |
| 630 | ipmiOemSetMachineCfgInfo, |
| 631 | PRIVILEGE_USER); // Set Machine Config Info |
| 632 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_START, NULL, |
| 633 | ipmiOemSetPostStart, |
| 634 | PRIVILEGE_USER); // Set POST start |
| 635 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_END, NULL, |
| 636 | ipmiOemSetPostEnd, |
| 637 | PRIVILEGE_USER); // Set POST End |
| 638 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_BIOS_FLASH_INFO, NULL, |
| 639 | ipmiOemSetBiosFlashInfo, |
| 640 | PRIVILEGE_USER); // Set Bios Flash Info |
| 641 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPR, NULL, ipmiOemSetPpr, |
| 642 | PRIVILEGE_USER); // Set PPR |
| 643 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_PPR, NULL, ipmiOemGetPpr, |
| 644 | PRIVILEGE_USER); // Get PPR |
| 645 | return; |
| 646 | } |
| 647 | |
| 648 | } // namespace ipmi |