blob: 66eb2fc0012cc3d0a0fbd742eb12db1f3a44fd10 [file] [log] [blame]
Jayanth Othayothb1eda6a2021-06-28 00:26:30 -05001extern "C"
2{
Ben Tyner792f32f2020-06-02 08:50:47 -05003#include <libpdbg.h>
Jayanth Othayothb1eda6a2021-06-28 00:26:30 -05004#include <libpdbg_sbe.h>
5}
Ben Tyner792f32f2020-06-02 08:50:47 -05006
Zane Shelleya06dcf82021-11-03 10:23:21 -05007#include <config.h>
8
Ben Tynerb9715172021-09-29 08:46:19 -05009#ifdef CONFIG_PHAL_API
10#include <libphal.H>
11#endif
12
Ben Tyner0205f3b2020-02-24 10:24:47 -060013#include <analyzer/analyzer_main.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -050014#include <attn/attention.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -060015#include <attn/attn_common.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -050016#include <attn/attn_config.hpp>
Ben Tyner4bbcb382021-02-22 09:29:00 -060017#include <attn/attn_dbus.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -050018#include <attn/attn_handler.hpp>
19#include <attn/attn_logging.hpp>
20#include <attn/bp_handler.hpp>
21#include <attn/ti_handler.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -060022#include <attn/vital_handler.hpp>
Ben Tynerfe2c50d2021-07-23 13:38:53 -050023#include <util/dbus.hpp>
Ben Tyner76e52f62022-02-01 10:46:44 -060024#include <util/ffdc_file.hpp>
25#include <util/trace.hpp>
Ben Tyneref320152020-01-09 10:31:23 -060026
Ben Tynerb481d902020-03-05 10:24:23 -060027#include <algorithm>
Ben Tyneref320152020-01-09 10:31:23 -060028#include <iomanip>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050029#include <map>
Ben Tyner9ae5ca42020-02-28 13:13:50 -060030#include <sstream>
Ben Tynerb481d902020-03-05 10:24:23 -060031#include <vector>
Ben Tyneref320152020-01-09 10:31:23 -060032
33namespace attn
34{
35
36/**
Ben Tyneref320152020-01-09 10:31:23 -060037 * @brief Handle checkstop attention
38 *
Ben Tynerb481d902020-03-05 10:24:23 -060039 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050040 * @return 0 indicates that the checkstop attention was successfully handled
41 * 1 indicates that the checkstop attention was NOT successfully
42 * handled.
Ben Tyneref320152020-01-09 10:31:23 -060043 */
Ben Tynerb481d902020-03-05 10:24:23 -060044int handleCheckstop(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060045
46/**
47 * @brief Handle special attention
48 *
Ben Tynerb481d902020-03-05 10:24:23 -060049 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050050 * @return 0 indicates that the special attention was successfully handled
51 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -060052 */
Ben Tynerb481d902020-03-05 10:24:23 -060053int handleSpecial(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060054
Ben Tynerfb190542020-11-06 09:27:56 -060055/** @brief Determine if attention is active and not masked */
Ben Tyner1965e502020-11-20 10:32:24 -060056bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn);
Ben Tynerfb190542020-11-06 09:27:56 -060057
Ben Tynerb9715172021-09-29 08:46:19 -050058#ifdef CONFIG_PHAL_API
59/** @brief Handle phal sbe exception */
60void phalSbeExceptionHandler(openpower::phal::exception::SbeError& e,
Ben Tyner76e52f62022-02-01 10:46:44 -060061 uint32_t chipPosition, uint32_t command);
Ben Tynerb9715172021-09-29 08:46:19 -050062#endif
63
64/** @brief Get static TI info data based on host state */
65void getStaticTiInfo(uint8_t*& tiInfoPtr);
66
67/** @brief Check if TI info data is valid */
68bool tiInfoValid(uint8_t* tiInfo);
69
Ben Tyneref320152020-01-09 10:31:23 -060070/**
Ben Tyneref320152020-01-09 10:31:23 -060071 * @brief The main attention handler logic
Ben Tyner970fd4f2020-02-19 13:46:42 -060072 *
73 * @param i_breakpoints true = breakpoint special attn handling enabled
Ben Tyneref320152020-01-09 10:31:23 -060074 */
Ben Tyner3fb52e52020-03-31 10:10:07 -050075void attnHandler(Config* i_config)
Ben Tyneref320152020-01-09 10:31:23 -060076{
Ben Tynerb481d902020-03-05 10:24:23 -060077 // Vector of active attentions to be handled
78 std::vector<Attention> active_attentions;
79
Ben Tyneref320152020-01-09 10:31:23 -060080 uint32_t isr_val, isr_mask;
Ben Tyneref320152020-01-09 10:31:23 -060081
82 // loop through processors looking for active attentions
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050083 trace<level::INFO>("Attention handler started");
Ben Tyner117af992020-05-22 13:32:11 -050084
Ben Tyneref320152020-01-09 10:31:23 -060085 pdbg_target* target;
Ben Tyner5e622d82020-09-11 10:10:24 -050086 pdbg_for_each_class_target("proc", target)
Ben Tyneref320152020-01-09 10:31:23 -060087 {
88 if (PDBG_TARGET_ENABLED == pdbg_target_probe(target))
89 {
Zane Shelleya79f6c82021-01-12 16:38:49 -060090 auto proc = pdbg_target_index(target); // get processor number
Ben Tyneref320152020-01-09 10:31:23 -060091
Ben Tynerb83c8522020-11-20 10:45:26 -060092 // Use PIB target to determine if a processor is enabled
Ben Tyner5e622d82020-09-11 10:10:24 -050093 char path[16];
Ben Tynerb83c8522020-11-20 10:45:26 -060094 sprintf(path, "/proc%d/pib", proc);
Ben Tyner8882c322021-02-05 12:13:21 -060095 pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050096
Ben Tynerb83c8522020-11-20 10:45:26 -060097 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -060098 if (nullptr == pibTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -060099 {
100 trace<level::INFO>("pib path or target not found");
101 continue;
102 }
103
Ben Tyner8882c322021-02-05 12:13:21 -0600104 // check if pib target is enabled
105 if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget))
Ben Tyneref320152020-01-09 10:31:23 -0600106 {
Ben Tynerb83c8522020-11-20 10:45:26 -0600107 // The processor FSI target is required for CFAM read
108 sprintf(path, "/proc%d/fsi", proc);
Ben Tyner8882c322021-02-05 12:13:21 -0600109 pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb83c8522020-11-20 10:45:26 -0600110
111 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -0600112 if (nullptr == fsiTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -0600113 {
114 trace<level::INFO>("fsi path or target not found");
115 continue;
116 }
117
Ben Tyner8882c322021-02-05 12:13:21 -0600118 // trace the proc number
119 std::string traceMsg = "proc: " + std::to_string(proc);
120 trace<level::INFO>(traceMsg.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600121
Ben Tyner5adc96e2020-11-20 10:54:12 -0600122 isr_val = 0xffffffff; // invalid isr value
123
Ben Tyner5e622d82020-09-11 10:10:24 -0500124 // get active attentions on processor
Ben Tyner8882c322021-02-05 12:13:21 -0600125 if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val))
Ben Tyneref320152020-01-09 10:31:23 -0600126 {
Ben Tynerfb190542020-11-06 09:27:56 -0600127 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500128 trace<level::INFO>("Error! cfam read 0x1007 FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600129 eventAttentionFail((int)AttnSection::attnHandler |
130 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600131 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600132 else if (0xffffffff == isr_val)
133 {
134 trace<level::INFO>("Error! cfam read 0x1007 INVALID");
135 continue;
136 }
Ben Tyneref320152020-01-09 10:31:23 -0600137 else
138 {
Ben Tyner8882c322021-02-05 12:13:21 -0600139 // trace isr value
140 std::stringstream ssIsr;
141 ssIsr << "cfam 0x1007 = 0x" << std::setw(8)
142 << std::setfill('0') << std::hex << isr_val;
143 std::string strobjIsr = ssIsr.str();
144 trace<level::INFO>(strobjIsr.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600145
Ben Tyner5adc96e2020-11-20 10:54:12 -0600146 isr_mask = 0xffffffff; // invalid isr mask
147
Ben Tyner5e622d82020-09-11 10:10:24 -0500148 // get interrupt enabled special attentions mask
Ben Tyner8882c322021-02-05 12:13:21 -0600149 if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask))
Ben Tyneref320152020-01-09 10:31:23 -0600150 {
Ben Tynerfb190542020-11-06 09:27:56 -0600151 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500152 trace<level::INFO>("Error! cfam read 0x100d FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600153 eventAttentionFail((int)AttnSection::attnHandler |
154 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600155 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600156 else if (0xffffffff == isr_mask)
157 {
158 trace<level::INFO>("Error! cfam read 0x100d INVALID");
159 continue;
160 }
Ben Tyner5e622d82020-09-11 10:10:24 -0500161 else
162 {
Ben Tyner8882c322021-02-05 12:13:21 -0600163 // trace true mask
164 std::stringstream ssMask;
165 ssMask << "cfam 0x100d = 0x" << std::setw(8)
166 << std::setfill('0') << std::hex << isr_mask;
167 std::string strobjMask = ssMask.str();
168 trace<level::INFO>(strobjMask.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600169
Ben Tynerfb190542020-11-06 09:27:56 -0600170 // SBE vital attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600171 if (true == activeAttn(isr_val, isr_mask, SBE_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500172 {
173 active_attentions.emplace_back(Attention::Vital,
174 handleVital, target,
175 i_config);
176 }
177
Ben Tynerfb190542020-11-06 09:27:56 -0600178 // Checkstop attention active and not masked?
179 if (true ==
Ben Tyner1965e502020-11-20 10:32:24 -0600180 activeAttn(isr_val, isr_mask, CHECKSTOP_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500181 {
182 active_attentions.emplace_back(Attention::Checkstop,
183 handleCheckstop,
184 target, i_config);
185 }
186
Ben Tynerfb190542020-11-06 09:27:56 -0600187 // Special attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600188 if (true == activeAttn(isr_val, isr_mask, SPECIAL_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500189 {
190 active_attentions.emplace_back(Attention::Special,
191 handleSpecial,
192 target, i_config);
193 }
194 } // cfam 0x100d valid
195 } // cfam 0x1007 valid
Ben Tyner8882c322021-02-05 12:13:21 -0600196 } // fsi target enabled
197 } // pib target enabled
Ben Tyner5e622d82020-09-11 10:10:24 -0500198 } // next processor
Ben Tyneref320152020-01-09 10:31:23 -0600199
Ben Tynerb481d902020-03-05 10:24:23 -0600200 // convert to heap, highest priority is at front
201 if (!std::is_heap(active_attentions.begin(), active_attentions.end()))
202 {
203 std::make_heap(active_attentions.begin(), active_attentions.end());
204 }
205
206 // call the attention handler until one is handled or all were attempted
207 while (false == active_attentions.empty())
208 {
209 // handle highest priority attention, done if successful
210 if (RC_SUCCESS == active_attentions.front().handle())
211 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500212 // an attention was handled so we are done
Ben Tynerb481d902020-03-05 10:24:23 -0600213 break;
214 }
215
216 // move attention to back of vector
217 std::pop_heap(active_attentions.begin(), active_attentions.end());
218
219 // remove attention from vector
220 active_attentions.pop_back();
221 }
Ben Tyneref320152020-01-09 10:31:23 -0600222}
223
224/**
Ben Tyneref320152020-01-09 10:31:23 -0600225 * @brief Handle checkstop attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500226 *
227 * @param i_attention Attention object
228 * @return 0 indicates that the checkstop attention was successfully handled
229 * 1 indicates that the checkstop attention was NOT successfully
230 * handled.
Ben Tyneref320152020-01-09 10:31:23 -0600231 */
Ben Tynerb481d902020-03-05 10:24:23 -0600232int handleCheckstop(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600233{
Ben Tyner3fb52e52020-03-31 10:10:07 -0500234 int rc = RC_SUCCESS; // assume checkstop handled
Ben Tyneref320152020-01-09 10:31:23 -0600235
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500236 trace<level::INFO>("checkstop handler started");
237
Ben Tynerb8335562021-07-16 12:43:52 -0500238 // capture some additional data for logs/traces
239 addHbStatusRegs();
240
Ben Tyner3fb52e52020-03-31 10:10:07 -0500241 // if checkstop handling enabled, handle checkstop attention
242 if (false == (i_attention->getConfig()->getFlag(enCheckstop)))
243 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500244 trace<level::INFO>("Checkstop handling disabled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500245 }
246 else
247 {
Ben Tyner07ebb9b2021-12-01 12:16:24 -0600248 // wait for power fault handling before starting analyses
249 sleepSeconds(POWER_FAULT_WAIT);
250
Zane Shelley9fb73932020-09-15 13:34:57 -0500251 // Look for any attentions found in hardware. This will generate and
Zane Shelley7ae9c8c2020-12-02 20:10:31 -0600252 // commit a PEL if any errors are found.
Ben Tyner7029e522021-08-09 19:18:24 -0500253 DumpParameters dumpParameters;
Zane Shelleyebff0d32021-11-21 10:52:07 -0600254 auto logid = analyzer::analyzeHardware(
255 analyzer::AnalysisType::SYSTEM_CHECKSTOP, dumpParameters);
Zane Shelley611b3442021-11-19 16:02:01 -0600256 if (0 == logid)
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500257 {
Zane Shelley611b3442021-11-19 16:02:01 -0600258 // A PEL should exist for a checkstop attention.
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500259 rc = RC_ANALYZER_ERROR;
260 }
Ben Tyner7029e522021-08-09 19:18:24 -0500261 else
262 {
Zane Shelley611b3442021-11-19 16:02:01 -0600263 requestDump(logid, dumpParameters);
Ben Tyner7029e522021-08-09 19:18:24 -0500264 util::dbus::transitionHost(util::dbus::HostState::Quiesce);
265 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500266 }
Ben Tyneref320152020-01-09 10:31:23 -0600267
Ben Tyneref320152020-01-09 10:31:23 -0600268 return rc;
269}
270
271/**
272 * @brief Handle special attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500273 *
274 * @param i_attention Attention object
275 * @return 0 indicates that the special attention was successfully handled
276 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -0600277 */
Ben Tynerb481d902020-03-05 10:24:23 -0600278int handleSpecial(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600279{
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500280 int rc = RC_SUCCESS; // assume special attention handled
Ben Tyneref320152020-01-09 10:31:23 -0600281
Ben Tynerfb190542020-11-06 09:27:56 -0600282 // The TI info chipop will give us a pointer to the TI info data
Ben Tyner98430b32020-08-19 19:14:02 -0500283 uint8_t* tiInfo = nullptr; // ptr to TI info data
284 uint32_t tiInfoLen = 0; // length of TI info data
285 pdbg_target* attnProc = i_attention->getTarget(); // proc with attention
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500286
Ben Tyner29651ef2021-02-08 10:51:03 -0600287 bool tiInfoStatic = false; // assume TI info was provided (not created)
288
Ben Tynerb9715172021-09-29 08:46:19 -0500289 // need proc target to get dynamic TI info
290 if (nullptr != attnProc)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500291 {
Ben Tynerb9715172021-09-29 08:46:19 -0500292#ifdef CONFIG_PHAL_API
293 trace<level::INFO>("using libphal to get TI info");
294
295 // phal library uses proc target for get ti info
296 if (PDBG_TARGET_ENABLED == pdbg_target_probe(attnProc))
297 {
298 try
299 {
300 // get dynamic TI info
301 openpower::phal::sbe::getTiInfo(attnProc, &tiInfo, &tiInfoLen);
302 }
Ben Tyner76e52f62022-02-01 10:46:44 -0600303 catch (openpower::phal::exception::SbeError& sbeError)
Ben Tynerb9715172021-09-29 08:46:19 -0500304 {
305 // library threw an exception
Ben Tyner76e52f62022-02-01 10:46:44 -0600306 // note: phal::sbe::getTiInfo = command class | command ==
307 // 0xa900 | 0x04 = 0xa904. The sbe fifo command class and
308 // commands are defined in the sbefifo library source code but
309 // do not seem to be exported/installed for consumption
310 // externally.
Ben Tynerb9715172021-09-29 08:46:19 -0500311 uint32_t procNum = pdbg_target_index(attnProc);
Ben Tyner76e52f62022-02-01 10:46:44 -0600312 phalSbeExceptionHandler(sbeError, procNum, 0xa904);
Ben Tynerb9715172021-09-29 08:46:19 -0500313 }
314 }
315#else
316 trace<level::INFO>("using libpdbg to get TI info");
317
318 // pdbg library uses pib target for get ti info
Ben Tyner98430b32020-08-19 19:14:02 -0500319 char path[16];
320 sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc));
321 pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path);
322
323 if (nullptr != tiInfoTarget)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500324 {
Ben Tyner98430b32020-08-19 19:14:02 -0500325 if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget))
326 {
Ben Tyner98430b32020-08-19 19:14:02 -0500327 sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen);
Ben Tyner98430b32020-08-19 19:14:02 -0500328 }
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500329 }
Ben Tynerb9715172021-09-29 08:46:19 -0500330#endif
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500331 }
Ben Tyneref320152020-01-09 10:31:23 -0600332
Ben Tynerb9715172021-09-29 08:46:19 -0500333 // dynamic TI info is not available
334 if (nullptr == tiInfo)
Ben Tyner970fd4f2020-02-19 13:46:42 -0600335 {
Ben Tynerb9715172021-09-29 08:46:19 -0500336 trace<level::INFO>("TI info data ptr is invalid");
337 getStaticTiInfo(tiInfo);
338 tiInfoStatic = true;
Ben Tyner3fb52e52020-03-31 10:10:07 -0500339 }
Ben Tyner0fe5df42020-12-03 08:57:17 -0600340
Ben Tynerb9715172021-09-29 08:46:19 -0500341 // check TI info for validity and handle
342 if (true == tiInfoValid(tiInfo))
343 {
344 // TI info is valid handle TI if support enabled
345 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
346 {
347 // Call TI special attention handler
348 rc = tiHandler((TiDataArea*)tiInfo);
349 }
350 }
351 else
Ben Tyner3fb52e52020-03-31 10:10:07 -0500352 {
Ben Tynerfe156492021-04-08 07:28:13 -0500353 trace<level::INFO>("TI info NOT valid");
Ben Tyner98430b32020-08-19 19:14:02 -0500354
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500355 // if configured to handle TI as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500356 if (i_attention->getConfig()->getFlag(dfltTi))
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500357 {
Ben Tynerfe156492021-04-08 07:28:13 -0500358 // TI handling may be disabled
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500359 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
360 {
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500361 // Call TI special attention handler
Ben Tynerb9715172021-09-29 08:46:19 -0500362 rc = tiHandler((TiDataArea*)tiInfo);
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500363 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500364 }
Ben Tynerb9715172021-09-29 08:46:19 -0500365 // configured to handle breakpoint as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500366 else
367 {
368 // breakpoint handling may be disabled
369 if (true == (i_attention->getConfig()->getFlag(enBreakpoints)))
370 {
371 // Call the breakpoint special attention handler
372 rc = bpHandler();
373 }
374 }
Ben Tyner970fd4f2020-02-19 13:46:42 -0600375 }
Ben Tyneref320152020-01-09 10:31:23 -0600376
Ben Tynerb9715172021-09-29 08:46:19 -0500377 // release TI data buffer if not ours
378 if (false == tiInfoStatic)
Ben Tyner792f32f2020-06-02 08:50:47 -0500379 {
Ben Tynerb9715172021-09-29 08:46:19 -0500380 // sanity check
381 if (nullptr != tiInfo)
382 {
383 free(tiInfo);
384 }
Ben Tyner792f32f2020-06-02 08:50:47 -0500385 }
386
Ben Tynerb9715172021-09-29 08:46:19 -0500387 // trace non-successful exit condition
Ben Tyner3fb52e52020-03-31 10:10:07 -0500388 if (RC_SUCCESS != rc)
389 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500390 trace<level::INFO>("Special attn not handled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500391 }
Ben Tyneref320152020-01-09 10:31:23 -0600392
393 return rc;
394}
395
Ben Tynerfb190542020-11-06 09:27:56 -0600396/**
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 Tyner1965e502020-11-20 10:32:24 -0600409bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn)
Ben Tynerfb190542020-11-06 09:27:56 -0600410{
Zane Shelley9fb657f2021-01-12 15:30:58 -0600411 bool rc = false; // assume attn masked and/or inactive
Ben Tynerfb190542020-11-06 09:27:56 -0600412
413 // if attention active
414 if (0 != (i_val & i_attn))
415 {
Ben Tynerfb190542020-11-06 09:27:56 -0600416 std::stringstream ss;
Ben Tynerfb190542020-11-06 09:27:56 -0600417
Zane Shelley9fb657f2021-01-12 15:30:58 -0600418 bool validAttn = true; // known attention type
419
Ben Tynerfb190542020-11-06 09:27:56 -0600420 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 Tyner8882c322021-02-05 12:13:21 -0600449 std::string strobj = ss.str(); // ss.str() is temporary
450 trace<level::INFO>(strobj.c_str()); // commit trace stream
Ben Tynerfb190542020-11-06 09:27:56 -0600451 }
452
453 return rc;
454}
Ben Tynerb9715172021-09-29 08:46:19 -0500455
456#ifdef CONFIG_PHAL_API
Ben Tyner76e52f62022-02-01 10:46:44 -0600457
Ben Tynerb9715172021-09-29 08:46:19 -0500458/**
459 * @brief Handle phal sbe exception
460 *
461 * @param[in] e - exception object
462 * @param[in] procNum - processor number associated with sbe exception
463 */
Ben Tyner76e52f62022-02-01 10:46:44 -0600464void phalSbeExceptionHandler(openpower::phal::exception::SbeError& sbeError,
465 uint32_t chipPosition, uint32_t command)
Ben Tynerb9715172021-09-29 08:46:19 -0500466{
Ben Tyner76e52f62022-02-01 10:46:44 -0600467 trace::err("Attention handler phal exception handler");
Ben Tynerb9715172021-09-29 08:46:19 -0500468
Ben Tyner76e52f62022-02-01 10:46:44 -0600469 // Trace exception details
470 trace::err(sbeError.what());
471
472 // Create event log entry with SBE FFDC data if provided
473 auto fd = sbeError.getFd();
474 if (fd > 0)
Ben Tynerb9715172021-09-29 08:46:19 -0500475 {
Ben Tyner76e52f62022-02-01 10:46:44 -0600476 trace::err("SBE FFDC data is available");
477
478 // FFDC parser expects chip position and command (command class |
479 // command) to be in the additional data.
480 std::map<std::string, std::string> additionalData = {
481 {"SRC6", std::to_string((chipPosition << 16) | command)}};
482
483 // See phosphor-logging/extensions/openpower-pels/README.md, "Self Boot
484 // Engine(SBE) First Failure Data Capture(FFDC)" - SBE FFDC file type
485 // is 0xCB, version is 0x01.
486 std::vector<util::FFDCTuple> ffdc{util::FFDCTuple{
487 util::FFDCFormat::Custom, static_cast<uint8_t>(0xCB),
488 static_cast<uint8_t>(0x01), fd}};
489
490 // Create event log entry with FFDC data
491 createPel("org.open_power.Processor.Error.SbeChipOpFailure",
492 additionalData, ffdc);
Ben Tynerb9715172021-09-29 08:46:19 -0500493 }
494}
495#endif
496
497/**
498 * @brief Get static TI info data based on host state
499 *
500 * @param[out] tiInfo - pointer to static TI info data
501 */
502void getStaticTiInfo(uint8_t*& tiInfo)
503{
504 util::dbus::HostRunningState runningState = util::dbus::hostRunningState();
505
506 // assume host state is unknown
507 std::string stateString = "host state unknown";
508
509 if ((util::dbus::HostRunningState::Started == runningState) ||
510 (util::dbus::HostRunningState::Unknown == runningState))
511 {
512 if (util::dbus::HostRunningState::Started == runningState)
513 {
514 stateString = "host started";
515 }
516 tiInfo = (uint8_t*)defaultPhypTiInfo;
517 }
518 else
519 {
520 stateString = "host not started";
521 tiInfo = (uint8_t*)defaultHbTiInfo;
522 }
523
524 // trace host state
525 trace<level::INFO>(stateString.c_str());
526}
527
528/**
529 * @brief Check if TI info data is valid
530 *
531 * @param[in] tiInfo - pointer to TI info data
532 * @return true if TI info data is valid, else false
533 */
534bool tiInfoValid(uint8_t* tiInfo)
535{
536 bool tiInfoValid = false; // assume TI info invalid
537
538 // TI info data[0] non-zero indicates TI info valid (usually)
539 if ((nullptr != tiInfo) && (0 != tiInfo[0]))
540 {
541 TiDataArea* tiDataArea = (TiDataArea*)tiInfo;
542
543 std::stringstream ss; // string stream object for tracing
544 std::string strobj; // string object for tracing
545
546 // trace a few known TI data area values
547 ss.str(std::string()); // empty the stream
548 ss.clear(); // clear the stream
549 ss << "TI data command = 0x" << std::setw(2) << std::setfill('0')
550 << std::hex << (int)tiDataArea->command;
551 strobj = ss.str();
552 trace<level::INFO>(strobj.c_str());
553
554 // Another check for valid TI Info since it has been seen that
555 // tiInfo[0] != 0 but TI info is not valid
556 if (0xa1 == tiDataArea->command)
557 {
558 tiInfoValid = true;
559
560 // trace some more data since TI info appears valid
561 ss.str(std::string()); // empty the stream
562 ss.clear(); // clear the stream
563 ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0')
564 << std::hex << (int)tiDataArea->hbTerminateType;
565 strobj = ss.str();
566 trace<level::INFO>(strobj.c_str());
567
568 ss.str(std::string()); // empty the stream
569 ss.clear(); // clear the stream
570 ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0')
571 << std::hex << (int)tiDataArea->srcFormat;
572 strobj = ss.str();
573 trace<level::INFO>(strobj.c_str());
574
575 ss.str(std::string()); // empty the stream
576 ss.clear(); // clear the stream
577 ss << "TI data source = 0x" << std::setw(2) << std::setfill('0')
578 << std::hex << (int)tiDataArea->source;
579 strobj = ss.str();
580 trace<level::INFO>(strobj.c_str());
581 }
582 }
583
584 return tiInfoValid;
585}
586
Ben Tyneref320152020-01-09 10:31:23 -0600587} // namespace attn