blob: ef3453e353898d9e768306f668e2706f42570ee1 [file] [log] [blame]
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -06001#pragma once
2
3#include "dump_entry.hpp"
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -05004#include "xyz/openbmc_project/Common/OriginatedBy/server.hpp"
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -06005#include "xyz/openbmc_project/Dump/Entry/System/server.hpp"
6
7#include <sdbusplus/bus.hpp>
8#include <sdbusplus/server/object.hpp>
9
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060010namespace openpower
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060011{
12namespace dump
13{
14namespace system
15{
16template <typename T>
Patrick Williams9b18bf22022-07-22 19:26:55 -050017using ServerObject = typename sdbusplus::server::object_t<T>;
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060018
Patrick Williams9b18bf22022-07-22 19:26:55 -050019using EntryIfaces = sdbusplus::server::object_t<
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050020 sdbusplus::xyz::openbmc_project::Common::server::OriginatedBy,
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060021 sdbusplus::xyz::openbmc_project::Dump::Entry::server::System>;
22
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050023using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
24 OriginatedBy::OriginatorTypes;
25
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060026class Manager;
27
28/** @class Entry
29 * @brief System Dump Entry implementation.
30 * @details A concrete implementation for the
31 * xyz.openbmc_project.Dump.Entry DBus API
32 */
33class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
34{
35 public:
36 Entry() = delete;
37 Entry(const Entry&) = delete;
38 Entry& operator=(const Entry&) = delete;
39 Entry(Entry&&) = delete;
40 Entry& operator=(Entry&&) = delete;
41 ~Entry() = default;
42
43 /** @brief Constructor for the Dump Entry Object
44 * @param[in] bus - Bus to attach to.
45 * @param[in] objPath - Object path to attach to
46 * @param[in] dumpId - Dump id.
47 * @param[in] timeStamp - Dump creation timestamp
48 * since the epoch.
49 * @param[in] dumpSize - Dump size in bytes.
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050050 * @param[in] sourceId - DumpId provided by the source.
51 * @param[in] status - status of the dump.
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050052 * @param[in] originatorId - Id of the originator of the dump
53 * @param[in] originatorType - Originator type
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060054 * @param[in] parent - The dump entry's parent.
55 */
Patrick Williams9b18bf22022-07-22 19:26:55 -050056 Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060057 uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050058 phosphor::dump::OperationStatus status, std::string originatorId,
59 originatorTypes originatorType, phosphor::dump::Manager& parent) :
Patrick Williams73f64072022-04-01 17:04:47 -050060 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit),
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060061 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050062 status, originatorId, originatorType, parent)
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060063 {
64 sourceDumpId(sourceId);
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060065 // Emit deferred signal.
66 this->openpower::dump::system::EntryIfaces::emit_object_added();
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060067 };
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060068
69 /** @brief Method to initiate the offload of dump
70 * @param[in] uri - URI to offload dump.
71 */
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060072 void initiateOffload(std::string uri) override;
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050073
74 /** @brief Method to update an existing dump entry
75 * @param[in] timeStamp - Dump creation timestamp
76 * @param[in] dumpSize - Dump size in bytes.
77 * @param[in] sourceId - DumpId provided by the source.
78 */
79 void update(uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId)
80 {
81 elapsed(timeStamp);
82 size(dumpSize);
83 sourceDumpId(sourceId);
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050084 // TODO: Handled dump failure case with
85 // #bm-openbmc/2808
86 status(OperationStatus::Completed);
87 completedTime(timeStamp);
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050088 }
Ramesh Iyyar22793862020-12-04 04:03:03 -060089
90 /**
91 * @brief Delete host system dump and it entry dbus object
92 */
93 void delete_() override;
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060094};
95
96} // namespace system
97} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060098} // namespace openpower