blob: c17ddf5f0985477186fab7f654616d461847a112 [file] [log] [blame]
Lei YU96232822017-01-20 14:05:46 +08001#include "bmc_epoch.hpp"
2
3#include <phosphor-logging/log.hpp>
4
5namespace phosphor
6{
7namespace time
8{
9namespace server = sdbusplus::xyz::openbmc_project::Time::server;
10using namespace phosphor::logging;
11
12BmcEpoch::BmcEpoch(sdbusplus::bus::bus& bus,
13 const char* objPath)
14 : EpochBase(bus, objPath)
15{
16 // Empty
17}
18
19uint64_t BmcEpoch::elapsed() const
20{
21 // It does not needs to check owner when getting time
22 return getTime().count();
23}
24
25uint64_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