Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 1 | #include <libpdbg.h> |
| 2 | |
| 3 | #include <attn/attn_common.hpp> |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 4 | #include <attn/attn_logging.hpp> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 5 | #include <sdbusplus/bus.hpp> |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 6 | #include <util/pdbg.hpp> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 7 | |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 8 | #include <iomanip> |
| 9 | #include <iostream> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 10 | #include <map> |
| 11 | |
| 12 | namespace attn |
| 13 | { |
| 14 | |
| 15 | /** @brief Transition the host state */ |
| 16 | void transitionHost(const HostState i_hostState) |
| 17 | { |
Ben Tyner | e8b2aed | 2020-12-16 18:58:41 -0600 | [diff] [blame] | 18 | // The host quiesce code will handle the instruction-stop task(s) |
| 19 | // thread_stop_all(); // in libpdbg |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 20 | |
| 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 Tyner | fe2757b | 2021-01-14 13:17:50 -0600 | [diff] [blame] | 24 | // crash (mpipl) mode state requested |
| 25 | if (HostState::Crash == i_hostState) |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 26 | { |
Ben Tyner | fe2757b | 2021-01-14 13:17:50 -0600 | [diff] [blame] | 27 | target = "obmc-host-crash@0.target"; |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 28 | } |
| 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 Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 41 | /** @brief Traces some regs for hostboot */ |
| 42 | void 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 Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 113 | } // namespace attn |