diff options
author | William A. Kennington III <wak@google.com> | 2018-02-09 16:12:53 -0800 |
---|---|---|
committer | William A. Kennington III <wak@google.com> | 2018-02-21 23:54:59 +0000 |
commit | b638de22154aa4cae788d9117d2507394388f839 (patch) | |
tree | 6445adf4a1e1914dcf05d35d467961f14de940c0 /app/watchdog.cpp | |
parent | de14a027c06d93dadf05322529bec9d83f4cd181 (diff) | |
download | phosphor-host-ipmid-b638de22154aa4cae788d9117d2507394388f839.tar.gz phosphor-host-ipmid-b638de22154aa4cae788d9117d2507394388f839.zip |
watchdog: Implement watchdog action setting
We now respect the action set during the SetTimeout command. This maps
to one of the actions defined by the dbus Watchdog interface
Change-Id: I4d13d2539a2d955a4340bf5f915ca6f3b694550a
Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'app/watchdog.cpp')
-rw-r--r-- | app/watchdog.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/app/watchdog.cpp b/app/watchdog.cpp index f28ff80..84d80b9 100644 --- a/app/watchdog.cpp +++ b/app/watchdog.cpp @@ -66,6 +66,37 @@ enum class IpmiAction : uint8_t { PowerCycle = 0x3, }; +/** @brief Converts an IPMI Watchdog Action to DBUS defined action + * @param[in] ipmi_action The IPMI Watchdog Action + * @return The Watchdog Action that the ipmi_action maps to + */ +WatchdogService::Action ipmiActionToWdAction(IpmiAction ipmi_action) +{ + switch(ipmi_action) + { + case IpmiAction::None: + { + return WatchdogService::Action::None; + } + case IpmiAction::HardReset: + { + return WatchdogService::Action::HardReset; + } + case IpmiAction::PowerOff: + { + return WatchdogService::Action::PowerOff; + } + case IpmiAction::PowerCycle: + { + return WatchdogService::Action::PowerCycle; + } + default: + { + throw std::domain_error("IPMI Action is invalid"); + } + } +} + struct wd_set_req { uint8_t timer_use; uint8_t timer_action; @@ -106,15 +137,9 @@ ipmi_ret_t ipmi_app_watchdog_set( } // Set the action based on the request - // Unfortunately we only really support enable or disable - // and don't actually support a real action. Until we have proper - // action support just map NONE as a disable action. const auto ipmi_action = static_cast<IpmiAction>( req.timer_action & wd_timeout_action_mask); - if (ipmi_action == IpmiAction::None) - { - wd_service.setEnabled(false); - } + wd_service.setExpireAction(ipmiActionToWdAction(ipmi_action)); // Set the new interval and the time remaining deci -> mill seconds const uint64_t interval = req.initial_countdown * 100; |