blob: 6eef10735c31d7c03e6a6dae027a5f25f49145ae [file] [log] [blame]
Ben Tyner792f32f2020-06-02 08:50:47 -05001#include <libpdbg.h>
2
Ben Tyner0205f3b2020-02-24 10:24:47 -06003#include <analyzer/analyzer_main.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -05004#include <attn/attention.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -06005#include <attn/attn_common.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -05006#include <attn/attn_config.hpp>
Ben Tyner4bbcb382021-02-22 09:29:00 -06007#include <attn/attn_dbus.hpp>
Ben Tynerb797b3e2020-06-29 10:12:05 -05008#include <attn/attn_handler.hpp>
9#include <attn/attn_logging.hpp>
10#include <attn/bp_handler.hpp>
11#include <attn/ti_handler.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -060012#include <attn/vital_handler.hpp>
Ben Tyneref320152020-01-09 10:31:23 -060013
Ben Tynerb481d902020-03-05 10:24:23 -060014#include <algorithm>
Ben Tyneref320152020-01-09 10:31:23 -060015#include <iomanip>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050016#include <map>
Ben Tyner9ae5ca42020-02-28 13:13:50 -060017#include <sstream>
Ben Tynerb481d902020-03-05 10:24:23 -060018#include <vector>
Ben Tyneref320152020-01-09 10:31:23 -060019
20namespace attn
21{
22
23/**
Ben Tyneref320152020-01-09 10:31:23 -060024 * @brief Handle checkstop attention
25 *
Ben Tynerb481d902020-03-05 10:24:23 -060026 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050027 * @return 0 indicates that the checkstop attention was successfully handled
28 * 1 indicates that the checkstop attention was NOT successfully
29 * handled.
Ben Tyneref320152020-01-09 10:31:23 -060030 */
Ben Tynerb481d902020-03-05 10:24:23 -060031int handleCheckstop(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060032
33/**
34 * @brief Handle special attention
35 *
Ben Tynerb481d902020-03-05 10:24:23 -060036 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050037 * @return 0 indicates that the special attention was successfully handled
38 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -060039 */
Ben Tynerb481d902020-03-05 10:24:23 -060040int handleSpecial(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060041
Ben Tynerfb190542020-11-06 09:27:56 -060042/** @brief Determine if attention is active and not masked */
Ben Tyner1965e502020-11-20 10:32:24 -060043bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn);
Ben Tynerfb190542020-11-06 09:27:56 -060044
Ben Tyneref320152020-01-09 10:31:23 -060045/**
Brian Stegmiller2d5c63d2021-03-31 17:29:29 -050046 * @brief Traces some regs for hostboot
47 *
48 * @param i_procIndex - processor number (used in traces)
49 * @param i_pibTarget - target used for doing SCOMs to the processor
50 * @param i_fsiTarget - target used for doing CFAMs to the processor
51 *
52 * @return nothing
53 */
54void addHbStatusRegs(uint32_t i_procIndex, pdbg_target* i_pibTarget,
55 pdbg_target* i_fsiTarget);
56
57/**
Ben Tyneref320152020-01-09 10:31:23 -060058 * @brief The main attention handler logic
Ben Tyner970fd4f2020-02-19 13:46:42 -060059 *
60 * @param i_breakpoints true = breakpoint special attn handling enabled
Ben Tyneref320152020-01-09 10:31:23 -060061 */
Ben Tyner3fb52e52020-03-31 10:10:07 -050062void attnHandler(Config* i_config)
Ben Tyneref320152020-01-09 10:31:23 -060063{
Ben Tynerb481d902020-03-05 10:24:23 -060064 // Vector of active attentions to be handled
65 std::vector<Attention> active_attentions;
66
Ben Tyneref320152020-01-09 10:31:23 -060067 uint32_t isr_val, isr_mask;
Ben Tyneref320152020-01-09 10:31:23 -060068
69 // loop through processors looking for active attentions
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050070 trace<level::INFO>("Attention handler started");
Ben Tyner117af992020-05-22 13:32:11 -050071
Ben Tyneref320152020-01-09 10:31:23 -060072 pdbg_target* target;
Ben Tyner5e622d82020-09-11 10:10:24 -050073 pdbg_for_each_class_target("proc", target)
Ben Tyneref320152020-01-09 10:31:23 -060074 {
75 if (PDBG_TARGET_ENABLED == pdbg_target_probe(target))
76 {
Zane Shelleya79f6c82021-01-12 16:38:49 -060077 auto proc = pdbg_target_index(target); // get processor number
Ben Tyneref320152020-01-09 10:31:23 -060078
Ben Tynerb83c8522020-11-20 10:45:26 -060079 // Use PIB target to determine if a processor is enabled
Ben Tyner5e622d82020-09-11 10:10:24 -050080 char path[16];
Ben Tynerb83c8522020-11-20 10:45:26 -060081 sprintf(path, "/proc%d/pib", proc);
Ben Tyner8882c322021-02-05 12:13:21 -060082 pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050083
Ben Tynerb83c8522020-11-20 10:45:26 -060084 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -060085 if (nullptr == pibTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -060086 {
87 trace<level::INFO>("pib path or target not found");
88 continue;
89 }
90
Ben Tyner8882c322021-02-05 12:13:21 -060091 // check if pib target is enabled
92 if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget))
Ben Tyneref320152020-01-09 10:31:23 -060093 {
Ben Tynerb83c8522020-11-20 10:45:26 -060094 // The processor FSI target is required for CFAM read
95 sprintf(path, "/proc%d/fsi", proc);
Ben Tyner8882c322021-02-05 12:13:21 -060096 pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb83c8522020-11-20 10:45:26 -060097
98 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -060099 if (nullptr == fsiTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -0600100 {
101 trace<level::INFO>("fsi path or target not found");
102 continue;
103 }
104
Ben Tyner8882c322021-02-05 12:13:21 -0600105 // trace the proc number
106 std::string traceMsg = "proc: " + std::to_string(proc);
107 trace<level::INFO>(traceMsg.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600108
Ben Tyner5adc96e2020-11-20 10:54:12 -0600109 isr_val = 0xffffffff; // invalid isr value
110
Ben Tyner5e622d82020-09-11 10:10:24 -0500111 // get active attentions on processor
Ben Tyner8882c322021-02-05 12:13:21 -0600112 if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val))
Ben Tyneref320152020-01-09 10:31:23 -0600113 {
Ben Tynerfb190542020-11-06 09:27:56 -0600114 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500115 trace<level::INFO>("Error! cfam read 0x1007 FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600116 eventAttentionFail((int)AttnSection::attnHandler |
117 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600118 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600119 else if (0xffffffff == isr_val)
120 {
121 trace<level::INFO>("Error! cfam read 0x1007 INVALID");
122 continue;
123 }
Ben Tyneref320152020-01-09 10:31:23 -0600124 else
125 {
Ben Tyner8882c322021-02-05 12:13:21 -0600126 // trace isr value
127 std::stringstream ssIsr;
128 ssIsr << "cfam 0x1007 = 0x" << std::setw(8)
129 << std::setfill('0') << std::hex << isr_val;
130 std::string strobjIsr = ssIsr.str();
131 trace<level::INFO>(strobjIsr.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600132
Ben Tyner5adc96e2020-11-20 10:54:12 -0600133 isr_mask = 0xffffffff; // invalid isr mask
134
Ben Tyner5e622d82020-09-11 10:10:24 -0500135 // get interrupt enabled special attentions mask
Ben Tyner8882c322021-02-05 12:13:21 -0600136 if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask))
Ben Tyneref320152020-01-09 10:31:23 -0600137 {
Ben Tynerfb190542020-11-06 09:27:56 -0600138 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500139 trace<level::INFO>("Error! cfam read 0x100d FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600140 eventAttentionFail((int)AttnSection::attnHandler |
141 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600142 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600143 else if (0xffffffff == isr_mask)
144 {
145 trace<level::INFO>("Error! cfam read 0x100d INVALID");
146 continue;
147 }
Ben Tyner5e622d82020-09-11 10:10:24 -0500148 else
149 {
Ben Tyner8882c322021-02-05 12:13:21 -0600150 // trace true mask
151 std::stringstream ssMask;
152 ssMask << "cfam 0x100d = 0x" << std::setw(8)
153 << std::setfill('0') << std::hex << isr_mask;
154 std::string strobjMask = ssMask.str();
155 trace<level::INFO>(strobjMask.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600156
Ben Tynerfb190542020-11-06 09:27:56 -0600157 // SBE vital attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600158 if (true == activeAttn(isr_val, isr_mask, SBE_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500159 {
160 active_attentions.emplace_back(Attention::Vital,
161 handleVital, target,
162 i_config);
163 }
Brian Stegmiller2d5c63d2021-03-31 17:29:29 -0500164 else
165 {
166 // Hostboot wants some debug regs on Checkstops/TIs.
167 // Don't bother on SBE Vitals (scoms will fail).
168 // Only need to do on primary proc if you know what
169 // it is, but eBMC may not so we will dump all
170 // procs.
171 addHbStatusRegs(proc, pibTarget, fsiTarget);
172 } // Not SBE Vital attention
Ben Tyner5e622d82020-09-11 10:10:24 -0500173
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 Tyner3fb52e52020-03-31 10:10:07 -0500234 // if checkstop handling enabled, handle checkstop attention
235 if (false == (i_attention->getConfig()->getFlag(enCheckstop)))
236 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500237 trace<level::INFO>("Checkstop handling disabled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500238 }
239 else
240 {
Zane Shelley9fb73932020-09-15 13:34:57 -0500241 // Look for any attentions found in hardware. This will generate and
Zane Shelley7ae9c8c2020-12-02 20:10:31 -0600242 // commit a PEL if any errors are found.
Zane Shelley9fb73932020-09-15 13:34:57 -0500243 if (true != analyzer::analyzeHardware())
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500244 {
245 rc = RC_ANALYZER_ERROR;
246 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500247 }
Ben Tyneref320152020-01-09 10:31:23 -0600248
Ben Tyneref320152020-01-09 10:31:23 -0600249 return rc;
250}
251
252/**
253 * @brief Handle special attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500254 *
255 * @param i_attention Attention object
256 * @return 0 indicates that the special attention was successfully handled
257 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -0600258 */
Ben Tynerb481d902020-03-05 10:24:23 -0600259int handleSpecial(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600260{
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500261 int rc = RC_SUCCESS; // assume special attention handled
Ben Tyneref320152020-01-09 10:31:23 -0600262
Ben Tynerfb190542020-11-06 09:27:56 -0600263 // The TI info chipop will give us a pointer to the TI info data
Ben Tyner98430b32020-08-19 19:14:02 -0500264 uint8_t* tiInfo = nullptr; // ptr to TI info data
265 uint32_t tiInfoLen = 0; // length of TI info data
266 pdbg_target* attnProc = i_attention->getTarget(); // proc with attention
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500267
Ben Tyner29651ef2021-02-08 10:51:03 -0600268 bool tiInfoStatic = false; // assume TI info was provided (not created)
269
Ben Tyner98430b32020-08-19 19:14:02 -0500270 if (attnProc != nullptr)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500271 {
Ben Tyner98430b32020-08-19 19:14:02 -0500272 // The processor PIB target is required for get TI info chipop
273 char path[16];
274 sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc));
275 pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path);
276
277 if (nullptr != tiInfoTarget)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500278 {
Ben Tyner98430b32020-08-19 19:14:02 -0500279 if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget))
280 {
Ben Tyner98430b32020-08-19 19:14:02 -0500281 sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen);
Ben Tyner4bbcb382021-02-22 09:29:00 -0600282
283 // If TI info not available use default based on host state
284 if (nullptr == tiInfo)
Ben Tyner98430b32020-08-19 19:14:02 -0500285 {
Ben Tyner4bbcb382021-02-22 09:29:00 -0600286 trace<level::INFO>("TI info data ptr is invalid");
287
288 HostRunningState runningState = hostRunningState();
289 std::string stateString = "host state unknown";
290
291 if ((HostRunningState::Started == runningState) ||
292 (HostRunningState::Unknown == runningState))
293 {
294 if (HostRunningState::Started == runningState)
295 {
296 stateString = "host started";
297 }
298 tiInfo = (uint8_t*)defaultPhypTiInfo;
299 }
300 else
301 {
302 stateString = "host not started";
303 tiInfo = (uint8_t*)defaultHbTiInfo;
304 }
305
306 // trace host state
307 trace<level::INFO>(stateString.c_str());
308
Ben Tyner29651ef2021-02-08 10:51:03 -0600309 tiInfoStatic = true; // using our TI info
Ben Tyner98430b32020-08-19 19:14:02 -0500310 }
311 }
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500312 }
313 }
Ben Tyneref320152020-01-09 10:31:23 -0600314
Ben Tyner0fe5df42020-12-03 08:57:17 -0600315 bool tiInfoValid = false; // TI area data not valid or not available
316
Ben Tyner792f32f2020-06-02 08:50:47 -0500317 // If TI area exists and is marked valid we can assume TI occurred
318 if ((nullptr != tiInfo) && (0 != tiInfo[0]))
Ben Tyner970fd4f2020-02-19 13:46:42 -0600319 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500320 TiDataArea* tiDataArea = (TiDataArea*)tiInfo;
Ben Tyner7e6611f2020-02-13 16:42:56 -0600321
Ben Tyner8882c322021-02-05 12:13:21 -0600322 std::stringstream ss; // string stream object for tracing
323 std::string strobj; // string object for tracing
Ben Tyner40717722020-09-23 09:43:20 -0500324
Ben Tyner8882c322021-02-05 12:13:21 -0600325 // trace a few known TI data area values
326 ss.str(std::string()); // empty the stream
327 ss.clear(); // clear the stream
328 ss << "TI data command = 0x" << std::setw(2) << std::setfill('0')
329 << std::hex << (int)tiDataArea->command;
330 strobj = ss.str();
331 trace<level::INFO>(strobj.c_str());
Ben Tyner40717722020-09-23 09:43:20 -0500332
Ben Tyner0fe5df42020-12-03 08:57:17 -0600333 // Another check for valid TI Info since it has been seen that
334 // tiInfo[0] != 0 but TI info is not valid
335 if (0xa1 == tiDataArea->command)
Ben Tyner792f32f2020-06-02 08:50:47 -0500336 {
Ben Tyner0fe5df42020-12-03 08:57:17 -0600337 tiInfoValid = true;
338
339 // trace some more data since TI info appears valid
Ben Tyner8882c322021-02-05 12:13:21 -0600340 ss.str(std::string()); // empty the stream
341 ss.clear(); // clear the stream
Ben Tyner7a0dd542021-02-12 09:33:44 -0600342 ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0')
343 << std::hex << (int)tiDataArea->hbTerminateType;
Ben Tyner8882c322021-02-05 12:13:21 -0600344 strobj = ss.str();
345 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600346
Ben Tyner8882c322021-02-05 12:13:21 -0600347 ss.str(std::string()); // empty the stream
348 ss.clear(); // clear the stream
349 ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0')
350 << std::hex << (int)tiDataArea->srcFormat;
351 strobj = ss.str();
352 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600353
Ben Tyner8882c322021-02-05 12:13:21 -0600354 ss.str(std::string()); // empty the stream
355 ss.clear(); // clear the stream
356 ss << "TI data source = 0x" << std::setw(2) << std::setfill('0')
357 << std::hex << (int)tiDataArea->source;
358 strobj = ss.str();
359 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600360
361 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
362 {
363 // Call TI special attention handler
364 rc = tiHandler(tiDataArea);
365 }
Ben Tyner792f32f2020-06-02 08:50:47 -0500366 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500367 }
Ben Tyner0fe5df42020-12-03 08:57:17 -0600368
Ben Tynerfe156492021-04-08 07:28:13 -0500369 // TI area is available but was not valid data
Ben Tyner0fe5df42020-12-03 08:57:17 -0600370 if (false == tiInfoValid)
Ben Tyner3fb52e52020-03-31 10:10:07 -0500371 {
Ben Tynerfe156492021-04-08 07:28:13 -0500372 trace<level::INFO>("TI info NOT valid");
Ben Tyner98430b32020-08-19 19:14:02 -0500373
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500374 // if configured to handle TI as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500375 if (i_attention->getConfig()->getFlag(dfltTi))
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500376 {
Ben Tynerfe156492021-04-08 07:28:13 -0500377 // TI handling may be disabled
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500378 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
379 {
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500380 // Call TI special attention handler
381 rc = tiHandler(nullptr);
382 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500383 }
Ben Tynerfe156492021-04-08 07:28:13 -0500384 // breakpoint is default special attention when TI info NOT valid
385 else
386 {
387 // breakpoint handling may be disabled
388 if (true == (i_attention->getConfig()->getFlag(enBreakpoints)))
389 {
390 // Call the breakpoint special attention handler
391 rc = bpHandler();
392 }
393 }
Ben Tyner970fd4f2020-02-19 13:46:42 -0600394 }
Ben Tyneref320152020-01-09 10:31:23 -0600395
Ben Tyner792f32f2020-06-02 08:50:47 -0500396 // release TI data buffer
Ben Tyner29651ef2021-02-08 10:51:03 -0600397 if ((nullptr != tiInfo) && (false == tiInfoStatic))
Ben Tyner792f32f2020-06-02 08:50:47 -0500398 {
399 free(tiInfo);
400 }
401
Ben Tyner3fb52e52020-03-31 10:10:07 -0500402 if (RC_SUCCESS != rc)
403 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500404 trace<level::INFO>("Special attn not handled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500405 }
Ben Tyneref320152020-01-09 10:31:23 -0600406
407 return rc;
408}
409
Ben Tynerfb190542020-11-06 09:27:56 -0600410/**
411 * @brief Determine if attention is active and not masked
412 *
413 * Determine whether an attention needs to be handled and trace details of
414 * attention type and whether it is masked or not.
415 *
416 * @param i_val attention status register
417 * @param i_mask attention true mask register
418 * @param i_attn attention type
419 * @param i_proc processor associated with registers
420 *
421 * @return true if attention is active and not masked, otherwise false
422 */
Ben Tyner1965e502020-11-20 10:32:24 -0600423bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn)
Ben Tynerfb190542020-11-06 09:27:56 -0600424{
Zane Shelley9fb657f2021-01-12 15:30:58 -0600425 bool rc = false; // assume attn masked and/or inactive
Ben Tynerfb190542020-11-06 09:27:56 -0600426
427 // if attention active
428 if (0 != (i_val & i_attn))
429 {
Ben Tynerfb190542020-11-06 09:27:56 -0600430 std::stringstream ss;
Ben Tynerfb190542020-11-06 09:27:56 -0600431
Zane Shelley9fb657f2021-01-12 15:30:58 -0600432 bool validAttn = true; // known attention type
433
Ben Tynerfb190542020-11-06 09:27:56 -0600434 switch (i_attn)
435 {
436 case SBE_ATTN:
437 ss << "SBE attn";
438 break;
439 case CHECKSTOP_ATTN:
440 ss << "Checkstop attn";
441 break;
442 case SPECIAL_ATTN:
443 ss << "Special attn";
444 break;
445 default:
446 ss << "Unknown attn";
447 validAttn = false;
448 }
449
450 // see if attention is masked
451 if (true == validAttn)
452 {
453 if (0 != (i_mask & i_attn))
454 {
455 rc = true; // attention active and not masked
456 }
457 else
458 {
459 ss << " masked";
460 }
461 }
462
Ben Tyner8882c322021-02-05 12:13:21 -0600463 std::string strobj = ss.str(); // ss.str() is temporary
464 trace<level::INFO>(strobj.c_str()); // commit trace stream
Ben Tynerfb190542020-11-06 09:27:56 -0600465 }
466
467 return rc;
468}
469
Brian Stegmiller2d5c63d2021-03-31 17:29:29 -0500470/**
471 * @brief Traces some regs for hostboot
472 *
473 * When we receive a Checkstop or special Attention Term Immediate,
474 * hostboot wants some regs added to the error log. We will do this
475 * by tracing them here and then the traces will get added to
476 * the error log later
477 *
478 * @param i_procIndex - processor number (used in traces)
479 * @param i_pibTarget - target used for doing SCOMs to the processor
480 * @param i_fsiTarget - target used for doing CFAMs to the processor
481 *
482 * @return nothing
483 */
484void addHbStatusRegs(uint32_t i_procIndex, pdbg_target* i_pibTarget,
485 pdbg_target* i_fsiTarget)
486{
487 uint32_t l_cfamData = 0xFFFFFFFF;
488 uint64_t l_scomData1 = 0xFFFFFFFFFFFFFFFFull;
489 uint64_t l_scomData2 = 0xFFFFFFFFFFFFFFFFull;
490 uint32_t l_cfamAddr = 0x283C;
491 uint64_t l_scomAddr1 = 0x4602F489;
492 uint64_t l_scomAddr2 = 0x4602F487;
493
494 // We only need this for PRIMARY proc, but will just do on all procs for
495 // now. All attentions handled are fatal (except for plain breakpoints). Not
496 // going to sweat the plain breakpoint case since this is lab only using
497 // cronus.
498
499 // get first debug reg (CFAM)
500 if (RC_SUCCESS != fsi_read(i_fsiTarget, l_cfamAddr, &l_cfamData))
501 {
502 l_cfamData = 0xFFFFFFFF;
503 }
504
505 // Get SCOM regs next (just 2 of them)
506 if (RC_SUCCESS != pib_read(i_pibTarget, l_scomAddr1, &l_scomData1))
507 {
508 l_scomData1 = 0xFFFFFFFFFFFFFFFFull;
509 }
510
511 if (RC_SUCCESS != pib_read(i_pibTarget, l_scomAddr2, &l_scomData2))
512 {
513 l_scomData2 = 0xFFFFFFFFFFFFFFFFull;
514 }
515
516 // Trace out the results here of all 3 regs
517 // (Format should resemble FSP: HostBoot Reg:0000283C Data:AA801504
518 // 00000000 Proc:00050001 )
519 std::stringstream ss1, ss2, ss3;
520
521 ss1 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
522 << l_cfamAddr << " Data:" << l_cfamData << " Proc:" << std::setw(8)
523 << i_procIndex;
524
525 ss2 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
526 << l_scomAddr1 << " Data:" << std::setw(16) << l_scomData1
527 << " Proc:" << std::setw(8) << i_procIndex;
528
529 ss3 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
530 << l_scomAddr2 << " Data:" << std::setw(16) << l_scomData2
531 << " Proc:" << std::setw(8) << i_procIndex;
532
533 std::string strobj1 = ss1.str();
534 std::string strobj2 = ss2.str();
535 std::string strobj3 = ss3.str();
536
537 trace<level::INFO>(strobj1.c_str());
538 trace<level::INFO>(strobj2.c_str());
539 trace<level::INFO>(strobj3.c_str());
540
541 return;
542
543} // end addHbStatusRegs
544
Ben Tyneref320152020-01-09 10:31:23 -0600545} // namespace attn