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