Zane Shelley | 2c228cd | 2021-12-16 23:45:12 -0600 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | |
| 3 | #include <analyzer/plugins/plugin.hpp> |
Zane Shelley | 9491cdb | 2022-02-01 10:40:45 -0600 | [diff] [blame] | 4 | #include <analyzer/ras-data/ras-data-parser.hpp> |
Zane Shelley | 2c228cd | 2021-12-16 23:45:12 -0600 | [diff] [blame] | 5 | #include <hei_util.hpp> |
| 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>("PLL_UNLOCK")); |
| 15 | |
| 16 | // Sub-test #1 - single PLL unlock attention on proc 1, clock 1 |
| 17 | TEST(PllUnlock, TestSet1) |
| 18 | { |
| 19 | pdbg_targets_init(nullptr); |
| 20 | |
| 21 | libhei::Chip chip1{util::pdbg::getTrgt("/proc1"), P10_20}; |
| 22 | |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 23 | libhei::Signature sig11{chip1, nodeId, 0, 1, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 2c228cd | 2021-12-16 23:45:12 -0600 | [diff] [blame] | 24 | |
Zane Shelley | 2c228cd | 2021-12-16 23:45:12 -0600 | [diff] [blame] | 25 | libhei::IsolationData isoData{}; |
| 26 | isoData.addSignature(sig11); |
| 27 | ServiceData sd{sig11, AnalysisType::SYSTEM_CHECKSTOP, isoData}; |
| 28 | |
Zane Shelley | 9491cdb | 2022-02-01 10:40:45 -0600 | [diff] [blame] | 29 | RasDataParser rasData{}; |
| 30 | rasData.getResolution(sig11)->resolve(sd); |
Zane Shelley | 2c228cd | 2021-12-16 23:45:12 -0600 | [diff] [blame] | 31 | |
| 32 | nlohmann::json j{}; |
| 33 | std::string s{}; |
| 34 | |
| 35 | // Callout list |
| 36 | j = sd.getCalloutList(); |
| 37 | s = R"([ |
| 38 | { |
| 39 | "Deconfigured": false, |
| 40 | "Guarded": false, |
| 41 | "LocationCode": "P0", |
| 42 | "Priority": "M" |
| 43 | }, |
| 44 | { |
| 45 | "Deconfigured": false, |
| 46 | "Guarded": false, |
| 47 | "LocationCode": "/proc1", |
| 48 | "Priority": "M" |
| 49 | } |
| 50 | ])"; |
| 51 | EXPECT_EQ(s, j.dump(4)); |
| 52 | |
| 53 | // Callout FFDC |
| 54 | j = sd.getCalloutFFDC(); |
| 55 | s = R"([ |
| 56 | { |
| 57 | "Callout Type": "Clock Callout", |
| 58 | "Clock Type": "OSC_REF_CLOCK_1", |
| 59 | "Priority": "medium" |
| 60 | }, |
| 61 | { |
| 62 | "Callout Type": "Hardware Callout", |
| 63 | "Guard": false, |
| 64 | "Priority": "medium", |
| 65 | "Target": "/proc1" |
| 66 | } |
| 67 | ])"; |
| 68 | EXPECT_EQ(s, j.dump(4)); |
| 69 | } |
| 70 | |
| 71 | // Sub-test #2 - PLL unlock attention on multiple procs and clocks. Isolating |
| 72 | // only to proc 1 clock 0 PLL unlock attentions. |
| 73 | TEST(PllUnlock, TestSet2) |
| 74 | { |
| 75 | pdbg_targets_init(nullptr); |
| 76 | |
| 77 | libhei::Chip chip0{util::pdbg::getTrgt("/proc0"), P10_20}; |
| 78 | libhei::Chip chip1{util::pdbg::getTrgt("/proc1"), P10_20}; |
| 79 | |
| 80 | // PLL unlock signatures for each clock per processor. |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 81 | libhei::Signature sig00{chip0, nodeId, 0, 0, libhei::ATTN_TYPE_CHIP_CS}; |
| 82 | libhei::Signature sig01{chip0, nodeId, 0, 1, libhei::ATTN_TYPE_CHIP_CS}; |
| 83 | libhei::Signature sig10{chip1, nodeId, 0, 0, libhei::ATTN_TYPE_CHIP_CS}; |
| 84 | libhei::Signature sig11{chip1, nodeId, 0, 1, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 2c228cd | 2021-12-16 23:45:12 -0600 | [diff] [blame] | 85 | |
| 86 | // Plugins for each processor. |
| 87 | auto plugin = PluginMap::getSingleton().get(chip1.getType(), "pll_unlock"); |
| 88 | |
| 89 | libhei::IsolationData isoData{}; |
| 90 | isoData.addSignature(sig00); |
| 91 | isoData.addSignature(sig01); |
| 92 | isoData.addSignature(sig10); |
| 93 | isoData.addSignature(sig11); |
| 94 | ServiceData sd{sig10, AnalysisType::SYSTEM_CHECKSTOP, isoData}; |
| 95 | |
| 96 | // Call the PLL unlock plugin. |
| 97 | plugin(0, chip1, sd); |
| 98 | |
| 99 | nlohmann::json j{}; |
| 100 | std::string s{}; |
| 101 | |
| 102 | // Callout list |
| 103 | j = sd.getCalloutList(); |
| 104 | s = R"([ |
| 105 | { |
| 106 | "Deconfigured": false, |
| 107 | "Guarded": false, |
| 108 | "LocationCode": "P0", |
| 109 | "Priority": "H" |
| 110 | }, |
| 111 | { |
| 112 | "Deconfigured": false, |
| 113 | "Guarded": false, |
| 114 | "LocationCode": "/proc0", |
| 115 | "Priority": "M" |
| 116 | }, |
| 117 | { |
| 118 | "Deconfigured": false, |
| 119 | "Guarded": false, |
| 120 | "LocationCode": "/proc1", |
| 121 | "Priority": "M" |
| 122 | } |
| 123 | ])"; |
| 124 | EXPECT_EQ(s, j.dump(4)); |
| 125 | |
| 126 | // Callout FFDC |
| 127 | j = sd.getCalloutFFDC(); |
| 128 | s = R"([ |
| 129 | { |
| 130 | "Callout Type": "Clock Callout", |
| 131 | "Clock Type": "OSC_REF_CLOCK_0", |
| 132 | "Priority": "high" |
| 133 | }, |
| 134 | { |
| 135 | "Callout Type": "Hardware Callout", |
| 136 | "Guard": false, |
| 137 | "Priority": "medium", |
| 138 | "Target": "/proc0" |
| 139 | }, |
| 140 | { |
| 141 | "Callout Type": "Hardware Callout", |
| 142 | "Guard": false, |
| 143 | "Priority": "medium", |
| 144 | "Target": "/proc1" |
| 145 | } |
| 146 | ])"; |
| 147 | EXPECT_EQ(s, j.dump(4)); |
| 148 | } |