1 #pragma once
2 
3 #include "dump_entry.hpp"
4 #include "xyz/openbmc_project/Common/OriginatedBy/server.hpp"
5 #include "xyz/openbmc_project/Dump/Entry/System/server.hpp"
6 
7 #include <sdbusplus/bus.hpp>
8 #include <sdbusplus/server/object.hpp>
9 
10 namespace openpower
11 {
12 namespace dump
13 {
14 namespace system
15 {
16 template <typename T>
17 using ServerObject = typename sdbusplus::server::object_t<T>;
18 
19 using EntryIfaces = sdbusplus::server::object_t<
20     sdbusplus::xyz::openbmc_project::Common::server::OriginatedBy,
21     sdbusplus::xyz::openbmc_project::Dump::Entry::server::System>;
22 
23 using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
24     OriginatedBy::OriginatorTypes;
25 
26 class 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  */
33 class 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.
50      *  @param[in] sourceId - DumpId provided by the source.
51      *  @param[in] status - status  of the dump.
52      *  @param[in] originatorId - Id of the originator of the dump
53      *  @param[in] originatorType - Originator type
54      *  @param[in] parent - The dump entry's parent.
55      */
56     Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
57           uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
58           phosphor::dump::OperationStatus status, std::string originatorId,
59           originatorTypes originatorType, phosphor::dump::Manager& parent) :
60         EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit),
61         phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
62                               status, originatorId, originatorType, parent)
63     {
64         sourceDumpId(sourceId);
65         // Emit deferred signal.
66         this->openpower::dump::system::EntryIfaces::emit_object_added();
67     };
68 
69     /** @brief Method to initiate the offload of dump
70      *  @param[in] uri - URI to offload dump.
71      */
72     void initiateOffload(std::string uri) override;
73 
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);
84         // TODO: Handled dump failure case with
85         // #bm-openbmc/2808
86         status(OperationStatus::Completed);
87         completedTime(timeStamp);
88     }
89 
90     /**
91      * @brief Delete host system dump and it entry dbus object
92      */
93     void delete_() override;
94 };
95 
96 } // namespace system
97 } // namespace dump
98 } // namespace openpower
99