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> |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 7 | #include <attn/attn_dbus.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 8 | #include <attn/attn_handler.hpp> |
| 9 | #include <attn/attn_logging.hpp> |
| 10 | #include <attn/bp_handler.hpp> |
| 11 | #include <attn/ti_handler.hpp> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 12 | #include <attn/vital_handler.hpp> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 13 | |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 14 | #include <algorithm> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 15 | #include <iomanip> |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 16 | #include <map> |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 17 | #include <sstream> |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 18 | #include <vector> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 19 | |
| 20 | namespace attn |
| 21 | { |
| 22 | |
| 23 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 24 | * @brief Handle checkstop attention |
| 25 | * |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 26 | * @param i_attention Attention object |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 27 | * @return 0 indicates that the checkstop attention was successfully handled |
| 28 | * 1 indicates that the checkstop attention was NOT successfully |
| 29 | * handled. |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 30 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 31 | int handleCheckstop(Attention* i_attention); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * @brief Handle special attention |
| 35 | * |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 36 | * @param i_attention Attention object |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 37 | * @return 0 indicates that the special attention was successfully handled |
| 38 | * 1 indicates that the special attention was NOT successfully handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 39 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 40 | int handleSpecial(Attention* i_attention); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 41 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 42 | /** @brief Determine if attention is active and not masked */ |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 43 | 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] | 44 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 45 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 46 | * @brief The main attention handler logic |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 47 | * |
| 48 | * @param i_breakpoints true = breakpoint special attn handling enabled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 49 | */ |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 50 | void attnHandler(Config* i_config) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 51 | { |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 52 | // Vector of active attentions to be handled |
| 53 | std::vector<Attention> active_attentions; |
| 54 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 55 | uint32_t isr_val, isr_mask; |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 56 | |
| 57 | // loop through processors looking for active attentions |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 58 | trace<level::INFO>("Attention handler started"); |
Ben Tyner | 117af99 | 2020-05-22 13:32:11 -0500 | [diff] [blame] | 59 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 60 | pdbg_target* target; |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 61 | pdbg_for_each_class_target("proc", target) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 62 | { |
| 63 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(target)) |
| 64 | { |
Zane Shelley | a79f6c8 | 2021-01-12 16:38:49 -0600 | [diff] [blame] | 65 | auto proc = pdbg_target_index(target); // get processor number |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 66 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 67 | // Use PIB target to determine if a processor is enabled |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 68 | char path[16]; |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 69 | sprintf(path, "/proc%d/pib", proc); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 70 | pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 71 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 72 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 73 | if (nullptr == pibTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 74 | { |
| 75 | trace<level::INFO>("pib path or target not found"); |
| 76 | continue; |
| 77 | } |
| 78 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 79 | // check if pib target is enabled |
| 80 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget)) |
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); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 84 | pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 85 | |
| 86 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 87 | if (nullptr == fsiTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 88 | { |
| 89 | trace<level::INFO>("fsi path or target not found"); |
| 90 | continue; |
| 91 | } |
| 92 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 93 | // trace the proc number |
| 94 | std::string traceMsg = "proc: " + std::to_string(proc); |
| 95 | trace<level::INFO>(traceMsg.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 96 | |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 97 | isr_val = 0xffffffff; // invalid isr value |
| 98 | |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 99 | // get active attentions on processor |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 100 | if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 101 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 102 | // log cfam read error |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 103 | trace<level::INFO>("Error! cfam read 0x1007 FAILED"); |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 104 | eventAttentionFail((int)AttnSection::attnHandler | |
| 105 | ATTN_PDBG_CFAM); |
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 | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 114 | // trace isr value |
| 115 | std::stringstream ssIsr; |
| 116 | ssIsr << "cfam 0x1007 = 0x" << std::setw(8) |
| 117 | << std::setfill('0') << std::hex << isr_val; |
| 118 | std::string strobjIsr = ssIsr.str(); |
| 119 | trace<level::INFO>(strobjIsr.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 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 |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 124 | if (RC_SUCCESS != fsi_read(fsiTarget, 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 | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 128 | eventAttentionFail((int)AttnSection::attnHandler | |
| 129 | ATTN_PDBG_CFAM); |
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 | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 138 | // trace true mask |
| 139 | std::stringstream ssMask; |
| 140 | ssMask << "cfam 0x100d = 0x" << std::setw(8) |
| 141 | << std::setfill('0') << std::hex << isr_mask; |
| 142 | std::string strobjMask = ssMask.str(); |
| 143 | trace<level::INFO>(strobjMask.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 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 |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 171 | } // fsi target enabled |
| 172 | } // pib target enabled |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 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 | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 247 | bool tiInfoStatic = false; // assume TI info was provided (not created) |
| 248 | |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 249 | if (attnProc != nullptr) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 250 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 251 | // The processor PIB target is required for get TI info chipop |
| 252 | char path[16]; |
| 253 | sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc)); |
| 254 | pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path); |
| 255 | |
| 256 | if (nullptr != tiInfoTarget) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 257 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 258 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget)) |
| 259 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 260 | sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen); |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 261 | |
| 262 | // If TI info not available use default based on host state |
| 263 | if (nullptr == tiInfo) |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 264 | { |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 265 | trace<level::INFO>("TI info data ptr is invalid"); |
| 266 | |
| 267 | HostRunningState runningState = hostRunningState(); |
| 268 | std::string stateString = "host state unknown"; |
| 269 | |
| 270 | if ((HostRunningState::Started == runningState) || |
| 271 | (HostRunningState::Unknown == runningState)) |
| 272 | { |
| 273 | if (HostRunningState::Started == runningState) |
| 274 | { |
| 275 | stateString = "host started"; |
| 276 | } |
| 277 | tiInfo = (uint8_t*)defaultPhypTiInfo; |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | stateString = "host not started"; |
| 282 | tiInfo = (uint8_t*)defaultHbTiInfo; |
| 283 | } |
| 284 | |
| 285 | // trace host state |
| 286 | trace<level::INFO>(stateString.c_str()); |
| 287 | |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 288 | tiInfoStatic = true; // using our TI info |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 289 | } |
| 290 | } |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 291 | } |
| 292 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 293 | |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 294 | bool tiInfoValid = false; // TI area data not valid or not available |
| 295 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 296 | // If TI area exists and is marked valid we can assume TI occurred |
| 297 | if ((nullptr != tiInfo) && (0 != tiInfo[0])) |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 298 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 299 | TiDataArea* tiDataArea = (TiDataArea*)tiInfo; |
Ben Tyner | 7e6611f | 2020-02-13 16:42:56 -0600 | [diff] [blame] | 300 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 301 | std::stringstream ss; // string stream object for tracing |
| 302 | std::string strobj; // string object for tracing |
Ben Tyner | 4071772 | 2020-09-23 09:43:20 -0500 | [diff] [blame] | 303 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 304 | // trace a few known TI data area values |
| 305 | ss.str(std::string()); // empty the stream |
| 306 | ss.clear(); // clear the stream |
| 307 | ss << "TI data command = 0x" << std::setw(2) << std::setfill('0') |
| 308 | << std::hex << (int)tiDataArea->command; |
| 309 | strobj = ss.str(); |
| 310 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 4071772 | 2020-09-23 09:43:20 -0500 | [diff] [blame] | 311 | |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 312 | // Another check for valid TI Info since it has been seen that |
| 313 | // tiInfo[0] != 0 but TI info is not valid |
| 314 | if (0xa1 == tiDataArea->command) |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 315 | { |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 316 | tiInfoValid = true; |
| 317 | |
| 318 | // trace some more data since TI info appears valid |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 319 | ss.str(std::string()); // empty the stream |
| 320 | ss.clear(); // clear the stream |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 321 | ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0') |
| 322 | << std::hex << (int)tiDataArea->hbTerminateType; |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 323 | strobj = ss.str(); |
| 324 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 325 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 326 | ss.str(std::string()); // empty the stream |
| 327 | ss.clear(); // clear the stream |
| 328 | ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0') |
| 329 | << std::hex << (int)tiDataArea->srcFormat; |
| 330 | strobj = ss.str(); |
| 331 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 332 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 333 | ss.str(std::string()); // empty the stream |
| 334 | ss.clear(); // clear the stream |
| 335 | ss << "TI data source = 0x" << std::setw(2) << std::setfill('0') |
| 336 | << std::hex << (int)tiDataArea->source; |
| 337 | strobj = ss.str(); |
| 338 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 339 | |
| 340 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 341 | { |
| 342 | // Call TI special attention handler |
| 343 | rc = tiHandler(tiDataArea); |
| 344 | } |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 345 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 346 | } |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 347 | |
| 348 | // If TI area not valid or not available |
| 349 | if (false == tiInfoValid) |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 350 | { |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 351 | trace<level::INFO>("TI info NOT available"); |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 352 | |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 353 | // if configured to handle breakpoint as default special attention |
| 354 | if (i_attention->getConfig()->getFlag(dfltBreakpoint)) |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 355 | { |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 356 | if (true == (i_attention->getConfig()->getFlag(enBreakpoints))) |
| 357 | { |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 358 | // Call the breakpoint special attention handler |
| 359 | bpHandler(); |
| 360 | } |
| 361 | } |
| 362 | // if configured to handle TI as default special attention |
| 363 | else |
| 364 | { |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 365 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 366 | { |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 367 | // Call TI special attention handler |
| 368 | rc = tiHandler(nullptr); |
| 369 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 370 | } |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 371 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 372 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 373 | // release TI data buffer |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 374 | if ((nullptr != tiInfo) && (false == tiInfoStatic)) |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 375 | { |
| 376 | free(tiInfo); |
| 377 | } |
| 378 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 379 | if (RC_SUCCESS != rc) |
| 380 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 381 | trace<level::INFO>("Special attn not handled"); |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 382 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 383 | |
| 384 | return rc; |
| 385 | } |
| 386 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 387 | /** |
| 388 | * @brief Determine if attention is active and not masked |
| 389 | * |
| 390 | * Determine whether an attention needs to be handled and trace details of |
| 391 | * attention type and whether it is masked or not. |
| 392 | * |
| 393 | * @param i_val attention status register |
| 394 | * @param i_mask attention true mask register |
| 395 | * @param i_attn attention type |
| 396 | * @param i_proc processor associated with registers |
| 397 | * |
| 398 | * @return true if attention is active and not masked, otherwise false |
| 399 | */ |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 400 | 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] | 401 | { |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 402 | bool rc = false; // assume attn masked and/or inactive |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 403 | |
| 404 | // if attention active |
| 405 | if (0 != (i_val & i_attn)) |
| 406 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 407 | std::stringstream ss; |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 408 | |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 409 | bool validAttn = true; // known attention type |
| 410 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 411 | switch (i_attn) |
| 412 | { |
| 413 | case SBE_ATTN: |
| 414 | ss << "SBE attn"; |
| 415 | break; |
| 416 | case CHECKSTOP_ATTN: |
| 417 | ss << "Checkstop attn"; |
| 418 | break; |
| 419 | case SPECIAL_ATTN: |
| 420 | ss << "Special attn"; |
| 421 | break; |
| 422 | default: |
| 423 | ss << "Unknown attn"; |
| 424 | validAttn = false; |
| 425 | } |
| 426 | |
| 427 | // see if attention is masked |
| 428 | if (true == validAttn) |
| 429 | { |
| 430 | if (0 != (i_mask & i_attn)) |
| 431 | { |
| 432 | rc = true; // attention active and not masked |
| 433 | } |
| 434 | else |
| 435 | { |
| 436 | ss << " masked"; |
| 437 | } |
| 438 | } |
| 439 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 440 | std::string strobj = ss.str(); // ss.str() is temporary |
| 441 | trace<level::INFO>(strobj.c_str()); // commit trace stream |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | return rc; |
| 445 | } |
| 446 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 447 | } // namespace attn |