Jason M. Bills | 4700852 | 2020-10-07 16:42:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2021 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 | */ |
| 16 | #pragma once |
Jason M. Bills | 881a4e1 | 2022-03-14 13:40:01 -0700 | [diff] [blame] | 17 | #include <error_monitors/err_pin_timeout_monitor.hpp> |
Jason M. Bills | 4700852 | 2020-10-07 16:42:34 -0700 | [diff] [blame] | 18 | #include <host_error_monitor.hpp> |
| 19 | #include <sdbusplus/asio/object_server.hpp> |
| 20 | |
| 21 | #include <iostream> |
| 22 | |
| 23 | namespace host_error_monitor::err2_monitor |
| 24 | { |
| 25 | static constexpr bool debug = false; |
| 26 | |
Jason M. Bills | 881a4e1 | 2022-03-14 13:40:01 -0700 | [diff] [blame] | 27 | class Err2Monitor : |
| 28 | public host_error_monitor::err_pin_timeout_monitor::ErrPinTimeoutMonitor |
Jason M. Bills | 4700852 | 2020-10-07 16:42:34 -0700 | [diff] [blame] | 29 | { |
| 30 | const static constexpr uint8_t beepCPUErr2 = 5; |
| 31 | |
| 32 | void assertHandler() override |
| 33 | { |
Jason M. Bills | 881a4e1 | 2022-03-14 13:40:01 -0700 | [diff] [blame] | 34 | host_error_monitor::err_pin_timeout_monitor::ErrPinTimeoutMonitor:: |
| 35 | assertHandler(); |
Jason M. Bills | 4700852 | 2020-10-07 16:42:34 -0700 | [diff] [blame] | 36 | |
| 37 | beep(conn, beepCPUErr2); |
| 38 | |
| 39 | conn->async_method_call( |
| 40 | [this](boost::system::error_code ec, |
| 41 | const std::variant<bool>& property) { |
JinFuLin | 519f2cd | 2022-11-08 10:48:56 +0800 | [diff] [blame] | 42 | // Default to no reset after Crashdump |
| 43 | bool reset = false; |
| 44 | if (!ec) |
Jason M. Bills | 4700852 | 2020-10-07 16:42:34 -0700 | [diff] [blame] | 45 | { |
JinFuLin | 519f2cd | 2022-11-08 10:48:56 +0800 | [diff] [blame] | 46 | const bool* resetPtr = std::get_if<bool>(&property); |
| 47 | if (resetPtr == nullptr) |
| 48 | { |
| 49 | std::cerr << "Unable to read reset on ERR2 value\n"; |
| 50 | } |
| 51 | else |
| 52 | { |
| 53 | reset = *resetPtr; |
| 54 | } |
Jason M. Bills | 4700852 | 2020-10-07 16:42:34 -0700 | [diff] [blame] | 55 | } |
JinFuLin | 519f2cd | 2022-11-08 10:48:56 +0800 | [diff] [blame] | 56 | startCrashdumpAndRecovery(conn, reset, "ERR2 Timeout"); |
Jason M. Bills | 4700852 | 2020-10-07 16:42:34 -0700 | [diff] [blame] | 57 | }, |
| 58 | "xyz.openbmc_project.Settings", |
| 59 | "/xyz/openbmc_project/control/processor_error_config", |
| 60 | "org.freedesktop.DBus.Properties", "Get", |
| 61 | "xyz.openbmc_project.Control.Processor.ErrConfig", "ResetOnERR2"); |
| 62 | } |
| 63 | |
| 64 | public: |
| 65 | Err2Monitor(boost::asio::io_service& io, |
| 66 | std::shared_ptr<sdbusplus::asio::connection> conn, |
| 67 | const std::string& signalName) : |
Jason M. Bills | 881a4e1 | 2022-03-14 13:40:01 -0700 | [diff] [blame] | 68 | host_error_monitor::err_pin_timeout_monitor::ErrPinTimeoutMonitor( |
| 69 | io, conn, signalName, 2) |
Jason M. Bills | 4700852 | 2020-10-07 16:42:34 -0700 | [diff] [blame] | 70 | {} |
| 71 | }; |
| 72 | } // namespace host_error_monitor::err2_monitor |