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 | /** |
Brian Stegmiller | 2d5c63d | 2021-03-31 17:29:29 -0500 | [diff] [blame] | 46 | * @brief Traces some regs for hostboot |
| 47 | * |
| 48 | * @param i_procIndex - processor number (used in traces) |
| 49 | * @param i_pibTarget - target used for doing SCOMs to the processor |
| 50 | * @param i_fsiTarget - target used for doing CFAMs to the processor |
| 51 | * |
| 52 | * @return nothing |
| 53 | */ |
| 54 | void addHbStatusRegs(uint32_t i_procIndex, pdbg_target* i_pibTarget, |
| 55 | pdbg_target* i_fsiTarget); |
| 56 | |
| 57 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 58 | * @brief The main attention handler logic |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 59 | * |
| 60 | * @param i_breakpoints true = breakpoint special attn handling enabled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 61 | */ |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 62 | void attnHandler(Config* i_config) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 63 | { |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 64 | // Vector of active attentions to be handled |
| 65 | std::vector<Attention> active_attentions; |
| 66 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 67 | uint32_t isr_val, isr_mask; |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 68 | |
| 69 | // loop through processors looking for active attentions |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 70 | trace<level::INFO>("Attention handler started"); |
Ben Tyner | 117af99 | 2020-05-22 13:32:11 -0500 | [diff] [blame] | 71 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 72 | pdbg_target* target; |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 73 | pdbg_for_each_class_target("proc", target) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 74 | { |
| 75 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(target)) |
| 76 | { |
Zane Shelley | a79f6c8 | 2021-01-12 16:38:49 -0600 | [diff] [blame] | 77 | auto proc = pdbg_target_index(target); // get processor number |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 78 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 79 | // Use PIB target to determine if a processor is enabled |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 80 | char path[16]; |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 81 | sprintf(path, "/proc%d/pib", proc); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 82 | pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 83 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 84 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 85 | if (nullptr == pibTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 86 | { |
| 87 | trace<level::INFO>("pib path or target not found"); |
| 88 | continue; |
| 89 | } |
| 90 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 91 | // check if pib target is enabled |
| 92 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 93 | { |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 94 | // The processor FSI target is required for CFAM read |
| 95 | sprintf(path, "/proc%d/fsi", proc); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 96 | pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 97 | |
| 98 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 99 | if (nullptr == fsiTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 100 | { |
| 101 | trace<level::INFO>("fsi path or target not found"); |
| 102 | continue; |
| 103 | } |
| 104 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 105 | // trace the proc number |
| 106 | std::string traceMsg = "proc: " + std::to_string(proc); |
| 107 | trace<level::INFO>(traceMsg.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 108 | |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 109 | isr_val = 0xffffffff; // invalid isr value |
| 110 | |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 111 | // get active attentions on processor |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 112 | if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 113 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 114 | // log cfam read error |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 115 | trace<level::INFO>("Error! cfam read 0x1007 FAILED"); |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 116 | eventAttentionFail((int)AttnSection::attnHandler | |
| 117 | ATTN_PDBG_CFAM); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 118 | } |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 119 | else if (0xffffffff == isr_val) |
| 120 | { |
| 121 | trace<level::INFO>("Error! cfam read 0x1007 INVALID"); |
| 122 | continue; |
| 123 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 124 | else |
| 125 | { |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 126 | // trace isr value |
| 127 | std::stringstream ssIsr; |
| 128 | ssIsr << "cfam 0x1007 = 0x" << std::setw(8) |
| 129 | << std::setfill('0') << std::hex << isr_val; |
| 130 | std::string strobjIsr = ssIsr.str(); |
| 131 | trace<level::INFO>(strobjIsr.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 132 | |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 133 | isr_mask = 0xffffffff; // invalid isr mask |
| 134 | |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 135 | // get interrupt enabled special attentions mask |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 136 | if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 137 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 138 | // log cfam read error |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 139 | trace<level::INFO>("Error! cfam read 0x100d FAILED"); |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 140 | eventAttentionFail((int)AttnSection::attnHandler | |
| 141 | ATTN_PDBG_CFAM); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 142 | } |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 143 | else if (0xffffffff == isr_mask) |
| 144 | { |
| 145 | trace<level::INFO>("Error! cfam read 0x100d INVALID"); |
| 146 | continue; |
| 147 | } |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 148 | else |
| 149 | { |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 150 | // trace true mask |
| 151 | std::stringstream ssMask; |
| 152 | ssMask << "cfam 0x100d = 0x" << std::setw(8) |
| 153 | << std::setfill('0') << std::hex << isr_mask; |
| 154 | std::string strobjMask = ssMask.str(); |
| 155 | trace<level::INFO>(strobjMask.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 156 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 157 | // SBE vital attention active and not masked? |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 158 | if (true == activeAttn(isr_val, isr_mask, SBE_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 159 | { |
| 160 | active_attentions.emplace_back(Attention::Vital, |
| 161 | handleVital, target, |
| 162 | i_config); |
| 163 | } |
Brian Stegmiller | 2d5c63d | 2021-03-31 17:29:29 -0500 | [diff] [blame] | 164 | else |
| 165 | { |
| 166 | // Hostboot wants some debug regs on Checkstops/TIs. |
| 167 | // Don't bother on SBE Vitals (scoms will fail). |
| 168 | // Only need to do on primary proc if you know what |
| 169 | // it is, but eBMC may not so we will dump all |
| 170 | // procs. |
| 171 | addHbStatusRegs(proc, pibTarget, fsiTarget); |
| 172 | } // Not SBE Vital attention |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 173 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 174 | // Checkstop attention active and not masked? |
| 175 | if (true == |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 176 | activeAttn(isr_val, isr_mask, CHECKSTOP_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 177 | { |
| 178 | active_attentions.emplace_back(Attention::Checkstop, |
| 179 | handleCheckstop, |
| 180 | target, i_config); |
| 181 | } |
| 182 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 183 | // Special attention active and not masked? |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 184 | if (true == activeAttn(isr_val, isr_mask, SPECIAL_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 185 | { |
| 186 | active_attentions.emplace_back(Attention::Special, |
| 187 | handleSpecial, |
| 188 | target, i_config); |
| 189 | } |
| 190 | } // cfam 0x100d valid |
| 191 | } // cfam 0x1007 valid |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 192 | } // fsi target enabled |
| 193 | } // pib target enabled |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 194 | } // next processor |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 195 | |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 196 | // convert to heap, highest priority is at front |
| 197 | if (!std::is_heap(active_attentions.begin(), active_attentions.end())) |
| 198 | { |
| 199 | std::make_heap(active_attentions.begin(), active_attentions.end()); |
| 200 | } |
| 201 | |
| 202 | // call the attention handler until one is handled or all were attempted |
| 203 | while (false == active_attentions.empty()) |
| 204 | { |
| 205 | // handle highest priority attention, done if successful |
| 206 | if (RC_SUCCESS == active_attentions.front().handle()) |
| 207 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 208 | // an attention was handled so we are done |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 209 | break; |
| 210 | } |
| 211 | |
| 212 | // move attention to back of vector |
| 213 | std::pop_heap(active_attentions.begin(), active_attentions.end()); |
| 214 | |
| 215 | // remove attention from vector |
| 216 | active_attentions.pop_back(); |
| 217 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 221 | * @brief Handle checkstop attention |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 222 | * |
| 223 | * @param i_attention Attention object |
| 224 | * @return 0 indicates that the checkstop attention was successfully handled |
| 225 | * 1 indicates that the checkstop attention was NOT successfully |
| 226 | * handled. |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 227 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 228 | int handleCheckstop(Attention* i_attention) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 229 | { |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 230 | int rc = RC_SUCCESS; // assume checkstop handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 231 | |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 232 | trace<level::INFO>("checkstop handler started"); |
| 233 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 234 | // if checkstop handling enabled, handle checkstop attention |
| 235 | if (false == (i_attention->getConfig()->getFlag(enCheckstop))) |
| 236 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 237 | trace<level::INFO>("Checkstop handling disabled"); |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 238 | } |
| 239 | else |
| 240 | { |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 241 | // Look for any attentions found in hardware. This will generate and |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 242 | // commit a PEL if any errors are found. |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 243 | if (true != analyzer::analyzeHardware()) |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 244 | { |
| 245 | rc = RC_ANALYZER_ERROR; |
| 246 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 247 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 248 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 249 | return rc; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * @brief Handle special attention |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 254 | * |
| 255 | * @param i_attention Attention object |
| 256 | * @return 0 indicates that the special attention was successfully handled |
| 257 | * 1 indicates that the special attention was NOT successfully handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 258 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 259 | int handleSpecial(Attention* i_attention) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 260 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 261 | int rc = RC_SUCCESS; // assume special attention handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 262 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 263 | // 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] | 264 | uint8_t* tiInfo = nullptr; // ptr to TI info data |
| 265 | uint32_t tiInfoLen = 0; // length of TI info data |
| 266 | pdbg_target* attnProc = i_attention->getTarget(); // proc with attention |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 267 | |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 268 | bool tiInfoStatic = false; // assume TI info was provided (not created) |
| 269 | |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 270 | if (attnProc != nullptr) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 271 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 272 | // The processor PIB target is required for get TI info chipop |
| 273 | char path[16]; |
| 274 | sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc)); |
| 275 | pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path); |
| 276 | |
| 277 | if (nullptr != tiInfoTarget) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 278 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 279 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget)) |
| 280 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 281 | sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen); |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 282 | |
| 283 | // If TI info not available use default based on host state |
| 284 | if (nullptr == tiInfo) |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 285 | { |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 286 | trace<level::INFO>("TI info data ptr is invalid"); |
| 287 | |
| 288 | HostRunningState runningState = hostRunningState(); |
| 289 | std::string stateString = "host state unknown"; |
| 290 | |
| 291 | if ((HostRunningState::Started == runningState) || |
| 292 | (HostRunningState::Unknown == runningState)) |
| 293 | { |
| 294 | if (HostRunningState::Started == runningState) |
| 295 | { |
| 296 | stateString = "host started"; |
| 297 | } |
| 298 | tiInfo = (uint8_t*)defaultPhypTiInfo; |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | stateString = "host not started"; |
| 303 | tiInfo = (uint8_t*)defaultHbTiInfo; |
| 304 | } |
| 305 | |
| 306 | // trace host state |
| 307 | trace<level::INFO>(stateString.c_str()); |
| 308 | |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 309 | tiInfoStatic = true; // using our TI info |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 310 | } |
| 311 | } |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 312 | } |
| 313 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 314 | |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 315 | bool tiInfoValid = false; // TI area data not valid or not available |
| 316 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 317 | // If TI area exists and is marked valid we can assume TI occurred |
| 318 | if ((nullptr != tiInfo) && (0 != tiInfo[0])) |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 319 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 320 | TiDataArea* tiDataArea = (TiDataArea*)tiInfo; |
Ben Tyner | 7e6611f | 2020-02-13 16:42:56 -0600 | [diff] [blame] | 321 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 322 | std::stringstream ss; // string stream object for tracing |
| 323 | std::string strobj; // string object for tracing |
Ben Tyner | 4071772 | 2020-09-23 09:43:20 -0500 | [diff] [blame] | 324 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 325 | // trace a few known TI data area values |
| 326 | ss.str(std::string()); // empty the stream |
| 327 | ss.clear(); // clear the stream |
| 328 | ss << "TI data command = 0x" << std::setw(2) << std::setfill('0') |
| 329 | << std::hex << (int)tiDataArea->command; |
| 330 | strobj = ss.str(); |
| 331 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 4071772 | 2020-09-23 09:43:20 -0500 | [diff] [blame] | 332 | |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 333 | // Another check for valid TI Info since it has been seen that |
| 334 | // tiInfo[0] != 0 but TI info is not valid |
| 335 | if (0xa1 == tiDataArea->command) |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 336 | { |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 337 | tiInfoValid = true; |
| 338 | |
| 339 | // trace some more data since TI info appears valid |
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 |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 342 | ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0') |
| 343 | << std::hex << (int)tiDataArea->hbTerminateType; |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 344 | strobj = ss.str(); |
| 345 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 346 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 347 | ss.str(std::string()); // empty the stream |
| 348 | ss.clear(); // clear the stream |
| 349 | ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0') |
| 350 | << std::hex << (int)tiDataArea->srcFormat; |
| 351 | strobj = ss.str(); |
| 352 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 353 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 354 | ss.str(std::string()); // empty the stream |
| 355 | ss.clear(); // clear the stream |
| 356 | ss << "TI data source = 0x" << std::setw(2) << std::setfill('0') |
| 357 | << std::hex << (int)tiDataArea->source; |
| 358 | strobj = ss.str(); |
| 359 | trace<level::INFO>(strobj.c_str()); |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 360 | |
| 361 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 362 | { |
| 363 | // Call TI special attention handler |
| 364 | rc = tiHandler(tiDataArea); |
| 365 | } |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 366 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 367 | } |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 368 | |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 369 | // TI area is available but was not valid data |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 370 | if (false == tiInfoValid) |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 371 | { |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 372 | trace<level::INFO>("TI info NOT valid"); |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 373 | |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 374 | // if configured to handle TI as default special attention |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 375 | if (i_attention->getConfig()->getFlag(dfltTi)) |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 376 | { |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 377 | // TI handling may be disabled |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 378 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 379 | { |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 380 | // Call TI special attention handler |
| 381 | rc = tiHandler(nullptr); |
| 382 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 383 | } |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 384 | // breakpoint is default special attention when TI info NOT valid |
| 385 | else |
| 386 | { |
| 387 | // breakpoint handling may be disabled |
| 388 | if (true == (i_attention->getConfig()->getFlag(enBreakpoints))) |
| 389 | { |
| 390 | // Call the breakpoint special attention handler |
| 391 | rc = bpHandler(); |
| 392 | } |
| 393 | } |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 394 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 395 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 396 | // release TI data buffer |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 397 | if ((nullptr != tiInfo) && (false == tiInfoStatic)) |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 398 | { |
| 399 | free(tiInfo); |
| 400 | } |
| 401 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 402 | if (RC_SUCCESS != rc) |
| 403 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 404 | trace<level::INFO>("Special attn not handled"); |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 405 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 406 | |
| 407 | return rc; |
| 408 | } |
| 409 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 410 | /** |
| 411 | * @brief Determine if attention is active and not masked |
| 412 | * |
| 413 | * Determine whether an attention needs to be handled and trace details of |
| 414 | * attention type and whether it is masked or not. |
| 415 | * |
| 416 | * @param i_val attention status register |
| 417 | * @param i_mask attention true mask register |
| 418 | * @param i_attn attention type |
| 419 | * @param i_proc processor associated with registers |
| 420 | * |
| 421 | * @return true if attention is active and not masked, otherwise false |
| 422 | */ |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 423 | 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] | 424 | { |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 425 | bool rc = false; // assume attn masked and/or inactive |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 426 | |
| 427 | // if attention active |
| 428 | if (0 != (i_val & i_attn)) |
| 429 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 430 | std::stringstream ss; |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 431 | |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 432 | bool validAttn = true; // known attention type |
| 433 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 434 | switch (i_attn) |
| 435 | { |
| 436 | case SBE_ATTN: |
| 437 | ss << "SBE attn"; |
| 438 | break; |
| 439 | case CHECKSTOP_ATTN: |
| 440 | ss << "Checkstop attn"; |
| 441 | break; |
| 442 | case SPECIAL_ATTN: |
| 443 | ss << "Special attn"; |
| 444 | break; |
| 445 | default: |
| 446 | ss << "Unknown attn"; |
| 447 | validAttn = false; |
| 448 | } |
| 449 | |
| 450 | // see if attention is masked |
| 451 | if (true == validAttn) |
| 452 | { |
| 453 | if (0 != (i_mask & i_attn)) |
| 454 | { |
| 455 | rc = true; // attention active and not masked |
| 456 | } |
| 457 | else |
| 458 | { |
| 459 | ss << " masked"; |
| 460 | } |
| 461 | } |
| 462 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 463 | std::string strobj = ss.str(); // ss.str() is temporary |
| 464 | trace<level::INFO>(strobj.c_str()); // commit trace stream |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | return rc; |
| 468 | } |
| 469 | |
Brian Stegmiller | 2d5c63d | 2021-03-31 17:29:29 -0500 | [diff] [blame] | 470 | /** |
| 471 | * @brief Traces some regs for hostboot |
| 472 | * |
| 473 | * When we receive a Checkstop or special Attention Term Immediate, |
| 474 | * hostboot wants some regs added to the error log. We will do this |
| 475 | * by tracing them here and then the traces will get added to |
| 476 | * the error log later |
| 477 | * |
| 478 | * @param i_procIndex - processor number (used in traces) |
| 479 | * @param i_pibTarget - target used for doing SCOMs to the processor |
| 480 | * @param i_fsiTarget - target used for doing CFAMs to the processor |
| 481 | * |
| 482 | * @return nothing |
| 483 | */ |
| 484 | void addHbStatusRegs(uint32_t i_procIndex, pdbg_target* i_pibTarget, |
| 485 | pdbg_target* i_fsiTarget) |
| 486 | { |
| 487 | uint32_t l_cfamData = 0xFFFFFFFF; |
| 488 | uint64_t l_scomData1 = 0xFFFFFFFFFFFFFFFFull; |
| 489 | uint64_t l_scomData2 = 0xFFFFFFFFFFFFFFFFull; |
| 490 | uint32_t l_cfamAddr = 0x283C; |
| 491 | uint64_t l_scomAddr1 = 0x4602F489; |
| 492 | uint64_t l_scomAddr2 = 0x4602F487; |
| 493 | |
| 494 | // We only need this for PRIMARY proc, but will just do on all procs for |
| 495 | // now. All attentions handled are fatal (except for plain breakpoints). Not |
| 496 | // going to sweat the plain breakpoint case since this is lab only using |
| 497 | // cronus. |
| 498 | |
| 499 | // get first debug reg (CFAM) |
| 500 | if (RC_SUCCESS != fsi_read(i_fsiTarget, l_cfamAddr, &l_cfamData)) |
| 501 | { |
| 502 | l_cfamData = 0xFFFFFFFF; |
| 503 | } |
| 504 | |
| 505 | // Get SCOM regs next (just 2 of them) |
| 506 | if (RC_SUCCESS != pib_read(i_pibTarget, l_scomAddr1, &l_scomData1)) |
| 507 | { |
| 508 | l_scomData1 = 0xFFFFFFFFFFFFFFFFull; |
| 509 | } |
| 510 | |
| 511 | if (RC_SUCCESS != pib_read(i_pibTarget, l_scomAddr2, &l_scomData2)) |
| 512 | { |
| 513 | l_scomData2 = 0xFFFFFFFFFFFFFFFFull; |
| 514 | } |
| 515 | |
| 516 | // Trace out the results here of all 3 regs |
| 517 | // (Format should resemble FSP: HostBoot Reg:0000283C Data:AA801504 |
| 518 | // 00000000 Proc:00050001 ) |
| 519 | std::stringstream ss1, ss2, ss3; |
| 520 | |
| 521 | ss1 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex |
| 522 | << l_cfamAddr << " Data:" << l_cfamData << " Proc:" << std::setw(8) |
| 523 | << i_procIndex; |
| 524 | |
| 525 | ss2 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex |
| 526 | << l_scomAddr1 << " Data:" << std::setw(16) << l_scomData1 |
| 527 | << " Proc:" << std::setw(8) << i_procIndex; |
| 528 | |
| 529 | ss3 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex |
| 530 | << l_scomAddr2 << " Data:" << std::setw(16) << l_scomData2 |
| 531 | << " Proc:" << std::setw(8) << i_procIndex; |
| 532 | |
| 533 | std::string strobj1 = ss1.str(); |
| 534 | std::string strobj2 = ss2.str(); |
| 535 | std::string strobj3 = ss3.str(); |
| 536 | |
| 537 | trace<level::INFO>(strobj1.c_str()); |
| 538 | trace<level::INFO>(strobj2.c_str()); |
| 539 | trace<level::INFO>(strobj3.c_str()); |
| 540 | |
| 541 | return; |
| 542 | |
| 543 | } // end addHbStatusRegs |
| 544 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 545 | } // namespace attn |