Lei YU | 9623282 | 2017-01-20 14:05:46 +0800 | [diff] [blame^] | 1 | #include "bmc_epoch.hpp" |
| 2 | |
| 3 | #include <phosphor-logging/log.hpp> |
| 4 | |
| 5 | namespace phosphor |
| 6 | { |
| 7 | namespace time |
| 8 | { |
| 9 | namespace server = sdbusplus::xyz::openbmc_project::Time::server; |
| 10 | using namespace phosphor::logging; |
| 11 | |
| 12 | BmcEpoch::BmcEpoch(sdbusplus::bus::bus& bus, |
| 13 | const char* objPath) |
| 14 | : EpochBase(bus, objPath) |
| 15 | { |
| 16 | // Empty |
| 17 | } |
| 18 | |
| 19 | uint64_t BmcEpoch::elapsed() const |
| 20 | { |
| 21 | // It does not needs to check owner when getting time |
| 22 | return getTime().count(); |
| 23 | } |
| 24 | |
| 25 | uint64_t BmcEpoch::elapsed(uint64_t value) |
| 26 | { |
| 27 | // TODO: set time based on current time mode and owner |
| 28 | auto time = std::chrono::microseconds(value); |
| 29 | switch (timeOwner) |
| 30 | { |
| 31 | case Owner::BMC: |
| 32 | { |
| 33 | setTime(time); |
| 34 | break; |
| 35 | } |
| 36 | // TODO: below cases are to be implemented |
| 37 | case Owner::HOST: |
| 38 | break; |
| 39 | case Owner::SPLIT: |
| 40 | break; |
| 41 | case Owner::BOTH: |
| 42 | break; |
| 43 | } |
| 44 | server::EpochTime::elapsed(value); |
| 45 | return value; |
| 46 | } |
| 47 | |
| 48 | } |
| 49 | } |
| 50 | |