blob: f213e6c297d4d31d6e4c7ee374117ee3f3fcf3b8 [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
17#include <error_monitors/err_pin_monitor.hpp>
18#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
27class Err2Monitor : public host_error_monitor::err_pin_monitor::ErrPinMonitor
28{
29 const static constexpr uint8_t beepCPUErr2 = 5;
30
31 void assertHandler() override
32 {
33 host_error_monitor::err_pin_monitor::ErrPinMonitor::assertHandler();
34
35 beep(conn, beepCPUErr2);
36
37 conn->async_method_call(
38 [this](boost::system::error_code ec,
39 const std::variant<bool>& property) {
40 if (ec)
41 {
42 return;
43 }
44 const bool* reset = std::get_if<bool>(&property);
45 if (reset == nullptr)
46 {
47 std::cerr << "Unable to read reset on ERR2 value\n";
48 return;
49 }
50 startCrashdumpAndRecovery(conn, *reset, "ERR2 Timeout");
51 },
52 "xyz.openbmc_project.Settings",
53 "/xyz/openbmc_project/control/processor_error_config",
54 "org.freedesktop.DBus.Properties", "Get",
55 "xyz.openbmc_project.Control.Processor.ErrConfig", "ResetOnERR2");
56 }
57
58 public:
59 Err2Monitor(boost::asio::io_service& io,
60 std::shared_ptr<sdbusplus::asio::connection> conn,
61 const std::string& signalName) :
62 host_error_monitor::err_pin_monitor::ErrPinMonitor(io, conn, signalName,
63 2)
64 {}
65};
66} // namespace host_error_monitor::err2_monitor