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 |
| 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 Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 65 | auto plugin = |
| 66 | PluginMap::getSingleton().get(chip1.getType(), "tod_step_check_fault"); |
| 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 | 3f363d4 | 2022-02-10 16:20:37 -0600 | [diff] [blame] | 84 | "EntityPath": [], |
| 85 | "GuardType": "GARD_Unrecoverable", |
| 86 | "Guarded": true, |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 87 | "LocationCode": "/proc0", |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 88 | "Priority": "M" |
| 89 | } |
| 90 | ])"; |
| 91 | EXPECT_EQ(s, j.dump(4)); |
| 92 | |
| 93 | // Callout FFDC |
| 94 | j = sd.getCalloutFFDC(); |
| 95 | s = R"([ |
| 96 | { |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 97 | "Callout Type": "Clock Callout", |
| 98 | "Clock Type": "TOD_CLOCK", |
| 99 | "Priority": "medium" |
| 100 | }, |
| 101 | { |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 102 | "Callout Type": "Hardware Callout", |
Zane Shelley | 3f363d4 | 2022-02-10 16:20:37 -0600 | [diff] [blame] | 103 | "Guard": true, |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 104 | "Priority": "medium", |
Zane Shelley | 27a17a5 | 2022-02-21 20:33:49 -0600 | [diff] [blame] | 105 | "Target": "/proc0" |
Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 106 | } |
| 107 | ])"; |
| 108 | EXPECT_EQ(s, j.dump(4)); |
| 109 | } |