Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 1 | #include "config.h" |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 2 | |
| 3 | #include "oemhandler.hpp" |
| 4 | |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 5 | #include "elog-errors.hpp" |
Matt Spinler | 34aca01 | 2018-09-25 11:21:06 -0500 | [diff] [blame] | 6 | #include "local_users.hpp" |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 7 | |
| 8 | #include <endian.h> |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 9 | #include <host-ipmid/ipmid-api.h> |
| 10 | #include <stdio.h> |
| 11 | #include <string.h> |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 12 | #include <systemd/sd-bus.h> |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 13 | |
| 14 | #include <fstream> |
| 15 | #include <functional> |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 16 | #include <host-interface.hpp> |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 17 | #include <host-ipmid/ipmid-host-cmd.hpp> |
| 18 | #include <memory> |
Tom Joseph | 3503fdc | 2019-01-10 11:25:27 +0530 | [diff] [blame] | 19 | #include <org/open_power/Host/error.hpp> |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 20 | #include <org/open_power/OCC/Metrics/error.hpp> |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 21 | #include <sdbusplus/bus.hpp> |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 22 | |
Andrew Jeffery | 8fb3f03 | 2018-07-27 16:45:44 +0930 | [diff] [blame] | 23 | void register_netfn_ibm_oem_commands() __attribute__((constructor)); |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 24 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 25 | const char* g_esel_path = "/tmp/esel"; |
Chris Austen | 29a8e0f | 2015-10-30 11:44:38 -0500 | [diff] [blame] | 26 | uint16_t g_record_id = 0x0001; |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 27 | using namespace phosphor::logging; |
| 28 | constexpr auto occMetricsType = 0xDD; |
| 29 | |
Tom Joseph | b61b107 | 2019-01-28 12:32:52 +0530 | [diff] [blame^] | 30 | extern const ObjectIDMap invSensors; |
| 31 | const std::map<uint8_t, Entry::Level> severityMap{ |
| 32 | {0x10, Entry::Level::Warning}, // Recoverable error |
| 33 | {0x20, Entry::Level::Warning}, // Predictive error |
| 34 | {0x40, Entry::Level::Error}, // Unrecoverable error |
| 35 | {0x50, Entry::Level::Error}, // Critical error |
| 36 | {0x60, Entry::Level::Error}, // Error from a diagnostic test |
| 37 | {0x70, Entry::Level::Warning}, // Recoverable symptom |
| 38 | {0xFF, Entry::Level::Error}, // Unknown error |
| 39 | }; |
| 40 | |
| 41 | Entry::Level mapSeverity(const std::string& eSELData) |
| 42 | { |
| 43 | constexpr size_t severityOffset = 0x4A; |
| 44 | |
| 45 | if (eSELData.size() > severityOffset) |
| 46 | { |
| 47 | // Dive in to the IBM log to find the severity |
| 48 | uint8_t sev = 0xF0 & eSELData[severityOffset]; |
| 49 | |
| 50 | auto find = severityMap.find(sev); |
| 51 | if (find != severityMap.end()) |
| 52 | { |
| 53 | return find->second; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // Default to Entry::Level::Error if a matching is not found. |
| 58 | return Entry::Level::Error; |
| 59 | } |
| 60 | |
| 61 | std::string mapCalloutAssociation(const std::string& eSELData) |
| 62 | { |
| 63 | auto rec = reinterpret_cast<const SELEventRecord*>(&eSELData[0]); |
| 64 | uint8_t sensor = rec->sensorNum; |
| 65 | |
| 66 | /* |
| 67 | * Search the sensor number to inventory path mapping to figure out the |
| 68 | * inventory associated with the ESEL. |
| 69 | */ |
| 70 | auto found = std::find_if(invSensors.begin(), invSensors.end(), |
| 71 | [&sensor](const auto& iter) { |
| 72 | return (iter.second.sensorID == sensor); |
| 73 | }); |
| 74 | if (found != invSensors.end()) |
| 75 | { |
| 76 | return found->first; |
| 77 | } |
| 78 | |
| 79 | return {}; |
| 80 | } |
| 81 | |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 82 | std::string readESEL(const char* fileName) |
| 83 | { |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 84 | std::string content{}; |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 85 | |
| 86 | std::ifstream handle(fileName); |
| 87 | |
| 88 | if (handle.fail()) |
| 89 | { |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 90 | log<level::ERR>("Failed to open eSEL", entry("FILENAME=%s", fileName)); |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 91 | return content; |
| 92 | } |
| 93 | |
| 94 | handle.seekg(0, std::ios::end); |
| 95 | content.resize(handle.tellg()); |
| 96 | handle.seekg(0, std::ios::beg); |
| 97 | handle.read(&content[0], content.size()); |
| 98 | handle.close(); |
| 99 | |
| 100 | return content; |
| 101 | } |
| 102 | |
| 103 | void createOCCLogEntry(const std::string& eSELData) |
| 104 | { |
| 105 | // Each byte in eSEL is formatted as %02x with a space between bytes and |
| 106 | // insert '/0' at the end of the character array. |
| 107 | constexpr auto byteSeperator = 3; |
| 108 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 109 | std::unique_ptr<char[]> data( |
| 110 | new char[(eSELData.size() * byteSeperator) + 1]()); |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 111 | |
| 112 | for (size_t i = 0; i < eSELData.size(); i++) |
| 113 | { |
| 114 | sprintf(&data[i * byteSeperator], "%02x ", eSELData[i]); |
| 115 | } |
| 116 | data[eSELData.size() * byteSeperator] = '\0'; |
| 117 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 118 | using error = sdbusplus::org::open_power::OCC::Metrics::Error::Event; |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 119 | using metadata = org::open_power::OCC::Metrics::Event; |
| 120 | |
| 121 | report<error>(metadata::ESEL(data.get())); |
| 122 | } |
| 123 | |
Tom Joseph | 3503fdc | 2019-01-10 11:25:27 +0530 | [diff] [blame] | 124 | void createHostEntry(const std::string& eSELData) |
| 125 | { |
| 126 | // Each byte in eSEL is formatted as %02x with a space between bytes and |
| 127 | // insert '/0' at the end of the character array. |
Tom Joseph | 3503fdc | 2019-01-10 11:25:27 +0530 | [diff] [blame] | 128 | constexpr auto byteSeperator = 3; |
| 129 | |
Tom Joseph | b61b107 | 2019-01-28 12:32:52 +0530 | [diff] [blame^] | 130 | auto sev = mapSeverity(eSELData); |
| 131 | auto inventoryPath = mapCalloutAssociation(eSELData); |
Tom Joseph | 3503fdc | 2019-01-10 11:25:27 +0530 | [diff] [blame] | 132 | |
Tom Joseph | b61b107 | 2019-01-28 12:32:52 +0530 | [diff] [blame^] | 133 | if (!inventoryPath.empty()) |
Tom Joseph | 3503fdc | 2019-01-10 11:25:27 +0530 | [diff] [blame] | 134 | { |
Tom Joseph | b61b107 | 2019-01-28 12:32:52 +0530 | [diff] [blame^] | 135 | std::unique_ptr<char[]> data( |
| 136 | new char[(eSELData.size() * byteSeperator) + 1]()); |
| 137 | |
| 138 | for (size_t i = 0; i < eSELData.size(); i++) |
| 139 | { |
| 140 | sprintf(&data[i * byteSeperator], "%02x ", eSELData[i]); |
| 141 | } |
| 142 | data[eSELData.size() * byteSeperator] = '\0'; |
| 143 | |
| 144 | using hosterror = sdbusplus::org::open_power::Host::Error::Event; |
| 145 | using hostmetadata = org::open_power::Host::Event; |
| 146 | |
| 147 | report<hosterror>( |
| 148 | sev, hostmetadata::ESEL(data.get()), |
| 149 | hostmetadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str())); |
Tom Joseph | 3503fdc | 2019-01-10 11:25:27 +0530 | [diff] [blame] | 150 | } |
Tom Joseph | 3503fdc | 2019-01-10 11:25:27 +0530 | [diff] [blame] | 151 | } |
| 152 | |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 153 | /////////////////////////////////////////////////////////////////////////////// |
Patrick Williams | 24fa5a9 | 2015-10-30 14:53:57 -0500 | [diff] [blame] | 154 | // For the First partial add eSEL the SEL Record ID and offset |
| 155 | // value should be 0x0000. The extended data needs to be in |
| 156 | // the form of an IPMI SEL Event Record, with Event sensor type |
| 157 | // of 0xDF and Event Message format of 0x04. The returned |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 158 | // Record ID should be used for all partial eSEL adds. |
| 159 | // |
Chris Austen | ba54afb | 2016-02-19 23:18:42 -0600 | [diff] [blame] | 160 | // This function creates a /tmp/esel file to store the |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 161 | // incoming partial esel. It is the role of some other |
Patrick Williams | 24fa5a9 | 2015-10-30 14:53:57 -0500 | [diff] [blame] | 162 | // function to commit the error log in to long term |
| 163 | // storage. Likely via the ipmi add_sel command. |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 164 | /////////////////////////////////////////////////////////////////////////////// |
Patrick Williams | 24fa5a9 | 2015-10-30 14:53:57 -0500 | [diff] [blame] | 165 | ipmi_ret_t ipmi_ibm_oem_partial_esel(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 166 | ipmi_request_t request, |
| 167 | ipmi_response_t response, |
| 168 | ipmi_data_len_t data_len, |
| 169 | ipmi_context_t context) |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 170 | { |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 171 | uint8_t* reqptr = (uint8_t*)request; |
| 172 | esel_request_t esel_req; |
| 173 | FILE* fp; |
| 174 | int r = 0; |
| 175 | uint8_t rlen; |
| 176 | ipmi_ret_t rc = IPMI_CC_OK; |
| 177 | const char* pio; |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 178 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 179 | esel_req.resid = le16toh((((uint16_t)reqptr[1]) << 8) + reqptr[0]); |
| 180 | esel_req.selrecord = le16toh((((uint16_t)reqptr[3]) << 8) + reqptr[2]); |
| 181 | esel_req.offset = le16toh((((uint16_t)reqptr[5]) << 8) + reqptr[4]); |
| 182 | esel_req.progress = reqptr[6]; |
Nan Li | b6c4c56 | 2016-03-30 17:06:13 +0800 | [diff] [blame] | 183 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 184 | // According to IPMI spec, Reservation ID must be checked. |
| 185 | if (!checkSELReservation(esel_req.resid)) |
| 186 | { |
| 187 | // 0xc5 means Reservation Cancelled or Invalid Reservation ID. |
| 188 | printf("Used Reservation ID = %d\n", esel_req.resid); |
| 189 | rc = IPMI_CC_INVALID_RESERVATION_ID; |
Nan Li | b6c4c56 | 2016-03-30 17:06:13 +0800 | [diff] [blame] | 190 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 191 | // clean g_esel_path. |
| 192 | r = remove(g_esel_path); |
| 193 | if (r < 0) |
| 194 | fprintf(stderr, "Error deleting %s\n", g_esel_path); |
Nan Li | b6c4c56 | 2016-03-30 17:06:13 +0800 | [diff] [blame] | 195 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 196 | return rc; |
| 197 | } |
Nan Li | b6c4c56 | 2016-03-30 17:06:13 +0800 | [diff] [blame] | 198 | |
| 199 | // OpenPOWER Host Interface spec says if RecordID and Offset are |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 200 | // 0 then then this is a new request |
| 201 | if (!esel_req.selrecord && !esel_req.offset) |
| 202 | pio = "wb"; |
| 203 | else |
| 204 | pio = "rb+"; |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 205 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 206 | rlen = (*data_len) - (uint8_t)(sizeof(esel_request_t)); |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 207 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 208 | if ((fp = fopen(g_esel_path, pio)) != NULL) |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 209 | { |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 210 | fseek(fp, esel_req.offset, SEEK_SET); |
| 211 | fwrite(reqptr + (uint8_t)(sizeof(esel_request_t)), rlen, 1, fp); |
| 212 | fclose(fp); |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 213 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 214 | *data_len = sizeof(g_record_id); |
| 215 | memcpy(response, &g_record_id, *data_len); |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | fprintf(stderr, "Error trying to perform %s for esel%s\n", pio, |
| 220 | g_esel_path); |
| 221 | rc = IPMI_CC_INVALID; |
| 222 | *data_len = 0; |
| 223 | } |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 224 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 225 | // The first bit presents that this is the last partial packet |
| 226 | // coming down. If that is the case advance the record id so we |
| 227 | // don't overlap logs. This allows anyone to establish a log |
| 228 | // directory system. |
| 229 | if (esel_req.progress & 1) |
| 230 | { |
| 231 | g_record_id++; |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 232 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 233 | auto eSELData = readESEL(g_esel_path); |
| 234 | |
| 235 | if (eSELData.empty()) |
| 236 | { |
| 237 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 238 | } |
| 239 | |
| 240 | // If the eSEL record type is OCC metrics, then create the OCC log |
| 241 | // entry. |
| 242 | if (eSELData[2] == occMetricsType) |
| 243 | { |
| 244 | createOCCLogEntry(eSELData); |
| 245 | } |
Tom Joseph | 3503fdc | 2019-01-10 11:25:27 +0530 | [diff] [blame] | 246 | else |
| 247 | { |
| 248 | createHostEntry(eSELData); |
| 249 | } |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | return rc; |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 253 | } |
| 254 | |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 255 | // Prepare for FW Update. |
| 256 | // Execute needed commands to prepare the system for a fw update from the host. |
| 257 | ipmi_ret_t ipmi_ibm_oem_prep_fw_update(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 258 | ipmi_request_t request, |
| 259 | ipmi_response_t response, |
| 260 | ipmi_data_len_t data_len, |
| 261 | ipmi_context_t context) |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 262 | { |
| 263 | ipmi_ret_t ipmi_rc = IPMI_CC_OK; |
| 264 | *data_len = 0; |
| 265 | |
| 266 | int rc = 0; |
| 267 | std::ofstream rwfs_file; |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 268 | const char* busname = "org.openbmc.control.Bmc"; |
| 269 | const char* objname = "/org/openbmc/control/bmc0"; |
| 270 | const char* iface = "org.openbmc.control.Bmc"; |
| 271 | sd_bus* bus = ipmid_get_sd_bus_connection(); |
| 272 | sd_bus_message* reply = NULL; |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 273 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 274 | int r = 0; |
| 275 | |
| 276 | // Set one time flag |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 277 | rc = system( |
| 278 | "fw_setenv openbmconce copy-files-to-ram copy-base-filesystem-to-ram"); |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 279 | rc = WEXITSTATUS(rc); |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 280 | if (rc != 0) |
| 281 | { |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 282 | fprintf(stderr, "fw_setenv openbmconce failed with rc=%d\n", rc); |
Andrew Geissler | d929605 | 2017-06-15 14:57:25 -0500 | [diff] [blame] | 283 | return IPMI_CC_UNSPECIFIED_ERROR; |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | // Touch the image-rwfs file to perform an empty update to force the save |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 287 | // in case we're already in ram and the flash is the same causing the ram |
| 288 | // files to not be copied back to flash |
| 289 | rwfs_file.open("/run/initramfs/image-rwfs", |
| 290 | std::ofstream::out | std::ofstream::app); |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 291 | rwfs_file.close(); |
| 292 | |
| 293 | // Reboot the BMC for settings to take effect |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 294 | r = sd_bus_call_method(bus, busname, objname, iface, "warmReset", &error, |
| 295 | &reply, NULL); |
| 296 | if (r < 0) |
| 297 | { |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 298 | fprintf(stderr, "Failed to reset BMC: %s\n", strerror(-r)); |
| 299 | return -1; |
| 300 | } |
| 301 | printf("Warning: BMC is going down for reboot!\n"); |
| 302 | sd_bus_error_free(&error); |
| 303 | reply = sd_bus_message_unref(reply); |
| 304 | |
| 305 | return ipmi_rc; |
| 306 | } |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 307 | |
Matt Spinler | 3288471 | 2018-09-28 13:56:20 -0500 | [diff] [blame] | 308 | ipmi_ret_t ipmi_ibm_oem_reset_bmc_auth(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 309 | ipmi_request_t request, |
| 310 | ipmi_response_t response, |
| 311 | ipmi_data_len_t data_len, |
| 312 | ipmi_context_t context) |
Adriana Kobylak | 81e2310 | 2018-08-09 14:44:19 -0500 | [diff] [blame] | 313 | { |
Matt Spinler | 34aca01 | 2018-09-25 11:21:06 -0500 | [diff] [blame] | 314 | ipmi_ret_t rc; |
| 315 | |
| 316 | rc = local::users::enableUsers(); |
| 317 | |
| 318 | return rc; |
Adriana Kobylak | 81e2310 | 2018-08-09 14:44:19 -0500 | [diff] [blame] | 319 | } |
| 320 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 321 | namespace |
| 322 | { |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 323 | // Storage to keep the object alive during process life |
| 324 | std::unique_ptr<open_power::host::command::Host> opHost |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 325 | __attribute__((init_priority(101))); |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 326 | std::unique_ptr<sdbusplus::server::manager::manager> objManager |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 327 | __attribute__((init_priority(101))); |
| 328 | } // namespace |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 329 | |
Andrew Jeffery | 8fb3f03 | 2018-07-27 16:45:44 +0930 | [diff] [blame] | 330 | void register_netfn_ibm_oem_commands() |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 331 | { |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 332 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n", NETFUN_IBM_OEM, |
| 333 | IPMI_CMD_PESEL); |
| 334 | ipmi_register_callback(NETFUN_IBM_OEM, IPMI_CMD_PESEL, NULL, |
| 335 | ipmi_ibm_oem_partial_esel, SYSTEM_INTERFACE); |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 336 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 337 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n", NETFUN_OEM, |
| 338 | IPMI_CMD_PREP_FW_UPDATE); |
| 339 | ipmi_register_callback(NETFUN_OEM, IPMI_CMD_PREP_FW_UPDATE, NULL, |
| 340 | ipmi_ibm_oem_prep_fw_update, SYSTEM_INTERFACE); |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 341 | |
Matt Spinler | 3288471 | 2018-09-28 13:56:20 -0500 | [diff] [blame] | 342 | ipmi_register_callback(NETFUN_IBM_OEM, IPMI_CMD_RESET_BMC_AUTH, NULL, |
| 343 | ipmi_ibm_oem_reset_bmc_auth, SYSTEM_INTERFACE); |
Adriana Kobylak | 81e2310 | 2018-08-09 14:44:19 -0500 | [diff] [blame] | 344 | |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 345 | // Create new object on the bus |
| 346 | auto objPath = std::string{CONTROL_HOST_OBJ_MGR} + '/' + HOST_NAME + '0'; |
| 347 | |
| 348 | // Add sdbusplus ObjectManager. |
| 349 | auto& sdbusPlusHandler = ipmid_get_sdbus_plus_handler(); |
| 350 | objManager = std::make_unique<sdbusplus::server::manager::manager>( |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 351 | *sdbusPlusHandler, CONTROL_HOST_OBJ_MGR); |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 352 | |
| 353 | opHost = std::make_unique<open_power::host::command::Host>( |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 354 | *sdbusPlusHandler, objPath.c_str()); |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 355 | |
| 356 | // Service for this is provided by phosphor layer systemcmdintf |
| 357 | // and this will be as part of that. |
Tom | cbfd6ec | 2016-09-14 17:45:55 +0530 | [diff] [blame] | 358 | return; |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 359 | } |