blob: 1f5e3c7c6dc80b49e73dd3488c3c6cec144b5243 [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 Subhashchandranddc33662021-07-19 09:28:42 -050014using DumpCreateParams =
15 std::map<std::string, std::variant<std::string, uint64_t>>;
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050016using Iface = sdbusplus::server::object::object<
17 sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
Marri Devender Rao0deb2872018-11-12 07:45:54 -060018
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050019/** @class Manager
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050020 * @brief Dump manager base class.
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050021 * @details A concrete implementation for the
Nagaraju Goruganti3c899a42017-09-12 06:14:46 -050022 * xyz::openbmc_project::Collection::server::DeleteAll.
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050023 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050024class Manager : public Iface
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050025{
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050026 friend class Entry;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050027
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050028 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 Othayotha320c7c2017-06-14 07:17:21 -050035
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050036 /** @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 Subhashchandranfef66a92020-09-06 13:10:59 -050040 * @param[in] baseEntryPath - Base path of the dump entry.
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050041 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050042 Manager(sdbusplus::bus::bus& bus, const char* path,
43 const std::string& baseEntryPath) :
Patrick Williams73f64072022-04-01 17:04:47 -050044 Iface(bus, path, Iface::action::defer_emit),
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050045 bus(bus), lastEntryId(0), baseEntryPath(baseEntryPath)
Jayanth Othayoth0af74a52021-04-08 03:55:21 -050046 {}
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050047
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050048 /** @brief Construct dump d-bus objects from their persisted
49 * representations.
50 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050051 virtual void restore() = 0;
Jayanth Othayoth43096592017-07-20 02:17:37 -050052
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050053 protected:
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050054 /** @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 Othayotha320c7c2017-06-14 07:17:21 -050059
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050060 /** @brief Erase all BMC dump entries and Delete all Dump files
61 * from Permanent location
62 *
63 */
64 void deleteAll() override;
Nagaraju Goruganti3c899a42017-09-12 06:14:46 -050065
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050066 /** @brief sdbusplus DBus bus connection. */
67 sdbusplus::bus::bus& bus;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050068
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050069 /** @brief Dump Entry dbus objects map based on entry id */
70 std::map<uint32_t, std::unique_ptr<Entry>> entries;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050071
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050072 /** @brief Id of the last Dump entry */
73 uint32_t lastEntryId;
Jayanth Othayothbcb174b2017-07-02 06:29:24 -050074
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050075 /** @bried base object path for the entry object */
76 std::string baseEntryPath;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050077};
78
79} // namespace dump
80} // namespace phosphor