blob: 4f333e8650f26e4b12692d62ac6b590a55842322 [file] [log] [blame]
Ben Tynerbcf65a82020-12-01 08:46:36 -06001#include <libpdbg.h>
2
3#include <attn/attn_common.hpp>
Ben Tynerb8335562021-07-16 12:43:52 -05004#include <attn/attn_logging.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -06005#include <sdbusplus/bus.hpp>
Ben Tynerb8335562021-07-16 12:43:52 -05006#include <util/pdbg.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -06007
Ben Tynerb8335562021-07-16 12:43:52 -05008#include <iomanip>
9#include <iostream>
Ben Tynerbcf65a82020-12-01 08:46:36 -060010#include <map>
11
12namespace attn
13{
14
15/** @brief Transition the host state */
16void transitionHost(const HostState i_hostState)
17{
Ben Tynere8b2aed2020-12-16 18:58:41 -060018 // The host quiesce code will handle the instruction-stop task(s)
19 // thread_stop_all(); // in libpdbg
Ben Tynerbcf65a82020-12-01 08:46:36 -060020
21 // We will be transitioning host by starting appropriate dbus target
22 std::string target = "obmc-host-quiesce@0.target"; // quiesce is default
23
Ben Tynerfe2757b2021-01-14 13:17:50 -060024 // crash (mpipl) mode state requested
25 if (HostState::Crash == i_hostState)
Ben Tynerbcf65a82020-12-01 08:46:36 -060026 {
Ben Tynerfe2757b2021-01-14 13:17:50 -060027 target = "obmc-host-crash@0.target";
Ben Tynerbcf65a82020-12-01 08:46:36 -060028 }
29
30 auto bus = sdbusplus::bus::new_system();
31 auto method = bus.new_method_call(
32 "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
33 "org.freedesktop.systemd1.Manager", "StartUnit");
34
35 method.append(target); // target unit to start
36 method.append("replace"); // mode = replace conflicting queued jobs
37
38 bus.call_noreply(method); // start the service
39}
40
Ben Tynerb8335562021-07-16 12:43:52 -050041/** @brief Traces some regs for hostboot */
42void addHbStatusRegs()
43{
44 // Only do this for P10 systems
45 if (util::pdbg::queryHardwareAnalysisSupported())
46 {
47 // We only need this for PRIMARY processor
48 pdbg_target* pibTarget = pdbg_target_from_path(nullptr, "/proc0/pib");
49 pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, "/proc0/fsi");
50
51 uint32_t l_cfamData = 0xFFFFFFFF;
52 uint64_t l_scomData1 = 0xFFFFFFFFFFFFFFFFull;
53 uint64_t l_scomData2 = 0xFFFFFFFFFFFFFFFFull;
54 uint32_t l_cfamAddr = 0x283C;
55 uint64_t l_scomAddr1 = 0x4602F489;
56 uint64_t l_scomAddr2 = 0x4602F487;
57
58 if ((nullptr != fsiTarget) && (nullptr != pibTarget))
59 {
60 // get first debug reg (CFAM)
61 if (RC_SUCCESS != fsi_read(fsiTarget, l_cfamAddr, &l_cfamData))
62 {
63 eventAttentionFail((int)AttnSection::addHbStatusRegs |
64 ATTN_PDBG_CFAM);
65 l_cfamData = 0xFFFFFFFF;
66 }
67
68 // Get SCOM regs next (just 2 of them)
69 if (RC_SUCCESS != pib_read(pibTarget, l_scomAddr1, &l_scomData1))
70 {
71 eventAttentionFail((int)AttnSection::addHbStatusRegs |
72 ATTN_PDBG_SCOM);
73 l_scomData1 = 0xFFFFFFFFFFFFFFFFull;
74 }
75
76 if (RC_SUCCESS != pib_read(pibTarget, l_scomAddr2, &l_scomData2))
77 {
78 eventAttentionFail((int)AttnSection::addHbStatusRegs |
79 ATTN_PDBG_SCOM);
80 l_scomData2 = 0xFFFFFFFFFFFFFFFFull;
81 }
82 }
83
84 // Trace out the results here of all 3 regs
85 // (Format should resemble FSP: HostBoot Reg:0000283C Data:AA801504
86 // 00000000 Proc:00050001 )
87 std::stringstream ss1, ss2, ss3;
88
89 ss1 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
90 << l_cfamAddr << " Data:" << l_cfamData << " Proc:00000000";
91
92 ss2 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
93 << l_scomAddr1 << " Data:" << std::setw(16) << l_scomData1
94 << " Proc:00000000";
95
96 ss3 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
97 << l_scomAddr2 << " Data:" << std::setw(16) << l_scomData2
98 << " Proc:00000000";
99
100 std::string strobj1 = ss1.str();
101 std::string strobj2 = ss2.str();
102 std::string strobj3 = ss3.str();
103
104 trace<level::INFO>(strobj1.c_str());
105 trace<level::INFO>(strobj2.c_str());
106 trace<level::INFO>(strobj3.c_str());
107 }
108
109 return;
110
111} // end addHbStatusRegs
112
Ben Tynerbcf65a82020-12-01 08:46:36 -0600113} // namespace attn