Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 3 | #include "dump_entry.hpp" |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 4 | #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp" |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 5 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 6 | #include <sdbusplus/bus.hpp> |
| 7 | #include <sdbusplus/server/object.hpp> |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 8 | |
Asmitha Karunanithi | 74a1f39 | 2021-10-27 03:23:59 -0500 | [diff] [blame] | 9 | #define CREATE_DUMP_MAX_PARAMS 2 |
| 10 | |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 11 | namespace phosphor |
| 12 | { |
| 13 | namespace dump |
| 14 | { |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 15 | |
Dhruvaraj Subhashchandran | ddc3366 | 2021-07-19 09:28:42 -0500 | [diff] [blame] | 16 | using DumpCreateParams = |
| 17 | std::map<std::string, std::variant<std::string, uint64_t>>; |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 18 | using Iface = sdbusplus::server::object_t< |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 19 | sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>; |
Marri Devender Rao | 0deb287 | 2018-11-12 07:45:54 -0600 | [diff] [blame] | 20 | |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 21 | /** @class Manager |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 22 | * @brief Dump manager base class. |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 23 | * @details A concrete implementation for the |
Nagaraju Goruganti | 3c899a4 | 2017-09-12 06:14:46 -0500 | [diff] [blame] | 24 | * xyz::openbmc_project::Collection::server::DeleteAll. |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 25 | */ |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 26 | class Manager : public Iface |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 27 | { |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 28 | friend class Entry; |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 29 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 30 | public: |
| 31 | Manager() = delete; |
| 32 | Manager(const Manager&) = default; |
| 33 | Manager& operator=(const Manager&) = delete; |
| 34 | Manager(Manager&&) = delete; |
| 35 | Manager& operator=(Manager&&) = delete; |
| 36 | virtual ~Manager() = default; |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 37 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 38 | /** @brief Constructor to put object onto bus at a dbus path. |
| 39 | * @param[in] bus - Bus to attach to. |
| 40 | * @param[in] event - Dump manager sd_event loop. |
| 41 | * @param[in] path - Path to attach at. |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 42 | * @param[in] baseEntryPath - Base path of the dump entry. |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 43 | */ |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 44 | Manager(sdbusplus::bus_t& bus, const char* path, |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 45 | const std::string& baseEntryPath) : |
Patrick Williams | 73f6407 | 2022-04-01 17:04:47 -0500 | [diff] [blame] | 46 | Iface(bus, path, Iface::action::defer_emit), |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 47 | bus(bus), lastEntryId(0), baseEntryPath(baseEntryPath) |
Jayanth Othayoth | 0af74a5 | 2021-04-08 03:55:21 -0500 | [diff] [blame] | 48 | {} |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 49 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 50 | /** @brief Construct dump d-bus objects from their persisted |
| 51 | * representations. |
| 52 | */ |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 53 | virtual void restore() = 0; |
Jayanth Othayoth | 4309659 | 2017-07-20 02:17:37 -0500 | [diff] [blame] | 54 | |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 55 | protected: |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 56 | /** @brief Erase specified entry d-bus object |
| 57 | * |
| 58 | * @param[in] entryId - unique identifier of the entry |
| 59 | */ |
| 60 | void erase(uint32_t entryId); |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 61 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 62 | /** @brief Erase all BMC dump entries and Delete all Dump files |
| 63 | * from Permanent location |
| 64 | * |
| 65 | */ |
| 66 | void deleteAll() override; |
Nagaraju Goruganti | 3c899a4 | 2017-09-12 06:14:46 -0500 | [diff] [blame] | 67 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 68 | /** @brief sdbusplus DBus bus connection. */ |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 69 | sdbusplus::bus_t& bus; |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 70 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 71 | /** @brief Dump Entry dbus objects map based on entry id */ |
| 72 | std::map<uint32_t, std::unique_ptr<Entry>> entries; |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 73 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 74 | /** @brief Id of the last Dump entry */ |
| 75 | uint32_t lastEntryId; |
Jayanth Othayoth | bcb174b | 2017-07-02 06:29:24 -0500 | [diff] [blame] | 76 | |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 77 | /** @bried base object path for the entry object */ |
| 78 | std::string baseEntryPath; |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | } // namespace dump |
| 82 | } // namespace phosphor |