summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/watchdog.cpp91
-rw-r--r--app/watchdog_service.cpp8
-rw-r--r--app/watchdog_service.hpp9
3 files changed, 108 insertions, 0 deletions
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index 7ca465c..abdf8e4 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -88,6 +88,8 @@ ipmi_ret_t ipmi_app_watchdog_reset(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
static constexpr uint8_t wd_dont_stop = 0x1 << 6;
static constexpr uint8_t wd_timeout_action_mask = 0x3;
+static constexpr uint8_t wdTimerUseMask = 0x7;
+
enum class IpmiAction : uint8_t
{
None = 0x0,
@@ -127,6 +129,51 @@ WatchdogService::Action ipmiActionToWdAction(IpmiAction ipmi_action)
}
}
+enum class IpmiTimerUse : uint8_t
+{
+ Reserved = 0x0,
+ BIOSFRB2 = 0x1,
+ BIOSPOST = 0x2,
+ OSLoad = 0x3,
+ SMSOS = 0x4,
+ OEM = 0x5,
+};
+
+WatchdogService::TimerUse ipmiTimerUseToWdTimerUse(IpmiTimerUse ipmiTimerUse)
+{
+ switch (ipmiTimerUse)
+ {
+ case IpmiTimerUse::Reserved:
+ {
+ return WatchdogService::TimerUse::Reserved;
+ }
+ case IpmiTimerUse::BIOSFRB2:
+ {
+ return WatchdogService::TimerUse::BIOSFRB2;
+ }
+ case IpmiTimerUse::BIOSPOST:
+ {
+ return WatchdogService::TimerUse::BIOSPOST;
+ }
+ case IpmiTimerUse::OSLoad:
+ {
+ return WatchdogService::TimerUse::OSLoad;
+ }
+ case IpmiTimerUse::SMSOS:
+ {
+ return WatchdogService::TimerUse::SMSOS;
+ }
+ case IpmiTimerUse::OEM:
+ {
+ return WatchdogService::TimerUse::OEM;
+ }
+ default:
+ {
+ return WatchdogService::TimerUse::Reserved;
+ }
+ }
+}
+
struct wd_set_req
{
uint8_t timer_use;
@@ -170,6 +217,10 @@ ipmi_ret_t ipmi_app_watchdog_set(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
static_cast<IpmiAction>(req.timer_action & wd_timeout_action_mask);
wd_service.setExpireAction(ipmiActionToWdAction(ipmi_action));
+ const auto ipmiTimerUse =
+ static_cast<IpmiTimerUse>(req.timer_use & wdTimerUseMask);
+ wd_service.setTimerUse(ipmiTimerUseToWdTimerUse(ipmiTimerUse));
+
// Set the new interval and the time remaining deci -> mill seconds
const uint64_t interval = req.initial_countdown * 100;
wd_service.setInterval(interval);
@@ -239,6 +290,42 @@ IpmiAction wdActionToIpmiAction(WatchdogService::Action wd_action)
}
}
+IpmiTimerUse wdTimerUseToIpmiTimerUse(WatchdogService::TimerUse wdTimerUse)
+{
+ switch (wdTimerUse)
+ {
+ case WatchdogService::TimerUse::Reserved:
+ {
+ return IpmiTimerUse::Reserved;
+ }
+ case WatchdogService::TimerUse::BIOSFRB2:
+ {
+ return IpmiTimerUse::BIOSFRB2;
+ }
+ case WatchdogService::TimerUse::BIOSPOST:
+ {
+ return IpmiTimerUse::BIOSPOST;
+ }
+ case WatchdogService::TimerUse::OSLoad:
+ {
+ return IpmiTimerUse::OSLoad;
+ }
+
+ case WatchdogService::TimerUse::SMSOS:
+ {
+ return IpmiTimerUse::SMSOS;
+ }
+ case WatchdogService::TimerUse::OEM:
+ {
+ return IpmiTimerUse::OEM;
+ }
+ default:
+ {
+ return IpmiTimerUse::Reserved;
+ }
+ }
+}
+
struct wd_get_res
{
uint8_t timer_use;
@@ -278,6 +365,10 @@ ipmi_ret_t ipmi_app_watchdog_get(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
{
res.timer_use |= wd_running;
}
+
+ res.timer_use |=
+ static_cast<uint8_t>(wdTimerUseToIpmiTimerUse(wd_prop.timerUse));
+
// TODO: Do something about having pretimeout support
res.pretimeout = 0;
res.expire_flags = 0;
diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp
index 1deb58b..e65ea63 100644
--- a/app/watchdog_service.cpp
+++ b/app/watchdog_service.cpp
@@ -80,6 +80,9 @@ WatchdogService::Properties WatchdogService::getProperties()
wd_prop.enabled = get<bool>(properties.at("Enabled"));
wd_prop.expireAction = Watchdog::convertActionFromString(
get<std::string>(properties.at("ExpireAction")));
+ wd_prop.timerUse = Watchdog::convertTimerUseFromString(
+ get<std::string>(properties.at("CurrentTimerUse")));
+
wd_prop.interval = get<uint64_t>(properties.at("Interval"));
wd_prop.timeRemaining = get<uint64_t>(properties.at("TimeRemaining"));
return wd_prop;
@@ -179,6 +182,11 @@ void WatchdogService::setExpireAction(Action expireAction)
setProperty("ExpireAction", convertForMessage(expireAction));
}
+void WatchdogService::setTimerUse(TimerUse timerUse)
+{
+ setProperty("CurrentTimerUse", convertForMessage(timerUse));
+}
+
void WatchdogService::setInterval(uint64_t interval)
{
setProperty("Interval", interval);
diff --git a/app/watchdog_service.hpp b/app/watchdog_service.hpp
index 8056fb7..75afc1e 100644
--- a/app/watchdog_service.hpp
+++ b/app/watchdog_service.hpp
@@ -16,6 +16,8 @@ class WatchdogService
using Action =
sdbusplus::xyz::openbmc_project::State::server::Watchdog::Action;
+ using TimerUse =
+ sdbusplus::xyz::openbmc_project::State::server::Watchdog::TimerUse;
/** @brief Resets the time remaining on the watchdog.
* Equivalent to setTimeRemaining(getInterval()).
@@ -33,6 +35,7 @@ class WatchdogService
bool initialized;
bool enabled;
Action expireAction;
+ TimerUse timerUse;
uint64_t interval;
uint64_t timeRemaining;
};
@@ -70,6 +73,12 @@ class WatchdogService
*/
void setExpireAction(Action expireAction);
+ /** @brief Sets the value of the timerUse property on the host watchdog
+ *
+ * @param[in] timerUse - The new timerUse value
+ */
+ void setTimerUse(TimerUse timerUse);
+
/** @brief Sets the value of the interval property on the host watchdog
*
* @param[in] interval - The new interval value
OpenPOWER on IntegriCloud