Add error_monitors with a sample signal
This file can be overridden to include the various signals that
need to be monitored for a platform.
A sample of an SMI monitor is included.
Change-Id: I9ba4e31b4e7fd7955737887c5920218a0301c50c
Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
diff --git a/include/error_monitors.hpp b/include/error_monitors.hpp
new file mode 100644
index 0000000..55b8790
--- /dev/null
+++ b/include/error_monitors.hpp
@@ -0,0 +1,55 @@
+/*
+// Copyright (c) 2021 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+#pragma once
+#include <sdbusplus/asio/object_server.hpp>
+// #include <error_monitors/smi_monitor.hpp>
+
+#include <memory>
+
+namespace host_error_monitor::error_monitors
+{
+// Error signals to monitor
+// static std::unique_ptr<host_error_monitor::smi_monitor::SMIMonitor>
+// smiMonitor;
+
+// Check if all the signal monitors started successfully
+bool checkMonitors()
+{
+ bool ret = true;
+
+ // ret &= smiMonitor->isValid();
+
+ return ret;
+}
+
+// Start the signal monitors
+bool startMonitors(boost::asio::io_service& io,
+ std::shared_ptr<sdbusplus::asio::connection> conn)
+{
+ // smiMonitor =
+ // std::make_unique<host_error_monitor::smi_monitor::SMIMonitor>(
+ // io, conn, "SMI");
+
+ return checkMonitors();
+}
+
+// Notify the signal monitors of host on event
+void sendHostOn()
+{
+ // smiMonitor->hostOn();
+}
+
+} // namespace host_error_monitor::error_monitors
diff --git a/src/host_error_monitor.cpp b/src/host_error_monitor.cpp
index 7937d9b..4f88b88 100644
--- a/src/host_error_monitor.cpp
+++ b/src/host_error_monitor.cpp
@@ -19,6 +19,7 @@
#include <boost/asio/io_service.hpp>
#include <boost/asio/posix/stream_descriptor.hpp>
#include <boost/asio/steady_timer.hpp>
+#include <error_monitors.hpp>
#include <gpiod.hpp>
#include <host_error_monitor.hpp>
#include <sdbusplus/asio/object_server.hpp>
@@ -252,8 +253,9 @@
}
static void initializeErrorState();
-static void initializeHostState()
+static void init()
{
+ // Get the current host state to prepare to start the signal monitors
conn->async_method_call(
[](boost::system::error_code ec,
const std::variant<std::string>& property) {
@@ -273,6 +275,12 @@
{
initializeErrorState();
}
+
+ // Now we have the host state, start the signal monitors
+ if (!error_monitors::startMonitors(io, conn))
+ {
+ throw std::runtime_error("Failed to start signal monitors");
+ }
},
"xyz.openbmc_project.State.Host", "/xyz/openbmc_project/state/host0",
"org.freedesktop.DBus.Properties", "Get",
@@ -328,6 +336,7 @@
{
// Handle any initial errors when the host turns on
initializeErrorState();
+ error_monitors::sendHostOn();
}
});
}
@@ -1594,9 +1603,6 @@
return -1;
}
- // Initialize the host state
- host_error_monitor::initializeHostState();
-
// Request CPU_CATERR GPIO events
if (!host_error_monitor::requestGPIOEvents(
"CPU_CATERR", host_error_monitor::caterrHandler,
@@ -1750,6 +1756,9 @@
return -1;
}
+ // Initialize the signal monitors
+ host_error_monitor::init();
+
host_error_monitor::io.run();
return 0;