| #pragma once | |
| #include "api.hpp" | |
| #include "node_config.hpp" | |
| #include <boost/container/flat_map.hpp> | |
| #include <sdbusplus/bus.hpp> | |
| #include <sdbusplus/bus/match.hpp> | |
| #include <sdbusplus/message.hpp> | |
| #include <string> | |
| namespace boot_time_monitor | |
| { | |
| /** | |
| * @brief Contains functionality related to interacting with the | |
| * [Phosphor-state-manager](https://github.com/openbmc/phosphor-state-manager) | |
| * (PSM). | |
| */ | |
| namespace psm | |
| { | |
| namespace btm = boot_time_monitor; | |
| /** | |
| * @brief Configuration for interacting with PSM D-Bus interfaces. | |
| * | |
| * Stores the necessary D-Bus service names and object paths required to | |
| * monitor host state and operating system status properties. | |
| */ | |
| struct PSMConfig | |
| { | |
| /** @brief D-Bus service name for the Host State interface (e.g., | |
| * "xyz.openbmc_project.State.Host"). */ | |
| std::string hostStateDbusService; | |
| /** @brief D-Bus object path for the Host State interface (e.g., | |
| * "/xyz/openbmc_project/state/host0"). */ | |
| std::string hostStateDbusObjPath; | |
| /** @brief D-Bus service name for the OS State interface (e.g., | |
| * "xyz.openbmc_project.State.OperatingSystem"). */ | |
| std::string osStateDbusService; | |
| /** @brief D-Bus object path for the OS State interface (e.g., | |
| * "/xyz/openbmc_project/state/os"). */ | |
| std::string osStateDbusObjPath; | |
| }; | |
| /** | |
| * @brief Handles monitoring of Platform State Manager (PSM) D-Bus signals for a | |
| * specific node. | |
| * | |
| * This class sets up D-Bus match rules to listen for property changes on | |
| * the Host State (`xyz.openbmc_project.State.Host`) and OS Status | |
| * (`xyz.openbmc_project.State.OperatingSystem.Status`) interfaces defined | |
| * in the `PSMConfig`. When a relevant property changes (e.g., | |
| * `CurrentHostState`, `OperatingSystemState`), it translates the new state | |
| * into a checkpoint name and records it using the provided `IApi` instance | |
| * for the associated `NodeConfig`. | |
| */ | |
| class Handler | |
| { | |
| public: | |
| /** | |
| * @brief Constructs the PSM Handler. | |
| * | |
| * Initializes previous state variables by querying current D-Bus properties | |
| * and sets up D-Bus match rules to monitor for future changes. | |
| * | |
| * @param bus The sdbusplus bus connection. | |
| * @param nodeConfig Configuration of the node this handler monitors. | |
| * @param psmConfig D-Bus configuration for PSM interfaces. | |
| * @param api Shared pointer to the central boot time monitoring API. | |
| */ | |
| Handler(sdbusplus::bus::bus& bus, const btm::NodeConfig& nodeConfig, | |
| const btm::psm::PSMConfig& psmConfig, | |
| std::shared_ptr<btm::api::IApi> api); | |
| private: | |
| /** @brief D-Bus match rule watcher for Host State property changes. */ | |
| std::unique_ptr<sdbusplus::bus::match::match> hostStateWatcher; | |
| /** @brief D-Bus match rule watcher for OS Status property changes. */ | |
| std::unique_ptr<sdbusplus::bus::match::match> osStatusWatcher; | |
| /** @brief Stores the previously observed Host State to detect changes. */ | |
| std::string mPreHostState; | |
| /** @brief Stores the previously observed OS State/Status to detect changes. | |
| */ | |
| std::string mPreOSState; | |
| /** @brief Configuration of the node associated with this handler. */ | |
| btm::NodeConfig mNodeConfig; | |
| /** @brief Shared pointer to the central boot time monitoring API. */ | |
| std::shared_ptr<btm::api::IApi> mApi; | |
| }; | |
| } // namespace psm | |
| } // namespace boot_time_monitor |