blob: 718828a5e1f5942fb6006f491df445dd4932508c [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
Ben Tynerb9715172021-09-29 08:46:19 -05007#ifdef CONFIG_PHAL_API
8#include <libphal.H>
9#endif
10
Ben Tyner0205f3b2020-02-24 10:24:47 -060011#include <analyzer/analyzer_main.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -050012#include <attn/attention.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -060013#include <attn/attn_common.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -050014#include <attn/attn_config.hpp>
Ben Tyner4bbcb382021-02-22 09:29:00 -060015#include <attn/attn_dbus.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -050016#include <attn/attn_handler.hpp>
17#include <attn/attn_logging.hpp>
18#include <attn/bp_handler.hpp>
19#include <attn/ti_handler.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -060020#include <attn/vital_handler.hpp>
Ben Tynerfe2c50d2021-07-23 13:38:53 -050021#include <util/dbus.hpp>
Ben Tyneref320152020-01-09 10:31:23 -060022
Ben Tynerb481d902020-03-05 10:24:23 -060023#include <algorithm>
Ben Tyneref320152020-01-09 10:31:23 -060024#include <iomanip>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050025#include <map>
Ben Tyner9ae5ca42020-02-28 13:13:50 -060026#include <sstream>
Ben Tynerb481d902020-03-05 10:24:23 -060027#include <vector>
Ben Tyneref320152020-01-09 10:31:23 -060028
29namespace attn
30{
31
32/**
Ben Tyneref320152020-01-09 10:31:23 -060033 * @brief Handle checkstop attention
34 *
Ben Tynerb481d902020-03-05 10:24:23 -060035 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050036 * @return 0 indicates that the checkstop attention was successfully handled
37 * 1 indicates that the checkstop attention was NOT successfully
38 * handled.
Ben Tyneref320152020-01-09 10:31:23 -060039 */
Ben Tynerb481d902020-03-05 10:24:23 -060040int handleCheckstop(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060041
42/**
43 * @brief Handle special attention
44 *
Ben Tynerb481d902020-03-05 10:24:23 -060045 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050046 * @return 0 indicates that the special attention was successfully handled
47 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -060048 */
Ben Tynerb481d902020-03-05 10:24:23 -060049int handleSpecial(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060050
Ben Tynerfb190542020-11-06 09:27:56 -060051/** @brief Determine if attention is active and not masked */
Ben Tyner1965e502020-11-20 10:32:24 -060052bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn);
Ben Tynerfb190542020-11-06 09:27:56 -060053
Ben Tynerb9715172021-09-29 08:46:19 -050054#ifdef CONFIG_PHAL_API
55/** @brief Handle phal sbe exception */
56void phalSbeExceptionHandler(openpower::phal::exception::SbeError& e,
57 uint32_t procNum);
58#endif
59
60/** @brief Get static TI info data based on host state */
61void getStaticTiInfo(uint8_t*& tiInfoPtr);
62
63/** @brief Check if TI info data is valid */
64bool tiInfoValid(uint8_t* tiInfo);
65
Ben Tyneref320152020-01-09 10:31:23 -060066/**
Ben Tyneref320152020-01-09 10:31:23 -060067 * @brief The main attention handler logic
Ben Tyner970fd4f2020-02-19 13:46:42 -060068 *
69 * @param i_breakpoints true = breakpoint special attn handling enabled
Ben Tyneref320152020-01-09 10:31:23 -060070 */
Ben Tyner3fb52e52020-03-31 10:10:07 -050071void attnHandler(Config* i_config)
Ben Tyneref320152020-01-09 10:31:23 -060072{
Ben Tynerb481d902020-03-05 10:24:23 -060073 // Vector of active attentions to be handled
74 std::vector<Attention> active_attentions;
75
Ben Tyneref320152020-01-09 10:31:23 -060076 uint32_t isr_val, isr_mask;
Ben Tyneref320152020-01-09 10:31:23 -060077
78 // loop through processors looking for active attentions
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050079 trace<level::INFO>("Attention handler started");
Ben Tyner117af992020-05-22 13:32:11 -050080
Ben Tyneref320152020-01-09 10:31:23 -060081 pdbg_target* target;
Ben Tyner5e622d82020-09-11 10:10:24 -050082 pdbg_for_each_class_target("proc", target)
Ben Tyneref320152020-01-09 10:31:23 -060083 {
84 if (PDBG_TARGET_ENABLED == pdbg_target_probe(target))
85 {
Zane Shelleya79f6c82021-01-12 16:38:49 -060086 auto proc = pdbg_target_index(target); // get processor number
Ben Tyneref320152020-01-09 10:31:23 -060087
Ben Tynerb83c8522020-11-20 10:45:26 -060088 // Use PIB target to determine if a processor is enabled
Ben Tyner5e622d82020-09-11 10:10:24 -050089 char path[16];
Ben Tynerb83c8522020-11-20 10:45:26 -060090 sprintf(path, "/proc%d/pib", proc);
Ben Tyner8882c322021-02-05 12:13:21 -060091 pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050092
Ben Tynerb83c8522020-11-20 10:45:26 -060093 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -060094 if (nullptr == pibTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -060095 {
96 trace<level::INFO>("pib path or target not found");
97 continue;
98 }
99
Ben Tyner8882c322021-02-05 12:13:21 -0600100 // check if pib target is enabled
101 if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget))
Ben Tyneref320152020-01-09 10:31:23 -0600102 {
Ben Tynerb83c8522020-11-20 10:45:26 -0600103 // The processor FSI target is required for CFAM read
104 sprintf(path, "/proc%d/fsi", proc);
Ben Tyner8882c322021-02-05 12:13:21 -0600105 pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb83c8522020-11-20 10:45:26 -0600106
107 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -0600108 if (nullptr == fsiTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -0600109 {
110 trace<level::INFO>("fsi path or target not found");
111 continue;
112 }
113
Ben Tyner8882c322021-02-05 12:13:21 -0600114 // trace the proc number
115 std::string traceMsg = "proc: " + std::to_string(proc);
116 trace<level::INFO>(traceMsg.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600117
Ben Tyner5adc96e2020-11-20 10:54:12 -0600118 isr_val = 0xffffffff; // invalid isr value
119
Ben Tyner5e622d82020-09-11 10:10:24 -0500120 // get active attentions on processor
Ben Tyner8882c322021-02-05 12:13:21 -0600121 if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val))
Ben Tyneref320152020-01-09 10:31:23 -0600122 {
Ben Tynerfb190542020-11-06 09:27:56 -0600123 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500124 trace<level::INFO>("Error! cfam read 0x1007 FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600125 eventAttentionFail((int)AttnSection::attnHandler |
126 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600127 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600128 else if (0xffffffff == isr_val)
129 {
130 trace<level::INFO>("Error! cfam read 0x1007 INVALID");
131 continue;
132 }
Ben Tyneref320152020-01-09 10:31:23 -0600133 else
134 {
Ben Tyner8882c322021-02-05 12:13:21 -0600135 // 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 Tyner1965e502020-11-20 10:32:24 -0600141
Ben Tyner5adc96e2020-11-20 10:54:12 -0600142 isr_mask = 0xffffffff; // invalid isr mask
143
Ben Tyner5e622d82020-09-11 10:10:24 -0500144 // get interrupt enabled special attentions mask
Ben Tyner8882c322021-02-05 12:13:21 -0600145 if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask))
Ben Tyneref320152020-01-09 10:31:23 -0600146 {
Ben Tynerfb190542020-11-06 09:27:56 -0600147 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500148 trace<level::INFO>("Error! cfam read 0x100d FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600149 eventAttentionFail((int)AttnSection::attnHandler |
150 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600151 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600152 else if (0xffffffff == isr_mask)
153 {
154 trace<level::INFO>("Error! cfam read 0x100d INVALID");
155 continue;
156 }
Ben Tyner5e622d82020-09-11 10:10:24 -0500157 else
158 {
Ben Tyner8882c322021-02-05 12:13:21 -0600159 // 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 Tyner1965e502020-11-20 10:32:24 -0600165
Ben Tynerfb190542020-11-06 09:27:56 -0600166 // SBE vital attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600167 if (true == activeAttn(isr_val, isr_mask, SBE_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500168 {
169 active_attentions.emplace_back(Attention::Vital,
170 handleVital, target,
171 i_config);
172 }
173
Ben Tynerfb190542020-11-06 09:27:56 -0600174 // Checkstop attention active and not masked?
175 if (true ==
Ben Tyner1965e502020-11-20 10:32:24 -0600176 activeAttn(isr_val, isr_mask, CHECKSTOP_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500177 {
178 active_attentions.emplace_back(Attention::Checkstop,
179 handleCheckstop,
180 target, i_config);
181 }
182
Ben Tynerfb190542020-11-06 09:27:56 -0600183 // Special attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600184 if (true == activeAttn(isr_val, isr_mask, SPECIAL_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500185 {
186 active_attentions.emplace_back(Attention::Special,
187 handleSpecial,
188 target, i_config);
189 }
190 } // cfam 0x100d valid
191 } // cfam 0x1007 valid
Ben Tyner8882c322021-02-05 12:13:21 -0600192 } // fsi target enabled
193 } // pib target enabled
Ben Tyner5e622d82020-09-11 10:10:24 -0500194 } // next processor
Ben Tyneref320152020-01-09 10:31:23 -0600195
Ben Tynerb481d902020-03-05 10:24:23 -0600196 // 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 Tynerb1ebfcb2020-05-08 18:52:48 -0500208 // an attention was handled so we are done
Ben Tynerb481d902020-03-05 10:24:23 -0600209 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 Tyneref320152020-01-09 10:31:23 -0600218}
219
220/**
Ben Tyneref320152020-01-09 10:31:23 -0600221 * @brief Handle checkstop attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500222 *
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 Tyneref320152020-01-09 10:31:23 -0600227 */
Ben Tynerb481d902020-03-05 10:24:23 -0600228int handleCheckstop(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600229{
Ben Tyner3fb52e52020-03-31 10:10:07 -0500230 int rc = RC_SUCCESS; // assume checkstop handled
Ben Tyneref320152020-01-09 10:31:23 -0600231
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500232 trace<level::INFO>("checkstop handler started");
233
Ben Tynerb8335562021-07-16 12:43:52 -0500234 // capture some additional data for logs/traces
235 addHbStatusRegs();
236
Ben Tyner3fb52e52020-03-31 10:10:07 -0500237 // if checkstop handling enabled, handle checkstop attention
238 if (false == (i_attention->getConfig()->getFlag(enCheckstop)))
239 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500240 trace<level::INFO>("Checkstop handling disabled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500241 }
242 else
243 {
Zane Shelley9fb73932020-09-15 13:34:57 -0500244 // Look for any attentions found in hardware. This will generate and
Zane Shelley7ae9c8c2020-12-02 20:10:31 -0600245 // commit a PEL if any errors are found.
Ben Tyner7029e522021-08-09 19:18:24 -0500246 DumpParameters dumpParameters;
247 if (true != analyzer::analyzeHardware(dumpParameters))
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500248 {
249 rc = RC_ANALYZER_ERROR;
250 }
Ben Tyner7029e522021-08-09 19:18:24 -0500251 else
252 {
253 requestDump(dumpParameters);
254 util::dbus::transitionHost(util::dbus::HostState::Quiesce);
255 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500256 }
Ben Tyneref320152020-01-09 10:31:23 -0600257
Ben Tyneref320152020-01-09 10:31:23 -0600258 return rc;
259}
260
261/**
262 * @brief Handle special attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500263 *
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 Tyneref320152020-01-09 10:31:23 -0600267 */
Ben Tynerb481d902020-03-05 10:24:23 -0600268int handleSpecial(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600269{
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500270 int rc = RC_SUCCESS; // assume special attention handled
Ben Tyneref320152020-01-09 10:31:23 -0600271
Ben Tynerfb190542020-11-06 09:27:56 -0600272 // The TI info chipop will give us a pointer to the TI info data
Ben Tyner98430b32020-08-19 19:14:02 -0500273 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 Tynerb1ebfcb2020-05-08 18:52:48 -0500276
Ben Tyner29651ef2021-02-08 10:51:03 -0600277 bool tiInfoStatic = false; // assume TI info was provided (not created)
278
Ben Tynerb9715172021-09-29 08:46:19 -0500279 // need proc target to get dynamic TI info
280 if (nullptr != attnProc)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500281 {
Ben Tynerb9715172021-09-29 08:46:19 -0500282#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 Tyner98430b32020-08-19 19:14:02 -0500304 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 Tyner89c0a7a2020-08-07 12:07:35 -0500309 {
Ben Tyner98430b32020-08-19 19:14:02 -0500310 if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget))
311 {
Ben Tyner98430b32020-08-19 19:14:02 -0500312 sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen);
Ben Tyner98430b32020-08-19 19:14:02 -0500313 }
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500314 }
Ben Tynerb9715172021-09-29 08:46:19 -0500315#endif
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500316 }
Ben Tyneref320152020-01-09 10:31:23 -0600317
Ben Tynerb9715172021-09-29 08:46:19 -0500318 // dynamic TI info is not available
319 if (nullptr == tiInfo)
Ben Tyner970fd4f2020-02-19 13:46:42 -0600320 {
Ben Tynerb9715172021-09-29 08:46:19 -0500321 trace<level::INFO>("TI info data ptr is invalid");
322 getStaticTiInfo(tiInfo);
323 tiInfoStatic = true;
Ben Tyner3fb52e52020-03-31 10:10:07 -0500324 }
Ben Tyner0fe5df42020-12-03 08:57:17 -0600325
Ben Tynerb9715172021-09-29 08:46:19 -0500326 // 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 Tyner3fb52e52020-03-31 10:10:07 -0500337 {
Ben Tynerfe156492021-04-08 07:28:13 -0500338 trace<level::INFO>("TI info NOT valid");
Ben Tyner98430b32020-08-19 19:14:02 -0500339
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500340 // if configured to handle TI as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500341 if (i_attention->getConfig()->getFlag(dfltTi))
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500342 {
Ben Tynerfe156492021-04-08 07:28:13 -0500343 // TI handling may be disabled
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500344 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
345 {
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500346 // Call TI special attention handler
Ben Tynerb9715172021-09-29 08:46:19 -0500347 rc = tiHandler((TiDataArea*)tiInfo);
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500348 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500349 }
Ben Tynerb9715172021-09-29 08:46:19 -0500350 // configured to handle breakpoint as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500351 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 Tyner970fd4f2020-02-19 13:46:42 -0600360 }
Ben Tyneref320152020-01-09 10:31:23 -0600361
Ben Tynerb9715172021-09-29 08:46:19 -0500362 // release TI data buffer if not ours
363 if (false == tiInfoStatic)
Ben Tyner792f32f2020-06-02 08:50:47 -0500364 {
Ben Tynerb9715172021-09-29 08:46:19 -0500365 // sanity check
366 if (nullptr != tiInfo)
367 {
368 free(tiInfo);
369 }
Ben Tyner792f32f2020-06-02 08:50:47 -0500370 }
371
Ben Tynerb9715172021-09-29 08:46:19 -0500372 // trace non-successful exit condition
Ben Tyner3fb52e52020-03-31 10:10:07 -0500373 if (RC_SUCCESS != rc)
374 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500375 trace<level::INFO>("Special attn not handled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500376 }
Ben Tyneref320152020-01-09 10:31:23 -0600377
378 return rc;
379}
380
Ben Tynerfb190542020-11-06 09:27:56 -0600381/**
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 Tyner1965e502020-11-20 10:32:24 -0600394bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn)
Ben Tynerfb190542020-11-06 09:27:56 -0600395{
Zane Shelley9fb657f2021-01-12 15:30:58 -0600396 bool rc = false; // assume attn masked and/or inactive
Ben Tynerfb190542020-11-06 09:27:56 -0600397
398 // if attention active
399 if (0 != (i_val & i_attn))
400 {
Ben Tynerfb190542020-11-06 09:27:56 -0600401 std::stringstream ss;
Ben Tynerfb190542020-11-06 09:27:56 -0600402
Zane Shelley9fb657f2021-01-12 15:30:58 -0600403 bool validAttn = true; // known attention type
404
Ben Tynerfb190542020-11-06 09:27:56 -0600405 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 Tyner8882c322021-02-05 12:13:21 -0600434 std::string strobj = ss.str(); // ss.str() is temporary
435 trace<level::INFO>(strobj.c_str()); // commit trace stream
Ben Tynerfb190542020-11-06 09:27:56 -0600436 }
437
438 return rc;
439}
Ben Tynerb9715172021-09-29 08:46:19 -0500440
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 */
448void 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 */
468void 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 */
500bool 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 Tyneref320152020-01-09 10:31:23 -0600553} // namespace attn