Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -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 | */ |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 16 | #include <peci.h> |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 17 | #include <systemd/sd-journal.h> |
| 18 | |
Jason M. Bills | 08b2c7a | 2020-08-28 15:39:14 -0700 | [diff] [blame] | 19 | #include <boost/asio/io_service.hpp> |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 20 | #include <boost/asio/posix/stream_descriptor.hpp> |
Jason M. Bills | 08b2c7a | 2020-08-28 15:39:14 -0700 | [diff] [blame] | 21 | #include <boost/asio/steady_timer.hpp> |
Jason M. Bills | 5245ed6 | 2020-12-04 16:50:21 -0800 | [diff] [blame] | 22 | #include <error_monitors.hpp> |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 23 | #include <gpiod.hpp> |
Jason M. Bills | d711cc8 | 2020-12-04 16:46:39 -0800 | [diff] [blame] | 24 | #include <host_error_monitor.hpp> |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 25 | #include <sdbusplus/asio/object_server.hpp> |
Jason M. Bills | 48e5dff | 2020-06-10 13:47:47 -0700 | [diff] [blame] | 26 | |
| 27 | #include <bitset> |
| 28 | #include <iostream> |
Jason M. Bills | d1a19f6 | 2019-08-06 11:52:58 -0700 | [diff] [blame] | 29 | #include <variant> |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 30 | |
| 31 | namespace host_error_monitor |
| 32 | { |
| 33 | static boost::asio::io_service io; |
| 34 | static std::shared_ptr<sdbusplus::asio::connection> conn; |
| 35 | |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 36 | static std::shared_ptr<sdbusplus::asio::dbus_interface> associationSSBThermTrip; |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 37 | |
| 38 | static const constexpr char* rootPath = "/xyz/openbmc_project/CallbackManager"; |
| 39 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 40 | static bool hostOff = true; |
Jason M. Bills | d711cc8 | 2020-12-04 16:46:39 -0800 | [diff] [blame] | 41 | bool hostIsOff() |
| 42 | { |
| 43 | return hostOff; |
| 44 | } |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 45 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 46 | // GPIO Lines and Event Descriptors |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 47 | static gpiod::line cpu1FIVRFaultLine; |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 48 | static gpiod::line cpu1ThermtripLine; |
| 49 | static boost::asio::posix::stream_descriptor cpu1ThermtripEvent(io); |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 50 | static gpiod::line cpu2FIVRFaultLine; |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 51 | static gpiod::line cpu2ThermtripLine; |
| 52 | static boost::asio::posix::stream_descriptor cpu2ThermtripEvent(io); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 53 | static gpiod::line cpu1VRHotLine; |
| 54 | static boost::asio::posix::stream_descriptor cpu1VRHotEvent(io); |
| 55 | static gpiod::line cpu2VRHotLine; |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 56 | static boost::asio::posix::stream_descriptor cpu1MemABCDVRHotEvent(io); |
| 57 | static gpiod::line cpu1MemEFGHVRHotLine; |
| 58 | static boost::asio::posix::stream_descriptor cpu1MemEFGHVRHotEvent(io); |
| 59 | static gpiod::line cpu2MemABCDVRHotLine; |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 60 | static boost::asio::posix::stream_descriptor cpu2VRHotEvent(io); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 61 | static gpiod::line cpu1MemABCDVRHotLine; |
| 62 | static boost::asio::posix::stream_descriptor cpu2MemABCDVRHotEvent(io); |
| 63 | static gpiod::line cpu2MemEFGHVRHotLine; |
| 64 | static boost::asio::posix::stream_descriptor cpu2MemEFGHVRHotEvent(io); |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 65 | //---------------------------------- |
| 66 | // PCH_BMC_THERMTRIP function related definition |
| 67 | //---------------------------------- |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 68 | static gpiod::line pchThermtripLine; |
| 69 | static boost::asio::posix::stream_descriptor pchThermtripEvent(io); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 70 | //---------------------------------- |
| 71 | // CPU_MEM_THERM_EVENT function related definition |
| 72 | //---------------------------------- |
| 73 | static gpiod::line cpu1MemtripLine; |
| 74 | static boost::asio::posix::stream_descriptor cpu1MemtripEvent(io); |
| 75 | static gpiod::line cpu2MemtripLine; |
| 76 | static boost::asio::posix::stream_descriptor cpu2MemtripEvent(io); |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 77 | |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 78 | static void cpuBootFIVRFaultLog(const int cpuNum) |
| 79 | { |
| 80 | std::string msg = "Boot FIVR Fault on CPU " + std::to_string(cpuNum); |
| 81 | |
| 82 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 83 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.CPUError", |
| 84 | "REDFISH_MESSAGE_ARGS=%s", msg.c_str(), NULL); |
| 85 | } |
| 86 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 87 | static void cpuThermTripLog(const int cpuNum) |
| 88 | { |
| 89 | std::string msg = "CPU " + std::to_string(cpuNum) + " thermal trip"; |
| 90 | |
| 91 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 92 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", |
| 93 | "OpenBMC.0.1.CPUThermalTrip", "REDFISH_MESSAGE_ARGS=%d", |
| 94 | cpuNum, NULL); |
| 95 | } |
| 96 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 97 | static void memThermTripLog(const int cpuNum) |
| 98 | { |
| 99 | std::string cpuNumber = "CPU " + std::to_string(cpuNum); |
| 100 | std::string msg = cpuNumber + " Memory Thermal trip."; |
| 101 | |
| 102 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 103 | LOG_ERR, "REDFISH_MESSAGE_ID=%s", |
| 104 | "OpenBMC.0.1.MemoryThermTrip", "REDFISH_MESSAGE_ARGS=%s", |
| 105 | cpuNumber.c_str(), NULL); |
| 106 | } |
| 107 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 108 | static void cpuVRHotLog(const std::string& vr) |
| 109 | { |
| 110 | std::string msg = vr + " Voltage Regulator Overheated."; |
| 111 | |
| 112 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 113 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", |
| 114 | "OpenBMC.0.1.VoltageRegulatorOverheated", |
| 115 | "REDFISH_MESSAGE_ARGS=%s", vr.c_str(), NULL); |
| 116 | } |
| 117 | |
Jason M. Bills | 0886654 | 2019-08-16 12:04:19 -0700 | [diff] [blame] | 118 | static void ssbThermTripLog() |
| 119 | { |
| 120 | sd_journal_send("MESSAGE=HostError: SSB thermal trip", "PRIORITY=%i", |
| 121 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", |
| 122 | "OpenBMC.0.1.SsbThermalTrip", NULL); |
| 123 | } |
| 124 | |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 125 | static void initializeErrorState(); |
Jason M. Bills | 5245ed6 | 2020-12-04 16:50:21 -0800 | [diff] [blame] | 126 | static void init() |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 127 | { |
Jason M. Bills | 5245ed6 | 2020-12-04 16:50:21 -0800 | [diff] [blame] | 128 | // Get the current host state to prepare to start the signal monitors |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 129 | conn->async_method_call( |
| 130 | [](boost::system::error_code ec, |
| 131 | const std::variant<std::string>& property) { |
| 132 | if (ec) |
| 133 | { |
| 134 | return; |
| 135 | } |
| 136 | const std::string* state = std::get_if<std::string>(&property); |
| 137 | if (state == nullptr) |
| 138 | { |
| 139 | std::cerr << "Unable to read host state value\n"; |
| 140 | return; |
| 141 | } |
| 142 | hostOff = *state == "xyz.openbmc_project.State.Host.HostState.Off"; |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 143 | // If the system is on, initialize the error state |
| 144 | if (!hostOff) |
| 145 | { |
| 146 | initializeErrorState(); |
| 147 | } |
Jason M. Bills | 5245ed6 | 2020-12-04 16:50:21 -0800 | [diff] [blame] | 148 | |
| 149 | // Now we have the host state, start the signal monitors |
| 150 | if (!error_monitors::startMonitors(io, conn)) |
| 151 | { |
| 152 | throw std::runtime_error("Failed to start signal monitors"); |
| 153 | } |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 154 | }, |
| 155 | "xyz.openbmc_project.State.Host", "/xyz/openbmc_project/state/host0", |
| 156 | "org.freedesktop.DBus.Properties", "Get", |
| 157 | "xyz.openbmc_project.State.Host", "CurrentHostState"); |
| 158 | } |
| 159 | |
| 160 | static std::shared_ptr<sdbusplus::bus::match::match> startHostStateMonitor() |
| 161 | { |
| 162 | return std::make_shared<sdbusplus::bus::match::match>( |
| 163 | *conn, |
| 164 | "type='signal',interface='org.freedesktop.DBus.Properties'," |
Jason M. Bills | 2fbb9ea | 2020-06-19 14:46:54 -0700 | [diff] [blame] | 165 | "member='PropertiesChanged',arg0='xyz.openbmc_project.State.Host'", |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 166 | [](sdbusplus::message::message& msg) { |
| 167 | std::string interfaceName; |
| 168 | boost::container::flat_map<std::string, std::variant<std::string>> |
| 169 | propertiesChanged; |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 170 | try |
| 171 | { |
| 172 | msg.read(interfaceName, propertiesChanged); |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 173 | } |
| 174 | catch (std::exception& e) |
| 175 | { |
| 176 | std::cerr << "Unable to read host state\n"; |
| 177 | return; |
| 178 | } |
Jason M. Bills | 566ccc4 | 2020-06-18 16:38:26 -0700 | [diff] [blame] | 179 | // We only want to check for CurrentHostState |
| 180 | if (propertiesChanged.begin()->first != "CurrentHostState") |
| 181 | { |
| 182 | return; |
| 183 | } |
| 184 | std::string* state = |
| 185 | std::get_if<std::string>(&(propertiesChanged.begin()->second)); |
| 186 | if (state == nullptr) |
| 187 | { |
| 188 | std::cerr << propertiesChanged.begin()->first |
| 189 | << " property invalid\n"; |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | hostOff = *state == "xyz.openbmc_project.State.Host.HostState.Off"; |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 194 | |
Jason M. Bills | 8fa1c96 | 2020-12-10 14:33:56 -0800 | [diff] [blame] | 195 | if (!hostOff) |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 196 | { |
| 197 | // Handle any initial errors when the host turns on |
| 198 | initializeErrorState(); |
Jason M. Bills | 5245ed6 | 2020-12-04 16:50:21 -0800 | [diff] [blame] | 199 | error_monitors::sendHostOn(); |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 200 | } |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 201 | }); |
| 202 | } |
| 203 | |
| 204 | static bool requestGPIOEvents( |
| 205 | const std::string& name, const std::function<void()>& handler, |
| 206 | gpiod::line& gpioLine, |
| 207 | boost::asio::posix::stream_descriptor& gpioEventDescriptor) |
| 208 | { |
| 209 | // Find the GPIO line |
| 210 | gpioLine = gpiod::find_line(name); |
| 211 | if (!gpioLine) |
| 212 | { |
| 213 | std::cerr << "Failed to find the " << name << " line\n"; |
| 214 | return false; |
| 215 | } |
| 216 | |
| 217 | try |
| 218 | { |
| 219 | gpioLine.request( |
| 220 | {"host-error-monitor", gpiod::line_request::EVENT_BOTH_EDGES}); |
| 221 | } |
| 222 | catch (std::exception&) |
| 223 | { |
| 224 | std::cerr << "Failed to request events for " << name << "\n"; |
| 225 | return false; |
| 226 | } |
| 227 | |
| 228 | int gpioLineFd = gpioLine.event_get_fd(); |
| 229 | if (gpioLineFd < 0) |
| 230 | { |
| 231 | std::cerr << "Failed to get " << name << " fd\n"; |
| 232 | return false; |
| 233 | } |
| 234 | |
| 235 | gpioEventDescriptor.assign(gpioLineFd); |
| 236 | |
| 237 | gpioEventDescriptor.async_wait( |
| 238 | boost::asio::posix::stream_descriptor::wait_read, |
| 239 | [&name, handler](const boost::system::error_code ec) { |
| 240 | if (ec) |
| 241 | { |
| 242 | std::cerr << name << " fd handler error: " << ec.message() |
| 243 | << "\n"; |
| 244 | return; |
| 245 | } |
| 246 | handler(); |
| 247 | }); |
| 248 | return true; |
| 249 | } |
| 250 | |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 251 | static bool requestGPIOInput(const std::string& name, gpiod::line& gpioLine) |
| 252 | { |
| 253 | // Find the GPIO line |
| 254 | gpioLine = gpiod::find_line(name); |
| 255 | if (!gpioLine) |
| 256 | { |
| 257 | std::cerr << "Failed to find the " << name << " line.\n"; |
| 258 | return false; |
| 259 | } |
| 260 | |
| 261 | // Request GPIO input |
| 262 | try |
| 263 | { |
| 264 | gpioLine.request({__FUNCTION__, gpiod::line_request::DIRECTION_INPUT}); |
| 265 | } |
| 266 | catch (std::exception&) |
| 267 | { |
| 268 | std::cerr << "Failed to request " << name << " input\n"; |
| 269 | return false; |
| 270 | } |
| 271 | |
| 272 | return true; |
| 273 | } |
| 274 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 275 | static void cpu1ThermtripAssertHandler() |
| 276 | { |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 277 | if (cpu1FIVRFaultLine.get_value() == 0) |
| 278 | { |
| 279 | cpuBootFIVRFaultLog(1); |
| 280 | } |
| 281 | else |
| 282 | { |
| 283 | cpuThermTripLog(1); |
| 284 | } |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 287 | static void cpu1ThermtripHandler() |
| 288 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 289 | gpiod::line_event gpioLineEvent = cpu1ThermtripLine.event_read(); |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 290 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 291 | bool cpu1Thermtrip = |
| 292 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 293 | if (cpu1Thermtrip) |
| 294 | { |
| 295 | cpu1ThermtripAssertHandler(); |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 296 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 297 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 298 | cpu1ThermtripEvent.async_wait( |
| 299 | boost::asio::posix::stream_descriptor::wait_read, |
| 300 | [](const boost::system::error_code ec) { |
| 301 | if (ec) |
| 302 | { |
| 303 | std::cerr << "CPU 1 Thermtrip handler error: " << ec.message() |
| 304 | << "\n"; |
| 305 | return; |
| 306 | } |
| 307 | cpu1ThermtripHandler(); |
| 308 | }); |
| 309 | } |
| 310 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 311 | static void cpu1MemtripHandler() |
| 312 | { |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 313 | gpiod::line_event gpioLineEvent = cpu1MemtripLine.event_read(); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 314 | |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 315 | bool cpu1Memtrip = |
| 316 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 317 | if (cpu1Memtrip) |
| 318 | { |
| 319 | memThermTripLog(1); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 320 | } |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 321 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 322 | cpu1MemtripEvent.async_wait( |
| 323 | boost::asio::posix::stream_descriptor::wait_read, |
| 324 | [](const boost::system::error_code ec) { |
| 325 | if (ec) |
| 326 | { |
| 327 | std::cerr << "CPU 1 Memory Thermaltrip handler error: " |
| 328 | << ec.message() << "\n"; |
| 329 | return; |
| 330 | } |
| 331 | cpu1MemtripHandler(); |
| 332 | }); |
| 333 | } |
| 334 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 335 | static void cpu2ThermtripAssertHandler() |
| 336 | { |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 337 | if (cpu2FIVRFaultLine.get_value() == 0) |
| 338 | { |
| 339 | cpuBootFIVRFaultLog(2); |
| 340 | } |
| 341 | else |
| 342 | { |
| 343 | cpuThermTripLog(2); |
| 344 | } |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 345 | } |
| 346 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 347 | static void cpu2ThermtripHandler() |
| 348 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 349 | gpiod::line_event gpioLineEvent = cpu2ThermtripLine.event_read(); |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 350 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 351 | bool cpu2Thermtrip = |
| 352 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 353 | if (cpu2Thermtrip) |
| 354 | { |
| 355 | cpu2ThermtripAssertHandler(); |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 356 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 357 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 358 | cpu2ThermtripEvent.async_wait( |
| 359 | boost::asio::posix::stream_descriptor::wait_read, |
| 360 | [](const boost::system::error_code ec) { |
| 361 | if (ec) |
| 362 | { |
| 363 | std::cerr << "CPU 2 Thermtrip handler error: " << ec.message() |
| 364 | << "\n"; |
| 365 | return; |
| 366 | } |
| 367 | cpu2ThermtripHandler(); |
| 368 | }); |
| 369 | } |
| 370 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 371 | static void cpu2MemtripHandler() |
| 372 | { |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 373 | gpiod::line_event gpioLineEvent = cpu2MemtripLine.event_read(); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 374 | |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 375 | bool cpu2Memtrip = |
| 376 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 377 | if (cpu2Memtrip) |
| 378 | { |
| 379 | memThermTripLog(2); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 380 | } |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 381 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 382 | cpu2MemtripEvent.async_wait( |
| 383 | boost::asio::posix::stream_descriptor::wait_read, |
| 384 | [](const boost::system::error_code ec) { |
| 385 | if (ec) |
| 386 | { |
| 387 | std::cerr << "CPU 2 Memory Thermaltrip handler error: " |
| 388 | << ec.message() << "\n"; |
| 389 | return; |
| 390 | } |
| 391 | cpu2MemtripHandler(); |
| 392 | }); |
| 393 | } |
| 394 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 395 | static void cpu1VRHotAssertHandler() |
| 396 | { |
| 397 | cpuVRHotLog("CPU 1"); |
| 398 | } |
| 399 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 400 | static void cpu1VRHotHandler() |
| 401 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 402 | gpiod::line_event gpioLineEvent = cpu1VRHotLine.event_read(); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 403 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 404 | bool cpu1VRHot = |
| 405 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 406 | if (cpu1VRHot) |
| 407 | { |
| 408 | cpu1VRHotAssertHandler(); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 409 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 410 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 411 | cpu1VRHotEvent.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 412 | [](const boost::system::error_code ec) { |
| 413 | if (ec) |
| 414 | { |
| 415 | std::cerr << "CPU 1 VRHot handler error: " |
| 416 | << ec.message() << "\n"; |
| 417 | return; |
| 418 | } |
| 419 | cpu1VRHotHandler(); |
| 420 | }); |
| 421 | } |
| 422 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 423 | static void cpu1MemABCDVRHotAssertHandler() |
| 424 | { |
| 425 | cpuVRHotLog("CPU 1 Memory ABCD"); |
| 426 | } |
| 427 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 428 | static void cpu1MemABCDVRHotHandler() |
| 429 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 430 | gpiod::line_event gpioLineEvent = cpu1MemABCDVRHotLine.event_read(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 431 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 432 | bool cpu1MemABCDVRHot = |
| 433 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 434 | if (cpu1MemABCDVRHot) |
| 435 | { |
| 436 | cpu1MemABCDVRHotAssertHandler(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 437 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 438 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 439 | cpu1MemABCDVRHotEvent.async_wait( |
| 440 | boost::asio::posix::stream_descriptor::wait_read, |
| 441 | [](const boost::system::error_code ec) { |
| 442 | if (ec) |
| 443 | { |
| 444 | std::cerr << "CPU 1 Memory ABCD VRHot handler error: " |
| 445 | << ec.message() << "\n"; |
| 446 | return; |
| 447 | } |
| 448 | cpu1MemABCDVRHotHandler(); |
| 449 | }); |
| 450 | } |
| 451 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 452 | static void cpu1MemEFGHVRHotAssertHandler() |
| 453 | { |
| 454 | cpuVRHotLog("CPU 1 Memory EFGH"); |
| 455 | } |
| 456 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 457 | static void cpu1MemEFGHVRHotHandler() |
| 458 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 459 | gpiod::line_event gpioLineEvent = cpu1MemEFGHVRHotLine.event_read(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 460 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 461 | bool cpu1MemEFGHVRHot = |
| 462 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 463 | if (cpu1MemEFGHVRHot) |
| 464 | { |
| 465 | cpu1MemEFGHVRHotAssertHandler(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 466 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 467 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 468 | cpu1MemEFGHVRHotEvent.async_wait( |
| 469 | boost::asio::posix::stream_descriptor::wait_read, |
| 470 | [](const boost::system::error_code ec) { |
| 471 | if (ec) |
| 472 | { |
| 473 | std::cerr << "CPU 1 Memory EFGH VRHot handler error: " |
| 474 | << ec.message() << "\n"; |
| 475 | return; |
| 476 | } |
| 477 | cpu1MemEFGHVRHotHandler(); |
| 478 | }); |
| 479 | } |
| 480 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 481 | static void cpu2VRHotAssertHandler() |
| 482 | { |
| 483 | cpuVRHotLog("CPU 2"); |
| 484 | } |
| 485 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 486 | static void cpu2VRHotHandler() |
| 487 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 488 | gpiod::line_event gpioLineEvent = cpu2VRHotLine.event_read(); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 489 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 490 | bool cpu2VRHot = |
| 491 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 492 | if (cpu2VRHot) |
| 493 | { |
| 494 | cpu2VRHotAssertHandler(); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 495 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 496 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 497 | cpu2VRHotEvent.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 498 | [](const boost::system::error_code ec) { |
| 499 | if (ec) |
| 500 | { |
| 501 | std::cerr << "CPU 2 VRHot handler error: " |
| 502 | << ec.message() << "\n"; |
| 503 | return; |
| 504 | } |
| 505 | cpu2VRHotHandler(); |
| 506 | }); |
| 507 | } |
| 508 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 509 | static void cpu2MemABCDVRHotAssertHandler() |
| 510 | { |
| 511 | cpuVRHotLog("CPU 2 Memory ABCD"); |
| 512 | } |
| 513 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 514 | static void cpu2MemABCDVRHotHandler() |
| 515 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 516 | gpiod::line_event gpioLineEvent = cpu2MemABCDVRHotLine.event_read(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 517 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 518 | bool cpu2MemABCDVRHot = |
| 519 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 520 | if (cpu2MemABCDVRHot) |
| 521 | { |
| 522 | cpu2MemABCDVRHotAssertHandler(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 523 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 524 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 525 | cpu2MemABCDVRHotEvent.async_wait( |
| 526 | boost::asio::posix::stream_descriptor::wait_read, |
| 527 | [](const boost::system::error_code ec) { |
| 528 | if (ec) |
| 529 | { |
| 530 | std::cerr << "CPU 2 Memory ABCD VRHot handler error: " |
| 531 | << ec.message() << "\n"; |
| 532 | return; |
| 533 | } |
| 534 | cpu2MemABCDVRHotHandler(); |
| 535 | }); |
| 536 | } |
| 537 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 538 | static void cpu2MemEFGHVRHotAssertHandler() |
| 539 | { |
| 540 | cpuVRHotLog("CPU 2 Memory EFGH"); |
| 541 | } |
| 542 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 543 | static void cpu2MemEFGHVRHotHandler() |
| 544 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 545 | gpiod::line_event gpioLineEvent = cpu2MemEFGHVRHotLine.event_read(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 546 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 547 | bool cpu2MemEFGHVRHot = |
| 548 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 549 | if (cpu2MemEFGHVRHot) |
| 550 | { |
| 551 | cpu2MemEFGHVRHotAssertHandler(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 552 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 553 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 554 | cpu2MemEFGHVRHotEvent.async_wait( |
| 555 | boost::asio::posix::stream_descriptor::wait_read, |
| 556 | [](const boost::system::error_code ec) { |
| 557 | if (ec) |
| 558 | { |
| 559 | std::cerr << "CPU 2 Memory EFGH VRHot handler error: " |
| 560 | << ec.message() << "\n"; |
| 561 | return; |
| 562 | } |
| 563 | cpu2MemEFGHVRHotHandler(); |
| 564 | }); |
| 565 | } |
| 566 | |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 567 | static void pchThermtripHandler() |
| 568 | { |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 569 | std::vector<Association> associations; |
| 570 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 571 | gpiod::line_event gpioLineEvent = pchThermtripLine.event_read(); |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 572 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 573 | bool pchThermtrip = |
| 574 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 575 | if (pchThermtrip) |
| 576 | { |
| 577 | ssbThermTripLog(); |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 578 | associations.emplace_back( |
| 579 | "", "critical", |
| 580 | "/xyz/openbmc_project/host_error_monitor/ssb_thermal_trip"); |
| 581 | associations.emplace_back("", "critical", host_error_monitor::rootPath); |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 582 | } |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 583 | else |
| 584 | { |
| 585 | associations.emplace_back("", "", ""); |
| 586 | } |
| 587 | host_error_monitor::associationSSBThermTrip->set_property("Associations", |
| 588 | associations); |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 589 | |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 590 | pchThermtripEvent.async_wait( |
| 591 | boost::asio::posix::stream_descriptor::wait_read, |
| 592 | [](const boost::system::error_code ec) { |
| 593 | if (ec) |
| 594 | { |
| 595 | std::cerr << "PCH Thermal trip handler error: " << ec.message() |
| 596 | << "\n"; |
| 597 | return; |
| 598 | } |
| 599 | pchThermtripHandler(); |
| 600 | }); |
| 601 | } |
| 602 | |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 603 | static void initializeErrorState() |
| 604 | { |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 605 | // Handle CPU1_THERMTRIP if it's asserted now |
| 606 | if (cpu1ThermtripLine.get_value() == 0) |
| 607 | { |
| 608 | cpu1ThermtripAssertHandler(); |
| 609 | } |
| 610 | |
| 611 | // Handle CPU2_THERMTRIP if it's asserted now |
| 612 | if (cpu2ThermtripLine.get_value() == 0) |
| 613 | { |
| 614 | cpu2ThermtripAssertHandler(); |
| 615 | } |
| 616 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 617 | // Handle CPU1_MEM_THERM_EVENT (CPU1 DIMM Thermal trip) if it's asserted now |
| 618 | if (cpu1MemtripLine.get_value() == 0) |
| 619 | { |
| 620 | memThermTripLog(1); |
| 621 | } |
| 622 | |
| 623 | // Handle CPU2_MEM_THERM_EVENT (CPU2 DIMM Thermal trip) if it's asserted now |
| 624 | if (cpu2MemtripLine.get_value() == 0) |
| 625 | { |
| 626 | memThermTripLog(2); |
| 627 | } |
| 628 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 629 | // Handle CPU1_VRHOT if it's asserted now |
| 630 | if (cpu1VRHotLine.get_value() == 0) |
| 631 | { |
| 632 | cpu1VRHotAssertHandler(); |
| 633 | } |
| 634 | |
| 635 | // Handle CPU1_MEM_ABCD_VRHOT if it's asserted now |
| 636 | if (cpu1MemABCDVRHotLine.get_value() == 0) |
| 637 | { |
| 638 | cpu1MemABCDVRHotAssertHandler(); |
| 639 | } |
| 640 | |
| 641 | // Handle CPU1_MEM_EFGH_VRHOT if it's asserted now |
| 642 | if (cpu1MemEFGHVRHotLine.get_value() == 0) |
| 643 | { |
| 644 | cpu1MemEFGHVRHotAssertHandler(); |
| 645 | } |
| 646 | |
| 647 | // Handle CPU2_VRHOT if it's asserted now |
| 648 | if (cpu2VRHotLine.get_value() == 0) |
| 649 | { |
| 650 | cpu2VRHotAssertHandler(); |
| 651 | } |
| 652 | |
| 653 | // Handle CPU2_MEM_ABCD_VRHOT if it's asserted now |
| 654 | if (cpu2MemABCDVRHotLine.get_value() == 0) |
| 655 | { |
| 656 | cpu2MemABCDVRHotAssertHandler(); |
| 657 | } |
| 658 | |
| 659 | // Handle CPU2_MEM_EFGH_VRHOT if it's asserted now |
| 660 | if (cpu2MemEFGHVRHotLine.get_value() == 0) |
| 661 | { |
| 662 | cpu2MemEFGHVRHotAssertHandler(); |
| 663 | } |
| 664 | |
Jason M. Bills | 0886654 | 2019-08-16 12:04:19 -0700 | [diff] [blame] | 665 | // Handle PCH_BMC_THERMTRIP if it's asserted now |
| 666 | if (pchThermtripLine.get_value() == 0) |
| 667 | { |
| 668 | ssbThermTripLog(); |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 669 | std::vector<Association> associations; |
| 670 | associations.emplace_back( |
| 671 | "", "critical", |
| 672 | "/xyz/openbmc_project/host_error_monitor/ssb_thermal_trip"); |
| 673 | associations.emplace_back("", "critical", host_error_monitor::rootPath); |
| 674 | host_error_monitor::associationSSBThermTrip->set_property( |
| 675 | "Associations", associations); |
Jason M. Bills | 0886654 | 2019-08-16 12:04:19 -0700 | [diff] [blame] | 676 | } |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 677 | } |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 678 | } // namespace host_error_monitor |
| 679 | |
| 680 | int main(int argc, char* argv[]) |
| 681 | { |
| 682 | // setup connection to dbus |
| 683 | host_error_monitor::conn = |
| 684 | std::make_shared<sdbusplus::asio::connection>(host_error_monitor::io); |
| 685 | |
Jason M. Bills | c4b91f2 | 2019-11-26 17:04:50 -0800 | [diff] [blame] | 686 | // Host Error Monitor Service |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 687 | host_error_monitor::conn->request_name( |
| 688 | "xyz.openbmc_project.HostErrorMonitor"); |
| 689 | sdbusplus::asio::object_server server = |
| 690 | sdbusplus::asio::object_server(host_error_monitor::conn); |
| 691 | |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 692 | // Associations interface for led status |
| 693 | std::vector<host_error_monitor::Association> associations; |
| 694 | associations.emplace_back("", "", ""); |
| 695 | host_error_monitor::associationSSBThermTrip = server.add_interface( |
| 696 | "/xyz/openbmc_project/host_error_monitor/ssb_thermal_trip", |
| 697 | "xyz.openbmc_project.Association.Definitions"); |
| 698 | host_error_monitor::associationSSBThermTrip->register_property( |
| 699 | "Associations", associations); |
| 700 | host_error_monitor::associationSSBThermTrip->initialize(); |
| 701 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 702 | // Start tracking host state |
| 703 | std::shared_ptr<sdbusplus::bus::match::match> hostStateMonitor = |
| 704 | host_error_monitor::startHostStateMonitor(); |
| 705 | |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 706 | // Request CPU1_FIVR_FAULT GPIO input |
| 707 | if (!host_error_monitor::requestGPIOInput( |
| 708 | "CPU1_FIVR_FAULT", host_error_monitor::cpu1FIVRFaultLine)) |
| 709 | { |
| 710 | return -1; |
| 711 | } |
| 712 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 713 | // Request CPU1_THERMTRIP GPIO events |
| 714 | if (!host_error_monitor::requestGPIOEvents( |
| 715 | "CPU1_THERMTRIP", host_error_monitor::cpu1ThermtripHandler, |
| 716 | host_error_monitor::cpu1ThermtripLine, |
| 717 | host_error_monitor::cpu1ThermtripEvent)) |
| 718 | { |
| 719 | return -1; |
| 720 | } |
| 721 | |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 722 | // Request CPU2_FIVR_FAULT GPIO input |
| 723 | if (!host_error_monitor::requestGPIOInput( |
| 724 | "CPU2_FIVR_FAULT", host_error_monitor::cpu2FIVRFaultLine)) |
| 725 | { |
| 726 | return -1; |
| 727 | } |
| 728 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 729 | // Request CPU2_THERMTRIP GPIO events |
| 730 | if (!host_error_monitor::requestGPIOEvents( |
| 731 | "CPU2_THERMTRIP", host_error_monitor::cpu2ThermtripHandler, |
| 732 | host_error_monitor::cpu2ThermtripLine, |
| 733 | host_error_monitor::cpu2ThermtripEvent)) |
| 734 | { |
| 735 | return -1; |
| 736 | } |
| 737 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 738 | // Request CPU1_VRHOT GPIO events |
| 739 | if (!host_error_monitor::requestGPIOEvents( |
| 740 | "CPU1_VRHOT", host_error_monitor::cpu1VRHotHandler, |
| 741 | host_error_monitor::cpu1VRHotLine, |
| 742 | host_error_monitor::cpu1VRHotEvent)) |
| 743 | { |
| 744 | return -1; |
| 745 | } |
| 746 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 747 | // Request CPU1_MEM_ABCD_VRHOT GPIO events |
| 748 | if (!host_error_monitor::requestGPIOEvents( |
| 749 | "CPU1_MEM_ABCD_VRHOT", host_error_monitor::cpu1MemABCDVRHotHandler, |
| 750 | host_error_monitor::cpu1MemABCDVRHotLine, |
| 751 | host_error_monitor::cpu1MemABCDVRHotEvent)) |
| 752 | { |
| 753 | return -1; |
| 754 | } |
| 755 | |
| 756 | // Request CPU1_MEM_EFGH_VRHOT GPIO events |
| 757 | if (!host_error_monitor::requestGPIOEvents( |
| 758 | "CPU1_MEM_EFGH_VRHOT", host_error_monitor::cpu1MemEFGHVRHotHandler, |
| 759 | host_error_monitor::cpu1MemEFGHVRHotLine, |
| 760 | host_error_monitor::cpu1MemEFGHVRHotEvent)) |
| 761 | { |
| 762 | return -1; |
| 763 | } |
| 764 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 765 | // Request CPU2_VRHOT GPIO events |
| 766 | if (!host_error_monitor::requestGPIOEvents( |
| 767 | "CPU2_VRHOT", host_error_monitor::cpu2VRHotHandler, |
| 768 | host_error_monitor::cpu2VRHotLine, |
| 769 | host_error_monitor::cpu2VRHotEvent)) |
| 770 | { |
| 771 | return -1; |
| 772 | } |
| 773 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 774 | // Request CPU2_MEM_ABCD_VRHOT GPIO events |
| 775 | if (!host_error_monitor::requestGPIOEvents( |
| 776 | "CPU2_MEM_ABCD_VRHOT", host_error_monitor::cpu2MemABCDVRHotHandler, |
| 777 | host_error_monitor::cpu2MemABCDVRHotLine, |
| 778 | host_error_monitor::cpu2MemABCDVRHotEvent)) |
| 779 | { |
| 780 | return -1; |
| 781 | } |
| 782 | |
| 783 | // Request CPU2_MEM_EFGH_VRHOT GPIO events |
| 784 | if (!host_error_monitor::requestGPIOEvents( |
| 785 | "CPU2_MEM_EFGH_VRHOT", host_error_monitor::cpu2MemEFGHVRHotHandler, |
| 786 | host_error_monitor::cpu2MemEFGHVRHotLine, |
| 787 | host_error_monitor::cpu2MemEFGHVRHotEvent)) |
| 788 | { |
| 789 | return -1; |
| 790 | } |
| 791 | |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 792 | // Request PCH_BMC_THERMTRIP GPIO events |
| 793 | if (!host_error_monitor::requestGPIOEvents( |
| 794 | "PCH_BMC_THERMTRIP", host_error_monitor::pchThermtripHandler, |
| 795 | host_error_monitor::pchThermtripLine, |
| 796 | host_error_monitor::pchThermtripEvent)) |
| 797 | { |
| 798 | return -1; |
| 799 | } |
| 800 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 801 | // Request CPU1_MEM_THERM_EVENT GPIO events |
| 802 | if (!host_error_monitor::requestGPIOEvents( |
| 803 | "CPU1_MEM_THERM_EVENT", host_error_monitor::cpu1MemtripHandler, |
| 804 | host_error_monitor::cpu1MemtripLine, |
| 805 | host_error_monitor::cpu1MemtripEvent)) |
| 806 | { |
| 807 | return -1; |
| 808 | } |
| 809 | |
| 810 | // Request CPU2_MEM_THERM_EVENT GPIO events |
| 811 | if (!host_error_monitor::requestGPIOEvents( |
| 812 | "CPU2_MEM_THERM_EVENT", host_error_monitor::cpu2MemtripHandler, |
| 813 | host_error_monitor::cpu2MemtripLine, |
| 814 | host_error_monitor::cpu2MemtripEvent)) |
| 815 | { |
| 816 | return -1; |
| 817 | } |
| 818 | |
Jason M. Bills | 5245ed6 | 2020-12-04 16:50:21 -0800 | [diff] [blame] | 819 | // Initialize the signal monitors |
| 820 | host_error_monitor::init(); |
| 821 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 822 | host_error_monitor::io.run(); |
| 823 | |
| 824 | return 0; |
| 825 | } |