blob: c605cdc6f7b8222b4b827db51873518ae3be3f7b [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
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -05009#define CREATE_DUMP_MAX_PARAMS 2
10
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050011namespace phosphor
12{
13namespace dump
14{
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050015
Dhruvaraj Subhashchandranddc33662021-07-19 09:28:42 -050016using DumpCreateParams =
17 std::map<std::string, std::variant<std::string, uint64_t>>;
Patrick Williams9b18bf22022-07-22 19:26:55 -050018using Iface = sdbusplus::server::object_t<
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050019 sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
Marri Devender Rao0deb2872018-11-12 07:45:54 -060020
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050021/** @class Manager
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050022 * @brief Dump manager base class.
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050023 * @details A concrete implementation for the
Nagaraju Goruganti3c899a42017-09-12 06:14:46 -050024 * xyz::openbmc_project::Collection::server::DeleteAll.
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050025 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050026class Manager : public Iface
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050027{
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050028 friend class Entry;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050029
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050030 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 Othayotha320c7c2017-06-14 07:17:21 -050037
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050038 /** @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 Subhashchandranfef66a92020-09-06 13:10:59 -050042 * @param[in] baseEntryPath - Base path of the dump entry.
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050043 */
Patrick Williams9b18bf22022-07-22 19:26:55 -050044 Manager(sdbusplus::bus_t& bus, const char* path,
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050045 const std::string& baseEntryPath) :
Patrick Williams73f64072022-04-01 17:04:47 -050046 Iface(bus, path, Iface::action::defer_emit),
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050047 bus(bus), lastEntryId(0), baseEntryPath(baseEntryPath)
Jayanth Othayoth0af74a52021-04-08 03:55:21 -050048 {}
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050049
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050050 /** @brief Construct dump d-bus objects from their persisted
51 * representations.
52 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050053 virtual void restore() = 0;
Jayanth Othayoth43096592017-07-20 02:17:37 -050054
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050055 protected:
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050056 /** @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 Othayotha320c7c2017-06-14 07:17:21 -050061
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050062 /** @brief Erase all BMC dump entries and Delete all Dump files
63 * from Permanent location
64 *
65 */
66 void deleteAll() override;
Nagaraju Goruganti3c899a42017-09-12 06:14:46 -050067
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050068 /** @brief sdbusplus DBus bus connection. */
Patrick Williams9b18bf22022-07-22 19:26:55 -050069 sdbusplus::bus_t& bus;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050070
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050071 /** @brief Dump Entry dbus objects map based on entry id */
72 std::map<uint32_t, std::unique_ptr<Entry>> entries;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050073
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050074 /** @brief Id of the last Dump entry */
75 uint32_t lastEntryId;
Jayanth Othayothbcb174b2017-07-02 06:29:24 -050076
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050077 /** @bried base object path for the entry object */
78 std::string baseEntryPath;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050079};
80
81} // namespace dump
82} // namespace phosphor