Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | |
| 3 | #include <analyzer/plugins/plugin.hpp> |
| 4 | #include <hei_util.hpp> |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 5 | #include <test/sim-hw-access.hpp> |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 6 | #include <util/pdbg.hpp> |
| 7 | #include <util/trace.hpp> |
| 8 | |
| 9 | #include "gtest/gtest.h" |
| 10 | |
| 11 | using namespace analyzer; |
| 12 | |
| 13 | static const auto nodeId = |
| 14 | static_cast<libhei::NodeId_t>(libhei::hash<libhei::NodeId_t>("TOD_ERROR")); |
| 15 | |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 16 | TEST(TodStepCheckFault, MdmtFault) |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 17 | { |
| 18 | pdbg_targets_init(nullptr); |
| 19 | |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 20 | auto proc0 = util::pdbg::getTrgt("/proc0"); |
| 21 | auto proc1 = util::pdbg::getTrgt("/proc1"); |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 22 | |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 23 | libhei::Chip chip0{proc0, P10_20}; |
| 24 | libhei::Chip chip1{proc1, P10_20}; |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 25 | |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 26 | 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 |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 50 | libhei::Signature sig0{chip0, nodeId, 0, 14, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 51 | |
| 52 | // TOD_ERROR(0)[17] internal step check error |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 53 | libhei::Signature sig1{chip1, nodeId, 0, 17, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 54 | |
| 55 | // TOD_ERROR(0)[21] step check error on slave select 1 |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 56 | libhei::Signature sig2{chip1, nodeId, 0, 21, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 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. |
Patrick Williams | 27dd636 | 2023-05-10 07:51:20 -0500 | [diff] [blame] | 65 | auto plugin = PluginMap::getSingleton().get(chip1.getType(), |
| 66 | "tod_step_check_fault"); |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 67 | |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 68 | plugin(0, chip1, sd); |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 69 | |
| 70 | nlohmann::json j{}; |
| 71 | std::string s{}; |
| 72 | |
| 73 | // Callout list |
| 74 | j = sd.getCalloutList(); |
| 75 | s = R"([ |
| 76 | { |
| 77 | "Deconfigured": false, |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 78 | "Guarded": false, |
| 79 | "LocationCode": "P0", |
| 80 | "Priority": "M" |
| 81 | }, |
| 82 | { |
| 83 | "Deconfigured": false, |
Zane Shelley | 026e5a3 | 2022-05-05 10:37:59 -0500 | [diff] [blame] | 84 | "Guarded": false, |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 85 | "LocationCode": "/proc0", |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 86 | "Priority": "M" |
| 87 | } |
| 88 | ])"; |
| 89 | EXPECT_EQ(s, j.dump(4)); |
| 90 | |
| 91 | // Callout FFDC |
| 92 | j = sd.getCalloutFFDC(); |
| 93 | s = R"([ |
| 94 | { |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 95 | "Callout Type": "Clock Callout", |
| 96 | "Clock Type": "TOD_CLOCK", |
| 97 | "Priority": "medium" |
| 98 | }, |
| 99 | { |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 100 | "Callout Type": "Hardware Callout", |
Zane Shelley | 026e5a3 | 2022-05-05 10:37:59 -0500 | [diff] [blame] | 101 | "Guard": false, |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 102 | "Priority": "medium", |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 103 | "Target": "/proc0" |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 104 | } |
| 105 | ])"; |
| 106 | EXPECT_EQ(s, j.dump(4)); |
| 107 | } |