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