blob: b1fa27b3df30d3f55cb981487eb4ed0b797c88d5 [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 Tyneref320152020-01-09 10:31:23 -060017
Ben Tynerb481d902020-03-05 10:24:23 -060018#include <algorithm>
Ben Tyneref320152020-01-09 10:31:23 -060019#include <iomanip>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050020#include <map>
Ben Tyner9ae5ca42020-02-28 13:13:50 -060021#include <sstream>
Ben Tynerb481d902020-03-05 10:24:23 -060022#include <vector>
Ben Tyneref320152020-01-09 10:31:23 -060023
24namespace attn
25{
26
27/**
Ben Tyneref320152020-01-09 10:31:23 -060028 * @brief Handle checkstop attention
29 *
Ben Tynerb481d902020-03-05 10:24:23 -060030 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050031 * @return 0 indicates that the checkstop attention was successfully handled
32 * 1 indicates that the checkstop attention was NOT successfully
33 * handled.
Ben Tyneref320152020-01-09 10:31:23 -060034 */
Ben Tynerb481d902020-03-05 10:24:23 -060035int handleCheckstop(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060036
37/**
38 * @brief Handle special attention
39 *
Ben Tynerb481d902020-03-05 10:24:23 -060040 * @param i_attention Attention object
Ben Tyner3fb52e52020-03-31 10:10:07 -050041 * @return 0 indicates that the special attention was successfully handled
42 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -060043 */
Ben Tynerb481d902020-03-05 10:24:23 -060044int handleSpecial(Attention* i_attention);
Ben Tyneref320152020-01-09 10:31:23 -060045
Ben Tynerfb190542020-11-06 09:27:56 -060046/** @brief Determine if attention is active and not masked */
Ben Tyner1965e502020-11-20 10:32:24 -060047bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn);
Ben Tynerfb190542020-11-06 09:27:56 -060048
Ben Tyneref320152020-01-09 10:31:23 -060049/**
Brian Stegmiller2d5c63d2021-03-31 17:29:29 -050050 * @brief Traces some regs for hostboot
51 *
52 * @param i_procIndex - processor number (used in traces)
53 * @param i_pibTarget - target used for doing SCOMs to the processor
54 * @param i_fsiTarget - target used for doing CFAMs to the processor
55 *
56 * @return nothing
57 */
58void addHbStatusRegs(uint32_t i_procIndex, pdbg_target* i_pibTarget,
59 pdbg_target* i_fsiTarget);
60
61/**
Ben Tyneref320152020-01-09 10:31:23 -060062 * @brief The main attention handler logic
Ben Tyner970fd4f2020-02-19 13:46:42 -060063 *
64 * @param i_breakpoints true = breakpoint special attn handling enabled
Ben Tyneref320152020-01-09 10:31:23 -060065 */
Ben Tyner3fb52e52020-03-31 10:10:07 -050066void attnHandler(Config* i_config)
Ben Tyneref320152020-01-09 10:31:23 -060067{
Ben Tynerb481d902020-03-05 10:24:23 -060068 // Vector of active attentions to be handled
69 std::vector<Attention> active_attentions;
70
Ben Tyneref320152020-01-09 10:31:23 -060071 uint32_t isr_val, isr_mask;
Ben Tyneref320152020-01-09 10:31:23 -060072
73 // loop through processors looking for active attentions
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050074 trace<level::INFO>("Attention handler started");
Ben Tyner117af992020-05-22 13:32:11 -050075
Ben Tyneref320152020-01-09 10:31:23 -060076 pdbg_target* target;
Ben Tyner5e622d82020-09-11 10:10:24 -050077 pdbg_for_each_class_target("proc", target)
Ben Tyneref320152020-01-09 10:31:23 -060078 {
79 if (PDBG_TARGET_ENABLED == pdbg_target_probe(target))
80 {
Zane Shelleya79f6c82021-01-12 16:38:49 -060081 auto proc = pdbg_target_index(target); // get processor number
Ben Tyneref320152020-01-09 10:31:23 -060082
Ben Tynerb83c8522020-11-20 10:45:26 -060083 // Use PIB target to determine if a processor is enabled
Ben Tyner5e622d82020-09-11 10:10:24 -050084 char path[16];
Ben Tynerb83c8522020-11-20 10:45:26 -060085 sprintf(path, "/proc%d/pib", proc);
Ben Tyner8882c322021-02-05 12:13:21 -060086 pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050087
Ben Tynerb83c8522020-11-20 10:45:26 -060088 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -060089 if (nullptr == pibTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -060090 {
91 trace<level::INFO>("pib path or target not found");
92 continue;
93 }
94
Ben Tyner8882c322021-02-05 12:13:21 -060095 // check if pib target is enabled
96 if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget))
Ben Tyneref320152020-01-09 10:31:23 -060097 {
Ben Tynerb83c8522020-11-20 10:45:26 -060098 // The processor FSI target is required for CFAM read
99 sprintf(path, "/proc%d/fsi", proc);
Ben Tyner8882c322021-02-05 12:13:21 -0600100 pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path);
Ben Tynerb83c8522020-11-20 10:45:26 -0600101
102 // sanity check
Ben Tyner8882c322021-02-05 12:13:21 -0600103 if (nullptr == fsiTarget)
Ben Tynerb83c8522020-11-20 10:45:26 -0600104 {
105 trace<level::INFO>("fsi path or target not found");
106 continue;
107 }
108
Ben Tyner8882c322021-02-05 12:13:21 -0600109 // trace the proc number
110 std::string traceMsg = "proc: " + std::to_string(proc);
111 trace<level::INFO>(traceMsg.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600112
Ben Tyner5adc96e2020-11-20 10:54:12 -0600113 isr_val = 0xffffffff; // invalid isr value
114
Ben Tyner5e622d82020-09-11 10:10:24 -0500115 // get active attentions on processor
Ben Tyner8882c322021-02-05 12:13:21 -0600116 if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val))
Ben Tyneref320152020-01-09 10:31:23 -0600117 {
Ben Tynerfb190542020-11-06 09:27:56 -0600118 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500119 trace<level::INFO>("Error! cfam read 0x1007 FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600120 eventAttentionFail((int)AttnSection::attnHandler |
121 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600122 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600123 else if (0xffffffff == isr_val)
124 {
125 trace<level::INFO>("Error! cfam read 0x1007 INVALID");
126 continue;
127 }
Ben Tyneref320152020-01-09 10:31:23 -0600128 else
129 {
Ben Tyner8882c322021-02-05 12:13:21 -0600130 // trace isr value
131 std::stringstream ssIsr;
132 ssIsr << "cfam 0x1007 = 0x" << std::setw(8)
133 << std::setfill('0') << std::hex << isr_val;
134 std::string strobjIsr = ssIsr.str();
135 trace<level::INFO>(strobjIsr.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600136
Ben Tyner5adc96e2020-11-20 10:54:12 -0600137 isr_mask = 0xffffffff; // invalid isr mask
138
Ben Tyner5e622d82020-09-11 10:10:24 -0500139 // get interrupt enabled special attentions mask
Ben Tyner8882c322021-02-05 12:13:21 -0600140 if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask))
Ben Tyneref320152020-01-09 10:31:23 -0600141 {
Ben Tynerfb190542020-11-06 09:27:56 -0600142 // log cfam read error
Ben Tyner5e622d82020-09-11 10:10:24 -0500143 trace<level::INFO>("Error! cfam read 0x100d FAILED");
Ben Tyner7a0dd542021-02-12 09:33:44 -0600144 eventAttentionFail((int)AttnSection::attnHandler |
145 ATTN_PDBG_CFAM);
Ben Tyneref320152020-01-09 10:31:23 -0600146 }
Ben Tyner5adc96e2020-11-20 10:54:12 -0600147 else if (0xffffffff == isr_mask)
148 {
149 trace<level::INFO>("Error! cfam read 0x100d INVALID");
150 continue;
151 }
Ben Tyner5e622d82020-09-11 10:10:24 -0500152 else
153 {
Ben Tyner8882c322021-02-05 12:13:21 -0600154 // trace true mask
155 std::stringstream ssMask;
156 ssMask << "cfam 0x100d = 0x" << std::setw(8)
157 << std::setfill('0') << std::hex << isr_mask;
158 std::string strobjMask = ssMask.str();
159 trace<level::INFO>(strobjMask.c_str());
Ben Tyner1965e502020-11-20 10:32:24 -0600160
Ben Tynerfb190542020-11-06 09:27:56 -0600161 // SBE vital attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600162 if (true == activeAttn(isr_val, isr_mask, SBE_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500163 {
164 active_attentions.emplace_back(Attention::Vital,
165 handleVital, target,
166 i_config);
167 }
Brian Stegmiller2d5c63d2021-03-31 17:29:29 -0500168 else
169 {
170 // Hostboot wants some debug regs on Checkstops/TIs.
171 // Don't bother on SBE Vitals (scoms will fail).
172 // Only need to do on primary proc if you know what
173 // it is, but eBMC may not so we will dump all
174 // procs.
175 addHbStatusRegs(proc, pibTarget, fsiTarget);
176 } // Not SBE Vital attention
Ben Tyner5e622d82020-09-11 10:10:24 -0500177
Ben Tynerfb190542020-11-06 09:27:56 -0600178 // Checkstop attention active and not masked?
179 if (true ==
Ben Tyner1965e502020-11-20 10:32:24 -0600180 activeAttn(isr_val, isr_mask, CHECKSTOP_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500181 {
182 active_attentions.emplace_back(Attention::Checkstop,
183 handleCheckstop,
184 target, i_config);
185 }
186
Ben Tynerfb190542020-11-06 09:27:56 -0600187 // Special attention active and not masked?
Ben Tyner1965e502020-11-20 10:32:24 -0600188 if (true == activeAttn(isr_val, isr_mask, SPECIAL_ATTN))
Ben Tyner5e622d82020-09-11 10:10:24 -0500189 {
190 active_attentions.emplace_back(Attention::Special,
191 handleSpecial,
192 target, i_config);
193 }
194 } // cfam 0x100d valid
195 } // cfam 0x1007 valid
Ben Tyner8882c322021-02-05 12:13:21 -0600196 } // fsi target enabled
197 } // pib target enabled
Ben Tyner5e622d82020-09-11 10:10:24 -0500198 } // next processor
Ben Tyneref320152020-01-09 10:31:23 -0600199
Ben Tynerb481d902020-03-05 10:24:23 -0600200 // convert to heap, highest priority is at front
201 if (!std::is_heap(active_attentions.begin(), active_attentions.end()))
202 {
203 std::make_heap(active_attentions.begin(), active_attentions.end());
204 }
205
206 // call the attention handler until one is handled or all were attempted
207 while (false == active_attentions.empty())
208 {
209 // handle highest priority attention, done if successful
210 if (RC_SUCCESS == active_attentions.front().handle())
211 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500212 // an attention was handled so we are done
Ben Tynerb481d902020-03-05 10:24:23 -0600213 break;
214 }
215
216 // move attention to back of vector
217 std::pop_heap(active_attentions.begin(), active_attentions.end());
218
219 // remove attention from vector
220 active_attentions.pop_back();
221 }
Ben Tyneref320152020-01-09 10:31:23 -0600222}
223
224/**
Ben Tyneref320152020-01-09 10:31:23 -0600225 * @brief Handle checkstop attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500226 *
227 * @param i_attention Attention object
228 * @return 0 indicates that the checkstop attention was successfully handled
229 * 1 indicates that the checkstop attention was NOT successfully
230 * handled.
Ben Tyneref320152020-01-09 10:31:23 -0600231 */
Ben Tynerb481d902020-03-05 10:24:23 -0600232int handleCheckstop(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600233{
Ben Tyner3fb52e52020-03-31 10:10:07 -0500234 int rc = RC_SUCCESS; // assume checkstop handled
Ben Tyneref320152020-01-09 10:31:23 -0600235
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500236 trace<level::INFO>("checkstop handler started");
237
Ben Tyner3fb52e52020-03-31 10:10:07 -0500238 // if checkstop handling enabled, handle checkstop attention
239 if (false == (i_attention->getConfig()->getFlag(enCheckstop)))
240 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500241 trace<level::INFO>("Checkstop handling disabled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500242 }
243 else
244 {
Zane Shelley9fb73932020-09-15 13:34:57 -0500245 // Look for any attentions found in hardware. This will generate and
Zane Shelley7ae9c8c2020-12-02 20:10:31 -0600246 // commit a PEL if any errors are found.
Zane Shelley9fb73932020-09-15 13:34:57 -0500247 if (true != analyzer::analyzeHardware())
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500248 {
249 rc = RC_ANALYZER_ERROR;
250 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500251 }
Ben Tyneref320152020-01-09 10:31:23 -0600252
Ben Tyneref320152020-01-09 10:31:23 -0600253 return rc;
254}
255
256/**
257 * @brief Handle special attention
Ben Tyner3fb52e52020-03-31 10:10:07 -0500258 *
259 * @param i_attention Attention object
260 * @return 0 indicates that the special attention was successfully handled
261 * 1 indicates that the special attention was NOT successfully handled
Ben Tyneref320152020-01-09 10:31:23 -0600262 */
Ben Tynerb481d902020-03-05 10:24:23 -0600263int handleSpecial(Attention* i_attention)
Ben Tyneref320152020-01-09 10:31:23 -0600264{
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500265 int rc = RC_SUCCESS; // assume special attention handled
Ben Tyneref320152020-01-09 10:31:23 -0600266
Ben Tynerfb190542020-11-06 09:27:56 -0600267 // The TI info chipop will give us a pointer to the TI info data
Ben Tyner98430b32020-08-19 19:14:02 -0500268 uint8_t* tiInfo = nullptr; // ptr to TI info data
269 uint32_t tiInfoLen = 0; // length of TI info data
270 pdbg_target* attnProc = i_attention->getTarget(); // proc with attention
Ben Tynerb1ebfcb2020-05-08 18:52:48 -0500271
Ben Tyner29651ef2021-02-08 10:51:03 -0600272 bool tiInfoStatic = false; // assume TI info was provided (not created)
273
Ben Tyner98430b32020-08-19 19:14:02 -0500274 if (attnProc != nullptr)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500275 {
Ben Tyner98430b32020-08-19 19:14:02 -0500276 // The processor PIB target is required for get TI info chipop
277 char path[16];
278 sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc));
279 pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path);
280
281 if (nullptr != tiInfoTarget)
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500282 {
Ben Tyner98430b32020-08-19 19:14:02 -0500283 if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget))
284 {
Ben Tyner98430b32020-08-19 19:14:02 -0500285 sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen);
Ben Tyner4bbcb382021-02-22 09:29:00 -0600286
287 // If TI info not available use default based on host state
288 if (nullptr == tiInfo)
Ben Tyner98430b32020-08-19 19:14:02 -0500289 {
Ben Tyner4bbcb382021-02-22 09:29:00 -0600290 trace<level::INFO>("TI info data ptr is invalid");
291
292 HostRunningState runningState = hostRunningState();
293 std::string stateString = "host state unknown";
294
295 if ((HostRunningState::Started == runningState) ||
296 (HostRunningState::Unknown == runningState))
297 {
298 if (HostRunningState::Started == runningState)
299 {
300 stateString = "host started";
301 }
302 tiInfo = (uint8_t*)defaultPhypTiInfo;
303 }
304 else
305 {
306 stateString = "host not started";
307 tiInfo = (uint8_t*)defaultHbTiInfo;
308 }
309
310 // trace host state
311 trace<level::INFO>(stateString.c_str());
312
Ben Tyner29651ef2021-02-08 10:51:03 -0600313 tiInfoStatic = true; // using our TI info
Ben Tyner98430b32020-08-19 19:14:02 -0500314 }
315 }
Ben Tyner89c0a7a2020-08-07 12:07:35 -0500316 }
317 }
Ben Tyneref320152020-01-09 10:31:23 -0600318
Ben Tyner0fe5df42020-12-03 08:57:17 -0600319 bool tiInfoValid = false; // TI area data not valid or not available
320
Ben Tyner792f32f2020-06-02 08:50:47 -0500321 // If TI area exists and is marked valid we can assume TI occurred
322 if ((nullptr != tiInfo) && (0 != tiInfo[0]))
Ben Tyner970fd4f2020-02-19 13:46:42 -0600323 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500324 TiDataArea* tiDataArea = (TiDataArea*)tiInfo;
Ben Tyner7e6611f2020-02-13 16:42:56 -0600325
Ben Tyner8882c322021-02-05 12:13:21 -0600326 std::stringstream ss; // string stream object for tracing
327 std::string strobj; // string object for tracing
Ben Tyner40717722020-09-23 09:43:20 -0500328
Ben Tyner8882c322021-02-05 12:13:21 -0600329 // trace a few known TI data area values
330 ss.str(std::string()); // empty the stream
331 ss.clear(); // clear the stream
332 ss << "TI data command = 0x" << std::setw(2) << std::setfill('0')
333 << std::hex << (int)tiDataArea->command;
334 strobj = ss.str();
335 trace<level::INFO>(strobj.c_str());
Ben Tyner40717722020-09-23 09:43:20 -0500336
Ben Tyner0fe5df42020-12-03 08:57:17 -0600337 // Another check for valid TI Info since it has been seen that
338 // tiInfo[0] != 0 but TI info is not valid
339 if (0xa1 == tiDataArea->command)
Ben Tyner792f32f2020-06-02 08:50:47 -0500340 {
Ben Tyner0fe5df42020-12-03 08:57:17 -0600341 tiInfoValid = true;
342
343 // trace some more data since TI info appears valid
Ben Tyner8882c322021-02-05 12:13:21 -0600344 ss.str(std::string()); // empty the stream
345 ss.clear(); // clear the stream
Ben Tyner7a0dd542021-02-12 09:33:44 -0600346 ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0')
347 << std::hex << (int)tiDataArea->hbTerminateType;
Ben Tyner8882c322021-02-05 12:13:21 -0600348 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 SRC format = 0x" << std::setw(2) << std::setfill('0')
354 << std::hex << (int)tiDataArea->srcFormat;
355 strobj = ss.str();
356 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600357
Ben Tyner8882c322021-02-05 12:13:21 -0600358 ss.str(std::string()); // empty the stream
359 ss.clear(); // clear the stream
360 ss << "TI data source = 0x" << std::setw(2) << std::setfill('0')
361 << std::hex << (int)tiDataArea->source;
362 strobj = ss.str();
363 trace<level::INFO>(strobj.c_str());
Ben Tyner0fe5df42020-12-03 08:57:17 -0600364
365 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
366 {
367 // Call TI special attention handler
368 rc = tiHandler(tiDataArea);
369 }
Ben Tyner792f32f2020-06-02 08:50:47 -0500370 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500371 }
Ben Tyner0fe5df42020-12-03 08:57:17 -0600372
Ben Tynerfe156492021-04-08 07:28:13 -0500373 // TI area is available but was not valid data
Ben Tyner0fe5df42020-12-03 08:57:17 -0600374 if (false == tiInfoValid)
Ben Tyner3fb52e52020-03-31 10:10:07 -0500375 {
Ben Tynerfe156492021-04-08 07:28:13 -0500376 trace<level::INFO>("TI info NOT valid");
Ben Tyner98430b32020-08-19 19:14:02 -0500377
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500378 // if configured to handle TI as default special attention
Ben Tynerfe156492021-04-08 07:28:13 -0500379 if (i_attention->getConfig()->getFlag(dfltTi))
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500380 {
Ben Tynerfe156492021-04-08 07:28:13 -0500381 // TI handling may be disabled
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500382 if (true == (i_attention->getConfig()->getFlag(enTerminate)))
383 {
Ben Tynere4f5dbe2020-10-19 07:19:33 -0500384 // Call TI special attention handler
385 rc = tiHandler(nullptr);
386 }
Ben Tyner3fb52e52020-03-31 10:10:07 -0500387 }
Ben Tynerfe156492021-04-08 07:28:13 -0500388 // breakpoint is default special attention when TI info NOT valid
389 else
390 {
391 // breakpoint handling may be disabled
392 if (true == (i_attention->getConfig()->getFlag(enBreakpoints)))
393 {
394 // Call the breakpoint special attention handler
395 rc = bpHandler();
396 }
397 }
Ben Tyner970fd4f2020-02-19 13:46:42 -0600398 }
Ben Tyneref320152020-01-09 10:31:23 -0600399
Ben Tyner792f32f2020-06-02 08:50:47 -0500400 // release TI data buffer
Ben Tyner29651ef2021-02-08 10:51:03 -0600401 if ((nullptr != tiInfo) && (false == tiInfoStatic))
Ben Tyner792f32f2020-06-02 08:50:47 -0500402 {
403 free(tiInfo);
404 }
405
Ben Tyner3fb52e52020-03-31 10:10:07 -0500406 if (RC_SUCCESS != rc)
407 {
Ben Tyner792f32f2020-06-02 08:50:47 -0500408 trace<level::INFO>("Special attn not handled");
Ben Tyner3fb52e52020-03-31 10:10:07 -0500409 }
Ben Tyneref320152020-01-09 10:31:23 -0600410
411 return rc;
412}
413
Ben Tynerfb190542020-11-06 09:27:56 -0600414/**
415 * @brief Determine if attention is active and not masked
416 *
417 * Determine whether an attention needs to be handled and trace details of
418 * attention type and whether it is masked or not.
419 *
420 * @param i_val attention status register
421 * @param i_mask attention true mask register
422 * @param i_attn attention type
423 * @param i_proc processor associated with registers
424 *
425 * @return true if attention is active and not masked, otherwise false
426 */
Ben Tyner1965e502020-11-20 10:32:24 -0600427bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn)
Ben Tynerfb190542020-11-06 09:27:56 -0600428{
Zane Shelley9fb657f2021-01-12 15:30:58 -0600429 bool rc = false; // assume attn masked and/or inactive
Ben Tynerfb190542020-11-06 09:27:56 -0600430
431 // if attention active
432 if (0 != (i_val & i_attn))
433 {
Ben Tynerfb190542020-11-06 09:27:56 -0600434 std::stringstream ss;
Ben Tynerfb190542020-11-06 09:27:56 -0600435
Zane Shelley9fb657f2021-01-12 15:30:58 -0600436 bool validAttn = true; // known attention type
437
Ben Tynerfb190542020-11-06 09:27:56 -0600438 switch (i_attn)
439 {
440 case SBE_ATTN:
441 ss << "SBE attn";
442 break;
443 case CHECKSTOP_ATTN:
444 ss << "Checkstop attn";
445 break;
446 case SPECIAL_ATTN:
447 ss << "Special attn";
448 break;
449 default:
450 ss << "Unknown attn";
451 validAttn = false;
452 }
453
454 // see if attention is masked
455 if (true == validAttn)
456 {
457 if (0 != (i_mask & i_attn))
458 {
459 rc = true; // attention active and not masked
460 }
461 else
462 {
463 ss << " masked";
464 }
465 }
466
Ben Tyner8882c322021-02-05 12:13:21 -0600467 std::string strobj = ss.str(); // ss.str() is temporary
468 trace<level::INFO>(strobj.c_str()); // commit trace stream
Ben Tynerfb190542020-11-06 09:27:56 -0600469 }
470
471 return rc;
472}
473
Brian Stegmiller2d5c63d2021-03-31 17:29:29 -0500474/**
475 * @brief Traces some regs for hostboot
476 *
477 * When we receive a Checkstop or special Attention Term Immediate,
478 * hostboot wants some regs added to the error log. We will do this
479 * by tracing them here and then the traces will get added to
480 * the error log later
481 *
482 * @param i_procIndex - processor number (used in traces)
483 * @param i_pibTarget - target used for doing SCOMs to the processor
484 * @param i_fsiTarget - target used for doing CFAMs to the processor
485 *
486 * @return nothing
487 */
488void addHbStatusRegs(uint32_t i_procIndex, pdbg_target* i_pibTarget,
489 pdbg_target* i_fsiTarget)
490{
491 uint32_t l_cfamData = 0xFFFFFFFF;
492 uint64_t l_scomData1 = 0xFFFFFFFFFFFFFFFFull;
493 uint64_t l_scomData2 = 0xFFFFFFFFFFFFFFFFull;
494 uint32_t l_cfamAddr = 0x283C;
495 uint64_t l_scomAddr1 = 0x4602F489;
496 uint64_t l_scomAddr2 = 0x4602F487;
497
498 // We only need this for PRIMARY proc, but will just do on all procs for
499 // now. All attentions handled are fatal (except for plain breakpoints). Not
500 // going to sweat the plain breakpoint case since this is lab only using
501 // cronus.
502
503 // get first debug reg (CFAM)
504 if (RC_SUCCESS != fsi_read(i_fsiTarget, l_cfamAddr, &l_cfamData))
505 {
506 l_cfamData = 0xFFFFFFFF;
507 }
508
509 // Get SCOM regs next (just 2 of them)
510 if (RC_SUCCESS != pib_read(i_pibTarget, l_scomAddr1, &l_scomData1))
511 {
512 l_scomData1 = 0xFFFFFFFFFFFFFFFFull;
513 }
514
515 if (RC_SUCCESS != pib_read(i_pibTarget, l_scomAddr2, &l_scomData2))
516 {
517 l_scomData2 = 0xFFFFFFFFFFFFFFFFull;
518 }
519
520 // Trace out the results here of all 3 regs
521 // (Format should resemble FSP: HostBoot Reg:0000283C Data:AA801504
522 // 00000000 Proc:00050001 )
523 std::stringstream ss1, ss2, ss3;
524
525 ss1 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
526 << l_cfamAddr << " Data:" << l_cfamData << " Proc:" << std::setw(8)
527 << i_procIndex;
528
529 ss2 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
530 << l_scomAddr1 << " Data:" << std::setw(16) << l_scomData1
531 << " Proc:" << std::setw(8) << i_procIndex;
532
533 ss3 << "HostBoot Reg:" << std::setw(8) << std::setfill('0') << std::hex
534 << l_scomAddr2 << " Data:" << std::setw(16) << l_scomData2
535 << " Proc:" << std::setw(8) << i_procIndex;
536
537 std::string strobj1 = ss1.str();
538 std::string strobj2 = ss2.str();
539 std::string strobj3 = ss3.str();
540
541 trace<level::INFO>(strobj1.c_str());
542 trace<level::INFO>(strobj2.c_str());
543 trace<level::INFO>(strobj3.c_str());
544
545 return;
546
547} // end addHbStatusRegs
548
Ben Tyneref320152020-01-09 10:31:23 -0600549} // namespace attn