Jayanth Othayoth | ee10ead | 2021-12-05 22:54:06 -0600 | [diff] [blame] | 1 | #include "registration.hpp" |
| 2 | |
| 3 | #include <fmt/format.h> |
| 4 | extern "C" |
| 5 | { |
| 6 | #include <libpdbg.h> |
| 7 | } |
| 8 | #include <phosphor-logging/log.hpp> |
| 9 | |
| 10 | namespace openpower |
| 11 | { |
| 12 | namespace phal |
| 13 | { |
| 14 | using namespace phosphor::logging; |
| 15 | |
| 16 | /** |
| 17 | * @brief Stop instruction executions on all functional threads in the |
| 18 | * host processors. |
| 19 | * This procedure is used to stop all threads in the system in |
| 20 | * attempt best case approach. Like issue processor level stopall |
| 21 | * chip-op with ignore hardware error mode. Since this function |
| 22 | * is used in power-off/error path, ignore the internal error now. |
| 23 | */ |
| 24 | void threadStopAll(void) |
| 25 | { |
| 26 | // Set pdbg back-end to sbefifo. |
| 27 | pdbg_set_backend(PDBG_BACKEND_SBEFIFO, NULL); |
| 28 | |
| 29 | // initialize the pdbg. |
| 30 | pdbg_targets_init(NULL); |
| 31 | |
| 32 | struct pdbg_target* pibTarget; |
| 33 | |
| 34 | pdbg_for_each_class_target("pib", pibTarget) |
| 35 | { |
| 36 | // probe pib traget. |
| 37 | pdbg_target_probe(pibTarget); |
| 38 | } |
| 39 | |
| 40 | // Issue system level thread stop |
| 41 | if (thread_stop_all() < 0) |
| 42 | { |
| 43 | log<level::ERR>("Failed to stop all threads"); |
| 44 | return; |
| 45 | } |
| 46 | log<level::INFO>("Processor thread stopall completed"); |
| 47 | } |
| 48 | |
| 49 | REGISTER_PROCEDURE("threadStopAll", threadStopAll) |
| 50 | |
| 51 | } // namespace phal |
| 52 | } // namespace openpower |