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