blob: 66315d806f60fc5e1aaccb3304b7ef88483b8ac8 [file] [log] [blame]
Jason M. Bills47008522020-10-07 16:42:34 -07001/*
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. Bills881a4e12022-03-14 13:40:01 -070017#include <error_monitors/err_pin_timeout_monitor.hpp>
Jason M. Bills47008522020-10-07 16:42:34 -070018#include <host_error_monitor.hpp>
19#include <sdbusplus/asio/object_server.hpp>
20
21#include <iostream>
22
23namespace host_error_monitor::err2_monitor
24{
25static constexpr bool debug = false;
26
Jason M. Bills881a4e12022-03-14 13:40:01 -070027class Err2Monitor :
28 public host_error_monitor::err_pin_timeout_monitor::ErrPinTimeoutMonitor
Jason M. Bills47008522020-10-07 16:42:34 -070029{
30 const static constexpr uint8_t beepCPUErr2 = 5;
31
32 void assertHandler() override
33 {
Jason M. Bills881a4e12022-03-14 13:40:01 -070034 host_error_monitor::err_pin_timeout_monitor::ErrPinTimeoutMonitor::
35 assertHandler();
Jason M. Bills47008522020-10-07 16:42:34 -070036
37 beep(conn, beepCPUErr2);
38
39 conn->async_method_call(
40 [this](boost::system::error_code ec,
41 const std::variant<bool>& property) {
JinFuLin519f2cd2022-11-08 10:48:56 +080042 // Default to no reset after Crashdump
43 bool reset = false;
44 if (!ec)
Jason M. Bills47008522020-10-07 16:42:34 -070045 {
JinFuLin519f2cd2022-11-08 10:48:56 +080046 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. Bills47008522020-10-07 16:42:34 -070055 }
JinFuLin519f2cd2022-11-08 10:48:56 +080056 startCrashdumpAndRecovery(conn, reset, "ERR2 Timeout");
Jason M. Bills47008522020-10-07 16:42:34 -070057 },
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. Bills881a4e12022-03-14 13:40:01 -070068 host_error_monitor::err_pin_timeout_monitor::ErrPinTimeoutMonitor(
69 io, conn, signalName, 2)
Jason M. Bills47008522020-10-07 16:42:34 -070070 {}
71};
72} // namespace host_error_monitor::err2_monitor