summaryrefslogtreecommitdiff
path: root/special-mode-mgr
diff options
context:
space:
mode:
authorRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-08-02 07:54:11 +0300
committerRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-08-02 07:54:11 +0300
commit4c64b1593dc059486c6f39c7c9a50c445af1e21c (patch)
tree484c3824bba11cfd9b204f30788861d173fac88f /special-mode-mgr
parent197f412ce7aafe23f4aca762c4ca54a78f9523c0 (diff)
downloadprovingground-4c64b1593dc059486c6f39c7c9a50c445af1e21c.tar.xz
[mfg]: Manufacutring timeout & timer reset update
As per the manufacturing EAS document 0.7, updated timeout for manufacturing mode from 12 hours to 15 minutes. Added support for ResetTimer method, which will be used by all manufacturing commands to extend the timer for next 15 minutes. Tested: 1. Entered manufacturing mode, and verified that mode expires after 15 minutes of power on 2. Entered manufacturing mode, executed ResetTimer() method and verified timer got expired and BMC was in manufacturing mode itself. Change-Id: Ieb785b4a59d914548909d422415584ccd94c6ccc Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'special-mode-mgr')
-rw-r--r--special-mode-mgr/include/specialmodemgr.hpp5
-rw-r--r--special-mode-mgr/src/specialmodemgr.cpp50
2 files changed, 33 insertions, 22 deletions
diff --git a/special-mode-mgr/include/specialmodemgr.hpp b/special-mode-mgr/include/specialmodemgr.hpp
index a5f23fd..2f0183b 100644
--- a/special-mode-mgr/include/specialmodemgr.hpp
+++ b/special-mode-mgr/include/specialmodemgr.hpp
@@ -16,8 +16,8 @@
#pragma once
-#include <boost/asio/deadline_timer.hpp>
#include <sdbusplus/asio/object_server.hpp>
+#include <chrono>
static constexpr const char* strSpecialMode = "SpecialMode";
@@ -35,11 +35,12 @@ class SpecialModeMgr
std::shared_ptr<sdbusplus::asio::connection> conn;
std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
uint8_t specialMode = none;
- std::unique_ptr<boost::asio::deadline_timer> timer = nullptr;
+ std::unique_ptr<boost::asio::steady_timer> timer = nullptr;
std::unique_ptr<sdbusplus::bus::match::match> intfAddMatchRule = nullptr;
std::unique_ptr<sdbusplus::bus::match::match> propUpdMatchRule = nullptr;
void addSpecialModeProperty();
void checkAndAddSpecialModeProperty(const std::string& provMode);
+ void updateTimer(int countInSeconds);
public:
void setSpecialModeValue(uint8_t value) const
diff --git a/special-mode-mgr/src/specialmodemgr.cpp b/special-mode-mgr/src/specialmodemgr.cpp
index 217705a..1e3ba3a 100644
--- a/special-mode-mgr/src/specialmodemgr.cpp
+++ b/special-mode-mgr/src/specialmodemgr.cpp
@@ -36,6 +36,7 @@ static constexpr const char* restrictionModeIntf =
"xyz.openbmc_project.Control.Security.RestrictionMode";
static constexpr const char* restrictionModeProperty = "RestrictionMode";
+static constexpr int mtmAllowedTime = 15 * 60; // 15 minutes
using VariantValue =
std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t,
@@ -46,7 +47,7 @@ SpecialModeMgr::SpecialModeMgr(
std::shared_ptr<sdbusplus::asio::connection>& conn_) :
io(io_),
server(srv_), conn(conn_),
- timer(std::make_unique<boost::asio::deadline_timer>(io))
+ timer(std::make_unique<boost::asio::steady_timer>(io))
{
// Following condition must match to indicate specialMode.
@@ -169,7 +170,6 @@ void SpecialModeMgr::checkAndAddSpecialModeProperty(const std::string& provMode)
addSpecialModeProperty();
return;
}
- constexpr int mtmAllowedTime = 12 * 60 * 60; // 12 hours
int specialModeLockoutSeconds = 0;
if (mtmAllowedTime > sysInfo.uptime)
{
@@ -181,24 +181,7 @@ void SpecialModeMgr::checkAndAddSpecialModeProperty(const std::string& provMode)
{
return;
}
- timer->expires_from_now(
- boost::posix_time::seconds(specialModeLockoutSeconds));
- timer->async_wait([this](const boost::system::error_code& ec) {
- if (ec == boost::asio::error::operation_aborted)
- {
- // timer aborted
- return;
- }
- else if (ec)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in special mode "
- "timer");
- return;
- }
- iface->set_property(strSpecialMode,
- static_cast<uint8_t>(manufacturingExpired));
- });
+ updateTimer(specialModeLockoutSeconds);
}
void SpecialModeMgr::addSpecialModeProperty()
@@ -219,9 +202,36 @@ void SpecialModeMgr::addSpecialModeProperty()
},
// Override get
[this](const uint8_t& mode) { return specialMode; });
+ iface->register_method("ResetTimer", [this]() {
+ if (specialMode == manufacturingMode)
+ {
+ updateTimer(mtmAllowedTime);
+ }
+ return;
+ });
iface->initialize(true);
}
+void SpecialModeMgr::updateTimer(int countInSeconds)
+{
+ timer->expires_after(std::chrono::seconds(countInSeconds));
+ timer->async_wait([this](const boost::system::error_code& ec) {
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ // timer aborted
+ return;
+ }
+ else if (ec)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Error in special mode timer");
+ return;
+ }
+ iface->set_property(strSpecialMode,
+ static_cast<uint8_t>(manufacturingExpired));
+ });
+}
+
int main()
{
boost::asio::io_service io;