Implement part of BmcEpoch
Add BmcEpoch which inherits EpochBase and will handle times for BMC,
it is partly implemented.
Add unit test cases to test basic functions.
Change-Id: Ia5e4d0f884156d238f3f84df490a2efbce43e89a
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/bmc_epoch.cpp b/bmc_epoch.cpp
new file mode 100644
index 0000000..c17ddf5
--- /dev/null
+++ b/bmc_epoch.cpp
@@ -0,0 +1,50 @@
+#include "bmc_epoch.hpp"
+
+#include <phosphor-logging/log.hpp>
+
+namespace phosphor
+{
+namespace time
+{
+namespace server = sdbusplus::xyz::openbmc_project::Time::server;
+using namespace phosphor::logging;
+
+BmcEpoch::BmcEpoch(sdbusplus::bus::bus& bus,
+ const char* objPath)
+ : EpochBase(bus, objPath)
+{
+ // Empty
+}
+
+uint64_t BmcEpoch::elapsed() const
+{
+ // It does not needs to check owner when getting time
+ return getTime().count();
+}
+
+uint64_t BmcEpoch::elapsed(uint64_t value)
+{
+ // TODO: set time based on current time mode and owner
+ auto time = std::chrono::microseconds(value);
+ switch (timeOwner)
+ {
+ case Owner::BMC:
+ {
+ setTime(time);
+ break;
+ }
+ // TODO: below cases are to be implemented
+ case Owner::HOST:
+ break;
+ case Owner::SPLIT:
+ break;
+ case Owner::BOTH:
+ break;
+ }
+ server::EpochTime::elapsed(value);
+ return value;
+}
+
+}
+}
+