blob: 85172ea903f423703e22f8bcc7b6b3ba12480933 [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.
Zane Shelley9fb73932020-09-15 13:34:57 -0500230 if (true != analyzer::analyzeHardware())
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500231 {
232 rc = RC_ANALYZER_ERROR;
233 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500234 }
Ben Tyneref320152020-01-09 10:31:23 -0600235
Ben Tyneref320152020-01-09 10:31:23 -0600236 return rc;
237}
238
239/**
240 * @brief Handle special attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500241 *
242 * @param i_attention Attention object
243 * @return 0 indicates that the special attention was successfully handled
244 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -0600245 */
Ben Tynerb481d902020-03-05 10:24:23 -0600246int handleSpecial(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600247{
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500248 int rc = RC_SUCCESS; // assume special attention handled
Ben Tyneref320152020-01-09 10:31:23 -0600249
Ben Tynerfb190542020-11-06 09:27:56 -0600250 // The TI info chipop will give us a pointer to the TI info data
Ben Tyner98430b32020-08-19 19:14:02 -0500251 uint8_t* tiInfo = nullptr; // ptr to TI info data
252 uint32_t tiInfoLen = 0; // length of TI info data
253 pdbg_target* attnProc = i_attention->getTarget(); // proc with attention
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500254
Ben Tyner29651ef2021-02-08 10:51:03 -0600255 bool tiInfoStatic = false; // assume TI info was provided (not created)
256
Ben Tyner98430b32020-08-19 19:14:02 -0500257 if (attnProc != nullptr)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500258 {
Ben Tyner98430b32020-08-19 19:14:02 -0500259 // The processor PIB target is required for get TI info chipop
260 char path[16];
261 sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc));
262 pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path);
263
264 if (nullptr != tiInfoTarget)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500265 {
Ben Tyner98430b32020-08-19 19:14:02 -0500266 if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget))
267 {
Ben Tyner98430b32020-08-19 19:14:02 -0500268 sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen);
Ben Tyner4bbcb382021-02-22 09:29:00 -0600269
270 // If TI info not available use default based on host state
271 if (nullptr == tiInfo)
Ben Tyner98430b32020-08-19 19:14:02 -0500272 {
Ben Tyner4bbcb382021-02-22 09:29:00 -0600273 trace<level::INFO>("TI info data ptr is invalid");
274
Ben Tynerfe2c50d2021-07-23 13:38:53 -0500275 util::dbus::HostRunningState runningState =
276 util::dbus::hostRunningState();
Ben Tyner4bbcb382021-02-22 09:29:00 -0600277
Ben Tynerfe2c50d2021-07-23 13:38:53 -0500278 std::string stateString = "host state unknown";
279
280 if ((util::dbus::HostRunningState::Started ==
281 runningState) ||
282 (util::dbus::HostRunningState::Unknown == runningState))
Ben Tyner4bbcb382021-02-22 09:29:00 -0600283 {
Ben Tynerfe2c50d2021-07-23 13:38:53 -0500284 if (util::dbus::HostRunningState::Started ==
285 runningState)
Ben Tyner4bbcb382021-02-22 09:29:00 -0600286 {
287 stateString = "host started";
288 }
289 tiInfo = (uint8_t*)defaultPhypTiInfo;
290 }
291 else
292 {
293 stateString = "host not started";
294 tiInfo = (uint8_t*)defaultHbTiInfo;
295 }
296
297 // trace host state
298 trace<level::INFO>(stateString.c_str());
299
Ben Tyner29651ef2021-02-08 10:51:03 -0600300 tiInfoStatic = true; // using our TI info
Ben Tyner98430b32020-08-19 19:14:02 -0500301 }
302 }
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500303 }
304 }
Ben Tyneref320152020-01-09 10:31:23 -0600305
Ben Tyner0fe5df42020-12-03 08:57:17 -0600306 bool tiInfoValid = false; // TI area data not valid or not available
307
Ben Tyner792f32f2020-06-02 08:50:47 -0500308 // If TI area exists and is marked valid we can assume TI occurred
309 if ((nullptr != tiInfo) && (0 != tiInfo[0]))
Ben Tyner970fd4f2020-02-19 13:46:42 -0600310 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500311 TiDataArea* tiDataArea = (TiDataArea*)tiInfo;
Ben Tyner7e6611f2020-02-13 16:42:56 -0600312
Ben Tyner8882c322021-02-05 12:13:21 -0600313 std::stringstream ss; // string stream object for tracing
314 std::string strobj; // string object for tracing
Ben Tyner40717722020-09-23 09:43:20 -0500315
Ben Tyner8882c322021-02-05 12:13:21 -0600316 // trace a few known TI data area values
317 ss.str(std::string()); // empty the stream
318 ss.clear(); // clear the stream
319 ss << "TI data command = 0x" << std::setw(2) << std::setfill('0')
320 << std::hex << (int)tiDataArea->command;
321 strobj = ss.str();
322 trace<level::INFO>(strobj.c_str());
Ben Tyner40717722020-09-23 09:43:20 -0500323
Ben Tyner0fe5df42020-12-03 08:57:17 -0600324 // Another check for valid TI Info since it has been seen that
325 // tiInfo[0] != 0 but TI info is not valid
326 if (0xa1 == tiDataArea->command)
Ben Tyner792f32f2020-06-02 08:50:47 -0500327 {
Ben Tyner0fe5df42020-12-03 08:57:17 -0600328 tiInfoValid = true;
329
330 // trace some more data since TI info appears valid
Ben Tyner8882c322021-02-05 12:13:21 -0600331 ss.str(std::string()); // empty the stream
332 ss.clear(); // clear the stream
Ben Tyner7a0dd542021-02-12 09:33:44 -0600333 ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0')
334 << std::hex << (int)tiDataArea->hbTerminateType;
Ben Tyner8882c322021-02-05 12:13:21 -0600335 strobj = ss.str();
336 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600337
Ben Tyner8882c322021-02-05 12:13:21 -0600338 ss.str(std::string()); // empty the stream
339 ss.clear(); // clear the stream
340 ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0')
341 << std::hex << (int)tiDataArea->srcFormat;
342 strobj = ss.str();
343 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600344
Ben Tyner8882c322021-02-05 12:13:21 -0600345 ss.str(std::string()); // empty the stream
346 ss.clear(); // clear the stream
347 ss << "TI data source = 0x" << std::setw(2) << std::setfill('0')
348 << std::hex << (int)tiDataArea->source;
349 strobj = ss.str();
350 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600351
352 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
353 {
354 // Call TI special attention handler
355 rc = tiHandler(tiDataArea);
356 }
Ben Tyner792f32f2020-06-02 08:50:47 -0500357 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500358 }
Ben Tyner0fe5df42020-12-03 08:57:17 -0600359
Ben Tynerfe156492021-04-08 07:28:13 -0500360 // TI area is available but was not valid data
Ben Tyner0fe5df42020-12-03 08:57:17 -0600361 if (false == tiInfoValid)
Ben Tyner3fb52e52020-03-31 10:10:07 -0500362 {
Ben Tynerfe156492021-04-08 07:28:13 -0500363 trace<level::INFO>("TI info NOT valid");
Ben Tyner98430b32020-08-19 19:14:02 -0500364
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500365 // if configured to handle TI as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500366 if (i_attention->getConfig()->getFlag(dfltTi))
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500367 {
Ben Tynerfe156492021-04-08 07:28:13 -0500368 // TI handling may be disabled
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500369 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
370 {
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500371 // Call TI special attention handler
372 rc = tiHandler(nullptr);
373 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500374 }
Ben Tynerfe156492021-04-08 07:28:13 -0500375 // breakpoint is default special attention when TI info NOT valid
376 else
377 {
378 // breakpoint handling may be disabled
379 if (true == (i_attention->getConfig()->getFlag(enBreakpoints)))
380 {
381 // Call the breakpoint special attention handler
382 rc = bpHandler();
383 }
384 }
Ben Tyner970fd4f2020-02-19 13:46:42 -0600385 }
Ben Tyneref320152020-01-09 10:31:23 -0600386
Ben Tyner792f32f2020-06-02 08:50:47 -0500387 // release TI data buffer
Ben Tyner29651ef2021-02-08 10:51:03 -0600388 if ((nullptr != tiInfo) && (false == tiInfoStatic))
Ben Tyner792f32f2020-06-02 08:50:47 -0500389 {
390 free(tiInfo);
391 }
392
Ben Tyner3fb52e52020-03-31 10:10:07 -0500393 if (RC_SUCCESS != rc)
394 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500395 trace<level::INFO>("Special attn not handled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500396 }
Ben Tyneref320152020-01-09 10:31:23 -0600397
398 return rc;
399}
400
Ben Tynerfb190542020-11-06 09:27:56 -0600401/**
402 * @brief Determine if attention is active and not masked
403 *
404 * Determine whether an attention needs to be handled and trace details of
405 * attention type and whether it is masked or not.
406 *
407 * @param i_val attention status register
408 * @param i_mask attention true mask register
409 * @param i_attn attention type
410 * @param i_proc processor associated with registers
411 *
412 * @return true if attention is active and not masked, otherwise false
413 */
Ben Tyner1965e502020-11-20 10:32:24 -0600414bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn)
Ben Tynerfb190542020-11-06 09:27:56 -0600415{
Zane Shelley9fb657f2021-01-12 15:30:58 -0600416 bool rc = false; // assume attn masked and/or inactive
Ben Tynerfb190542020-11-06 09:27:56 -0600417
418 // if attention active
419 if (0 != (i_val & i_attn))
420 {
Ben Tynerfb190542020-11-06 09:27:56 -0600421 std::stringstream ss;
Ben Tynerfb190542020-11-06 09:27:56 -0600422
Zane Shelley9fb657f2021-01-12 15:30:58 -0600423 bool validAttn = true; // known attention type
424
Ben Tynerfb190542020-11-06 09:27:56 -0600425 switch (i_attn)
426 {
427 case SBE_ATTN:
428 ss << "SBE attn";
429 break;
430 case CHECKSTOP_ATTN:
431 ss << "Checkstop attn";
432 break;
433 case SPECIAL_ATTN:
434 ss << "Special attn";
435 break;
436 default:
437 ss << "Unknown attn";
438 validAttn = false;
439 }
440
441 // see if attention is masked
442 if (true == validAttn)
443 {
444 if (0 != (i_mask & i_attn))
445 {
446 rc = true; // attention active and not masked
447 }
448 else
449 {
450 ss << " masked";
451 }
452 }
453
Ben Tyner8882c322021-02-05 12:13:21 -0600454 std::string strobj = ss.str(); // ss.str() is temporary
455 trace<level::INFO>(strobj.c_str()); // commit trace stream
Ben Tynerfb190542020-11-06 09:27:56 -0600456 }
457
458 return rc;
459}
Ben Tyneref320152020-01-09 10:31:23 -0600460} // namespace attn