Jayanth Othayoth | b1eda6a | 2021-06-28 00:26:30 -0500 | [diff] [blame] | 1 | extern "C" |
| 2 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 3 | #include <libpdbg.h> |
Jayanth Othayoth | b1eda6a | 2021-06-28 00:26:30 -0500 | [diff] [blame] | 4 | #include <libpdbg_sbe.h> |
| 5 | } |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 6 | |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 7 | #include <analyzer/analyzer_main.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 8 | #include <attn/attention.hpp> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 9 | #include <attn/attn_common.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 10 | #include <attn/attn_config.hpp> |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 11 | #include <attn/attn_dbus.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 12 | #include <attn/attn_handler.hpp> |
| 13 | #include <attn/attn_logging.hpp> |
| 14 | #include <attn/bp_handler.hpp> |
| 15 | #include <attn/ti_handler.hpp> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 16 | #include <attn/vital_handler.hpp> |
Ben Tyner | fe2c50d | 2021-07-23 13:38:53 -0500 | [diff] [blame] | 17 | #include <util/dbus.hpp> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 18 | |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 19 | #include <algorithm> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 20 | #include <iomanip> |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 21 | #include <map> |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 22 | #include <sstream> |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 23 | #include <vector> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 24 | |
| 25 | namespace attn |
| 26 | { |
| 27 | |
| 28 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 29 | * @brief Handle checkstop attention |
| 30 | * |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 31 | * @param i_attention Attention object |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 32 | * @return 0 indicates that the checkstop attention was successfully handled |
| 33 | * 1 indicates that the checkstop attention was NOT successfully |
| 34 | * handled. |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 35 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 36 | int handleCheckstop(Attention* i_attention); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * @brief Handle special attention |
| 40 | * |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 41 | * @param i_attention Attention object |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 42 | * @return 0 indicates that the special attention was successfully handled |
| 43 | * 1 indicates that the special attention was NOT successfully handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 44 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 45 | int handleSpecial(Attention* i_attention); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 46 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 47 | /** @brief Determine if attention is active and not masked */ |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 48 | bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn); |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 49 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 50 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 51 | * @brief The main attention handler logic |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 52 | * |
| 53 | * @param i_breakpoints true = breakpoint special attn handling enabled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 54 | */ |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 55 | void attnHandler(Config* i_config) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 56 | { |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 57 | // Vector of active attentions to be handled |
| 58 | std::vector<Attention> active_attentions; |
| 59 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 60 | uint32_t isr_val, isr_mask; |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 61 | |
| 62 | // loop through processors looking for active attentions |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 63 | trace<level::INFO>("Attention handler started"); |
Ben Tyner | 117af99 | 2020-05-22 13:32:11 -0500 | [diff] [blame] | 64 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 65 | pdbg_target* target; |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 66 | pdbg_for_each_class_target("proc", target) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 67 | { |
| 68 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(target)) |
| 69 | { |
Zane Shelley | a79f6c8 | 2021-01-12 16:38:49 -0600 | [diff] [blame] | 70 | auto proc = pdbg_target_index(target); // get processor number |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 71 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 72 | // Use PIB target to determine if a processor is enabled |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 73 | char path[16]; |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 74 | sprintf(path, "/proc%d/pib", proc); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 75 | pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 76 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 77 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 78 | if (nullptr == pibTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 79 | { |
| 80 | trace<level::INFO>("pib path or target not found"); |
| 81 | continue; |
| 82 | } |
| 83 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 84 | // check if pib target is enabled |
| 85 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 86 | { |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 87 | // The processor FSI target is required for CFAM read |
| 88 | sprintf(path, "/proc%d/fsi", proc); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 89 | pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 90 | |
| 91 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 92 | if (nullptr == fsiTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 93 | { |
| 94 | trace<level::INFO>("fsi path or target not found"); |
| 95 | continue; |
| 96 | } |
| 97 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 98 | // trace the proc number |
| 99 | std::string traceMsg = "proc: " + std::to_string(proc); |
| 100 | trace<level::INFO>(traceMsg.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 101 | |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 102 | isr_val = 0xffffffff; // invalid isr value |
| 103 | |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 104 | // get active attentions on processor |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 105 | if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 106 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 107 | // log cfam read error |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 108 | trace<level::INFO>("Error! cfam read 0x1007 FAILED"); |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 109 | eventAttentionFail((int)AttnSection::attnHandler | |
| 110 | ATTN_PDBG_CFAM); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 111 | } |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 112 | else if (0xffffffff == isr_val) |
| 113 | { |
| 114 | trace<level::INFO>("Error! cfam read 0x1007 INVALID"); |
| 115 | continue; |
| 116 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 117 | else |
| 118 | { |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 119 | // trace isr value |
| 120 | std::stringstream ssIsr; |
| 121 | ssIsr << "cfam 0x1007 = 0x" << std::setw(8) |
| 122 | << std::setfill('0') << std::hex << isr_val; |
| 123 | std::string strobjIsr = ssIsr.str(); |
| 124 | trace<level::INFO>(strobjIsr.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 125 | |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 126 | isr_mask = 0xffffffff; // invalid isr mask |
| 127 | |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 128 | // get interrupt enabled special attentions mask |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 129 | if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 130 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 131 | // log cfam read error |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 132 | trace<level::INFO>("Error! cfam read 0x100d FAILED"); |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 133 | eventAttentionFail((int)AttnSection::attnHandler | |
| 134 | ATTN_PDBG_CFAM); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 135 | } |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 136 | else if (0xffffffff == isr_mask) |
| 137 | { |
| 138 | trace<level::INFO>("Error! cfam read 0x100d INVALID"); |
| 139 | continue; |
| 140 | } |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 141 | else |
| 142 | { |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 143 | // trace true mask |
| 144 | std::stringstream ssMask; |
| 145 | ssMask << "cfam 0x100d = 0x" << std::setw(8) |
| 146 | << std::setfill('0') << std::hex << isr_mask; |
| 147 | std::string strobjMask = ssMask.str(); |
| 148 | trace<level::INFO>(strobjMask.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 149 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 150 | // SBE vital attention active and not masked? |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 151 | if (true == activeAttn(isr_val, isr_mask, SBE_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 152 | { |
| 153 | active_attentions.emplace_back(Attention::Vital, |
| 154 | handleVital, target, |
| 155 | i_config); |
| 156 | } |
| 157 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 158 | // Checkstop attention active and not masked? |
| 159 | if (true == |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 160 | activeAttn(isr_val, isr_mask, CHECKSTOP_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 161 | { |
| 162 | active_attentions.emplace_back(Attention::Checkstop, |
| 163 | handleCheckstop, |
| 164 | target, i_config); |
| 165 | } |
| 166 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 167 | // Special attention active and not masked? |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 168 | if (true == activeAttn(isr_val, isr_mask, SPECIAL_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 169 | { |
| 170 | active_attentions.emplace_back(Attention::Special, |
| 171 | handleSpecial, |
| 172 | target, i_config); |
| 173 | } |
| 174 | } // cfam 0x100d valid |
| 175 | } // cfam 0x1007 valid |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 176 | } // fsi target enabled |
| 177 | } // pib target enabled |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 178 | } // next processor |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 179 | |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 180 | // convert to heap, highest priority is at front |
| 181 | if (!std::is_heap(active_attentions.begin(), active_attentions.end())) |
| 182 | { |
| 183 | std::make_heap(active_attentions.begin(), active_attentions.end()); |
| 184 | } |
| 185 | |
| 186 | // call the attention handler until one is handled or all were attempted |
| 187 | while (false == active_attentions.empty()) |
| 188 | { |
| 189 | // handle highest priority attention, done if successful |
| 190 | if (RC_SUCCESS == active_attentions.front().handle()) |
| 191 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 192 | // an attention was handled so we are done |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 193 | break; |
| 194 | } |
| 195 | |
| 196 | // move attention to back of vector |
| 197 | std::pop_heap(active_attentions.begin(), active_attentions.end()); |
| 198 | |
| 199 | // remove attention from vector |
| 200 | active_attentions.pop_back(); |
| 201 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 205 | * @brief Handle checkstop attention |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 206 | * |
| 207 | * @param i_attention Attention object |
| 208 | * @return 0 indicates that the checkstop attention was successfully handled |
| 209 | * 1 indicates that the checkstop attention was NOT successfully |
| 210 | * handled. |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 211 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 212 | int handleCheckstop(Attention* i_attention) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 213 | { |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 214 | int rc = RC_SUCCESS; // assume checkstop handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 215 | |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 216 | trace<level::INFO>("checkstop handler started"); |
| 217 | |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 218 | // capture some additional data for logs/traces |
| 219 | addHbStatusRegs(); |
| 220 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 221 | // if checkstop handling enabled, handle checkstop attention |
| 222 | if (false == (i_attention->getConfig()->getFlag(enCheckstop))) |
| 223 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 224 | trace<level::INFO>("Checkstop handling disabled"); |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 225 | } |
| 226 | else |
| 227 | { |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 228 | // Look for any attentions found in hardware. This will generate and |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 229 | // commit a PEL if any errors are found. |
Ben Tyner | 7029e52 | 2021-08-09 19:18:24 -0500 | [diff] [blame] | 230 | DumpParameters dumpParameters; |
| 231 | if (true != analyzer::analyzeHardware(dumpParameters)) |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 232 | { |
| 233 | rc = RC_ANALYZER_ERROR; |
| 234 | } |
Ben Tyner | 7029e52 | 2021-08-09 19:18:24 -0500 | [diff] [blame] | 235 | else |
| 236 | { |
| 237 | requestDump(dumpParameters); |
| 238 | util::dbus::transitionHost(util::dbus::HostState::Quiesce); |
| 239 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 240 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 241 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 242 | return rc; |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * @brief Handle special attention |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 247 | * |
| 248 | * @param i_attention Attention object |
| 249 | * @return 0 indicates that the special attention was successfully handled |
| 250 | * 1 indicates that the special attention was NOT successfully handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 251 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 252 | int handleSpecial(Attention* i_attention) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 253 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 254 | int rc = RC_SUCCESS; // assume special attention handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 255 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 256 | // The TI info chipop will give us a pointer to the TI info data |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 257 | uint8_t* tiInfo = nullptr; // ptr to TI info data |
| 258 | uint32_t tiInfoLen = 0; // length of TI info data |
| 259 | pdbg_target* attnProc = i_attention->getTarget(); // proc with attention |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 260 | |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 261 | bool tiInfoStatic = false; // assume TI info was provided (not created) |
| 262 | |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 263 | if (attnProc != nullptr) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 264 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 265 | // The processor PIB target is required for get TI info chipop |
| 266 | char path[16]; |
| 267 | sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc)); |
| 268 | pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path); |
| 269 | |
| 270 | if (nullptr != tiInfoTarget) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 271 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 272 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget)) |
| 273 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 274 | sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen); |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 275 | |
| 276 | // If TI info not available use default based on host state |
| 277 | if (nullptr == tiInfo) |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 278 | { |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 279 | trace<level::INFO>("TI info data ptr is invalid"); |
| 280 | |
Ben Tyner | fe2c50d | 2021-07-23 13:38:53 -0500 | [diff] [blame] | 281 | util::dbus::HostRunningState runningState = |
| 282 | util::dbus::hostRunningState(); |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 283 | |
Ben Tyner | fe2c50d | 2021-07-23 13:38:53 -0500 | [diff] [blame] | 284 | std::string stateString = "host state unknown"; |
| 285 | |
| 286 | if ((util::dbus::HostRunningState::Started == |
| 287 | runningState) || |
| 288 | (util::dbus::HostRunningState::Unknown == runningState)) |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 289 | { |
Ben Tyner | fe2c50d | 2021-07-23 13:38:53 -0500 | [diff] [blame] | 290 | if (util::dbus::HostRunningState::Started == |
| 291 | runningState) |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 292 | { |
| 293 | stateString = "host started"; |
| 294 | } |
| 295 | tiInfo = (uint8_t*)defaultPhypTiInfo; |
| 296 | } |
| 297 | else |
| 298 | { |
| 299 | stateString = "host not started"; |
| 300 | tiInfo = (uint8_t*)defaultHbTiInfo; |
| 301 | } |
| 302 | |
| 303 | // trace host state |
| 304 | trace<level::INFO>(stateString.c_str()); |
| 305 | |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 306 | tiInfoStatic = true; // using our TI info |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 307 | } |
| 308 | } |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 309 | } |
| 310 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 311 | |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 312 | bool tiInfoValid = false; // TI area data not valid or not available |
| 313 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 314 | // If TI area exists and is marked valid we can assume TI occurred |
| 315 | if ((nullptr != tiInfo) && (0 != tiInfo[0])) |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 316 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 317 | TiDataArea* tiDataArea = (TiDataArea*)tiInfo; |
Ben Tyner | 7e6611f | 2020-02-13 16:42:56 -0600 | [diff] [blame] | 318 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 319 | std::stringstream ss; // string stream object for tracing |
| 320 | std::string strobj; // string object for tracing |
Ben Tyner | 4071772 | 2020-09-23 09:43:20 -0500 | [diff] [blame] | 321 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 322 | // trace a few known TI data area values |
| 323 | ss.str(std::string()); // empty the stream |
| 324 | ss.clear(); // clear the stream |
| 325 | ss << "TI data command = 0x" << std::setw(2) << std::setfill('0') |
| 326 | << std::hex << (int)tiDataArea->command; |
| 327 | strobj = ss.str(); |
| 328 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 4071772 | 2020-09-23 09:43:20 -0500 | [diff] [blame] | 329 | |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 330 | // Another check for valid TI Info since it has been seen that |
| 331 | // tiInfo[0] != 0 but TI info is not valid |
| 332 | if (0xa1 == tiDataArea->command) |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 333 | { |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 334 | tiInfoValid = true; |
| 335 | |
| 336 | // trace some more data since TI info appears valid |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 337 | ss.str(std::string()); // empty the stream |
| 338 | ss.clear(); // clear the stream |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 339 | ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0') |
| 340 | << std::hex << (int)tiDataArea->hbTerminateType; |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 341 | strobj = ss.str(); |
| 342 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 343 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 344 | ss.str(std::string()); // empty the stream |
| 345 | ss.clear(); // clear the stream |
| 346 | ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0') |
| 347 | << std::hex << (int)tiDataArea->srcFormat; |
| 348 | strobj = ss.str(); |
| 349 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 350 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 351 | ss.str(std::string()); // empty the stream |
| 352 | ss.clear(); // clear the stream |
| 353 | ss << "TI data source = 0x" << std::setw(2) << std::setfill('0') |
| 354 | << std::hex << (int)tiDataArea->source; |
| 355 | strobj = ss.str(); |
| 356 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 357 | |
| 358 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 359 | { |
| 360 | // Call TI special attention handler |
| 361 | rc = tiHandler(tiDataArea); |
| 362 | } |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 363 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 364 | } |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 365 | |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 366 | // TI area is available but was not valid data |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 367 | if (false == tiInfoValid) |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 368 | { |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 369 | trace<level::INFO>("TI info NOT valid"); |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 370 | |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 371 | // if configured to handle TI as default special attention |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 372 | if (i_attention->getConfig()->getFlag(dfltTi)) |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 373 | { |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 374 | // TI handling may be disabled |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 375 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 376 | { |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 377 | // Call TI special attention handler |
| 378 | rc = tiHandler(nullptr); |
| 379 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 380 | } |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 381 | // breakpoint is default special attention when TI info NOT valid |
| 382 | else |
| 383 | { |
| 384 | // breakpoint handling may be disabled |
| 385 | if (true == (i_attention->getConfig()->getFlag(enBreakpoints))) |
| 386 | { |
| 387 | // Call the breakpoint special attention handler |
| 388 | rc = bpHandler(); |
| 389 | } |
| 390 | } |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 391 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 392 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 393 | // release TI data buffer |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 394 | if ((nullptr != tiInfo) && (false == tiInfoStatic)) |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 395 | { |
| 396 | free(tiInfo); |
| 397 | } |
| 398 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 399 | if (RC_SUCCESS != rc) |
| 400 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 401 | trace<level::INFO>("Special attn not handled"); |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 402 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 403 | |
| 404 | return rc; |
| 405 | } |
| 406 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 407 | /** |
| 408 | * @brief Determine if attention is active and not masked |
| 409 | * |
| 410 | * Determine whether an attention needs to be handled and trace details of |
| 411 | * attention type and whether it is masked or not. |
| 412 | * |
| 413 | * @param i_val attention status register |
| 414 | * @param i_mask attention true mask register |
| 415 | * @param i_attn attention type |
| 416 | * @param i_proc processor associated with registers |
| 417 | * |
| 418 | * @return true if attention is active and not masked, otherwise false |
| 419 | */ |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 420 | bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn) |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 421 | { |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 422 | bool rc = false; // assume attn masked and/or inactive |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 423 | |
| 424 | // if attention active |
| 425 | if (0 != (i_val & i_attn)) |
| 426 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 427 | std::stringstream ss; |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 428 | |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 429 | bool validAttn = true; // known attention type |
| 430 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 431 | switch (i_attn) |
| 432 | { |
| 433 | case SBE_ATTN: |
| 434 | ss << "SBE attn"; |
| 435 | break; |
| 436 | case CHECKSTOP_ATTN: |
| 437 | ss << "Checkstop attn"; |
| 438 | break; |
| 439 | case SPECIAL_ATTN: |
| 440 | ss << "Special attn"; |
| 441 | break; |
| 442 | default: |
| 443 | ss << "Unknown attn"; |
| 444 | validAttn = false; |
| 445 | } |
| 446 | |
| 447 | // see if attention is masked |
| 448 | if (true == validAttn) |
| 449 | { |
| 450 | if (0 != (i_mask & i_attn)) |
| 451 | { |
| 452 | rc = true; // attention active and not masked |
| 453 | } |
| 454 | else |
| 455 | { |
| 456 | ss << " masked"; |
| 457 | } |
| 458 | } |
| 459 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 460 | std::string strobj = ss.str(); // ss.str() is temporary |
| 461 | trace<level::INFO>(strobj.c_str()); // commit trace stream |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | return rc; |
| 465 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 466 | } // namespace attn |