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 | |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 15 | /** @brief Traces some regs for hostboot */ |
| 16 | void addHbStatusRegs() |
| 17 | { |
| 18 | // Only do this for P10 systems |
| 19 | if (util::pdbg::queryHardwareAnalysisSupported()) |
| 20 | { |
| 21 | // We only need this for PRIMARY processor |
| 22 | pdbg_target* pibTarget = pdbg_target_from_path(nullptr, "/proc0/pib"); |
| 23 | pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, "/proc0/fsi"); |
| 24 | |
| 25 | uint32_t l_cfamData = 0xFFFFFFFF; |
| 26 | uint64_t l_scomData1 = 0xFFFFFFFFFFFFFFFFull; |
| 27 | uint64_t l_scomData2 = 0xFFFFFFFFFFFFFFFFull; |
| 28 | uint32_t l_cfamAddr = 0x283C; |
| 29 | uint64_t l_scomAddr1 = 0x4602F489; |
| 30 | uint64_t l_scomAddr2 = 0x4602F487; |
| 31 | |
| 32 | if ((nullptr != fsiTarget) && (nullptr != pibTarget)) |
| 33 | { |
Ben Tyner | 74b40bf | 2021-09-15 19:37:04 -0500 | [diff] [blame] | 34 | // buffer for formatted strings (+1 for null, just in case) |
| 35 | char buffer[sizeof("some read error: 0x0123456789ABCDEF ")]; |
| 36 | |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 37 | // get first debug reg (CFAM) |
| 38 | if (RC_SUCCESS != fsi_read(fsiTarget, l_cfamAddr, &l_cfamData)) |
| 39 | { |
Ben Tyner | 74b40bf | 2021-09-15 19:37:04 -0500 | [diff] [blame] | 40 | sprintf(buffer, "cfam read error: 0x%08x", l_cfamAddr); |
| 41 | trace<level::ERROR>(buffer); |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 42 | l_cfamData = 0xFFFFFFFF; |
| 43 | } |
| 44 | |
| 45 | // Get SCOM regs next (just 2 of them) |
| 46 | if (RC_SUCCESS != pib_read(pibTarget, l_scomAddr1, &l_scomData1)) |
| 47 | { |
Ben Tyner | 74b40bf | 2021-09-15 19:37:04 -0500 | [diff] [blame] | 48 | sprintf(buffer, "scom read error: 0x%016" PRIx64 "", |
| 49 | l_scomAddr1); |
| 50 | trace<level::ERROR>(buffer); |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 51 | l_scomData1 = 0xFFFFFFFFFFFFFFFFull; |
| 52 | } |
| 53 | |
| 54 | if (RC_SUCCESS != pib_read(pibTarget, l_scomAddr2, &l_scomData2)) |
| 55 | { |
Ben Tyner | 74b40bf | 2021-09-15 19:37:04 -0500 | [diff] [blame] | 56 | sprintf(buffer, "scom read error: 0x%016" PRIx64 "", |
| 57 | l_scomAddr2); |
| 58 | trace<level::ERROR>(buffer); |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 59 | l_scomData2 = 0xFFFFFFFFFFFFFFFFull; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // Trace out the results here of all 3 regs |
| 64 | // (Format should resemble FSP: HostBoot Reg:0000283C Data:AA801504 |
| 65 | // 00000000 Proc:00050001 ) |
| 66 | std::stringstream ss1, ss2, ss3; |
| 67 | |
| 68 | ss1 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex |
| 69 | << l_cfamAddr << " Data:" << l_cfamData << " Proc:00000000"; |
| 70 | |
| 71 | ss2 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex |
| 72 | << l_scomAddr1 << " Data:" << std::setw(16) << l_scomData1 |
| 73 | << " Proc:00000000"; |
| 74 | |
| 75 | ss3 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex |
| 76 | << l_scomAddr2 << " Data:" << std::setw(16) << l_scomData2 |
| 77 | << " Proc:00000000"; |
| 78 | |
| 79 | std::string strobj1 = ss1.str(); |
| 80 | std::string strobj2 = ss2.str(); |
| 81 | std::string strobj3 = ss3.str(); |
| 82 | |
| 83 | trace<level::INFO>(strobj1.c_str()); |
| 84 | trace<level::INFO>(strobj2.c_str()); |
| 85 | trace<level::INFO>(strobj3.c_str()); |
| 86 | } |
| 87 | |
| 88 | return; |
| 89 | |
| 90 | } // end addHbStatusRegs |
| 91 | |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 92 | } // namespace attn |