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