blob: 89d28b985b838c70ca31ea50b5bfcfae42a46b6c [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 {
34 // get first debug reg (CFAM)
35 if (RC_SUCCESS != fsi_read(fsiTarget, l_cfamAddr, &l_cfamData))
36 {
37 eventAttentionFail((int)AttnSection::addHbStatusRegs |
38 ATTN_PDBG_CFAM);
39 l_cfamData = 0xFFFFFFFF;
40 }
41
42 // Get SCOM regs next (just 2 of them)
43 if (RC_SUCCESS != pib_read(pibTarget, l_scomAddr1, &l_scomData1))
44 {
45 eventAttentionFail((int)AttnSection::addHbStatusRegs |
46 ATTN_PDBG_SCOM);
47 l_scomData1 = 0xFFFFFFFFFFFFFFFFull;
48 }
49
50 if (RC_SUCCESS != pib_read(pibTarget, l_scomAddr2, &l_scomData2))
51 {
52 eventAttentionFail((int)AttnSection::addHbStatusRegs |
53 ATTN_PDBG_SCOM);
54 l_scomData2 = 0xFFFFFFFFFFFFFFFFull;
55 }
56 }
57
58 // Trace out the results here of all 3 regs
59 // (Format should resemble FSP: HostBoot Reg:0000283C Data:AA801504
60 // 00000000 Proc:00050001 )
61 std::stringstream ss1, ss2, ss3;
62
63 ss1 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
64 << l_cfamAddr << " Data:" << l_cfamData << " Proc:00000000";
65
66 ss2 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
67 << l_scomAddr1 << " Data:" << std::setw(16) << l_scomData1
68 << " Proc:00000000";
69
70 ss3 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
71 << l_scomAddr2 << " Data:" << std::setw(16) << l_scomData2
72 << " Proc:00000000";
73
74 std::string strobj1 = ss1.str();
75 std::string strobj2 = ss2.str();
76 std::string strobj3 = ss3.str();
77
78 trace<level::INFO>(strobj1.c_str());
79 trace<level::INFO>(strobj2.c_str());
80 trace<level::INFO>(strobj3.c_str());
81 }
82
83 return;
84
85} // end addHbStatusRegs
86
Ben Tynerbcf65a82020-12-01 08:46:36 -060087} // namespace attn