1224882b0SJayanth Othayoth #pragma once 2224882b0SJayanth Othayoth 3*a6ab806dSDhruvaraj Subhashchandran #include "xyz/openbmc_project/Common/Progress/server.hpp" 4224882b0SJayanth Othayoth #include "xyz/openbmc_project/Dump/Entry/server.hpp" 5224882b0SJayanth Othayoth #include "xyz/openbmc_project/Object/Delete/server.hpp" 6224882b0SJayanth Othayoth #include "xyz/openbmc_project/Time/EpochTime/server.hpp" 7224882b0SJayanth Othayoth 8cb65ffceSJayanth Othayoth #include <experimental/filesystem> 9cb65ffceSJayanth Othayoth #include <sdbusplus/bus.hpp> 10cb65ffceSJayanth Othayoth #include <sdbusplus/server/object.hpp> 11cb65ffceSJayanth Othayoth 12224882b0SJayanth Othayoth namespace phosphor 13224882b0SJayanth Othayoth { 14224882b0SJayanth Othayoth namespace dump 15224882b0SJayanth Othayoth { 16224882b0SJayanth Othayoth 17224882b0SJayanth Othayoth template <typename T> 18224882b0SJayanth Othayoth using ServerObject = typename sdbusplus::server::object::object<T>; 19224882b0SJayanth Othayoth 20*a6ab806dSDhruvaraj Subhashchandran // TODO Revisit whether sdbusplus::xyz::openbmc_project::Time::server::EpochTime 21*a6ab806dSDhruvaraj Subhashchandran // still needed in dump entry since start time and completed time are available 22*a6ab806dSDhruvaraj Subhashchandran // from sdbusplus::xyz::openbmc_project::Common::server::Progress 23*a6ab806dSDhruvaraj Subhashchandran // #ibm-openbmc/2809 24224882b0SJayanth Othayoth using EntryIfaces = sdbusplus::server::object::object< 25*a6ab806dSDhruvaraj Subhashchandran sdbusplus::xyz::openbmc_project::Common::server::Progress, 26224882b0SJayanth Othayoth sdbusplus::xyz::openbmc_project::Dump::server::Entry, 27224882b0SJayanth Othayoth sdbusplus::xyz::openbmc_project::Object::server::Delete, 28224882b0SJayanth Othayoth sdbusplus::xyz::openbmc_project::Time::server::EpochTime>; 29224882b0SJayanth Othayoth 30*a6ab806dSDhruvaraj Subhashchandran using OperationStatus = 31*a6ab806dSDhruvaraj Subhashchandran sdbusplus::xyz::openbmc_project::Common::server::Progress::OperationStatus; 32a320c7caSJayanth Othayoth namespace fs = std::experimental::filesystem; 33a320c7caSJayanth Othayoth 34a320c7caSJayanth Othayoth class Manager; 35a320c7caSJayanth Othayoth 36224882b0SJayanth Othayoth /** @class Entry 37f140f665SDhruvaraj Subhashchandran * @brief Base Dump Entry implementation. 38224882b0SJayanth Othayoth * @details A concrete implementation for the 39224882b0SJayanth Othayoth * xyz.openbmc_project.Dump.Entry DBus API 40224882b0SJayanth Othayoth */ 41224882b0SJayanth Othayoth class Entry : public EntryIfaces 42224882b0SJayanth Othayoth { 43224882b0SJayanth Othayoth public: 44224882b0SJayanth Othayoth Entry() = delete; 45224882b0SJayanth Othayoth Entry(const Entry&) = delete; 46224882b0SJayanth Othayoth Entry& operator=(const Entry&) = delete; 47224882b0SJayanth Othayoth Entry(Entry&&) = delete; 48224882b0SJayanth Othayoth Entry& operator=(Entry&&) = delete; 49a320c7caSJayanth Othayoth ~Entry() = default; 50224882b0SJayanth Othayoth 51224882b0SJayanth Othayoth /** @brief Constructor for the Dump Entry Object 52224882b0SJayanth Othayoth * @param[in] bus - Bus to attach to. 53a320c7caSJayanth Othayoth * @param[in] objPath - Object path to attach to 54a320c7caSJayanth Othayoth * @param[in] dumpId - Dump id. 55a320c7caSJayanth Othayoth * @param[in] timeStamp - Dump creation timestamp 56a320c7caSJayanth Othayoth * since the epoch. 574a98e8feSDhruvaraj Subhashchandran * @param[in] dumpSize - Dump file size in bytes. 58a320c7caSJayanth Othayoth * @param[in] parent - The dump entry's parent. 59224882b0SJayanth Othayoth */ 60cb65ffceSJayanth Othayoth Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId, 61*a6ab806dSDhruvaraj Subhashchandran uint64_t timeStamp, uint64_t dumpSize, OperationStatus dumpStatus, 62*a6ab806dSDhruvaraj Subhashchandran Manager& parent) : 63a320c7caSJayanth Othayoth EntryIfaces(bus, objPath.c_str(), true), 644a98e8feSDhruvaraj Subhashchandran parent(parent), id(dumpId) 65a320c7caSJayanth Othayoth { 664a98e8feSDhruvaraj Subhashchandran size(dumpSize); 67*a6ab806dSDhruvaraj Subhashchandran status(dumpStatus); 68*a6ab806dSDhruvaraj Subhashchandran 69*a6ab806dSDhruvaraj Subhashchandran // If the object is created after the dump creation keep 70*a6ab806dSDhruvaraj Subhashchandran // all same as timeStamp 71*a6ab806dSDhruvaraj Subhashchandran // if the object created before the dump creation, update 72*a6ab806dSDhruvaraj Subhashchandran // only the start time. Completed and elapsed time will 73*a6ab806dSDhruvaraj Subhashchandran // be updated once the dump is completed. 74*a6ab806dSDhruvaraj Subhashchandran if (dumpStatus == OperationStatus::Completed) 75*a6ab806dSDhruvaraj Subhashchandran { 76a320c7caSJayanth Othayoth elapsed(timeStamp); 77*a6ab806dSDhruvaraj Subhashchandran startTime(timeStamp); 78*a6ab806dSDhruvaraj Subhashchandran completedTime(timeStamp); 79*a6ab806dSDhruvaraj Subhashchandran } 80*a6ab806dSDhruvaraj Subhashchandran else 81*a6ab806dSDhruvaraj Subhashchandran { 82*a6ab806dSDhruvaraj Subhashchandran elapsed(0); 83*a6ab806dSDhruvaraj Subhashchandran startTime(timeStamp); 84*a6ab806dSDhruvaraj Subhashchandran completedTime(0); 85*a6ab806dSDhruvaraj Subhashchandran } 86a320c7caSJayanth Othayoth // Emit deferred signal. 87a320c7caSJayanth Othayoth this->emit_object_added(); 88a320c7caSJayanth Othayoth }; 89224882b0SJayanth Othayoth 90224882b0SJayanth Othayoth /** @brief Delete this d-bus object. 91224882b0SJayanth Othayoth */ 92224882b0SJayanth Othayoth void delete_() override; 93224882b0SJayanth Othayoth 944a98e8feSDhruvaraj Subhashchandran /** @brief Method to initiate the offload of dump 9569e6152fSDhruvaraj Subhashchandran * @param[in] uri - URI to offload dump 964a98e8feSDhruvaraj Subhashchandran */ 9769e6152fSDhruvaraj Subhashchandran void initiateOffload(std::string uri) override 984a98e8feSDhruvaraj Subhashchandran { 9969e6152fSDhruvaraj Subhashchandran offloadUri(uri); 1004a98e8feSDhruvaraj Subhashchandran } 101a320c7caSJayanth Othayoth 1024a98e8feSDhruvaraj Subhashchandran protected: 103a320c7caSJayanth Othayoth /** @brief This entry's parent */ 104a320c7caSJayanth Othayoth Manager& parent; 105a320c7caSJayanth Othayoth 106a320c7caSJayanth Othayoth /** @brief This entry's id */ 107a320c7caSJayanth Othayoth uint32_t id; 108224882b0SJayanth Othayoth }; 109224882b0SJayanth Othayoth 110224882b0SJayanth Othayoth } // namespace dump 111224882b0SJayanth Othayoth } // namespace phosphor 112