blob: 566b2f7918e90bc5ec34a44daf28f2612d13bbe5 [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 Tyner0205f3b2020-02-24 10:24:47 -06007#include <analyzer/analyzer_main.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -05008#include <attn/attention.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -06009#include <attn/attn_common.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -050010#include <attn/attn_config.hpp>
Ben Tyner4bbcb382021-02-22 09:29:00 -060011#include <attn/attn_dbus.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -050012#include <attn/attn_handler.hpp>
13#include <attn/attn_logging.hpp>
14#include <attn/bp_handler.hpp>
15#include <attn/ti_handler.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -060016#include <attn/vital_handler.hpp>
Ben Tynerfe2c50d2021-07-23 13:38:53 -050017#include <util/dbus.hpp>
Ben Tyneref320152020-01-09 10:31:23 -060018
Ben Tynerb481d902020-03-05 10:24:23 -060019#include <algorithm>
Ben Tyneref320152020-01-09 10:31:23 -060020#include <iomanip>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050021#include <map>
Ben Tyner9ae5ca42020-02-28 13:13:50 -060022#include <sstream>
Ben Tynerb481d902020-03-05 10:24:23 -060023#include <vector>
Ben Tyneref320152020-01-09 10:31:23 -060024
25namespace attn
26{
27
28/**
Ben Tyneref320152020-01-09 10:31:23 -060029 * @brief Handle checkstop attention
30 *
Ben Tynerb481d902020-03-05 10:24:23 -060031 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050032 * @return 0 indicates that the checkstop attention was successfully handled
33 * 1 indicates that the checkstop attention was NOT successfully
34 * handled.
Ben Tyneref320152020-01-09 10:31:23 -060035 */
Ben Tynerb481d902020-03-05 10:24:23 -060036int handleCheckstop(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060037
38/**
39 * @brief Handle special attention
40 *
Ben Tynerb481d902020-03-05 10:24:23 -060041 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050042 * @return 0 indicates that the special attention was successfully handled
43 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -060044 */
Ben Tynerb481d902020-03-05 10:24:23 -060045int handleSpecial(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060046
Ben Tynerfb190542020-11-06 09:27:56 -060047/** @brief Determine if attention is active and not masked */
Ben Tyner1965e502020-11-20 10:32:24 -060048bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn);
Ben Tynerfb190542020-11-06 09:27:56 -060049
Ben Tyneref320152020-01-09 10:31:23 -060050/**
Ben Tyneref320152020-01-09 10:31:23 -060051 * @brief The main attention handler logic
Ben Tyner970fd4f2020-02-19 13:46:42 -060052 *
53 * @param i_breakpoints true = breakpoint special attn handling enabled
Ben Tyneref320152020-01-09 10:31:23 -060054 */
Ben Tyner3fb52e52020-03-31 10:10:07 -050055void attnHandler(Config* i_config)
Ben Tyneref320152020-01-09 10:31:23 -060056{
Ben Tynerb481d902020-03-05 10:24:23 -060057 // Vector of active attentions to be handled
58 std::vector<Attention> active_attentions;
59
Ben Tyneref320152020-01-09 10:31:23 -060060 uint32_t isr_val, isr_mask;
Ben Tyneref320152020-01-09 10:31:23 -060061
62 // loop through processors looking for active attentions
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050063 trace<level::INFO>("Attention handler started");
Ben Tyner117af992020-05-22 13:32:11 -050064
Ben Tyneref320152020-01-09 10:31:23 -060065 pdbg_target* target;
Ben Tyner5e622d82020-09-11 10:10:24 -050066 pdbg_for_each_class_target("proc", target)
Ben Tyneref320152020-01-09 10:31:23 -060067 {
68 if (PDBG_TARGET_ENABLED == pdbg_target_probe(target))
69 {
Zane Shelleya79f6c82021-01-12 16:38:49 -060070 auto proc = pdbg_target_index(target); // get processor number
Ben Tyneref320152020-01-09 10:31:23 -060071
Ben Tynerb83c8522020-11-20 10:45:26 -060072 // Use PIB target to determine if a processor is enabled
Ben Tyner5e622d82020-09-11 10:10:24 -050073 char path[16];
Ben Tynerb83c8522020-11-20 10:45:26 -060074 sprintf(path, "/proc%d/pib", proc);
Ben Tyner8882c322021-02-05 12:13:21 -060075 pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050076
Ben Tynerb83c8522020-11-20 10:45:26 -060077 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -060078 if (nullptr == pibTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -060079 {
80 trace<level::INFO>("pib path or target not found");
81 continue;
82 }
83
Ben Tyner8882c322021-02-05 12:13:21 -060084 // check if pib target is enabled
85 if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget))
Ben Tyneref320152020-01-09 10:31:23 -060086 {
Ben Tynerb83c8522020-11-20 10:45:26 -060087 // The processor FSI target is required for CFAM read
88 sprintf(path, "/proc%d/fsi", proc);
Ben Tyner8882c322021-02-05 12:13:21 -060089 pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb83c8522020-11-20 10:45:26 -060090
91 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -060092 if (nullptr == fsiTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -060093 {
94 trace<level::INFO>("fsi path or target not found");
95 continue;
96 }
97
Ben Tyner8882c322021-02-05 12:13:21 -060098 // trace the proc number
99 std::string traceMsg = "proc: " + std::to_string(proc);
100 trace<level::INFO>(traceMsg.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600101
Ben Tyner5adc96e2020-11-20 10:54:12 -0600102 isr_val = 0xffffffff; // invalid isr value
103
Ben Tyner5e622d82020-09-11 10:10:24 -0500104 // get active attentions on processor
Ben Tyner8882c322021-02-05 12:13:21 -0600105 if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val))
Ben Tyneref320152020-01-09 10:31:23 -0600106 {
Ben Tynerfb190542020-11-06 09:27:56 -0600107 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500108 trace<level::INFO>("Error! cfam read 0x1007 FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600109 eventAttentionFail((int)AttnSection::attnHandler |
110 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600111 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600112 else if (0xffffffff == isr_val)
113 {
114 trace<level::INFO>("Error! cfam read 0x1007 INVALID");
115 continue;
116 }
Ben Tyneref320152020-01-09 10:31:23 -0600117 else
118 {
Ben Tyner8882c322021-02-05 12:13:21 -0600119 // trace isr value
120 std::stringstream ssIsr;
121 ssIsr << "cfam 0x1007 = 0x" << std::setw(8)
122 << std::setfill('0') << std::hex << isr_val;
123 std::string strobjIsr = ssIsr.str();
124 trace<level::INFO>(strobjIsr.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600125
Ben Tyner5adc96e2020-11-20 10:54:12 -0600126 isr_mask = 0xffffffff; // invalid isr mask
127
Ben Tyner5e622d82020-09-11 10:10:24 -0500128 // get interrupt enabled special attentions mask
Ben Tyner8882c322021-02-05 12:13:21 -0600129 if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask))
Ben Tyneref320152020-01-09 10:31:23 -0600130 {
Ben Tynerfb190542020-11-06 09:27:56 -0600131 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500132 trace<level::INFO>("Error! cfam read 0x100d FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600133 eventAttentionFail((int)AttnSection::attnHandler |
134 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600135 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600136 else if (0xffffffff == isr_mask)
137 {
138 trace<level::INFO>("Error! cfam read 0x100d INVALID");
139 continue;
140 }
Ben Tyner5e622d82020-09-11 10:10:24 -0500141 else
142 {
Ben Tyner8882c322021-02-05 12:13:21 -0600143 // trace true mask
144 std::stringstream ssMask;
145 ssMask << "cfam 0x100d = 0x" << std::setw(8)
146 << std::setfill('0') << std::hex << isr_mask;
147 std::string strobjMask = ssMask.str();
148 trace<level::INFO>(strobjMask.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600149
Ben Tynerfb190542020-11-06 09:27:56 -0600150 // SBE vital attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600151 if (true == activeAttn(isr_val, isr_mask, SBE_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500152 {
153 active_attentions.emplace_back(Attention::Vital,
154 handleVital, target,
155 i_config);
156 }
157
Ben Tynerfb190542020-11-06 09:27:56 -0600158 // Checkstop attention active and not masked?
159 if (true ==
Ben Tyner1965e502020-11-20 10:32:24 -0600160 activeAttn(isr_val, isr_mask, CHECKSTOP_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500161 {
162 active_attentions.emplace_back(Attention::Checkstop,
163 handleCheckstop,
164 target, i_config);
165 }
166
Ben Tynerfb190542020-11-06 09:27:56 -0600167 // Special attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600168 if (true == activeAttn(isr_val, isr_mask, SPECIAL_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500169 {
170 active_attentions.emplace_back(Attention::Special,
171 handleSpecial,
172 target, i_config);
173 }
174 } // cfam 0x100d valid
175 } // cfam 0x1007 valid
Ben Tyner8882c322021-02-05 12:13:21 -0600176 } // fsi target enabled
177 } // pib target enabled
Ben Tyner5e622d82020-09-11 10:10:24 -0500178 } // next processor
Ben Tyneref320152020-01-09 10:31:23 -0600179
Ben Tynerb481d902020-03-05 10:24:23 -0600180 // convert to heap, highest priority is at front
181 if (!std::is_heap(active_attentions.begin(), active_attentions.end()))
182 {
183 std::make_heap(active_attentions.begin(), active_attentions.end());
184 }
185
186 // call the attention handler until one is handled or all were attempted
187 while (false == active_attentions.empty())
188 {
189 // handle highest priority attention, done if successful
190 if (RC_SUCCESS == active_attentions.front().handle())
191 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500192 // an attention was handled so we are done
Ben Tynerb481d902020-03-05 10:24:23 -0600193 break;
194 }
195
196 // move attention to back of vector
197 std::pop_heap(active_attentions.begin(), active_attentions.end());
198
199 // remove attention from vector
200 active_attentions.pop_back();
201 }
Ben Tyneref320152020-01-09 10:31:23 -0600202}
203
204/**
Ben Tyneref320152020-01-09 10:31:23 -0600205 * @brief Handle checkstop attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500206 *
207 * @param i_attention Attention object
208 * @return 0 indicates that the checkstop attention was successfully handled
209 * 1 indicates that the checkstop attention was NOT successfully
210 * handled.
Ben Tyneref320152020-01-09 10:31:23 -0600211 */
Ben Tynerb481d902020-03-05 10:24:23 -0600212int handleCheckstop(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600213{
Ben Tyner3fb52e52020-03-31 10:10:07 -0500214 int rc = RC_SUCCESS; // assume checkstop handled
Ben Tyneref320152020-01-09 10:31:23 -0600215
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500216 trace<level::INFO>("checkstop handler started");
217
Ben Tynerb8335562021-07-16 12:43:52 -0500218 // capture some additional data for logs/traces
219 addHbStatusRegs();
220
Ben Tyner3fb52e52020-03-31 10:10:07 -0500221 // if checkstop handling enabled, handle checkstop attention
222 if (false == (i_attention->getConfig()->getFlag(enCheckstop)))
223 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500224 trace<level::INFO>("Checkstop handling disabled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500225 }
226 else
227 {
Zane Shelley9fb73932020-09-15 13:34:57 -0500228 // Look for any attentions found in hardware. This will generate and
Zane Shelley7ae9c8c2020-12-02 20:10:31 -0600229 // commit a PEL if any errors are found.
Ben Tyner7029e522021-08-09 19:18:24 -0500230 DumpParameters dumpParameters;
231 if (true != analyzer::analyzeHardware(dumpParameters))
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500232 {
233 rc = RC_ANALYZER_ERROR;
234 }
Ben Tyner7029e522021-08-09 19:18:24 -0500235 else
236 {
237 requestDump(dumpParameters);
238 util::dbus::transitionHost(util::dbus::HostState::Quiesce);
239 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500240 }
Ben Tyneref320152020-01-09 10:31:23 -0600241
Ben Tyneref320152020-01-09 10:31:23 -0600242 return rc;
243}
244
245/**
246 * @brief Handle special attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500247 *
248 * @param i_attention Attention object
249 * @return 0 indicates that the special attention was successfully handled
250 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -0600251 */
Ben Tynerb481d902020-03-05 10:24:23 -0600252int handleSpecial(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600253{
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500254 int rc = RC_SUCCESS; // assume special attention handled
Ben Tyneref320152020-01-09 10:31:23 -0600255
Ben Tynerfb190542020-11-06 09:27:56 -0600256 // The TI info chipop will give us a pointer to the TI info data
Ben Tyner98430b32020-08-19 19:14:02 -0500257 uint8_t* tiInfo = nullptr; // ptr to TI info data
258 uint32_t tiInfoLen = 0; // length of TI info data
259 pdbg_target* attnProc = i_attention->getTarget(); // proc with attention
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500260
Ben Tyner29651ef2021-02-08 10:51:03 -0600261 bool tiInfoStatic = false; // assume TI info was provided (not created)
262
Ben Tyner98430b32020-08-19 19:14:02 -0500263 if (attnProc != nullptr)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500264 {
Ben Tyner98430b32020-08-19 19:14:02 -0500265 // The processor PIB target is required for get TI info chipop
266 char path[16];
267 sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc));
268 pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path);
269
270 if (nullptr != tiInfoTarget)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500271 {
Ben Tyner98430b32020-08-19 19:14:02 -0500272 if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget))
273 {
Ben Tyner98430b32020-08-19 19:14:02 -0500274 sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen);
Ben Tyner4bbcb382021-02-22 09:29:00 -0600275
276 // If TI info not available use default based on host state
277 if (nullptr == tiInfo)
Ben Tyner98430b32020-08-19 19:14:02 -0500278 {
Ben Tyner4bbcb382021-02-22 09:29:00 -0600279 trace<level::INFO>("TI info data ptr is invalid");
280
Ben Tynerfe2c50d2021-07-23 13:38:53 -0500281 util::dbus::HostRunningState runningState =
282 util::dbus::hostRunningState();
Ben Tyner4bbcb382021-02-22 09:29:00 -0600283
Ben Tynerfe2c50d2021-07-23 13:38:53 -0500284 std::string stateString = "host state unknown";
285
286 if ((util::dbus::HostRunningState::Started ==
287 runningState) ||
288 (util::dbus::HostRunningState::Unknown == runningState))
Ben Tyner4bbcb382021-02-22 09:29:00 -0600289 {
Ben Tynerfe2c50d2021-07-23 13:38:53 -0500290 if (util::dbus::HostRunningState::Started ==
291 runningState)
Ben Tyner4bbcb382021-02-22 09:29:00 -0600292 {
293 stateString = "host started";
294 }
295 tiInfo = (uint8_t*)defaultPhypTiInfo;
296 }
297 else
298 {
299 stateString = "host not started";
300 tiInfo = (uint8_t*)defaultHbTiInfo;
301 }
302
303 // trace host state
304 trace<level::INFO>(stateString.c_str());
305
Ben Tyner29651ef2021-02-08 10:51:03 -0600306 tiInfoStatic = true; // using our TI info
Ben Tyner98430b32020-08-19 19:14:02 -0500307 }
308 }
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500309 }
310 }
Ben Tyneref320152020-01-09 10:31:23 -0600311
Ben Tyner0fe5df42020-12-03 08:57:17 -0600312 bool tiInfoValid = false; // TI area data not valid or not available
313
Ben Tyner792f32f2020-06-02 08:50:47 -0500314 // If TI area exists and is marked valid we can assume TI occurred
315 if ((nullptr != tiInfo) && (0 != tiInfo[0]))
Ben Tyner970fd4f2020-02-19 13:46:42 -0600316 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500317 TiDataArea* tiDataArea = (TiDataArea*)tiInfo;
Ben Tyner7e6611f2020-02-13 16:42:56 -0600318
Ben Tyner8882c322021-02-05 12:13:21 -0600319 std::stringstream ss; // string stream object for tracing
320 std::string strobj; // string object for tracing
Ben Tyner40717722020-09-23 09:43:20 -0500321
Ben Tyner8882c322021-02-05 12:13:21 -0600322 // trace a few known TI data area values
323 ss.str(std::string()); // empty the stream
324 ss.clear(); // clear the stream
325 ss << "TI data command = 0x" << std::setw(2) << std::setfill('0')
326 << std::hex << (int)tiDataArea->command;
327 strobj = ss.str();
328 trace<level::INFO>(strobj.c_str());
Ben Tyner40717722020-09-23 09:43:20 -0500329
Ben Tyner0fe5df42020-12-03 08:57:17 -0600330 // Another check for valid TI Info since it has been seen that
331 // tiInfo[0] != 0 but TI info is not valid
332 if (0xa1 == tiDataArea->command)
Ben Tyner792f32f2020-06-02 08:50:47 -0500333 {
Ben Tyner0fe5df42020-12-03 08:57:17 -0600334 tiInfoValid = true;
335
336 // trace some more data since TI info appears valid
Ben Tyner8882c322021-02-05 12:13:21 -0600337 ss.str(std::string()); // empty the stream
338 ss.clear(); // clear the stream
Ben Tyner7a0dd542021-02-12 09:33:44 -0600339 ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0')
340 << std::hex << (int)tiDataArea->hbTerminateType;
Ben Tyner8882c322021-02-05 12:13:21 -0600341 strobj = ss.str();
342 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600343
Ben Tyner8882c322021-02-05 12:13:21 -0600344 ss.str(std::string()); // empty the stream
345 ss.clear(); // clear the stream
346 ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0')
347 << std::hex << (int)tiDataArea->srcFormat;
348 strobj = ss.str();
349 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600350
Ben Tyner8882c322021-02-05 12:13:21 -0600351 ss.str(std::string()); // empty the stream
352 ss.clear(); // clear the stream
353 ss << "TI data source = 0x" << std::setw(2) << std::setfill('0')
354 << std::hex << (int)tiDataArea->source;
355 strobj = ss.str();
356 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600357
358 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
359 {
360 // Call TI special attention handler
361 rc = tiHandler(tiDataArea);
362 }
Ben Tyner792f32f2020-06-02 08:50:47 -0500363 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500364 }
Ben Tyner0fe5df42020-12-03 08:57:17 -0600365
Ben Tynerfe156492021-04-08 07:28:13 -0500366 // TI area is available but was not valid data
Ben Tyner0fe5df42020-12-03 08:57:17 -0600367 if (false == tiInfoValid)
Ben Tyner3fb52e52020-03-31 10:10:07 -0500368 {
Ben Tynerfe156492021-04-08 07:28:13 -0500369 trace<level::INFO>("TI info NOT valid");
Ben Tyner98430b32020-08-19 19:14:02 -0500370
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500371 // if configured to handle TI as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500372 if (i_attention->getConfig()->getFlag(dfltTi))
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500373 {
Ben Tynerfe156492021-04-08 07:28:13 -0500374 // TI handling may be disabled
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500375 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
376 {
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500377 // Call TI special attention handler
378 rc = tiHandler(nullptr);
379 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500380 }
Ben Tynerfe156492021-04-08 07:28:13 -0500381 // breakpoint is default special attention when TI info NOT valid
382 else
383 {
384 // breakpoint handling may be disabled
385 if (true == (i_attention->getConfig()->getFlag(enBreakpoints)))
386 {
387 // Call the breakpoint special attention handler
388 rc = bpHandler();
389 }
390 }
Ben Tyner970fd4f2020-02-19 13:46:42 -0600391 }
Ben Tyneref320152020-01-09 10:31:23 -0600392
Ben Tyner792f32f2020-06-02 08:50:47 -0500393 // release TI data buffer
Ben Tyner29651ef2021-02-08 10:51:03 -0600394 if ((nullptr != tiInfo) && (false == tiInfoStatic))
Ben Tyner792f32f2020-06-02 08:50:47 -0500395 {
396 free(tiInfo);
397 }
398
Ben Tyner3fb52e52020-03-31 10:10:07 -0500399 if (RC_SUCCESS != rc)
400 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500401 trace<level::INFO>("Special attn not handled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500402 }
Ben Tyneref320152020-01-09 10:31:23 -0600403
404 return rc;
405}
406
Ben Tynerfb190542020-11-06 09:27:56 -0600407/**
408 * @brief Determine if attention is active and not masked
409 *
410 * Determine whether an attention needs to be handled and trace details of
411 * attention type and whether it is masked or not.
412 *
413 * @param i_val attention status register
414 * @param i_mask attention true mask register
415 * @param i_attn attention type
416 * @param i_proc processor associated with registers
417 *
418 * @return true if attention is active and not masked, otherwise false
419 */
Ben Tyner1965e502020-11-20 10:32:24 -0600420bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn)
Ben Tynerfb190542020-11-06 09:27:56 -0600421{
Zane Shelley9fb657f2021-01-12 15:30:58 -0600422 bool rc = false; // assume attn masked and/or inactive
Ben Tynerfb190542020-11-06 09:27:56 -0600423
424 // if attention active
425 if (0 != (i_val & i_attn))
426 {
Ben Tynerfb190542020-11-06 09:27:56 -0600427 std::stringstream ss;
Ben Tynerfb190542020-11-06 09:27:56 -0600428
Zane Shelley9fb657f2021-01-12 15:30:58 -0600429 bool validAttn = true; // known attention type
430
Ben Tynerfb190542020-11-06 09:27:56 -0600431 switch (i_attn)
432 {
433 case SBE_ATTN:
434 ss << "SBE attn";
435 break;
436 case CHECKSTOP_ATTN:
437 ss << "Checkstop attn";
438 break;
439 case SPECIAL_ATTN:
440 ss << "Special attn";
441 break;
442 default:
443 ss << "Unknown attn";
444 validAttn = false;
445 }
446
447 // see if attention is masked
448 if (true == validAttn)
449 {
450 if (0 != (i_mask & i_attn))
451 {
452 rc = true; // attention active and not masked
453 }
454 else
455 {
456 ss << " masked";
457 }
458 }
459
Ben Tyner8882c322021-02-05 12:13:21 -0600460 std::string strobj = ss.str(); // ss.str() is temporary
461 trace<level::INFO>(strobj.c_str()); // commit trace stream
Ben Tynerfb190542020-11-06 09:27:56 -0600462 }
463
464 return rc;
465}
Ben Tyneref320152020-01-09 10:31:23 -0600466} // namespace attn