196232827SLei YU #include "bmc_epoch.hpp" 296232827SLei YU 396232827SLei YU #include <phosphor-logging/log.hpp> 496232827SLei YU 596232827SLei YU namespace phosphor 696232827SLei YU { 796232827SLei YU namespace time 896232827SLei YU { 996232827SLei YU namespace server = sdbusplus::xyz::openbmc_project::Time::server; 1096232827SLei YU using namespace phosphor::logging; 1196232827SLei YU 1296232827SLei YU BmcEpoch::BmcEpoch(sdbusplus::bus::bus& bus, 1396232827SLei YU const char* objPath) 1496232827SLei YU : EpochBase(bus, objPath) 1596232827SLei YU { 1696232827SLei YU // Empty 1796232827SLei YU } 1896232827SLei YU 1996232827SLei YU uint64_t BmcEpoch::elapsed() const 2096232827SLei YU { 2196232827SLei YU // It does not needs to check owner when getting time 2296232827SLei YU return getTime().count(); 2396232827SLei YU } 2496232827SLei YU 2596232827SLei YU uint64_t BmcEpoch::elapsed(uint64_t value) 2696232827SLei YU { 27e7abcdc7SLei YU if (timeMode == Mode::NTP) 28e7abcdc7SLei YU { 29e7abcdc7SLei YU log<level::ERR>("Setting BmcTime with NTP mode is not allowed"); 30e7abcdc7SLei YU // TODO: throw NotAllowed exception 31e7abcdc7SLei YU return 0; 32e7abcdc7SLei YU } 33e7abcdc7SLei YU if (timeOwner == Owner::HOST) 34e7abcdc7SLei YU { 35e7abcdc7SLei YU log<level::ERR>("Setting BmcTime with HOST owner is not allowed"); 36e7abcdc7SLei YU // TODO: throw NotAllowed exception 37e7abcdc7SLei YU return 0; 38e7abcdc7SLei YU } 39e7abcdc7SLei YU 4096232827SLei YU auto time = std::chrono::microseconds(value); 4196232827SLei YU setTime(time); 42e7abcdc7SLei YU 4396232827SLei YU server::EpochTime::elapsed(value); 4496232827SLei YU return value; 4596232827SLei YU } 4696232827SLei YU 47*af5abc57SLei YU } // namespace time 48*af5abc57SLei YU } // namespace phosphor 4996232827SLei YU 50