kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 3 | #include <sdbusplus/server.hpp> |
| 4 | #include <xyz/openbmc_project/Common/FilePath/server.hpp> |
| 5 | |
Patrick Williams | 5de9061 | 2024-02-13 21:31:53 -0600 | [diff] [blame^] | 6 | #include <format> |
kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 7 | #include <string> |
| 8 | |
| 9 | namespace bios_bmc_smm_error_logger |
| 10 | { |
| 11 | |
| 12 | using FileNotifierInterface = sdbusplus::server::object_t< |
| 13 | sdbusplus::xyz::openbmc_project::Common::server::FilePath>; |
| 14 | |
| 15 | /** |
| 16 | * @brief A class for notifying file paths of CPER logs. |
| 17 | */ |
| 18 | class CperFileNotifier : public FileNotifierInterface |
| 19 | { |
| 20 | public: |
| 21 | /** |
| 22 | * @brief Constructor for the CperFileNotifier class. |
| 23 | * |
| 24 | * @param bus - bus to attach to. |
| 25 | * @param filePath - full path of the CPER log JSON file. |
| 26 | * @param entry - index of the DBus file path object. |
| 27 | */ |
Patrick Williams | bea36e2 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 28 | CperFileNotifier(sdbusplus::bus_t& bus, const std::string& filePath, |
kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 29 | uint64_t entry) : |
| 30 | FileNotifierInterface(bus, generatePath(entry).c_str(), |
Edward Lee | 3cbb6ef | 2023-03-15 17:08:40 +0000 | [diff] [blame] | 31 | action::emit_no_signals) |
kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 32 | { |
| 33 | // We only need the interface added signal for the fault monitor. So |
| 34 | // stop emitting properties changed signal. |
| 35 | path(filePath, /*skipSignal=*/true); |
| 36 | } |
| 37 | |
| 38 | static constexpr const char* cperBasePath = |
| 39 | "/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER"; |
| 40 | |
| 41 | private: |
| 42 | /** |
kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 43 | * @brief Generate a path for the CperFileNotifier DBus object. |
| 44 | * |
| 45 | * @param[in] entry - unique index for the DBus object. |
| 46 | */ |
| 47 | std::string generatePath(uint64_t entry) |
| 48 | { |
Patrick Williams | 5de9061 | 2024-02-13 21:31:53 -0600 | [diff] [blame^] | 49 | return std::format("{}/entry{}", cperBasePath, entry); |
kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 50 | } |
| 51 | }; |
| 52 | |
| 53 | } // namespace bios_bmc_smm_error_logger |