| #include <config.h> |
| |
| #include <CLI/CLI.hpp> |
| |
| #ifdef WATCHDOG_DUMP_COLLECTION |
| extern "C" |
| { |
| #include <libpdbg.h> |
| #include <libpdbg_sbe.h> |
| } |
| |
| #include <fmt/format.h> |
| #include <libphal.H> |
| |
| #include <phosphor-logging/log.hpp> |
| #include <watchdog/watchdog_common.hpp> |
| #include <watchdog/watchdog_dbus.hpp> |
| #include <watchdog/watchdog_main.hpp> |
| #else |
| #include "org/open_power/Host/Boot/error.hpp" |
| #include "phosphor-logging/elog-errors.hpp" |
| |
| #include <phosphor-logging/elog.hpp> |
| #endif |
| |
| int main(int argc, char* argv[]) |
| { |
| CLI::App app{"Hostboot dump collector for watchdog timeout"}; |
| |
| #ifdef WATCHDOG_DUMP_COLLECTION |
| constexpr uint32_t dumpTimeout = 1500; // in seconds |
| uint32_t timeout = dumpTimeout; |
| app.add_option("-t,--timeout", timeout, |
| "Set timeout interval for watchdog timeout in seconds"); |
| #endif |
| |
| CLI11_PARSE(app, argc, argv); |
| |
| #ifdef WATCHDOG_DUMP_COLLECTION |
| using namespace phosphor::logging; |
| using namespace watchdog::dump; |
| |
| log<level::INFO>("Host did not respond within watchdog timeout interval"); |
| try |
| { |
| using namespace openpower::phal; |
| |
| // Initialize pdbg library, default parameters are used for init() |
| pdbg::init(); |
| |
| // Get Primary Proc |
| struct pdbg_target* procTarget = pdbg::getPrimaryProc(); |
| |
| // Check Primary IPL done |
| bool primaryIplDone = sbe::isPrimaryIplDone(); |
| if (primaryIplDone) |
| { |
| // SBE boot done, Need to collect hostboot dump |
| log<level::INFO>("Handle Hostboot boot failure"); |
| triggerHostbootDump(timeout); |
| } |
| else |
| { |
| // SBE boot window, handle SBE boot failure |
| log<level::INFO>("Handle SBE boot failure"); |
| handleSbeBootError(procTarget, timeout); |
| } |
| } |
| catch (const std::exception& e) |
| { |
| log<level::ERR>(fmt::format("Exception {} occurred", e.what()).c_str()); |
| std::string eventType = |
| "org.open_power.Processor.Error.WatchdogTimeout"; |
| auto ffdc = std::vector<FFDCTuple>{}; |
| std::map<std::string, std::string> additionalData; |
| |
| if (!createPel(eventType, additionalData, ffdc)) |
| { |
| log<level::ERR>("Failed to create PEL"); |
| } |
| |
| return EXIT_SUCCESS; |
| } |
| |
| #else |
| using namespace phosphor::logging; |
| using error = |
| sdbusplus::org::open_power::Host::Boot::Error::WatchdogTimedOut; |
| report<error>(); |
| #endif |
| |
| return EXIT_SUCCESS; |
| } |