blob: 0b9061dabc9308517144deb9887bde9ce249fac6 [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
Ben Tynerb8335562021-07-16 12:43:52 -050015/** @brief Traces some regs for hostboot */
16void 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 Tyner74b40bf2021-09-15 19:37:04 -050034 // buffer for formatted strings (+1 for null, just in case)
35 char buffer[sizeof("some read error: 0x0123456789ABCDEF ")];
36
Ben Tynerb8335562021-07-16 12:43:52 -050037 // get first debug reg (CFAM)
38 if (RC_SUCCESS != fsi_read(fsiTarget, l_cfamAddr, &l_cfamData))
39 {
Ben Tyner74b40bf2021-09-15 19:37:04 -050040 sprintf(buffer, "cfam read error: 0x%08x", l_cfamAddr);
41 trace<level::ERROR>(buffer);
Ben Tynerb8335562021-07-16 12:43:52 -050042 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 Tyner74b40bf2021-09-15 19:37:04 -050048 sprintf(buffer, "scom read error: 0x%016" PRIx64 "",
49 l_scomAddr1);
50 trace<level::ERROR>(buffer);
Ben Tynerb8335562021-07-16 12:43:52 -050051 l_scomData1 = 0xFFFFFFFFFFFFFFFFull;
52 }
53
54 if (RC_SUCCESS != pib_read(pibTarget, l_scomAddr2, &l_scomData2))
55 {
Ben Tyner74b40bf2021-09-15 19:37:04 -050056 sprintf(buffer, "scom read error: 0x%016" PRIx64 "",
57 l_scomAddr2);
58 trace<level::ERROR>(buffer);
Ben Tynerb8335562021-07-16 12:43:52 -050059 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 Tynerbcf65a82020-12-01 08:46:36 -060092} // namespace attn