blob: 67390d8ab584b150446b129a71c8af44059e774d [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 Tyneref320152020-01-09 10:31:23 -060024
Ben Tynerb481d902020-03-05 10:24:23 -060025#include <algorithm>
Ben Tyneref320152020-01-09 10:31:23 -060026#include <iomanip>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050027#include <map>
Ben Tyner9ae5ca42020-02-28 13:13:50 -060028#include <sstream>
Ben Tynerb481d902020-03-05 10:24:23 -060029#include <vector>
Ben Tyneref320152020-01-09 10:31:23 -060030
31namespace attn
32{
33
34/**
Ben Tyneref320152020-01-09 10:31:23 -060035 * @brief Handle checkstop attention
36 *
Ben Tynerb481d902020-03-05 10:24:23 -060037 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050038 * @return 0 indicates that the checkstop attention was successfully handled
39 * 1 indicates that the checkstop attention was NOT successfully
40 * handled.
Ben Tyneref320152020-01-09 10:31:23 -060041 */
Ben Tynerb481d902020-03-05 10:24:23 -060042int handleCheckstop(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060043
44/**
45 * @brief Handle special attention
46 *
Ben Tynerb481d902020-03-05 10:24:23 -060047 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050048 * @return 0 indicates that the special attention was successfully handled
49 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -060050 */
Ben Tynerb481d902020-03-05 10:24:23 -060051int handleSpecial(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060052
Ben Tynerfb190542020-11-06 09:27:56 -060053/** @brief Determine if attention is active and not masked */
Ben Tyner1965e502020-11-20 10:32:24 -060054bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn);
Ben Tynerfb190542020-11-06 09:27:56 -060055
Ben Tynerb9715172021-09-29 08:46:19 -050056#ifdef CONFIG_PHAL_API
57/** @brief Handle phal sbe exception */
58void phalSbeExceptionHandler(openpower::phal::exception::SbeError& e,
59 uint32_t procNum);
60#endif
61
62/** @brief Get static TI info data based on host state */
63void getStaticTiInfo(uint8_t*& tiInfoPtr);
64
65/** @brief Check if TI info data is valid */
66bool tiInfoValid(uint8_t* tiInfo);
67
Ben Tyneref320152020-01-09 10:31:23 -060068/**
Ben Tyneref320152020-01-09 10:31:23 -060069 * @brief The main attention handler logic
Ben Tyner970fd4f2020-02-19 13:46:42 -060070 *
71 * @param i_breakpoints true = breakpoint special attn handling enabled
Ben Tyneref320152020-01-09 10:31:23 -060072 */
Ben Tyner3fb52e52020-03-31 10:10:07 -050073void attnHandler(Config* i_config)
Ben Tyneref320152020-01-09 10:31:23 -060074{
Ben Tynerb481d902020-03-05 10:24:23 -060075 // Vector of active attentions to be handled
76 std::vector<Attention> active_attentions;
77
Ben Tyneref320152020-01-09 10:31:23 -060078 uint32_t isr_val, isr_mask;
Ben Tyneref320152020-01-09 10:31:23 -060079
80 // loop through processors looking for active attentions
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050081 trace<level::INFO>("Attention handler started");
Ben Tyner117af992020-05-22 13:32:11 -050082
Ben Tyneref320152020-01-09 10:31:23 -060083 pdbg_target* target;
Ben Tyner5e622d82020-09-11 10:10:24 -050084 pdbg_for_each_class_target("proc", target)
Ben Tyneref320152020-01-09 10:31:23 -060085 {
86 if (PDBG_TARGET_ENABLED == pdbg_target_probe(target))
87 {
Zane Shelleya79f6c82021-01-12 16:38:49 -060088 auto proc = pdbg_target_index(target); // get processor number
Ben Tyneref320152020-01-09 10:31:23 -060089
Ben Tynerb83c8522020-11-20 10:45:26 -060090 // Use PIB target to determine if a processor is enabled
Ben Tyner5e622d82020-09-11 10:10:24 -050091 char path[16];
Ben Tynerb83c8522020-11-20 10:45:26 -060092 sprintf(path, "/proc%d/pib", proc);
Ben Tyner8882c322021-02-05 12:13:21 -060093 pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050094
Ben Tynerb83c8522020-11-20 10:45:26 -060095 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -060096 if (nullptr == pibTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -060097 {
98 trace<level::INFO>("pib path or target not found");
99 continue;
100 }
101
Ben Tyner8882c322021-02-05 12:13:21 -0600102 // check if pib target is enabled
103 if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget))
Ben Tyneref320152020-01-09 10:31:23 -0600104 {
Ben Tynerb83c8522020-11-20 10:45:26 -0600105 // The processor FSI target is required for CFAM read
106 sprintf(path, "/proc%d/fsi", proc);
Ben Tyner8882c322021-02-05 12:13:21 -0600107 pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb83c8522020-11-20 10:45:26 -0600108
109 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -0600110 if (nullptr == fsiTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -0600111 {
112 trace<level::INFO>("fsi path or target not found");
113 continue;
114 }
115
Ben Tyner8882c322021-02-05 12:13:21 -0600116 // trace the proc number
117 std::string traceMsg = "proc: " + std::to_string(proc);
118 trace<level::INFO>(traceMsg.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600119
Ben Tyner5adc96e2020-11-20 10:54:12 -0600120 isr_val = 0xffffffff; // invalid isr value
121
Ben Tyner5e622d82020-09-11 10:10:24 -0500122 // get active attentions on processor
Ben Tyner8882c322021-02-05 12:13:21 -0600123 if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val))
Ben Tyneref320152020-01-09 10:31:23 -0600124 {
Ben Tynerfb190542020-11-06 09:27:56 -0600125 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500126 trace<level::INFO>("Error! cfam read 0x1007 FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600127 eventAttentionFail((int)AttnSection::attnHandler |
128 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600129 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600130 else if (0xffffffff == isr_val)
131 {
132 trace<level::INFO>("Error! cfam read 0x1007 INVALID");
133 continue;
134 }
Ben Tyneref320152020-01-09 10:31:23 -0600135 else
136 {
Ben Tyner8882c322021-02-05 12:13:21 -0600137 // trace isr value
138 std::stringstream ssIsr;
139 ssIsr << "cfam 0x1007 = 0x" << std::setw(8)
140 << std::setfill('0') << std::hex << isr_val;
141 std::string strobjIsr = ssIsr.str();
142 trace<level::INFO>(strobjIsr.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600143
Ben Tyner5adc96e2020-11-20 10:54:12 -0600144 isr_mask = 0xffffffff; // invalid isr mask
145
Ben Tyner5e622d82020-09-11 10:10:24 -0500146 // get interrupt enabled special attentions mask
Ben Tyner8882c322021-02-05 12:13:21 -0600147 if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask))
Ben Tyneref320152020-01-09 10:31:23 -0600148 {
Ben Tynerfb190542020-11-06 09:27:56 -0600149 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500150 trace<level::INFO>("Error! cfam read 0x100d FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600151 eventAttentionFail((int)AttnSection::attnHandler |
152 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600153 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600154 else if (0xffffffff == isr_mask)
155 {
156 trace<level::INFO>("Error! cfam read 0x100d INVALID");
157 continue;
158 }
Ben Tyner5e622d82020-09-11 10:10:24 -0500159 else
160 {
Ben Tyner8882c322021-02-05 12:13:21 -0600161 // trace true mask
162 std::stringstream ssMask;
163 ssMask << "cfam 0x100d = 0x" << std::setw(8)
164 << std::setfill('0') << std::hex << isr_mask;
165 std::string strobjMask = ssMask.str();
166 trace<level::INFO>(strobjMask.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600167
Ben Tynerfb190542020-11-06 09:27:56 -0600168 // SBE vital attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600169 if (true == activeAttn(isr_val, isr_mask, SBE_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500170 {
171 active_attentions.emplace_back(Attention::Vital,
172 handleVital, target,
173 i_config);
174 }
175
Ben Tynerfb190542020-11-06 09:27:56 -0600176 // Checkstop attention active and not masked?
177 if (true ==
Ben Tyner1965e502020-11-20 10:32:24 -0600178 activeAttn(isr_val, isr_mask, CHECKSTOP_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500179 {
180 active_attentions.emplace_back(Attention::Checkstop,
181 handleCheckstop,
182 target, i_config);
183 }
184
Ben Tynerfb190542020-11-06 09:27:56 -0600185 // Special attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600186 if (true == activeAttn(isr_val, isr_mask, SPECIAL_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500187 {
188 active_attentions.emplace_back(Attention::Special,
189 handleSpecial,
190 target, i_config);
191 }
192 } // cfam 0x100d valid
193 } // cfam 0x1007 valid
Ben Tyner8882c322021-02-05 12:13:21 -0600194 } // fsi target enabled
195 } // pib target enabled
Ben Tyner5e622d82020-09-11 10:10:24 -0500196 } // next processor
Ben Tyneref320152020-01-09 10:31:23 -0600197
Ben Tynerb481d902020-03-05 10:24:23 -0600198 // convert to heap, highest priority is at front
199 if (!std::is_heap(active_attentions.begin(), active_attentions.end()))
200 {
201 std::make_heap(active_attentions.begin(), active_attentions.end());
202 }
203
204 // call the attention handler until one is handled or all were attempted
205 while (false == active_attentions.empty())
206 {
207 // handle highest priority attention, done if successful
208 if (RC_SUCCESS == active_attentions.front().handle())
209 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500210 // an attention was handled so we are done
Ben Tynerb481d902020-03-05 10:24:23 -0600211 break;
212 }
213
214 // move attention to back of vector
215 std::pop_heap(active_attentions.begin(), active_attentions.end());
216
217 // remove attention from vector
218 active_attentions.pop_back();
219 }
Ben Tyneref320152020-01-09 10:31:23 -0600220}
221
222/**
Ben Tyneref320152020-01-09 10:31:23 -0600223 * @brief Handle checkstop attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500224 *
225 * @param i_attention Attention object
226 * @return 0 indicates that the checkstop attention was successfully handled
227 * 1 indicates that the checkstop attention was NOT successfully
228 * handled.
Ben Tyneref320152020-01-09 10:31:23 -0600229 */
Ben Tynerb481d902020-03-05 10:24:23 -0600230int handleCheckstop(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600231{
Ben Tyner3fb52e52020-03-31 10:10:07 -0500232 int rc = RC_SUCCESS; // assume checkstop handled
Ben Tyneref320152020-01-09 10:31:23 -0600233
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500234 trace<level::INFO>("checkstop handler started");
235
Ben Tynerb8335562021-07-16 12:43:52 -0500236 // capture some additional data for logs/traces
237 addHbStatusRegs();
238
Ben Tyner3fb52e52020-03-31 10:10:07 -0500239 // if checkstop handling enabled, handle checkstop attention
240 if (false == (i_attention->getConfig()->getFlag(enCheckstop)))
241 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500242 trace<level::INFO>("Checkstop handling disabled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500243 }
244 else
245 {
Zane Shelley9fb73932020-09-15 13:34:57 -0500246 // Look for any attentions found in hardware. This will generate and
Zane Shelley7ae9c8c2020-12-02 20:10:31 -0600247 // commit a PEL if any errors are found.
Ben Tyner7029e522021-08-09 19:18:24 -0500248 DumpParameters dumpParameters;
249 if (true != analyzer::analyzeHardware(dumpParameters))
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500250 {
251 rc = RC_ANALYZER_ERROR;
252 }
Ben Tyner7029e522021-08-09 19:18:24 -0500253 else
254 {
255 requestDump(dumpParameters);
256 util::dbus::transitionHost(util::dbus::HostState::Quiesce);
257 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500258 }
Ben Tyneref320152020-01-09 10:31:23 -0600259
Ben Tyneref320152020-01-09 10:31:23 -0600260 return rc;
261}
262
263/**
264 * @brief Handle special attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500265 *
266 * @param i_attention Attention object
267 * @return 0 indicates that the special attention was successfully handled
268 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -0600269 */
Ben Tynerb481d902020-03-05 10:24:23 -0600270int handleSpecial(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600271{
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500272 int rc = RC_SUCCESS; // assume special attention handled
Ben Tyneref320152020-01-09 10:31:23 -0600273
Ben Tynerfb190542020-11-06 09:27:56 -0600274 // The TI info chipop will give us a pointer to the TI info data
Ben Tyner98430b32020-08-19 19:14:02 -0500275 uint8_t* tiInfo = nullptr; // ptr to TI info data
276 uint32_t tiInfoLen = 0; // length of TI info data
277 pdbg_target* attnProc = i_attention->getTarget(); // proc with attention
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500278
Ben Tyner29651ef2021-02-08 10:51:03 -0600279 bool tiInfoStatic = false; // assume TI info was provided (not created)
280
Ben Tynerb9715172021-09-29 08:46:19 -0500281 // need proc target to get dynamic TI info
282 if (nullptr != attnProc)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500283 {
Ben Tynerb9715172021-09-29 08:46:19 -0500284#ifdef CONFIG_PHAL_API
285 trace<level::INFO>("using libphal to get TI info");
286
287 // phal library uses proc target for get ti info
288 if (PDBG_TARGET_ENABLED == pdbg_target_probe(attnProc))
289 {
290 try
291 {
292 // get dynamic TI info
293 openpower::phal::sbe::getTiInfo(attnProc, &tiInfo, &tiInfoLen);
294 }
295 catch (openpower::phal::exception::SbeError& e)
296 {
297 // library threw an exception
298 uint32_t procNum = pdbg_target_index(attnProc);
299 phalSbeExceptionHandler(e, procNum);
300 }
301 }
302#else
303 trace<level::INFO>("using libpdbg to get TI info");
304
305 // pdbg library uses pib target for get ti info
Ben Tyner98430b32020-08-19 19:14:02 -0500306 char path[16];
307 sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc));
308 pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path);
309
310 if (nullptr != tiInfoTarget)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500311 {
Ben Tyner98430b32020-08-19 19:14:02 -0500312 if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget))
313 {
Ben Tyner98430b32020-08-19 19:14:02 -0500314 sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen);
Ben Tyner98430b32020-08-19 19:14:02 -0500315 }
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500316 }
Ben Tynerb9715172021-09-29 08:46:19 -0500317#endif
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500318 }
Ben Tyneref320152020-01-09 10:31:23 -0600319
Ben Tynerb9715172021-09-29 08:46:19 -0500320 // dynamic TI info is not available
321 if (nullptr == tiInfo)
Ben Tyner970fd4f2020-02-19 13:46:42 -0600322 {
Ben Tynerb9715172021-09-29 08:46:19 -0500323 trace<level::INFO>("TI info data ptr is invalid");
324 getStaticTiInfo(tiInfo);
325 tiInfoStatic = true;
Ben Tyner3fb52e52020-03-31 10:10:07 -0500326 }
Ben Tyner0fe5df42020-12-03 08:57:17 -0600327
Ben Tynerb9715172021-09-29 08:46:19 -0500328 // check TI info for validity and handle
329 if (true == tiInfoValid(tiInfo))
330 {
331 // TI info is valid handle TI if support enabled
332 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
333 {
334 // Call TI special attention handler
335 rc = tiHandler((TiDataArea*)tiInfo);
336 }
337 }
338 else
Ben Tyner3fb52e52020-03-31 10:10:07 -0500339 {
Ben Tynerfe156492021-04-08 07:28:13 -0500340 trace<level::INFO>("TI info NOT valid");
Ben Tyner98430b32020-08-19 19:14:02 -0500341
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500342 // if configured to handle TI as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500343 if (i_attention->getConfig()->getFlag(dfltTi))
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500344 {
Ben Tynerfe156492021-04-08 07:28:13 -0500345 // TI handling may be disabled
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500346 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
347 {
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500348 // Call TI special attention handler
Ben Tynerb9715172021-09-29 08:46:19 -0500349 rc = tiHandler((TiDataArea*)tiInfo);
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500350 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500351 }
Ben Tynerb9715172021-09-29 08:46:19 -0500352 // configured to handle breakpoint as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500353 else
354 {
355 // breakpoint handling may be disabled
356 if (true == (i_attention->getConfig()->getFlag(enBreakpoints)))
357 {
358 // Call the breakpoint special attention handler
359 rc = bpHandler();
360 }
361 }
Ben Tyner970fd4f2020-02-19 13:46:42 -0600362 }
Ben Tyneref320152020-01-09 10:31:23 -0600363
Ben Tynerb9715172021-09-29 08:46:19 -0500364 // release TI data buffer if not ours
365 if (false == tiInfoStatic)
Ben Tyner792f32f2020-06-02 08:50:47 -0500366 {
Ben Tynerb9715172021-09-29 08:46:19 -0500367 // sanity check
368 if (nullptr != tiInfo)
369 {
370 free(tiInfo);
371 }
Ben Tyner792f32f2020-06-02 08:50:47 -0500372 }
373
Ben Tynerb9715172021-09-29 08:46:19 -0500374 // trace non-successful exit condition
Ben Tyner3fb52e52020-03-31 10:10:07 -0500375 if (RC_SUCCESS != rc)
376 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500377 trace<level::INFO>("Special attn not handled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500378 }
Ben Tyneref320152020-01-09 10:31:23 -0600379
380 return rc;
381}
382
Ben Tynerfb190542020-11-06 09:27:56 -0600383/**
384 * @brief Determine if attention is active and not masked
385 *
386 * Determine whether an attention needs to be handled and trace details of
387 * attention type and whether it is masked or not.
388 *
389 * @param i_val attention status register
390 * @param i_mask attention true mask register
391 * @param i_attn attention type
392 * @param i_proc processor associated with registers
393 *
394 * @return true if attention is active and not masked, otherwise false
395 */
Ben Tyner1965e502020-11-20 10:32:24 -0600396bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn)
Ben Tynerfb190542020-11-06 09:27:56 -0600397{
Zane Shelley9fb657f2021-01-12 15:30:58 -0600398 bool rc = false; // assume attn masked and/or inactive
Ben Tynerfb190542020-11-06 09:27:56 -0600399
400 // if attention active
401 if (0 != (i_val & i_attn))
402 {
Ben Tynerfb190542020-11-06 09:27:56 -0600403 std::stringstream ss;
Ben Tynerfb190542020-11-06 09:27:56 -0600404
Zane Shelley9fb657f2021-01-12 15:30:58 -0600405 bool validAttn = true; // known attention type
406
Ben Tynerfb190542020-11-06 09:27:56 -0600407 switch (i_attn)
408 {
409 case SBE_ATTN:
410 ss << "SBE attn";
411 break;
412 case CHECKSTOP_ATTN:
413 ss << "Checkstop attn";
414 break;
415 case SPECIAL_ATTN:
416 ss << "Special attn";
417 break;
418 default:
419 ss << "Unknown attn";
420 validAttn = false;
421 }
422
423 // see if attention is masked
424 if (true == validAttn)
425 {
426 if (0 != (i_mask & i_attn))
427 {
428 rc = true; // attention active and not masked
429 }
430 else
431 {
432 ss << " masked";
433 }
434 }
435
Ben Tyner8882c322021-02-05 12:13:21 -0600436 std::string strobj = ss.str(); // ss.str() is temporary
437 trace<level::INFO>(strobj.c_str()); // commit trace stream
Ben Tynerfb190542020-11-06 09:27:56 -0600438 }
439
440 return rc;
441}
Ben Tynerb9715172021-09-29 08:46:19 -0500442
443#ifdef CONFIG_PHAL_API
444/**
445 * @brief Handle phal sbe exception
446 *
447 * @param[in] e - exception object
448 * @param[in] procNum - processor number associated with sbe exception
449 */
450void phalSbeExceptionHandler(openpower::phal::exception::SbeError& e,
451 uint32_t procNum)
452{
453 // trace exception details
454 std::string traceMsg = std::string(e.what());
455 trace<level::ERROR>(traceMsg.c_str());
456
457 // Handle SBE chipop timeout error
458 if (e.errType() == openpower::phal::exception::SBE_CHIPOP_NOT_ALLOWED)
459 {
460 eventPhalSbeChipop(procNum);
461 }
462}
463#endif
464
465/**
466 * @brief Get static TI info data based on host state
467 *
468 * @param[out] tiInfo - pointer to static TI info data
469 */
470void getStaticTiInfo(uint8_t*& tiInfo)
471{
472 util::dbus::HostRunningState runningState = util::dbus::hostRunningState();
473
474 // assume host state is unknown
475 std::string stateString = "host state unknown";
476
477 if ((util::dbus::HostRunningState::Started == runningState) ||
478 (util::dbus::HostRunningState::Unknown == runningState))
479 {
480 if (util::dbus::HostRunningState::Started == runningState)
481 {
482 stateString = "host started";
483 }
484 tiInfo = (uint8_t*)defaultPhypTiInfo;
485 }
486 else
487 {
488 stateString = "host not started";
489 tiInfo = (uint8_t*)defaultHbTiInfo;
490 }
491
492 // trace host state
493 trace<level::INFO>(stateString.c_str());
494}
495
496/**
497 * @brief Check if TI info data is valid
498 *
499 * @param[in] tiInfo - pointer to TI info data
500 * @return true if TI info data is valid, else false
501 */
502bool tiInfoValid(uint8_t* tiInfo)
503{
504 bool tiInfoValid = false; // assume TI info invalid
505
506 // TI info data[0] non-zero indicates TI info valid (usually)
507 if ((nullptr != tiInfo) && (0 != tiInfo[0]))
508 {
509 TiDataArea* tiDataArea = (TiDataArea*)tiInfo;
510
511 std::stringstream ss; // string stream object for tracing
512 std::string strobj; // string object for tracing
513
514 // trace a few known TI data area values
515 ss.str(std::string()); // empty the stream
516 ss.clear(); // clear the stream
517 ss << "TI data command = 0x" << std::setw(2) << std::setfill('0')
518 << std::hex << (int)tiDataArea->command;
519 strobj = ss.str();
520 trace<level::INFO>(strobj.c_str());
521
522 // Another check for valid TI Info since it has been seen that
523 // tiInfo[0] != 0 but TI info is not valid
524 if (0xa1 == tiDataArea->command)
525 {
526 tiInfoValid = true;
527
528 // trace some more data since TI info appears valid
529 ss.str(std::string()); // empty the stream
530 ss.clear(); // clear the stream
531 ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0')
532 << std::hex << (int)tiDataArea->hbTerminateType;
533 strobj = ss.str();
534 trace<level::INFO>(strobj.c_str());
535
536 ss.str(std::string()); // empty the stream
537 ss.clear(); // clear the stream
538 ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0')
539 << std::hex << (int)tiDataArea->srcFormat;
540 strobj = ss.str();
541 trace<level::INFO>(strobj.c_str());
542
543 ss.str(std::string()); // empty the stream
544 ss.clear(); // clear the stream
545 ss << "TI data source = 0x" << std::setw(2) << std::setfill('0')
546 << std::hex << (int)tiDataArea->source;
547 strobj = ss.str();
548 trace<level::INFO>(strobj.c_str());
549 }
550 }
551
552 return tiInfoValid;
553}
554
Ben Tyneref320152020-01-09 10:31:23 -0600555} // namespace attn