Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2019 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 16 | #include <byteswap.h> |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 17 | |
Chen Yugang | 7a04f3a | 2019-10-08 11:12:35 +0800 | [diff] [blame] | 18 | #include <appcommands.hpp> |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 19 | #include <fstream> |
| 20 | #include <ipmid/api.hpp> |
| 21 | #include <ipmid/utils.hpp> |
| 22 | #include <nlohmann/json.hpp> |
| 23 | #include <phosphor-logging/log.hpp> |
| 24 | #include <regex> |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 25 | #include <xyz/openbmc_project/State/BMC/server.hpp> |
| 26 | |
| 27 | namespace ipmi |
| 28 | { |
| 29 | |
| 30 | static void registerAPPFunctions() __attribute__((constructor)); |
| 31 | |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 32 | static constexpr const char* bmcStateIntf = "xyz.openbmc_project.State.BMC"; |
| 33 | static constexpr const char* softwareVerIntf = |
| 34 | "xyz.openbmc_project.Software.Version"; |
| 35 | static constexpr const char* softwareActivationIntf = |
| 36 | "xyz.openbmc_project.Software.Activation"; |
| 37 | static constexpr const char* associationIntf = |
| 38 | "xyz.openbmc_project.Association"; |
| 39 | static constexpr const char* softwareFunctionalPath = |
| 40 | "/xyz/openbmc_project/software/functional"; |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 41 | |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 42 | using BMC = sdbusplus::xyz::openbmc_project::State::server::BMC; |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 43 | constexpr auto bmc_state_interface = "xyz.openbmc_project.State.BMC"; |
| 44 | constexpr auto bmc_state_property = "CurrentBMCState"; |
| 45 | |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 46 | bool getCurrentBmcState() |
| 47 | { |
| 48 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
| 49 | |
| 50 | // Get the Inventory object implementing the BMC interface |
| 51 | ipmi::DbusObjectInfo bmcObject = |
| 52 | ipmi::getDbusObject(bus, bmc_state_interface); |
| 53 | auto variant = |
| 54 | ipmi::getDbusProperty(bus, bmcObject.second, bmcObject.first, |
| 55 | bmc_state_interface, bmc_state_property); |
| 56 | |
| 57 | return std::holds_alternative<std::string>(variant) && |
| 58 | BMC::convertBMCStateFromString(std::get<std::string>(variant)) == |
| 59 | BMC::BMCState::Ready; |
| 60 | } |
| 61 | |
| 62 | bool getCurrentBmcStateWithFallback(const bool fallbackAvailability) |
| 63 | { |
| 64 | try |
| 65 | { |
| 66 | return getCurrentBmcState(); |
| 67 | } |
| 68 | catch (...) |
| 69 | { |
| 70 | // Nothing provided the BMC interface, therefore return whatever was |
| 71 | // configured as the default. |
| 72 | return fallbackAvailability; |
| 73 | } |
| 74 | } |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 75 | |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 76 | /** |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 77 | * @brief Returns the functional firmware version information. |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 78 | * |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 79 | * It reads the active firmware versions by checking functional |
| 80 | * endpoints association and matching the input version purpose string. |
| 81 | * ctx[in] - ipmi context. |
| 82 | * reqVersionPurpose[in] - Version purpose which need to be read. |
| 83 | * version[out] - Output Version string. |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 84 | * |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 85 | * @return Returns '0' on success and '-1' on failure. |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 86 | * |
| 87 | */ |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 88 | int getActiveSoftwareVersionInfo(ipmi::Context::ptr ctx, |
| 89 | const std::string& reqVersionPurpose, |
| 90 | std::string& version) |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 91 | { |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 92 | std::vector<std::string> activeEndPoints; |
| 93 | boost::system::error_code ec = ipmi::getDbusProperty( |
| 94 | ctx, ipmi::MAPPER_BUS_NAME, softwareFunctionalPath, associationIntf, |
| 95 | "endpoints", activeEndPoints); |
| 96 | if (ec) |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 97 | { |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 98 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 99 | "Failed to get Active firmware version endpoints."); |
| 100 | return -1; |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 101 | } |
| 102 | |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 103 | for (auto& activeEndPoint : activeEndPoints) |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 104 | { |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 105 | std::string serviceName; |
| 106 | ec = ipmi::getService(ctx, softwareActivationIntf, activeEndPoint, |
| 107 | serviceName); |
| 108 | if (ec) |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 109 | { |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 110 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 111 | "Failed to perform getService.", |
| 112 | phosphor::logging::entry("OBJPATH=%s", activeEndPoint.c_str())); |
| 113 | continue; |
| 114 | } |
| 115 | |
| 116 | PropertyMap propMap; |
| 117 | ec = ipmi::getAllDbusProperties(ctx, serviceName, activeEndPoint, |
| 118 | softwareVerIntf, propMap); |
| 119 | if (ec) |
| 120 | { |
| 121 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 122 | "Failed to perform GetAll on Version interface.", |
| 123 | phosphor::logging::entry("SERVICE=%s", serviceName.c_str()), |
| 124 | phosphor::logging::entry("PATH=%s", activeEndPoint.c_str())); |
| 125 | continue; |
| 126 | } |
| 127 | |
| 128 | std::string* purposeProp = |
| 129 | std::get_if<std::string>(&propMap["Purpose"]); |
| 130 | std::string* versionProp = |
| 131 | std::get_if<std::string>(&propMap["Version"]); |
| 132 | if (!purposeProp || !versionProp) |
| 133 | { |
| 134 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 135 | "Failed to get version or purpose property"); |
| 136 | continue; |
| 137 | } |
| 138 | |
| 139 | // Check for requested version information and return if found. |
| 140 | if (*purposeProp == reqVersionPurpose) |
| 141 | { |
| 142 | version = *versionProp; |
| 143 | return 0; |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 147 | phosphor::logging::log<phosphor::logging::level::INFO>( |
| 148 | "Failed to find version information.", |
| 149 | phosphor::logging::entry("PURPOSE=%s", reqVersionPurpose.c_str())); |
| 150 | return -1; |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 153 | // Support both 2 solutions: |
| 154 | // 1.Current solution 2.7.0-dev-533-g14dc00e79-5e7d997 |
| 155 | // openbmcTag 2.7.0-dev |
| 156 | // BuildNo 533 |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 157 | // openbmcHash 14dc00e79 |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 158 | // MetaHasg 5e7d997 |
| 159 | // |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 160 | // 2.New solution wht-0.2-3-gab3500-38384ac |
| 161 | // IdStr wht |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 162 | // Major 0 |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 163 | // Minor 2 |
| 164 | // buildNo 3 |
| 165 | // MetaHash ab3500 |
| 166 | // openbmcHash 38384ac |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 167 | std::optional<MetaRevision> convertIntelVersion(std::string& s) |
| 168 | { |
| 169 | std::smatch results; |
| 170 | MetaRevision rev; |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 171 | std::regex pattern1("(\\d+?).(\\d+?).\\d+?-\\w*?-(\\d+?)-g(\\w+?)-(\\w+?)"); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 172 | constexpr size_t matchedPhosphor = 6; |
| 173 | if (std::regex_match(s, results, pattern1)) |
| 174 | { |
| 175 | if (results.size() == matchedPhosphor) |
| 176 | { |
| 177 | rev.platform = "whtref"; |
| 178 | rev.major = static_cast<uint8_t>(std::stoi(results[1])); |
| 179 | rev.minor = static_cast<uint8_t>(std::stoi(results[2])); |
| 180 | rev.buildNo = static_cast<uint32_t>(std::stoi(results[3])); |
| 181 | rev.openbmcHash = results[4]; |
| 182 | rev.metaHash = results[5]; |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 183 | std::string versionString = |
| 184 | rev.platform + ":" + std::to_string(rev.major) + ":" + |
| 185 | std::to_string(rev.minor) + ":" + std::to_string(rev.buildNo) + |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 186 | ":" + rev.openbmcHash + ":" + rev.metaHash; |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 187 | phosphor::logging::log<phosphor::logging::level::INFO>( |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 188 | "Get BMC version", |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 189 | phosphor::logging::entry("VERSION=%s", versionString.c_str())); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 190 | return rev; |
| 191 | } |
| 192 | } |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 193 | constexpr size_t matchedIntel = 7; |
| 194 | std::regex pattern2("(\\w+?)-(\\d+?).(\\d+?)-(\\d+?)-g(\\w+?)-(\\w+?)"); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 195 | if (std::regex_match(s, results, pattern2)) |
| 196 | { |
| 197 | if (results.size() == matchedIntel) |
| 198 | { |
| 199 | rev.platform = results[1]; |
| 200 | rev.major = static_cast<uint8_t>(std::stoi(results[2])); |
| 201 | rev.minor = static_cast<uint8_t>(std::stoi(results[3])); |
| 202 | rev.buildNo = static_cast<uint32_t>(std::stoi(results[4])); |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 203 | rev.openbmcHash = results[6]; |
| 204 | rev.metaHash = results[5]; |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 205 | std::string versionString = |
| 206 | rev.platform + ":" + std::to_string(rev.major) + ":" + |
| 207 | std::to_string(rev.minor) + ":" + std::to_string(rev.buildNo) + |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 208 | ":" + rev.openbmcHash + ":" + rev.metaHash; |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 209 | phosphor::logging::log<phosphor::logging::level::INFO>( |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 210 | "Get BMC version", |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 211 | phosphor::logging::entry("VERSION=%s", versionString.c_str())); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 212 | return rev; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | return std::nullopt; |
| 217 | } |
Chen Yugang | 7a04f3a | 2019-10-08 11:12:35 +0800 | [diff] [blame] | 218 | |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 219 | RspType<uint8_t, // Device ID |
| 220 | uint8_t, // Device Revision |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 221 | uint7_t, // Firmware Revision Major |
| 222 | bool, // Device available(0=NormalMode,1=DeviceFirmware) |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 223 | uint8_t, // Firmware Revision minor |
| 224 | uint8_t, // IPMI version |
| 225 | uint8_t, // Additional device support |
| 226 | uint24_t, // MFG ID |
| 227 | uint16_t, // Product ID |
| 228 | uint32_t // AUX info |
| 229 | > |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 230 | ipmiAppGetDeviceId(ipmi::Context::ptr ctx) |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 231 | { |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 232 | static struct |
| 233 | { |
| 234 | uint8_t id; |
| 235 | uint8_t revision; |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 236 | uint7_t fwMajor; |
| 237 | bool devBusy; |
| 238 | uint8_t fwMinor; |
Johnathan Mantey | 3c8af65 | 2019-12-19 11:29:15 -0800 | [diff] [blame] | 239 | uint8_t ipmiVer = 2; |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 240 | uint8_t addnDevSupport; |
| 241 | uint24_t manufId; |
| 242 | uint16_t prodId; |
| 243 | uint32_t aux; |
| 244 | } devId; |
AppaRao Puli | cb6386b | 2020-01-16 14:53:30 +0530 | [diff] [blame] | 245 | static bool fwVerInitialized = false; |
| 246 | static bool devIdInitialized = false; |
Johnathan Mantey | 3c8af65 | 2019-12-19 11:29:15 -0800 | [diff] [blame] | 247 | static bool defaultActivationSetting = false; |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 248 | const char* filename = "/usr/share/ipmi-providers/dev_id.json"; |
Johnathan Mantey | 3c8af65 | 2019-12-19 11:29:15 -0800 | [diff] [blame] | 249 | const char* prodIdFilename = "/var/cache/private/prodID"; |
AppaRao Puli | cb6386b | 2020-01-16 14:53:30 +0530 | [diff] [blame] | 250 | if (!fwVerInitialized) |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 251 | { |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 252 | std::string versionString; |
| 253 | if (!getActiveSoftwareVersionInfo(ctx, versionPurposeBMC, |
| 254 | versionString)) |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 255 | { |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 256 | std::optional<MetaRevision> rev = |
| 257 | convertIntelVersion(versionString); |
| 258 | if (rev.has_value()) |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 259 | { |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 260 | MetaRevision revision = rev.value(); |
| 261 | devId.fwMajor = static_cast<uint7_t>(revision.major); |
| 262 | |
| 263 | revision.minor = (revision.minor > 99 ? 99 : revision.minor); |
| 264 | devId.fwMinor = |
| 265 | revision.minor % 10 + (revision.minor / 10) * 16; |
| 266 | try |
| 267 | { |
| 268 | uint32_t hash = std::stoul(revision.metaHash, 0, 16); |
| 269 | hash = bswap_32(hash); |
| 270 | devId.aux = (revision.buildNo & 0xFF) + (hash & 0xFFFFFF00); |
| 271 | fwVerInitialized = true; |
| 272 | } |
| 273 | catch (const std::exception& e) |
| 274 | { |
| 275 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 276 | "Failed to convert git hash", |
| 277 | phosphor::logging::entry("ERROR=%s", e.what())); |
| 278 | } |
Jia, chunhui | 82d178c | 2019-06-27 16:48:14 +0800 | [diff] [blame] | 279 | } |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 280 | } |
AppaRao Puli | cb6386b | 2020-01-16 14:53:30 +0530 | [diff] [blame] | 281 | } |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 282 | |
AppaRao Puli | cb6386b | 2020-01-16 14:53:30 +0530 | [diff] [blame] | 283 | if (!devIdInitialized) |
| 284 | { |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 285 | std::ifstream devIdFile(filename); |
| 286 | if (devIdFile.is_open()) |
| 287 | { |
| 288 | auto data = nlohmann::json::parse(devIdFile, nullptr, false); |
| 289 | if (!data.is_discarded()) |
| 290 | { |
| 291 | devId.id = data.value("id", 0); |
| 292 | devId.revision = data.value("revision", 0); |
| 293 | devId.addnDevSupport = data.value("addn_dev_support", 0); |
| 294 | devId.manufId = data.value("manuf_id", 0); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 295 | } |
| 296 | else |
| 297 | { |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 298 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 299 | "Device ID JSON parser failure"); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 300 | return ipmi::responseUnspecifiedError(); |
| 301 | } |
| 302 | } |
| 303 | else |
| 304 | { |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 305 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 306 | "Device ID file not found"); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 307 | return ipmi::responseUnspecifiedError(); |
| 308 | } |
Johnathan Mantey | 3c8af65 | 2019-12-19 11:29:15 -0800 | [diff] [blame] | 309 | |
| 310 | // Determine the Product ID. Using the DBus system is painfully slow at |
| 311 | // boot time. Avoid using DBus to get the Product ID. The Product ID is |
| 312 | // stored in a non-volatile file now. The /usr/bin/checkFru.sh script, |
| 313 | // run during bootup, will populate the productIdFile. |
| 314 | std::fstream prodIdFile(prodIdFilename); |
| 315 | if (prodIdFile.is_open()) |
| 316 | { |
| 317 | std::string id = "0x00"; |
| 318 | char* end; |
| 319 | prodIdFile.getline(&id[0], id.size() + 1); |
| 320 | devId.prodId = std::strtol(&id[0], &end, 0); |
AppaRao Puli | cb6386b | 2020-01-16 14:53:30 +0530 | [diff] [blame] | 321 | devIdInitialized = true; |
Johnathan Mantey | 3c8af65 | 2019-12-19 11:29:15 -0800 | [diff] [blame] | 322 | } |
| 323 | else |
| 324 | { |
| 325 | // For any exception send out platform id as 0, |
| 326 | // and make sure to re-query the device id. |
AppaRao Puli | cb6386b | 2020-01-16 14:53:30 +0530 | [diff] [blame] | 327 | devIdInitialized = false; |
Johnathan Mantey | 3c8af65 | 2019-12-19 11:29:15 -0800 | [diff] [blame] | 328 | devId.prodId = 0; |
| 329 | } |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 330 | } |
| 331 | |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 332 | // Set availability to the actual current BMC state. |
| 333 | // The availability may change in run time so don't cache. |
| 334 | bool bmcDevBusy = getCurrentBmcStateWithFallback(defaultActivationSetting); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 335 | |
AppaRao Puli | e99e7ed | 2020-01-17 12:27:10 +0530 | [diff] [blame^] | 336 | return ipmi::responseSuccess(devId.id, devId.revision, devId.fwMajor, |
| 337 | bmcDevBusy, devId.fwMinor, devId.ipmiVer, |
| 338 | devId.addnDevSupport, devId.manufId, |
| 339 | devId.prodId, devId.aux); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | static void registerAPPFunctions(void) |
| 343 | { |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 344 | // <Get Device ID> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 345 | registerHandler(prioOemBase, netFnApp, app::cmdGetDeviceId, Privilege::User, |
| 346 | ipmiAppGetDeviceId); |
Vernon Mauery | ce14e4d | 2019-06-25 11:38:20 -0700 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | } // namespace ipmi |