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