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) { |
| 42 | if (ec) |
| 43 | { |
| 44 | return; |
| 45 | } |
| 46 | const bool* reset = std::get_if<bool>(&property); |
| 47 | if (reset == nullptr) |
| 48 | { |
| 49 | std::cerr << "Unable to read reset on ERR2 value\n"; |
| 50 | return; |
| 51 | } |
| 52 | startCrashdumpAndRecovery(conn, *reset, "ERR2 Timeout"); |
| 53 | }, |
| 54 | "xyz.openbmc_project.Settings", |
| 55 | "/xyz/openbmc_project/control/processor_error_config", |
| 56 | "org.freedesktop.DBus.Properties", "Get", |
| 57 | "xyz.openbmc_project.Control.Processor.ErrConfig", "ResetOnERR2"); |
| 58 | } |
| 59 | |
| 60 | public: |
| 61 | Err2Monitor(boost::asio::io_service& io, |
| 62 | std::shared_ptr<sdbusplus::asio::connection> conn, |
| 63 | const std::string& signalName) : |
Jason M. Bills | 881a4e1 | 2022-03-14 13:40:01 -0700 | [diff] [blame^] | 64 | host_error_monitor::err_pin_timeout_monitor::ErrPinTimeoutMonitor( |
| 65 | io, conn, signalName, 2) |
Jason M. Bills | 4700852 | 2020-10-07 16:42:34 -0700 | [diff] [blame] | 66 | {} |
| 67 | }; |
| 68 | } // namespace host_error_monitor::err2_monitor |