Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 1 | /** |
| 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 | |
Jayanth Othayoth | 785cf6a | 2021-06-28 00:16:35 -0500 | [diff] [blame] | 19 | extern "C" |
| 20 | { |
Andrew Jeffery | 424475d | 2019-08-02 18:45:26 +0930 | [diff] [blame] | 21 | #include <libpdbg.h> |
Jayanth Othayoth | 785cf6a | 2021-06-28 00:16:35 -0500 | [diff] [blame] | 22 | #include <libpdbg_sbe.h> |
| 23 | } |
Andrew Jeffery | 424475d | 2019-08-02 18:45:26 +0930 | [diff] [blame] | 24 | |
Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 25 | #include <phosphor-logging/elog-errors.hpp> |
| 26 | #include <phosphor-logging/elog.hpp> |
| 27 | #include <xyz/openbmc_project/Common/error.hpp> |
| 28 | |
| 29 | namespace openpower |
| 30 | { |
| 31 | namespace proc |
| 32 | { |
| 33 | |
| 34 | NMI::NMI(sdbusplus::bus::bus& bus, const char* path) : |
| 35 | Interface(bus, path), bus(bus), objectPath(path) |
Brad Bishop | 5e5d445 | 2020-10-27 19:46:13 -0400 | [diff] [blame] | 36 | {} |
Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 37 | |
Patrick Williams | 1b607c3 | 2021-04-30 20:44:08 -0500 | [diff] [blame] | 38 | void NMI::nmi() |
Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 39 | { |
| 40 | using namespace phosphor::logging; |
Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 41 | using InternalFailure = |
| 42 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
| 43 | |
Andrew Jeffery | 424475d | 2019-08-02 18:45:26 +0930 | [diff] [blame] | 44 | struct pdbg_target* target; |
Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 45 | |
Andrew Jeffery | 424475d | 2019-08-02 18:45:26 +0930 | [diff] [blame] | 46 | pdbg_for_each_class_target("thread", target) |
Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 47 | { |
Andrew Jeffery | 424475d | 2019-08-02 18:45:26 +0930 | [diff] [blame] | 48 | if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) |
| 49 | continue; |
| 50 | |
| 51 | if (thread_stop(target) < 0 || !thread_status(target).quiesced) |
| 52 | { |
| 53 | log<level::ERR>("Failed to stop all threads"); |
| 54 | report<InternalFailure>(); |
| 55 | return; |
| 56 | } |
Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 57 | } |
Andrew Jeffery | 424475d | 2019-08-02 18:45:26 +0930 | [diff] [blame] | 58 | |
| 59 | if (thread_sreset_all() < 0) |
Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 60 | { |
Andrew Jeffery | 424475d | 2019-08-02 18:45:26 +0930 | [diff] [blame] | 61 | log<level::ERR>("Failed to sreset all threads"); |
Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame] | 62 | report<InternalFailure>(); |
| 63 | } |
| 64 | } |
| 65 | } // namespace proc |
| 66 | } // namespace openpower |