blob: c0762560e2dc81dfa4ee5583fc44fd74664c470a [file] [log] [blame]
Ben Tynerbcf65a82020-12-01 08:46:36 -06001#include <attn/attention.hpp>
2#include <attn/attn_common.hpp>
Ben Tyner7f6ce6a2021-08-17 19:40:00 -05003#include <attn/attn_dump.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -06004#include <attn/attn_logging.hpp>
5#include <sdbusplus/bus.hpp>
Ben Tyner93067162021-07-23 10:39:30 -05006#include <util/dbus.hpp>
austinfcuibfa831a2022-01-26 15:37:07 -06007#include <util/trace.hpp>
Ben Tynerbcf65a82020-12-01 08:46:36 -06008
9namespace attn
10{
11
12/**
13 * @brief Handle SBE vital attention
14 *
15 * @param i_attention Attention object
16 * @return 0 indicates that the vital attention was successfully handled
17 * 1 indicates that the vital attention was NOT successfully handled
18 */
19int handleVital(Attention* i_attention)
20{
21 int rc = RC_SUCCESS; // assume vital handled
22
austinfcuibfa831a2022-01-26 15:37:07 -060023 trace::inf("vital handler started");
Ben Tynerbcf65a82020-12-01 08:46:36 -060024
25 // if vital handling enabled, handle vital attention
26 if (false == (i_attention->getConfig()->getFlag(enVital)))
27 {
austinfcuibfa831a2022-01-26 15:37:07 -060028 trace::inf("vital handling disabled");
Ben Tynerbcf65a82020-12-01 08:46:36 -060029 rc = RC_NOT_HANDLED;
30 }
31 else
32 {
Ben Tyner3a80c982022-10-21 12:49:41 -050033 // wait for power fault handling before starting analyses
34 sleepSeconds(POWER_FAULT_WAIT);
35
Ben Tynerbcf65a82020-12-01 08:46:36 -060036 // generate pel
Ben Tyner7f6ce6a2021-08-17 19:40:00 -050037 auto pelId = eventVital();
38
39 // conditionally request dump
40 if ((0 != pelId) && (util::dbus::HostRunningState::NotStarted ==
41 util::dbus::hostRunningState()))
42 {
Zane Shelley611b3442021-11-19 16:02:01 -060043 requestDump(pelId, DumpParameters{0, DumpType::SBE});
Ben Tyner7f6ce6a2021-08-17 19:40:00 -050044 }
45
46 // transition host
47 util::dbus::transitionHost(util::dbus::HostState::Quiesce);
Ben Tynerbcf65a82020-12-01 08:46:36 -060048 }
49
50 return rc;
51}
52
53} // namespace attn