Jason M. Bills | d0a774d | 2020-12-14 15:57:50 -0800 | [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 |
| 17 | #include <error_monitors/base_gpio_monitor.hpp> |
| 18 | #include <host_error_monitor.hpp> |
| 19 | #include <sdbusplus/asio/object_server.hpp> |
| 20 | |
| 21 | namespace host_error_monitor::pch_thermtrip_monitor |
| 22 | { |
| 23 | class PCHThermtripMonitor : |
| 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; |
| 29 | |
| 30 | std::shared_ptr<sdbusplus::asio::dbus_interface> associationPCHThermtrip; |
| 31 | static const constexpr char* callbackMgrPath = |
| 32 | "/xyz/openbmc_project/CallbackManager"; |
| 33 | |
| 34 | void logEvent() override |
| 35 | { |
| 36 | sd_journal_send("MESSAGE=HostError: SSB thermal trip", "PRIORITY=%i", |
| 37 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", |
| 38 | "OpenBMC.0.1.SsbThermalTrip", NULL); |
| 39 | } |
| 40 | |
| 41 | void assertHandler() override |
| 42 | { |
| 43 | host_error_monitor::base_gpio_monitor::BaseGPIOMonitor::assertHandler(); |
| 44 | |
| 45 | setLED(); |
| 46 | } |
| 47 | |
| 48 | void deassertHandler() override |
| 49 | { |
| 50 | host_error_monitor::base_gpio_monitor::BaseGPIOMonitor:: |
| 51 | deassertHandler(); |
| 52 | |
| 53 | unsetLED(); |
| 54 | } |
| 55 | |
| 56 | void setLED() |
| 57 | { |
| 58 | std::vector<Association> associations; |
| 59 | |
| 60 | associations.emplace_back( |
| 61 | "", "critical", |
| 62 | "/xyz/openbmc_project/host_error_monitor/ssb_thermal_trip"); |
| 63 | associations.emplace_back("", "critical", callbackMgrPath); |
| 64 | |
| 65 | associationPCHThermtrip->set_property("Associations", associations); |
| 66 | } |
| 67 | |
| 68 | void unsetLED() |
| 69 | { |
| 70 | std::vector<Association> associations; |
| 71 | |
| 72 | associations.emplace_back("", "", ""); |
| 73 | |
| 74 | associationPCHThermtrip->set_property("Associations", associations); |
| 75 | } |
| 76 | |
| 77 | public: |
Ed Tanous | ee00ccc | 2023-03-01 10:37:43 -0800 | [diff] [blame^] | 78 | PCHThermtripMonitor(boost::asio::io_context& io, |
Jason M. Bills | d0a774d | 2020-12-14 15:57:50 -0800 | [diff] [blame] | 79 | std::shared_ptr<sdbusplus::asio::connection> conn, |
| 80 | const std::string& signalName) : |
| 81 | BaseGPIOMonitor(io, conn, signalName, assertValue) |
| 82 | { |
| 83 | // Associations interface for led status |
| 84 | std::vector<host_error_monitor::Association> associations; |
| 85 | associations.emplace_back("", "", ""); |
| 86 | |
| 87 | sdbusplus::asio::object_server server = |
| 88 | sdbusplus::asio::object_server(conn); |
| 89 | associationPCHThermtrip = server.add_interface( |
| 90 | "/xyz/openbmc_project/host_error_monitor/ssb_thermal_trip", |
| 91 | "xyz.openbmc_project.Association.Definitions"); |
| 92 | associationPCHThermtrip->register_property("Associations", |
| 93 | associations); |
| 94 | associationPCHThermtrip->initialize(); |
| 95 | |
| 96 | if (valid) |
| 97 | { |
| 98 | startMonitoring(); |
| 99 | } |
| 100 | } |
| 101 | }; |
| 102 | } // namespace host_error_monitor::pch_thermtrip_monitor |