bmc_monitor_app: Adding BMC boot time monitor instance
Adding boot time monitor instance for BMC. The initialization is mostly
the same as host besides it doesn't have event to be matched.
Tested:
```
\# DBus interfaces are added
bmc:~# busctl introspect \
com.google.gbmc.boot_time_monitor \
/xyz/openbmc_project/time/boot/bmc
......
xyz.openbmc_project.Time.Boot.Checkpoint interface - - -
.GetCheckpointList method - a(sxx) -
.RebootComplete method - - -
.SetCheckpoint method sxx - -
xyz.openbmc_project.Time.Boot.Duration interface - - -
.GetAdditionalDurations method - a(sx) -
.SetDuration method sx - -
xyz.openbmc_project.Time.Boot.Statistic interface - - -
.IsRebooting property b false emits-change
\# Try to call `SetCheckpoint`
bmc:~# busctl call \
com.google.gbmc.boot_time_monitor \
/xyz/openbmc_project/time/boot/bmc \
xyz.openbmc_project.Time.Boot.Checkpoint \
SetCheckpoint sxx "bmc_checkpoint1" 0 0
\# Check if it set correctly
bmc:~# busctl --verbose call \
com.google.gbmc.boot_time_monitor \
/xyz/openbmc_project/time/boot/bmc \
xyz.openbmc_project.Time.Boot.Checkpoint \
GetCheckpointList
MESSAGE "a(sxx)" {
ARRAY "(sxx)" {
STRUCT "sxx" {
STRING "bmc_checkpoint1";
INT64 1693991949237;
INT64 76140790;
};
};
};
```
Google-Bug-Id: 296530445
Change-Id: Ifc556d3b1950c7fd9ff533b1d1c7525e89af80e6
Signed-off-by: Michael Shen <gpgpgp@google.com>
diff --git a/include/bmc_monitor_app.hpp b/include/bmc_monitor_app.hpp
new file mode 100644
index 0000000..17fbe43
--- /dev/null
+++ b/include/bmc_monitor_app.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "boot_manager.hpp"
+#include "dbus_handler.hpp"
+#include "utils.hpp"
+
+#include <sdbusplus/bus.hpp>
+
+#include <memory>
+#include <string_view>
+
+namespace boot_time_monitor
+{
+
+class BMCMonitorApp
+{
+ public:
+ constexpr static std::string_view kNodeName = "bmc";
+ constexpr static std::string_view kObjPath =
+ "/xyz/openbmc_project/time/boot/bmc";
+
+ explicit BMCMonitorApp(sdbusplus::bus::bus& bus);
+
+ private:
+ sdbusplus::server::manager::manager objManager;
+ std::shared_ptr<Util> util;
+ std::shared_ptr<FileUtil> cpCSV;
+ std::shared_ptr<FileUtil> durCSV;
+ std::shared_ptr<BootManager> bootManager;
+ std::shared_ptr<DbusHandler> dbusHandler;
+};
+
+} // namespace boot_time_monitor
diff --git a/src/bmc_monitor_app.cpp b/src/bmc_monitor_app.cpp
new file mode 100644
index 0000000..bf1eb9e
--- /dev/null
+++ b/src/bmc_monitor_app.cpp
@@ -0,0 +1,24 @@
+#include "bmc_monitor_app.hpp"
+
+#include "boot_manager.hpp"
+#include "dbus_handler.hpp"
+#include "utils.hpp"
+
+#include <sdbusplus/bus.hpp>
+
+#include <memory>
+#include <string_view>
+
+namespace boot_time_monitor
+{
+
+BMCMonitorApp::BMCMonitorApp(sdbusplus::bus::bus& bus) :
+ objManager(bus, kObjPath.data()), util(std::make_shared<Util>()),
+ cpCSV(std::make_shared<FileUtil>(util->getCPPath(kNodeName, false))),
+ durCSV(std::make_shared<FileUtil>(util->getDurPath(kNodeName, false))),
+ bootManager(std::make_shared<BootManager>(util, cpCSV, durCSV)),
+ dbusHandler(
+ std::make_shared<DbusHandler>(bus, kObjPath.data(), bootManager, util))
+{}
+
+} // namespace boot_time_monitor
diff --git a/src/main.cpp b/src/main.cpp
index 2a0ebad..1f2e8eb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,3 +1,4 @@
+#include "bmc_monitor_app.hpp"
#include "host_monitor_app.hpp"
#include <boost/asio/io_service.hpp>
@@ -17,6 +18,7 @@
auto& bus = static_cast<sdbusplus::bus::bus&>(*conn);
HostMonitorApp host(bus, 0);
+ BMCMonitorApp bmc(bus);
io.run();
diff --git a/src/meson.build b/src/meson.build
index d9983ae..3e8c7dc 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -27,6 +27,7 @@
'utils.cpp',
'boot_manager.cpp',
'dbus_handler.cpp',
+ 'bmc_monitor_app.cpp',
generated_sources,
include_directories: boot_time_monitor_incs,
implicit_include_directories: false,