blob: e4ba7307674b07e389b0d4f869f426f76e41a02d [file] [log] [blame]
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05001#pragma once
2
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05003#include "dump_entry.hpp"
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05004#include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05005
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05006#include <sdbusplus/bus.hpp>
7#include <sdbusplus/server/object.hpp>
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05008
9namespace phosphor
10{
11namespace dump
12{
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050013
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050014using Iface = sdbusplus::server::object::object<
15 sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
Marri Devender Rao0deb2872018-11-12 07:45:54 -060016
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050017/** @class Manager
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050018 * @brief Dump manager base class.
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050019 * @details A concrete implementation for the
Nagaraju Goruganti3c899a42017-09-12 06:14:46 -050020 * xyz::openbmc_project::Collection::server::DeleteAll.
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050021 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050022class Manager : public Iface
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050023{
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050024 friend class Entry;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050025
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050026 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 Othayotha320c7c2017-06-14 07:17:21 -050033
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050034 /** @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 Subhashchandranfef66a92020-09-06 13:10:59 -050038 * @param[in] baseEntryPath - Base path of the dump entry.
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050039 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050040 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 Othayoth0af74a52021-04-08 03:55:21 -050044 {}
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050045
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050046 /** @brief Construct dump d-bus objects from their persisted
47 * representations.
48 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050049 virtual void restore() = 0;
Jayanth Othayoth43096592017-07-20 02:17:37 -050050
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050051 protected:
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050052 /** @brief Erase specified entry d-bus object
53 *
54 * @param[in] entryId - unique identifier of the entry
55 */
56 void erase(uint32_t entryId);
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050057
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050058 /** @brief Erase all BMC dump entries and Delete all Dump files
59 * from Permanent location
60 *
61 */
62 void deleteAll() override;
Nagaraju Goruganti3c899a42017-09-12 06:14:46 -050063
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050064 /** @brief sdbusplus DBus bus connection. */
65 sdbusplus::bus::bus& bus;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050066
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050067 /** @brief Dump Entry dbus objects map based on entry id */
68 std::map<uint32_t, std::unique_ptr<Entry>> entries;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050069
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050070 /** @brief Id of the last Dump entry */
71 uint32_t lastEntryId;
Jayanth Othayothbcb174b2017-07-02 06:29:24 -050072
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050073 /** @bried base object path for the entry object */
74 std::string baseEntryPath;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050075};
76
77} // namespace dump
78} // namespace phosphor