Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 3 | #include <analyzer/analyzer_main.hpp> |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 4 | #include <analyzer/resolution.hpp> |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 5 | #include <util/pdbg.hpp> |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 6 | #include <util/trace.hpp> |
| 7 | |
| 8 | #include <regex> |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 9 | |
| 10 | #include "gtest/gtest.h" |
| 11 | |
| 12 | // Chip string |
| 13 | constexpr auto chip_str = "/proc0"; |
| 14 | |
| 15 | // Unit paths |
Patrick Williams | 27dd636 | 2023-05-10 07:51:20 -0500 | [diff] [blame] | 16 | constexpr auto proc_str = ""; |
Caleb Palmer | 626270a | 2022-02-21 11:05:08 -0600 | [diff] [blame] | 17 | constexpr auto iolink_str = "pib/perv26/pauc1/iohs0/smpgroup0"; |
Patrick Williams | 27dd636 | 2023-05-10 07:51:20 -0500 | [diff] [blame] | 18 | constexpr auto omi_str = "pib/perv12/mc0/mi0/mcc0/omi0"; |
| 19 | constexpr auto ocmb_str = "pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"; |
| 20 | constexpr auto core_str = "pib/perv39/eq7/fc1/core1"; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 21 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 22 | using namespace analyzer; |
| 23 | |
| 24 | TEST(Resolution, TestSet1) |
| 25 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 26 | pdbg_targets_init(nullptr); |
| 27 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 28 | // Create a few resolutions |
| 29 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 30 | proc_str, callout::Priority::HIGH, false); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 31 | |
| 32 | auto c2 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 33 | omi_str, callout::Priority::MED_A, true); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 34 | |
| 35 | auto c3 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 36 | core_str, callout::Priority::MED, true); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 37 | |
| 38 | auto c4 = std::make_shared<ProcedureCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 39 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 40 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 41 | auto c5 = std::make_shared<ClockCalloutResolution>( |
| 42 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::LOW, false); |
| 43 | |
| 44 | // l1 = (c1, c2, c5) |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 45 | auto l1 = std::make_shared<ResolutionList>(); |
| 46 | l1->push(c1); |
| 47 | l1->push(c2); |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 48 | l1->push(c5); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 49 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 50 | // l2 = (c4, c3, c1, c2, c5) |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 51 | auto l2 = std::make_shared<ResolutionList>(); |
| 52 | l2->push(c4); |
| 53 | l2->push(c3); |
| 54 | l2->push(l1); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 55 | |
| 56 | // Get some ServiceData objects |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 57 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 58 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 59 | ServiceData sd1{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 60 | libhei::IsolationData{}}; |
| 61 | ServiceData sd2{sig, AnalysisType::TERMINATE_IMMEDIATE, |
| 62 | libhei::IsolationData{}}; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 63 | |
| 64 | // Resolve |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 65 | l1->resolve(sd1); |
| 66 | l2->resolve(sd2); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 67 | |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 68 | // Verify the subsystems |
| 69 | std::pair<callout::SrcSubsystem, callout::Priority> subsys = { |
Caleb Palmer | bc94bde | 2022-02-18 09:03:37 -0600 | [diff] [blame] | 70 | callout::SrcSubsystem::PROCESSOR_FRU, callout::Priority::HIGH}; |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 71 | EXPECT_EQ(sd1.getSubsys(), subsys); |
| 72 | |
Caleb Palmer | bc94bde | 2022-02-18 09:03:37 -0600 | [diff] [blame] | 73 | subsys = {callout::SrcSubsystem::PROCESSOR_FRU, callout::Priority::HIGH}; |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 74 | EXPECT_EQ(sd2.getSubsys(), subsys); |
| 75 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 76 | // Start verifying |
| 77 | nlohmann::json j{}; |
| 78 | std::string s{}; |
| 79 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 80 | j = sd1.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 81 | s = R"([ |
| 82 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 83 | "Deconfigured": false, |
| 84 | "Guarded": false, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 85 | "LocationCode": "/proc0", |
| 86 | "Priority": "H" |
| 87 | }, |
| 88 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 89 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 90 | "EntityPath": [], |
| 91 | "GuardType": "GARD_Unrecoverable", |
| 92 | "Guarded": true, |
| 93 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 94 | "Priority": "A" |
| 95 | }, |
| 96 | { |
| 97 | "Deconfigured": false, |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 98 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 99 | "LocationCode": "P0", |
| 100 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 101 | } |
| 102 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 103 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 104 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 105 | j = sd2.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 106 | s = R"([ |
| 107 | { |
| 108 | "Priority": "L", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 109 | "Procedure": "next_level_support" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 110 | }, |
| 111 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 112 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 113 | "EntityPath": [], |
| 114 | "GuardType": "GARD_Predictive", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 115 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 116 | "LocationCode": "/proc0/pib/perv39/eq7/fc1/core1", |
| 117 | "Priority": "M" |
| 118 | }, |
| 119 | { |
| 120 | "Deconfigured": false, |
| 121 | "Guarded": false, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 122 | "LocationCode": "/proc0", |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 123 | "Priority": "H" |
| 124 | }, |
| 125 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 126 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 127 | "EntityPath": [], |
| 128 | "GuardType": "GARD_Predictive", |
| 129 | "Guarded": true, |
| 130 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 131 | "Priority": "A" |
| 132 | }, |
| 133 | { |
| 134 | "Deconfigured": false, |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 135 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 136 | "LocationCode": "P0", |
| 137 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 138 | } |
| 139 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 140 | EXPECT_EQ(s, j.dump(4)); |
| 141 | } |
| 142 | |
| 143 | TEST(Resolution, HardwareCallout) |
| 144 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 145 | pdbg_targets_init(nullptr); |
| 146 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 147 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 148 | omi_str, callout::Priority::MED_A, true); |
| 149 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 150 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 151 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 152 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 153 | libhei::IsolationData{}}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 154 | |
| 155 | c1->resolve(sd); |
| 156 | |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 157 | // Verify the subsystem |
| 158 | std::pair<callout::SrcSubsystem, callout::Priority> subsys = { |
Caleb Palmer | bc94bde | 2022-02-18 09:03:37 -0600 | [diff] [blame] | 159 | callout::SrcSubsystem::MEMORY_CTLR, callout::Priority::MED_A}; |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 160 | EXPECT_EQ(sd.getSubsys(), subsys); |
| 161 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 162 | nlohmann::json j{}; |
| 163 | std::string s{}; |
| 164 | |
| 165 | // Callout list |
| 166 | j = sd.getCalloutList(); |
| 167 | s = R"([ |
| 168 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 169 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 170 | "EntityPath": [], |
| 171 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 172 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 173 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 174 | "Priority": "A" |
| 175 | } |
| 176 | ])"; |
| 177 | EXPECT_EQ(s, j.dump(4)); |
| 178 | |
| 179 | // Callout FFDC |
| 180 | j = sd.getCalloutFFDC(); |
| 181 | s = R"([ |
| 182 | { |
| 183 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 184 | "Guard": true, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 185 | "Priority": "medium_group_A", |
| 186 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 187 | } |
| 188 | ])"; |
| 189 | EXPECT_EQ(s, j.dump(4)); |
| 190 | } |
| 191 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 192 | TEST(Resolution, ConnectedCallout) |
| 193 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 194 | pdbg_targets_init(nullptr); |
| 195 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 196 | auto c1 = std::make_shared<ConnectedCalloutResolution>( |
| 197 | callout::BusType::SMP_BUS, iolink_str, callout::Priority::MED_A, true); |
| 198 | |
| 199 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 200 | callout::BusType::OMI_BUS, ocmb_str, callout::Priority::MED_B, true); |
| 201 | |
| 202 | auto c3 = std::make_shared<ConnectedCalloutResolution>( |
| 203 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_C, true); |
| 204 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 205 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 206 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 207 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 208 | libhei::IsolationData{}}; |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 209 | |
| 210 | nlohmann::json j{}; |
| 211 | std::string s{}; |
| 212 | |
| 213 | c1->resolve(sd); |
| 214 | c2->resolve(sd); |
| 215 | c3->resolve(sd); |
| 216 | |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 217 | // Verify the subsystem |
| 218 | std::pair<callout::SrcSubsystem, callout::Priority> subsys = { |
Caleb Palmer | bc94bde | 2022-02-18 09:03:37 -0600 | [diff] [blame] | 219 | callout::SrcSubsystem::PROCESSOR_BUS, callout::Priority::MED_A}; |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 220 | EXPECT_EQ(sd.getSubsys(), subsys); |
| 221 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 222 | // Callout list |
| 223 | j = sd.getCalloutList(); |
| 224 | s = R"([ |
| 225 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 226 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 227 | "EntityPath": [], |
| 228 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 229 | "Guarded": true, |
Caleb Palmer | 626270a | 2022-02-21 11:05:08 -0600 | [diff] [blame] | 230 | "LocationCode": "/proc1/pib/perv25/pauc0/iohs1/smpgroup0", |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 231 | "Priority": "A" |
| 232 | }, |
| 233 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 234 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 235 | "EntityPath": [], |
| 236 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 237 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 238 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 239 | "Priority": "B" |
| 240 | }, |
| 241 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 242 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 243 | "EntityPath": [], |
| 244 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 245 | "Guarded": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 246 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 247 | "Priority": "C" |
| 248 | } |
| 249 | ])"; |
| 250 | EXPECT_EQ(s, j.dump(4)); |
| 251 | |
| 252 | // Callout FFDC |
| 253 | j = sd.getCalloutFFDC(); |
| 254 | s = R"([ |
| 255 | { |
| 256 | "Bus Type": "SMP_BUS", |
| 257 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 258 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 259 | "Priority": "medium_group_A", |
Caleb Palmer | 626270a | 2022-02-21 11:05:08 -0600 | [diff] [blame] | 260 | "RX Target": "/proc0/pib/perv26/pauc1/iohs0/smpgroup0", |
| 261 | "TX Target": "/proc1/pib/perv25/pauc0/iohs1/smpgroup0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 262 | }, |
| 263 | { |
| 264 | "Bus Type": "OMI_BUS", |
| 265 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 266 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 267 | "Priority": "medium_group_B", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 268 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 269 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 270 | }, |
| 271 | { |
| 272 | "Bus Type": "OMI_BUS", |
| 273 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 274 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 275 | "Priority": "medium_group_C", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 276 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 277 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 278 | } |
| 279 | ])"; |
| 280 | EXPECT_EQ(s, j.dump(4)); |
| 281 | } |
| 282 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 283 | TEST(Resolution, BusCallout) |
| 284 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 285 | pdbg_targets_init(nullptr); |
| 286 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 287 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 288 | omi_str, callout::Priority::MED_A, true); |
| 289 | |
| 290 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 291 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_A, true); |
| 292 | |
| 293 | auto c3 = std::make_shared<BusCalloutResolution>( |
| 294 | callout::BusType::OMI_BUS, omi_str, callout::Priority::LOW, false); |
| 295 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 296 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 297 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 298 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 299 | libhei::IsolationData{}}; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 300 | |
| 301 | nlohmann::json j{}; |
| 302 | std::string s{}; |
| 303 | |
| 304 | c1->resolve(sd); |
| 305 | c2->resolve(sd); |
| 306 | c3->resolve(sd); |
| 307 | |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 308 | // Verify the subsystem |
| 309 | std::pair<callout::SrcSubsystem, callout::Priority> subsys = { |
Caleb Palmer | bc94bde | 2022-02-18 09:03:37 -0600 | [diff] [blame] | 310 | callout::SrcSubsystem::MEMORY_CTLR, callout::Priority::MED_A}; |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 311 | EXPECT_EQ(sd.getSubsys(), subsys); |
| 312 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 313 | // Callout list |
| 314 | j = sd.getCalloutList(); |
| 315 | s = R"([ |
| 316 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 317 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 318 | "EntityPath": [], |
| 319 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 320 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 321 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 322 | "Priority": "A" |
| 323 | }, |
| 324 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 325 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 326 | "EntityPath": [], |
| 327 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 328 | "Guarded": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 329 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 330 | "Priority": "A" |
| 331 | }, |
| 332 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 333 | "Deconfigured": false, |
| 334 | "Guarded": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 335 | "LocationCode": "P0", |
| 336 | "Priority": "L" |
| 337 | } |
| 338 | ])"; |
| 339 | EXPECT_EQ(s, j.dump(4)); |
| 340 | |
| 341 | // Callout FFDC |
| 342 | j = sd.getCalloutFFDC(); |
| 343 | s = R"([ |
| 344 | { |
| 345 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 346 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 347 | "Priority": "medium_group_A", |
| 348 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 349 | }, |
| 350 | { |
| 351 | "Bus Type": "OMI_BUS", |
| 352 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 353 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 354 | "Priority": "medium_group_A", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 355 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 356 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 357 | }, |
| 358 | { |
| 359 | "Bus Type": "OMI_BUS", |
| 360 | "Callout Type": "Bus Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 361 | "Guard": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 362 | "Priority": "low", |
| 363 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 364 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 365 | } |
| 366 | ])"; |
| 367 | EXPECT_EQ(s, j.dump(4)); |
| 368 | } |
| 369 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 370 | TEST(Resolution, ClockCallout) |
| 371 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 372 | pdbg_targets_init(nullptr); |
| 373 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 374 | auto c1 = std::make_shared<ClockCalloutResolution>( |
| 375 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false); |
| 376 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 377 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 378 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 379 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 380 | libhei::IsolationData{}}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 381 | |
| 382 | c1->resolve(sd); |
| 383 | |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 384 | // Verify the subsystem |
| 385 | std::pair<callout::SrcSubsystem, callout::Priority> subsys = { |
| 386 | callout::SrcSubsystem::CEC_CLOCKS, callout::Priority::HIGH}; |
| 387 | EXPECT_EQ(sd.getSubsys(), subsys); |
| 388 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 389 | nlohmann::json j{}; |
| 390 | std::string s{}; |
| 391 | |
| 392 | // Callout list |
| 393 | j = sd.getCalloutList(); |
| 394 | s = R"([ |
| 395 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 396 | "Deconfigured": false, |
| 397 | "Guarded": false, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 398 | "LocationCode": "P0", |
| 399 | "Priority": "H" |
| 400 | } |
| 401 | ])"; |
| 402 | EXPECT_EQ(s, j.dump(4)); |
| 403 | |
| 404 | // Callout FFDC |
| 405 | j = sd.getCalloutFFDC(); |
| 406 | s = R"([ |
| 407 | { |
| 408 | "Callout Type": "Clock Callout", |
| 409 | "Clock Type": "OSC_REF_CLOCK_1", |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 410 | "Priority": "high" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 411 | } |
| 412 | ])"; |
| 413 | EXPECT_EQ(s, j.dump(4)); |
| 414 | } |
| 415 | |
| 416 | TEST(Resolution, ProcedureCallout) |
| 417 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 418 | pdbg_targets_init(nullptr); |
| 419 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 420 | auto c1 = std::make_shared<ProcedureCalloutResolution>( |
| 421 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
| 422 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 423 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 424 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 425 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 426 | libhei::IsolationData{}}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 427 | |
| 428 | c1->resolve(sd); |
| 429 | |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 430 | // Verify the subsystem |
| 431 | std::pair<callout::SrcSubsystem, callout::Priority> subsys = { |
| 432 | callout::SrcSubsystem::OTHERS, callout::Priority::LOW}; |
| 433 | EXPECT_EQ(sd.getSubsys(), subsys); |
| 434 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 435 | nlohmann::json j{}; |
| 436 | std::string s{}; |
| 437 | |
| 438 | // Callout list |
| 439 | j = sd.getCalloutList(); |
| 440 | s = R"([ |
| 441 | { |
| 442 | "Priority": "L", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 443 | "Procedure": "next_level_support" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 444 | } |
| 445 | ])"; |
| 446 | EXPECT_EQ(s, j.dump(4)); |
| 447 | |
| 448 | // Callout FFDC |
| 449 | j = sd.getCalloutFFDC(); |
| 450 | s = R"([ |
| 451 | { |
| 452 | "Callout Type": "Procedure Callout", |
| 453 | "Priority": "low", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 454 | "Procedure": "next_level_support" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 455 | } |
| 456 | ])"; |
| 457 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 458 | } |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 459 | |
| 460 | TEST(Resolution, PartCallout) |
| 461 | { |
| 462 | pdbg_targets_init(nullptr); |
| 463 | |
| 464 | auto c1 = std::make_shared<PartCalloutResolution>(callout::PartType::PNOR, |
| 465 | callout::Priority::MED); |
| 466 | |
| 467 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | adda054 | 2023-04-06 16:38:02 -0500 | [diff] [blame] | 468 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 469 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 470 | libhei::IsolationData{}}; |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 471 | |
| 472 | c1->resolve(sd); |
| 473 | |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 474 | // Verify the subsystem |
| 475 | std::pair<callout::SrcSubsystem, callout::Priority> subsys = { |
| 476 | callout::SrcSubsystem::CEC_HARDWARE, callout::Priority::MED}; |
| 477 | EXPECT_EQ(sd.getSubsys(), subsys); |
| 478 | |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 479 | nlohmann::json j{}; |
| 480 | std::string s{}; |
| 481 | |
| 482 | // Callout list |
| 483 | j = sd.getCalloutList(); |
| 484 | s = R"([ |
| 485 | { |
| 486 | "Deconfigured": false, |
| 487 | "Guarded": false, |
| 488 | "LocationCode": "/bmc0", |
| 489 | "Priority": "M" |
| 490 | } |
| 491 | ])"; |
| 492 | EXPECT_EQ(s, j.dump(4)); |
| 493 | |
| 494 | // Callout FFDC |
| 495 | j = sd.getCalloutFFDC(); |
| 496 | s = R"([ |
| 497 | { |
| 498 | "Callout Type": "Part Callout", |
| 499 | "Part Type": "PNOR", |
| 500 | "Priority": "medium" |
| 501 | } |
| 502 | ])"; |
| 503 | EXPECT_EQ(s, j.dump(4)); |
| 504 | } |