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