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 19 extern "C" 20 { 21 #include <libpdbg.h> 22 #include <libpdbg_sbe.h> 23 } 24 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) 36 {} 37 38 #ifdef SDBUSPP_NEW_CAMELCASE 39 void NMI::nmi() 40 #else 41 void NMI::nMI() 42 #endif 43 { 44 using namespace phosphor::logging; 45 using InternalFailure = 46 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 47 48 struct pdbg_target* target; 49 50 pdbg_for_each_class_target("thread", target) 51 { 52 if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) 53 continue; 54 55 if (thread_stop(target) < 0 || !thread_status(target).quiesced) 56 { 57 log<level::ERR>("Failed to stop all threads"); 58 report<InternalFailure>(); 59 return; 60 } 61 } 62 63 if (thread_sreset_all() < 0) 64 { 65 log<level::ERR>("Failed to sreset all threads"); 66 report<InternalFailure>(); 67 } 68 } 69 } // namespace proc 70 } // namespace openpower 71