blob: fcce4515327f77387673835be9ca5d13605a6c9b [file] [log] [blame]
Lakshminarayana R. Kammath16ab00c2019-06-03 04:33:33 -05001/**
2 * Copyright (C) 2019 IBM 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
17#include "nmi_interface.hpp"
18
Andrew Jeffery424475d2019-08-02 18:45:26 +093019#include <libpdbg.h>
20
Lakshminarayana R. Kammath16ab00c2019-06-03 04:33:33 -050021#include <phosphor-logging/elog-errors.hpp>
22#include <phosphor-logging/elog.hpp>
23#include <xyz/openbmc_project/Common/error.hpp>
24
25namespace openpower
26{
27namespace proc
28{
29
30NMI::NMI(sdbusplus::bus::bus& bus, const char* path) :
31 Interface(bus, path), bus(bus), objectPath(path)
32{
33}
34
35void NMI::nMI()
36{
37 using namespace phosphor::logging;
Lakshminarayana R. Kammath16ab00c2019-06-03 04:33:33 -050038 using InternalFailure =
39 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
40
Andrew Jeffery424475d2019-08-02 18:45:26 +093041 struct pdbg_target* target;
Lakshminarayana R. Kammath16ab00c2019-06-03 04:33:33 -050042
Andrew Jeffery424475d2019-08-02 18:45:26 +093043 pdbg_for_each_class_target("thread", target)
Lakshminarayana R. Kammath16ab00c2019-06-03 04:33:33 -050044 {
Andrew Jeffery424475d2019-08-02 18:45:26 +093045 if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
46 continue;
47
48 if (thread_stop(target) < 0 || !thread_status(target).quiesced)
49 {
50 log<level::ERR>("Failed to stop all threads");
51 report<InternalFailure>();
52 return;
53 }
Lakshminarayana R. Kammath16ab00c2019-06-03 04:33:33 -050054 }
Andrew Jeffery424475d2019-08-02 18:45:26 +093055
56 if (thread_sreset_all() < 0)
Lakshminarayana R. Kammath16ab00c2019-06-03 04:33:33 -050057 {
Andrew Jeffery424475d2019-08-02 18:45:26 +093058 log<level::ERR>("Failed to sreset all threads");
Lakshminarayana R. Kammath16ab00c2019-06-03 04:33:33 -050059 report<InternalFailure>();
60 }
61}
62} // namespace proc
63} // namespace openpower