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