1d195b716SZane Shelley #include <stdio.h>
2d195b716SZane Shelley
3d195b716SZane Shelley #include <analyzer/plugins/plugin.hpp>
4d195b716SZane Shelley #include <hei_util.hpp>
527a17a5bSZane Shelley #include <test/sim-hw-access.hpp>
6d195b716SZane Shelley #include <util/pdbg.hpp>
7d195b716SZane Shelley #include <util/trace.hpp>
8d195b716SZane Shelley
9d195b716SZane Shelley #include "gtest/gtest.h"
10d195b716SZane Shelley
11d195b716SZane Shelley using namespace analyzer;
12d195b716SZane Shelley
13d195b716SZane Shelley static const auto nodeId =
14d195b716SZane Shelley static_cast<libhei::NodeId_t>(libhei::hash<libhei::NodeId_t>("TOD_ERROR"));
15d195b716SZane Shelley
TEST(TodStepCheckFault,MdmtFault)1627a17a5bSZane Shelley TEST(TodStepCheckFault, MdmtFault)
17d195b716SZane Shelley {
18d195b716SZane Shelley pdbg_targets_init(nullptr);
19d195b716SZane Shelley
2027a17a5bSZane Shelley auto proc0 = util::pdbg::getTrgt("/proc0");
2127a17a5bSZane Shelley auto proc1 = util::pdbg::getTrgt("/proc1");
22d195b716SZane Shelley
2327a17a5bSZane Shelley libhei::Chip chip0{proc0, P10_20};
2427a17a5bSZane Shelley libhei::Chip chip1{proc1, P10_20};
25d195b716SZane Shelley
2627a17a5bSZane Shelley sim::ScomAccess& scom = sim::ScomAccess::getSingleton();
2727a17a5bSZane Shelley scom.flush();
2827a17a5bSZane Shelley
2927a17a5bSZane Shelley // TOD_ERROR[14] = 0b1 step check on primary config master select 0
3027a17a5bSZane Shelley scom.add(proc0, 0x00040030, 0x0002000000000000); // TOD_ERROR
3127a17a5bSZane Shelley
3227a17a5bSZane Shelley // TOD_PSS_MSS_STATUS[0:2] = 0b000 primary config is active
3327a17a5bSZane Shelley // TOD_PSS_MSS_STATUS[12] = 0b0 primary config master select 0
3427a17a5bSZane Shelley // TOD_PSS_MSS_STATUS[13] = 0b1 primary config master TOD
3527a17a5bSZane Shelley // TOD_PSS_MSS_STATUS[14] = 0b1 primary config master drawer
3627a17a5bSZane Shelley scom.add(proc0, 0x00040008, 0x0006000000000000);
3727a17a5bSZane Shelley
3827a17a5bSZane Shelley // TOD_ERROR[17] = 0b1 internal step check
3927a17a5bSZane Shelley // TOD_ERROR[21] = 0b1 step check on primary config slave select 1
4027a17a5bSZane Shelley scom.add(proc1, 0x00040030, 0x0000440000000000); // TOD_ERROR
4127a17a5bSZane Shelley
4227a17a5bSZane Shelley // TOD_PSS_MSS_STATUS[0:2] = 0b000 primary config is active
4327a17a5bSZane Shelley // TOD_PSS_MSS_STATUS[15] = 0b1 primary config slave path select 1
4427a17a5bSZane Shelley scom.add(proc1, 0x00040008, 0x0001000000000000);
4527a17a5bSZane Shelley
4627a17a5bSZane Shelley // TOD_PRI_PORT_1_CTRL[0:2] = 0b001 IOHS 1
4727a17a5bSZane Shelley scom.add(proc1, 0x00040002, 0x2000000000000000);
4827a17a5bSZane Shelley
4927a17a5bSZane Shelley // TOD_ERROR(0)[14] step check error on master select 0
50adda0540SZane Shelley libhei::Signature sig0{chip0, nodeId, 0, 14, libhei::ATTN_TYPE_CHIP_CS};
5127a17a5bSZane Shelley
5227a17a5bSZane Shelley // TOD_ERROR(0)[17] internal step check error
53adda0540SZane Shelley libhei::Signature sig1{chip1, nodeId, 0, 17, libhei::ATTN_TYPE_CHIP_CS};
5427a17a5bSZane Shelley
5527a17a5bSZane Shelley // TOD_ERROR(0)[21] step check error on slave select 1
56adda0540SZane Shelley libhei::Signature sig2{chip1, nodeId, 0, 21, libhei::ATTN_TYPE_CHIP_CS};
5727a17a5bSZane Shelley
5827a17a5bSZane Shelley libhei::IsolationData isoData{};
5927a17a5bSZane Shelley isoData.addSignature(sig0);
6027a17a5bSZane Shelley isoData.addSignature(sig1);
6127a17a5bSZane Shelley isoData.addSignature(sig2);
6227a17a5bSZane Shelley ServiceData sd{sig1, AnalysisType::SYSTEM_CHECKSTOP, isoData};
6327a17a5bSZane Shelley
6427a17a5bSZane Shelley // Call the plugin.
65*a0c724d3SPatrick Williams auto plugin =
66*a0c724d3SPatrick Williams PluginMap::getSingleton().get(chip1.getType(), "tod_step_check_fault");
67d195b716SZane Shelley
6827a17a5bSZane Shelley plugin(0, chip1, sd);
69d195b716SZane Shelley
70d195b716SZane Shelley nlohmann::json j{};
71d195b716SZane Shelley std::string s{};
72d195b716SZane Shelley
73d195b716SZane Shelley // Callout list
74d195b716SZane Shelley j = sd.getCalloutList();
75d195b716SZane Shelley s = R"([
76d195b716SZane Shelley {
77d195b716SZane Shelley "Deconfigured": false,
7827a17a5bSZane Shelley "Guarded": false,
7927a17a5bSZane Shelley "LocationCode": "P0",
8027a17a5bSZane Shelley "Priority": "M"
8127a17a5bSZane Shelley },
8227a17a5bSZane Shelley {
8327a17a5bSZane Shelley "Deconfigured": false,
84026e5a3fSZane Shelley "Guarded": false,
8527a17a5bSZane Shelley "LocationCode": "/proc0",
86d195b716SZane Shelley "Priority": "M"
87d195b716SZane Shelley }
88d195b716SZane Shelley ])";
89d195b716SZane Shelley EXPECT_EQ(s, j.dump(4));
90d195b716SZane Shelley
91d195b716SZane Shelley // Callout FFDC
92d195b716SZane Shelley j = sd.getCalloutFFDC();
93d195b716SZane Shelley s = R"([
94d195b716SZane Shelley {
9527a17a5bSZane Shelley "Callout Type": "Clock Callout",
9627a17a5bSZane Shelley "Clock Type": "TOD_CLOCK",
9727a17a5bSZane Shelley "Priority": "medium"
9827a17a5bSZane Shelley },
9927a17a5bSZane Shelley {
100d195b716SZane Shelley "Callout Type": "Hardware Callout",
101026e5a3fSZane Shelley "Guard": false,
102d195b716SZane Shelley "Priority": "medium",
10327a17a5bSZane Shelley "Target": "/proc0"
104d195b716SZane Shelley }
105d195b716SZane Shelley ])";
106d195b716SZane Shelley EXPECT_EQ(s, j.dump(4));
107d195b716SZane Shelley }
108