blob: dd57d517d2d82c6a059ac9be0cfb25fb8b78d37d [file] [log] [blame]
Zane Shelleyd195b712022-01-26 13:26:34 -06001#include <stdio.h>
2
3#include <analyzer/plugins/plugin.hpp>
4#include <hei_util.hpp>
Zane Shelley27a17a52022-02-21 20:33:49 -06005#include <test/sim-hw-access.hpp>
Zane Shelleyd195b712022-01-26 13:26:34 -06006#include <util/pdbg.hpp>
7#include <util/trace.hpp>
8
9#include "gtest/gtest.h"
10
11using namespace analyzer;
12
13static const auto nodeId =
14 static_cast<libhei::NodeId_t>(libhei::hash<libhei::NodeId_t>("TOD_ERROR"));
15
Zane Shelley27a17a52022-02-21 20:33:49 -060016TEST(TodStepCheckFault, MdmtFault)
Zane Shelleyd195b712022-01-26 13:26:34 -060017{
18 pdbg_targets_init(nullptr);
19
Zane Shelley27a17a52022-02-21 20:33:49 -060020 auto proc0 = util::pdbg::getTrgt("/proc0");
21 auto proc1 = util::pdbg::getTrgt("/proc1");
Zane Shelleyd195b712022-01-26 13:26:34 -060022
Zane Shelley27a17a52022-02-21 20:33:49 -060023 libhei::Chip chip0{proc0, P10_20};
24 libhei::Chip chip1{proc1, P10_20};
Zane Shelleyd195b712022-01-26 13:26:34 -060025
Zane Shelley27a17a52022-02-21 20:33:49 -060026 sim::ScomAccess& scom = sim::ScomAccess::getSingleton();
27 scom.flush();
28
29 // TOD_ERROR[14] = 0b1 step check on primary config master select 0
30 scom.add(proc0, 0x00040030, 0x0002000000000000); // TOD_ERROR
31
32 // TOD_PSS_MSS_STATUS[0:2] = 0b000 primary config is active
33 // TOD_PSS_MSS_STATUS[12] = 0b0 primary config master select 0
34 // TOD_PSS_MSS_STATUS[13] = 0b1 primary config master TOD
35 // TOD_PSS_MSS_STATUS[14] = 0b1 primary config master drawer
36 scom.add(proc0, 0x00040008, 0x0006000000000000);
37
38 // TOD_ERROR[17] = 0b1 internal step check
39 // TOD_ERROR[21] = 0b1 step check on primary config slave select 1
40 scom.add(proc1, 0x00040030, 0x0000440000000000); // TOD_ERROR
41
42 // TOD_PSS_MSS_STATUS[0:2] = 0b000 primary config is active
43 // TOD_PSS_MSS_STATUS[15] = 0b1 primary config slave path select 1
44 scom.add(proc1, 0x00040008, 0x0001000000000000);
45
46 // TOD_PRI_PORT_1_CTRL[0:2] = 0b001 IOHS 1
47 scom.add(proc1, 0x00040002, 0x2000000000000000);
48
49 // TOD_ERROR(0)[14] step check error on master select 0
50 libhei::Signature sig0{chip0, nodeId, 0, 14, libhei::ATTN_TYPE_CHECKSTOP};
51
52 // TOD_ERROR(0)[17] internal step check error
53 libhei::Signature sig1{chip1, nodeId, 0, 17, libhei::ATTN_TYPE_CHECKSTOP};
54
55 // TOD_ERROR(0)[21] step check error on slave select 1
56 libhei::Signature sig2{chip1, nodeId, 0, 21, libhei::ATTN_TYPE_CHECKSTOP};
57
58 libhei::IsolationData isoData{};
59 isoData.addSignature(sig0);
60 isoData.addSignature(sig1);
61 isoData.addSignature(sig2);
62 ServiceData sd{sig1, AnalysisType::SYSTEM_CHECKSTOP, isoData};
63
64 // Call the plugin.
Zane Shelleyd195b712022-01-26 13:26:34 -060065 auto plugin =
66 PluginMap::getSingleton().get(chip1.getType(), "tod_step_check_fault");
67
Zane Shelley27a17a52022-02-21 20:33:49 -060068 plugin(0, chip1, sd);
Zane Shelleyd195b712022-01-26 13:26:34 -060069
70 nlohmann::json j{};
71 std::string s{};
72
73 // Callout list
74 j = sd.getCalloutList();
75 s = R"([
76 {
77 "Deconfigured": false,
Zane Shelley27a17a52022-02-21 20:33:49 -060078 "Guarded": false,
79 "LocationCode": "P0",
80 "Priority": "M"
81 },
82 {
83 "Deconfigured": false,
Zane Shelley026e5a32022-05-05 10:37:59 -050084 "Guarded": false,
Zane Shelley27a17a52022-02-21 20:33:49 -060085 "LocationCode": "/proc0",
Zane Shelleyd195b712022-01-26 13:26:34 -060086 "Priority": "M"
87 }
88])";
89 EXPECT_EQ(s, j.dump(4));
90
91 // Callout FFDC
92 j = sd.getCalloutFFDC();
93 s = R"([
94 {
Zane Shelley27a17a52022-02-21 20:33:49 -060095 "Callout Type": "Clock Callout",
96 "Clock Type": "TOD_CLOCK",
97 "Priority": "medium"
98 },
99 {
Zane Shelleyd195b712022-01-26 13:26:34 -0600100 "Callout Type": "Hardware Callout",
Zane Shelley026e5a32022-05-05 10:37:59 -0500101 "Guard": false,
Zane Shelleyd195b712022-01-26 13:26:34 -0600102 "Priority": "medium",
Zane Shelley27a17a52022-02-21 20:33:49 -0600103 "Target": "/proc0"
Zane Shelleyd195b712022-01-26 13:26:34 -0600104 }
105])";
106 EXPECT_EQ(s, j.dump(4));
107}