| #pragma once | |
| #include "boottime_api/boottime_api.h" | |
| #include <fmt/printf.h> | |
| #include <sdbusplus/asio/object_server.hpp> | |
| #include <sdbusplus/bus/match.hpp> | |
| #include <xyz/openbmc_project/Time/Boot/Checkpoint/server.hpp> | |
| #include <xyz/openbmc_project/Time/Boot/Duration/server.hpp> | |
| #include <xyz/openbmc_project/Time/Boot/Statistic/server.hpp> | |
| #include <cstdint> | |
| #include <memory> | |
| #include <string> | |
| namespace boot_time_monitor | |
| { | |
| namespace dbus | |
| { | |
| namespace btm = boot_time_monitor; | |
| /** | |
| * @brief Configuration for the D-Bus handler. | |
| */ | |
| struct DbusConfig | |
| { | |
| /** @brief The D-Bus object path for this handler instance. */ | |
| std::string dbusObjPath; | |
| }; | |
| /** | |
| * @brief Handles D-Bus requests related to boot time monitoring for a specific | |
| * node. | |
| * | |
| * This class implements the D-Bus interfaces for Checkpoint, Duration, and | |
| * Statistic defined under `xyz.openbmc_project.Time.Boot`. It acts as a | |
| * bridge between incoming D-Bus calls and the underlying boot time monitoring | |
| * API (`api::IBoottimeApi`). Each instance of this handler is associated with a | |
| * specific node configuration (`NodeConfig`) and interacts with the central API | |
| * to record or retrieve boot time data for that node. | |
| */ | |
| class Handler : | |
| sdbusplus::server::object::object< | |
| sdbusplus::server::xyz::openbmc_project::time::boot::Duration>, | |
| sdbusplus::server::object::object< | |
| sdbusplus::server::xyz::openbmc_project::time::boot::Checkpoint>, | |
| sdbusplus::server::object::object< | |
| sdbusplus::server::xyz::openbmc_project::time::boot::Statistic> | |
| { | |
| public: | |
| /** | |
| * @brief Constructs the D-Bus handler. | |
| * | |
| * @param dbus The sdbusplus bus connection. | |
| * @param nodeConfig Configuration of the node this handler manages. | |
| * @param dbusConfig D-Bus specific configuration (object path). | |
| * @param api Shared pointer to the central boot time monitoring API. | |
| */ | |
| Handler(sdbusplus::bus::bus& dbus, const btm::NodeConfig& nodeConfig, | |
| const btm::dbus::DbusConfig& dbusConfig, | |
| std::shared_ptr<btm::api::IBoottimeApi> api); | |
| /** | |
| * @brief D-Bus method implementation for setting a boot checkpoint. | |
| * | |
| * Forwards the request to the appropriate API method | |
| * (`SetNodeCheckpoint` or `SetPSUCheckpoint`). | |
| * | |
| * @param checkpointName The name of the checkpoint. | |
| * @param wallTime The wall clock time (epoch time in ms). | |
| * @param selfMeasuredDuration Optional self-measured duration (ms). | |
| */ | |
| void setCheckpoint(std::string checkpointName, int64_t wallTime, | |
| int64_t selfMeasuredDuration) override; | |
| /** | |
| * @brief D-Bus method implementation for retrieving the checkpoint list. | |
| * | |
| * Retrieves the data from the API via `GetNodeCheckpointList`. | |
| * | |
| * @return A vector of tuples: (checkpoint name, wall time ms, monotonic | |
| * time ms). | |
| */ | |
| std::vector<std::tuple<std::string, int64_t, int64_t>> | |
| getCheckpointList() override; | |
| /** | |
| * @brief D-Bus method implementation to signal boot completion. | |
| * | |
| * Calls `NotifyNodeComplete` on the API if the node is currently rebooting. | |
| */ | |
| void rebootComplete() override; | |
| /** | |
| * @brief D-Bus method implementation for setting a boot duration. | |
| * | |
| * Forwards the request to the appropriate API method | |
| * (`SetNodeDuration` or `SetPSUDuration`). | |
| * | |
| * @param durationName The name of the duration measurement. | |
| * @param duration The measured duration in milliseconds. | |
| */ | |
| void setDuration(std::string durationName, int64_t duration) override; | |
| /** | |
| * @brief D-Bus method implementation for retrieving additional durations. | |
| * | |
| * Retrieves the data from the API via `GetNodeAdditionalDurations`. | |
| * | |
| * @return A vector of tuples: (duration name, duration ms). | |
| */ | |
| std::vector<std::tuple<std::string, int64_t>> | |
| getAdditionalDurations() override; | |
| /** | |
| * @brief D-Bus property getter implementation for checking reboot status. | |
| * | |
| * Retrieves the status from the API via `IsNodeRebooting`. | |
| * | |
| * @return True if the node is considered to be rebooting, false otherwise. | |
| */ | |
| bool isRebooting() const override; | |
| private: | |
| /** @brief Configuration of the node associated with this handler. */ | |
| NodeConfig mNodeConfig; | |
| /** @brief Shared pointer to the central boot time monitoring API. */ | |
| std::shared_ptr<api::IBoottimeApi> mApi; | |
| }; | |
| } // namespace dbus | |
| } // namespace boot_time_monitor |