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 | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 7 | #ifdef CONFIG_PHAL_API |
| 8 | #include <libphal.H> |
| 9 | #endif |
| 10 | |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 11 | #include <analyzer/analyzer_main.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 12 | #include <attn/attention.hpp> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 13 | #include <attn/attn_common.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 14 | #include <attn/attn_config.hpp> |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 15 | #include <attn/attn_dbus.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 16 | #include <attn/attn_handler.hpp> |
| 17 | #include <attn/attn_logging.hpp> |
| 18 | #include <attn/bp_handler.hpp> |
| 19 | #include <attn/ti_handler.hpp> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 20 | #include <attn/vital_handler.hpp> |
Ben Tyner | fe2c50d | 2021-07-23 13:38:53 -0500 | [diff] [blame] | 21 | #include <util/dbus.hpp> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 22 | |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 23 | #include <algorithm> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 24 | #include <iomanip> |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 25 | #include <map> |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 26 | #include <sstream> |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 27 | #include <vector> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 28 | |
| 29 | namespace attn |
| 30 | { |
| 31 | |
| 32 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 33 | * @brief Handle checkstop attention |
| 34 | * |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 35 | * @param i_attention Attention object |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 36 | * @return 0 indicates that the checkstop attention was successfully handled |
| 37 | * 1 indicates that the checkstop attention was NOT successfully |
| 38 | * 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 handleCheckstop(Attention* i_attention); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * @brief Handle special attention |
| 44 | * |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 45 | * @param i_attention Attention object |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 46 | * @return 0 indicates that the special attention was successfully handled |
| 47 | * 1 indicates that the special attention was NOT successfully handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 48 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 49 | int handleSpecial(Attention* i_attention); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 50 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 51 | /** @brief Determine if attention is active and not masked */ |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 52 | 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] | 53 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 54 | #ifdef CONFIG_PHAL_API |
| 55 | /** @brief Handle phal sbe exception */ |
| 56 | void phalSbeExceptionHandler(openpower::phal::exception::SbeError& e, |
| 57 | uint32_t procNum); |
| 58 | #endif |
| 59 | |
| 60 | /** @brief Get static TI info data based on host state */ |
| 61 | void getStaticTiInfo(uint8_t*& tiInfoPtr); |
| 62 | |
| 63 | /** @brief Check if TI info data is valid */ |
| 64 | bool tiInfoValid(uint8_t* tiInfo); |
| 65 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 66 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 67 | * @brief The main attention handler logic |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 68 | * |
| 69 | * @param i_breakpoints true = breakpoint special attn handling enabled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 70 | */ |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 71 | void attnHandler(Config* i_config) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 72 | { |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 73 | // Vector of active attentions to be handled |
| 74 | std::vector<Attention> active_attentions; |
| 75 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 76 | uint32_t isr_val, isr_mask; |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 77 | |
| 78 | // loop through processors looking for active attentions |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 79 | trace<level::INFO>("Attention handler started"); |
Ben Tyner | 117af99 | 2020-05-22 13:32:11 -0500 | [diff] [blame] | 80 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 81 | pdbg_target* target; |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 82 | pdbg_for_each_class_target("proc", target) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 83 | { |
| 84 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(target)) |
| 85 | { |
Zane Shelley | a79f6c8 | 2021-01-12 16:38:49 -0600 | [diff] [blame] | 86 | auto proc = pdbg_target_index(target); // get processor number |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 87 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 88 | // Use PIB target to determine if a processor is enabled |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 89 | char path[16]; |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 90 | sprintf(path, "/proc%d/pib", proc); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 91 | pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 92 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 93 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 94 | if (nullptr == pibTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 95 | { |
| 96 | trace<level::INFO>("pib path or target not found"); |
| 97 | continue; |
| 98 | } |
| 99 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 100 | // check if pib target is enabled |
| 101 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 102 | { |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 103 | // The processor FSI target is required for CFAM read |
| 104 | sprintf(path, "/proc%d/fsi", proc); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 105 | pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 106 | |
| 107 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 108 | if (nullptr == fsiTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 109 | { |
| 110 | trace<level::INFO>("fsi path or target not found"); |
| 111 | continue; |
| 112 | } |
| 113 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 114 | // trace the proc number |
| 115 | std::string traceMsg = "proc: " + std::to_string(proc); |
| 116 | trace<level::INFO>(traceMsg.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 117 | |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 118 | isr_val = 0xffffffff; // invalid isr value |
| 119 | |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 120 | // get active attentions on processor |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 121 | if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 122 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 123 | // log cfam read error |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 124 | trace<level::INFO>("Error! cfam read 0x1007 FAILED"); |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 125 | eventAttentionFail((int)AttnSection::attnHandler | |
| 126 | ATTN_PDBG_CFAM); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 127 | } |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 128 | else if (0xffffffff == isr_val) |
| 129 | { |
| 130 | trace<level::INFO>("Error! cfam read 0x1007 INVALID"); |
| 131 | continue; |
| 132 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 133 | else |
| 134 | { |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 135 | // trace isr value |
| 136 | std::stringstream ssIsr; |
| 137 | ssIsr << "cfam 0x1007 = 0x" << std::setw(8) |
| 138 | << std::setfill('0') << std::hex << isr_val; |
| 139 | std::string strobjIsr = ssIsr.str(); |
| 140 | trace<level::INFO>(strobjIsr.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 141 | |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 142 | isr_mask = 0xffffffff; // invalid isr mask |
| 143 | |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 144 | // get interrupt enabled special attentions mask |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 145 | if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 146 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 147 | // log cfam read error |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 148 | trace<level::INFO>("Error! cfam read 0x100d FAILED"); |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 149 | eventAttentionFail((int)AttnSection::attnHandler | |
| 150 | ATTN_PDBG_CFAM); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 151 | } |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 152 | else if (0xffffffff == isr_mask) |
| 153 | { |
| 154 | trace<level::INFO>("Error! cfam read 0x100d INVALID"); |
| 155 | continue; |
| 156 | } |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 157 | else |
| 158 | { |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 159 | // trace true mask |
| 160 | std::stringstream ssMask; |
| 161 | ssMask << "cfam 0x100d = 0x" << std::setw(8) |
| 162 | << std::setfill('0') << std::hex << isr_mask; |
| 163 | std::string strobjMask = ssMask.str(); |
| 164 | trace<level::INFO>(strobjMask.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 165 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 166 | // SBE vital 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, SBE_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 168 | { |
| 169 | active_attentions.emplace_back(Attention::Vital, |
| 170 | handleVital, target, |
| 171 | i_config); |
| 172 | } |
| 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 | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 234 | // capture some additional data for logs/traces |
| 235 | addHbStatusRegs(); |
| 236 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 237 | // if checkstop handling enabled, handle checkstop attention |
| 238 | if (false == (i_attention->getConfig()->getFlag(enCheckstop))) |
| 239 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 240 | trace<level::INFO>("Checkstop handling disabled"); |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 241 | } |
| 242 | else |
| 243 | { |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 244 | // Look for any attentions found in hardware. This will generate and |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 245 | // commit a PEL if any errors are found. |
Ben Tyner | 7029e52 | 2021-08-09 19:18:24 -0500 | [diff] [blame] | 246 | DumpParameters dumpParameters; |
| 247 | if (true != analyzer::analyzeHardware(dumpParameters)) |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 248 | { |
| 249 | rc = RC_ANALYZER_ERROR; |
| 250 | } |
Ben Tyner | 7029e52 | 2021-08-09 19:18:24 -0500 | [diff] [blame] | 251 | else |
| 252 | { |
| 253 | requestDump(dumpParameters); |
| 254 | util::dbus::transitionHost(util::dbus::HostState::Quiesce); |
| 255 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 256 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 257 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 258 | return rc; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * @brief Handle special attention |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 263 | * |
| 264 | * @param i_attention Attention object |
| 265 | * @return 0 indicates that the special attention was successfully handled |
| 266 | * 1 indicates that the special attention was NOT successfully handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 267 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 268 | int handleSpecial(Attention* i_attention) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 269 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 270 | int rc = RC_SUCCESS; // assume special attention handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 271 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 272 | // 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] | 273 | uint8_t* tiInfo = nullptr; // ptr to TI info data |
| 274 | uint32_t tiInfoLen = 0; // length of TI info data |
| 275 | pdbg_target* attnProc = i_attention->getTarget(); // proc with attention |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 276 | |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 277 | bool tiInfoStatic = false; // assume TI info was provided (not created) |
| 278 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 279 | // need proc target to get dynamic TI info |
| 280 | if (nullptr != attnProc) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 281 | { |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 282 | #ifdef CONFIG_PHAL_API |
| 283 | trace<level::INFO>("using libphal to get TI info"); |
| 284 | |
| 285 | // phal library uses proc target for get ti info |
| 286 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(attnProc)) |
| 287 | { |
| 288 | try |
| 289 | { |
| 290 | // get dynamic TI info |
| 291 | openpower::phal::sbe::getTiInfo(attnProc, &tiInfo, &tiInfoLen); |
| 292 | } |
| 293 | catch (openpower::phal::exception::SbeError& e) |
| 294 | { |
| 295 | // library threw an exception |
| 296 | uint32_t procNum = pdbg_target_index(attnProc); |
| 297 | phalSbeExceptionHandler(e, procNum); |
| 298 | } |
| 299 | } |
| 300 | #else |
| 301 | trace<level::INFO>("using libpdbg to get TI info"); |
| 302 | |
| 303 | // pdbg library uses pib target for get ti info |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 304 | char path[16]; |
| 305 | sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc)); |
| 306 | pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path); |
| 307 | |
| 308 | if (nullptr != tiInfoTarget) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 309 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 310 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget)) |
| 311 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 312 | sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen); |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 313 | } |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 314 | } |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 315 | #endif |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 316 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 317 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 318 | // dynamic TI info is not available |
| 319 | if (nullptr == tiInfo) |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 320 | { |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 321 | trace<level::INFO>("TI info data ptr is invalid"); |
| 322 | getStaticTiInfo(tiInfo); |
| 323 | tiInfoStatic = true; |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 324 | } |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 325 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 326 | // check TI info for validity and handle |
| 327 | if (true == tiInfoValid(tiInfo)) |
| 328 | { |
| 329 | // TI info is valid handle TI if support enabled |
| 330 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 331 | { |
| 332 | // Call TI special attention handler |
| 333 | rc = tiHandler((TiDataArea*)tiInfo); |
| 334 | } |
| 335 | } |
| 336 | else |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 337 | { |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 338 | trace<level::INFO>("TI info NOT valid"); |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 339 | |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 340 | // if configured to handle TI as default special attention |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 341 | if (i_attention->getConfig()->getFlag(dfltTi)) |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 342 | { |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 343 | // TI handling may be disabled |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 344 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 345 | { |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 346 | // Call TI special attention handler |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 347 | rc = tiHandler((TiDataArea*)tiInfo); |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 348 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 349 | } |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 350 | // configured to handle breakpoint as default special attention |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 351 | else |
| 352 | { |
| 353 | // breakpoint handling may be disabled |
| 354 | if (true == (i_attention->getConfig()->getFlag(enBreakpoints))) |
| 355 | { |
| 356 | // Call the breakpoint special attention handler |
| 357 | rc = bpHandler(); |
| 358 | } |
| 359 | } |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 360 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 361 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 362 | // release TI data buffer if not ours |
| 363 | if (false == tiInfoStatic) |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 364 | { |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 365 | // sanity check |
| 366 | if (nullptr != tiInfo) |
| 367 | { |
| 368 | free(tiInfo); |
| 369 | } |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 370 | } |
| 371 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 372 | // trace non-successful exit condition |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 373 | if (RC_SUCCESS != rc) |
| 374 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 375 | trace<level::INFO>("Special attn not handled"); |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 376 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 377 | |
| 378 | return rc; |
| 379 | } |
| 380 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 381 | /** |
| 382 | * @brief Determine if attention is active and not masked |
| 383 | * |
| 384 | * Determine whether an attention needs to be handled and trace details of |
| 385 | * attention type and whether it is masked or not. |
| 386 | * |
| 387 | * @param i_val attention status register |
| 388 | * @param i_mask attention true mask register |
| 389 | * @param i_attn attention type |
| 390 | * @param i_proc processor associated with registers |
| 391 | * |
| 392 | * @return true if attention is active and not masked, otherwise false |
| 393 | */ |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 394 | 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] | 395 | { |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 396 | bool rc = false; // assume attn masked and/or inactive |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 397 | |
| 398 | // if attention active |
| 399 | if (0 != (i_val & i_attn)) |
| 400 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 401 | std::stringstream ss; |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 402 | |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 403 | bool validAttn = true; // known attention type |
| 404 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 405 | switch (i_attn) |
| 406 | { |
| 407 | case SBE_ATTN: |
| 408 | ss << "SBE attn"; |
| 409 | break; |
| 410 | case CHECKSTOP_ATTN: |
| 411 | ss << "Checkstop attn"; |
| 412 | break; |
| 413 | case SPECIAL_ATTN: |
| 414 | ss << "Special attn"; |
| 415 | break; |
| 416 | default: |
| 417 | ss << "Unknown attn"; |
| 418 | validAttn = false; |
| 419 | } |
| 420 | |
| 421 | // see if attention is masked |
| 422 | if (true == validAttn) |
| 423 | { |
| 424 | if (0 != (i_mask & i_attn)) |
| 425 | { |
| 426 | rc = true; // attention active and not masked |
| 427 | } |
| 428 | else |
| 429 | { |
| 430 | ss << " masked"; |
| 431 | } |
| 432 | } |
| 433 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 434 | std::string strobj = ss.str(); // ss.str() is temporary |
| 435 | trace<level::INFO>(strobj.c_str()); // commit trace stream |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | return rc; |
| 439 | } |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 440 | |
| 441 | #ifdef CONFIG_PHAL_API |
| 442 | /** |
| 443 | * @brief Handle phal sbe exception |
| 444 | * |
| 445 | * @param[in] e - exception object |
| 446 | * @param[in] procNum - processor number associated with sbe exception |
| 447 | */ |
| 448 | void phalSbeExceptionHandler(openpower::phal::exception::SbeError& e, |
| 449 | uint32_t procNum) |
| 450 | { |
| 451 | // trace exception details |
| 452 | std::string traceMsg = std::string(e.what()); |
| 453 | trace<level::ERROR>(traceMsg.c_str()); |
| 454 | |
| 455 | // Handle SBE chipop timeout error |
| 456 | if (e.errType() == openpower::phal::exception::SBE_CHIPOP_NOT_ALLOWED) |
| 457 | { |
| 458 | eventPhalSbeChipop(procNum); |
| 459 | } |
| 460 | } |
| 461 | #endif |
| 462 | |
| 463 | /** |
| 464 | * @brief Get static TI info data based on host state |
| 465 | * |
| 466 | * @param[out] tiInfo - pointer to static TI info data |
| 467 | */ |
| 468 | void getStaticTiInfo(uint8_t*& tiInfo) |
| 469 | { |
| 470 | util::dbus::HostRunningState runningState = util::dbus::hostRunningState(); |
| 471 | |
| 472 | // assume host state is unknown |
| 473 | std::string stateString = "host state unknown"; |
| 474 | |
| 475 | if ((util::dbus::HostRunningState::Started == runningState) || |
| 476 | (util::dbus::HostRunningState::Unknown == runningState)) |
| 477 | { |
| 478 | if (util::dbus::HostRunningState::Started == runningState) |
| 479 | { |
| 480 | stateString = "host started"; |
| 481 | } |
| 482 | tiInfo = (uint8_t*)defaultPhypTiInfo; |
| 483 | } |
| 484 | else |
| 485 | { |
| 486 | stateString = "host not started"; |
| 487 | tiInfo = (uint8_t*)defaultHbTiInfo; |
| 488 | } |
| 489 | |
| 490 | // trace host state |
| 491 | trace<level::INFO>(stateString.c_str()); |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * @brief Check if TI info data is valid |
| 496 | * |
| 497 | * @param[in] tiInfo - pointer to TI info data |
| 498 | * @return true if TI info data is valid, else false |
| 499 | */ |
| 500 | bool tiInfoValid(uint8_t* tiInfo) |
| 501 | { |
| 502 | bool tiInfoValid = false; // assume TI info invalid |
| 503 | |
| 504 | // TI info data[0] non-zero indicates TI info valid (usually) |
| 505 | if ((nullptr != tiInfo) && (0 != tiInfo[0])) |
| 506 | { |
| 507 | TiDataArea* tiDataArea = (TiDataArea*)tiInfo; |
| 508 | |
| 509 | std::stringstream ss; // string stream object for tracing |
| 510 | std::string strobj; // string object for tracing |
| 511 | |
| 512 | // trace a few known TI data area values |
| 513 | ss.str(std::string()); // empty the stream |
| 514 | ss.clear(); // clear the stream |
| 515 | ss << "TI data command = 0x" << std::setw(2) << std::setfill('0') |
| 516 | << std::hex << (int)tiDataArea->command; |
| 517 | strobj = ss.str(); |
| 518 | trace<level::INFO>(strobj.c_str()); |
| 519 | |
| 520 | // Another check for valid TI Info since it has been seen that |
| 521 | // tiInfo[0] != 0 but TI info is not valid |
| 522 | if (0xa1 == tiDataArea->command) |
| 523 | { |
| 524 | tiInfoValid = true; |
| 525 | |
| 526 | // trace some more data since TI info appears valid |
| 527 | ss.str(std::string()); // empty the stream |
| 528 | ss.clear(); // clear the stream |
| 529 | ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0') |
| 530 | << std::hex << (int)tiDataArea->hbTerminateType; |
| 531 | strobj = ss.str(); |
| 532 | trace<level::INFO>(strobj.c_str()); |
| 533 | |
| 534 | ss.str(std::string()); // empty the stream |
| 535 | ss.clear(); // clear the stream |
| 536 | ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0') |
| 537 | << std::hex << (int)tiDataArea->srcFormat; |
| 538 | strobj = ss.str(); |
| 539 | trace<level::INFO>(strobj.c_str()); |
| 540 | |
| 541 | ss.str(std::string()); // empty the stream |
| 542 | ss.clear(); // clear the stream |
| 543 | ss << "TI data source = 0x" << std::setw(2) << std::setfill('0') |
| 544 | << std::hex << (int)tiDataArea->source; |
| 545 | strobj = ss.str(); |
| 546 | trace<level::INFO>(strobj.c_str()); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | return tiInfoValid; |
| 551 | } |
| 552 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 553 | } // namespace attn |