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