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