NMI (soft reset) control code enablement
Changes here include:
1) A service that triggers Open BMC App (openpower-proc-nmi)
2) An application that waits for a dbus event (NMI) to occur
3) A reset logic that triggers a NMI/softreset dbus service which
will invoke pdbg call to trigger stop followed by sreset on all
threads
4) Necessary Makefile.am changes
Tested: Verified following
1) openpower-proc-nmi app is automatically started once host is started
2) After killing the app made sure app is restarted successfully
3) Verified NMI is detected on the Host side and crash dump being
collected in /var/crash/ and taking a watchdog triggered reboot
4) System coming back to original state once all #3 is completed
5) Powered off the system (obmcutil poweroff) service disabled and
enabled after host is powered on
Signed-off-by: Lakshminarayana R. Kammath <lkammath@in.ibm.com>
Change-Id: I16f3bb2a2ed0c0ffcea2a720a2ae39a2b303ef9e
diff --git a/nmi_interface.cpp b/nmi_interface.cpp
new file mode 100644
index 0000000..aea38ae
--- /dev/null
+++ b/nmi_interface.cpp
@@ -0,0 +1,58 @@
+/**
+ * Copyright (C) 2019 IBM 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.
+ */
+
+#include "nmi_interface.hpp"
+
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
+namespace openpower
+{
+namespace proc
+{
+
+NMI::NMI(sdbusplus::bus::bus& bus, const char* path) :
+ Interface(bus, path), bus(bus), objectPath(path)
+{
+}
+
+void NMI::nMI()
+{
+ using namespace phosphor::logging;
+ using sdbusplus::exception::SdBusError;
+ using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
+
+ constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
+ constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
+ constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
+
+ auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
+ method.append("nmi.service", "replace");
+ try
+ {
+ bus.call_noreply(method);
+ }
+ catch (const SdBusError& e)
+ {
+ log<level::ALERT>("Error in starting NMI service. ");
+ report<InternalFailure>();
+ }
+}
+} // namespace proc
+} // namespace openpower