blob: fea3e21679af07ba5fdd32b59e1567f52247e45a [file] [log] [blame]
Jason M. Bills5b615092020-12-11 16:15:28 -08001/*
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/base_gpio_monitor.hpp>
18#include <host_error_monitor.hpp>
19#include <sdbusplus/asio/object_server.hpp>
20
21namespace host_error_monitor::mem_thermtrip_monitor
22{
23class MemThermtripMonitor :
24 public host_error_monitor::base_gpio_monitor::BaseGPIOMonitor
25{
26 const static host_error_monitor::base_gpio_monitor::AssertValue
27 assertValue =
28 host_error_monitor::base_gpio_monitor::AssertValue::lowAssert;
JinFuLina3d4a142022-12-05 15:38:35 +080029 std::shared_ptr<sdbusplus::asio::dbus_interface> assertInterface;
Jason M. Bills5b615092020-12-11 16:15:28 -080030 size_t cpuNum;
31
32 void logEvent() override
33 {
34 std::string cpuNumber = "CPU " + std::to_string(cpuNum);
35 std::string msg = cpuNumber + " Memory Thermal trip.";
36
37 sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i",
38 LOG_ERR, "REDFISH_MESSAGE_ID=%s",
39 "OpenBMC.0.1.MemoryThermTrip",
40 "REDFISH_MESSAGE_ARGS=%s", cpuNumber.c_str(), NULL);
JinFuLina3d4a142022-12-05 15:38:35 +080041 assertInterface->set_property("Asserted", true);
42 }
43
44 void deassertHandler() override
45 {
46 assertInterface->set_property("Asserted", false);
Jason M. Bills5b615092020-12-11 16:15:28 -080047 }
48
49 public:
50 MemThermtripMonitor(boost::asio::io_service& io,
51 std::shared_ptr<sdbusplus::asio::connection> conn,
JinFuLina3d4a142022-12-05 15:38:35 +080052 const std::string& signalName, const size_t cpuNum,
53 const std::string& customName = std::string()) :
Jason M. Bills5b615092020-12-11 16:15:28 -080054 BaseGPIOMonitor(io, conn, signalName, assertValue),
55 cpuNum(cpuNum)
56 {
JinFuLina3d4a142022-12-05 15:38:35 +080057 sdbusplus::asio::object_server server =
58 sdbusplus::asio::object_server(conn);
59 std::string objectName = customName.empty() ? signalName : customName;
60 std::string path =
61 "/xyz/openbmc_project/host_error_monitor/processor/" + objectName;
62
63 assertInterface = server.add_interface(
64 path, "xyz.openbmc_project.HostErrorMonitor.Processor.ThermalTrip");
65 assertInterface->register_property("Asserted", false);
66 assertInterface->initialize();
Jason M. Bills5b615092020-12-11 16:15:28 -080067 if (valid)
68 {
69 startMonitoring();
70 }
71 }
72};
73} // namespace host_error_monitor::mem_thermtrip_monitor