14a98e8feSDhruvaraj Subhashchandran #pragma once 24a98e8feSDhruvaraj Subhashchandran 34a98e8feSDhruvaraj Subhashchandran #include "dump_entry.hpp" 44a98e8feSDhruvaraj Subhashchandran #include "xyz/openbmc_project/Dump/Entry/BMC/server.hpp" 54a98e8feSDhruvaraj Subhashchandran #include "xyz/openbmc_project/Dump/Entry/server.hpp" 64a98e8feSDhruvaraj Subhashchandran #include "xyz/openbmc_project/Object/Delete/server.hpp" 74a98e8feSDhruvaraj Subhashchandran #include "xyz/openbmc_project/Time/EpochTime/server.hpp" 84a98e8feSDhruvaraj Subhashchandran 94a98e8feSDhruvaraj Subhashchandran #include <sdbusplus/bus.hpp> 104a98e8feSDhruvaraj Subhashchandran #include <sdbusplus/server/object.hpp> 114a98e8feSDhruvaraj Subhashchandran 120af74a5eSJayanth Othayoth #include <filesystem> 130af74a5eSJayanth Othayoth 144a98e8feSDhruvaraj Subhashchandran namespace phosphor 154a98e8feSDhruvaraj Subhashchandran { 164a98e8feSDhruvaraj Subhashchandran namespace dump 174a98e8feSDhruvaraj Subhashchandran { 184a98e8feSDhruvaraj Subhashchandran namespace bmc 194a98e8feSDhruvaraj Subhashchandran { 204a98e8feSDhruvaraj Subhashchandran template <typename T> 219b18bf2dSPatrick Williams using ServerObject = typename sdbusplus::server::object_t<T>; 224a98e8feSDhruvaraj Subhashchandran 239b18bf2dSPatrick Williams using EntryIfaces = sdbusplus::server::object_t< 244a98e8feSDhruvaraj Subhashchandran sdbusplus::xyz::openbmc_project::Dump::Entry::server::BMC>; 254a98e8feSDhruvaraj Subhashchandran 26*74a1f39cSAsmitha Karunanithi using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server:: 27*74a1f39cSAsmitha Karunanithi OriginatedBy::OriginatorTypes; 28*74a1f39cSAsmitha Karunanithi 294a98e8feSDhruvaraj Subhashchandran class Manager; 304a98e8feSDhruvaraj Subhashchandran 314a98e8feSDhruvaraj Subhashchandran /** @class Entry 324a98e8feSDhruvaraj Subhashchandran * @brief OpenBMC Dump Entry implementation. 334a98e8feSDhruvaraj Subhashchandran * @details A concrete implementation for the 344a98e8feSDhruvaraj Subhashchandran * xyz.openbmc_project.Dump.Entry DBus API 354a98e8feSDhruvaraj Subhashchandran */ 364a98e8feSDhruvaraj Subhashchandran class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry 374a98e8feSDhruvaraj Subhashchandran { 384a98e8feSDhruvaraj Subhashchandran public: 394a98e8feSDhruvaraj Subhashchandran Entry() = delete; 404a98e8feSDhruvaraj Subhashchandran Entry(const Entry&) = delete; 414a98e8feSDhruvaraj Subhashchandran Entry& operator=(const Entry&) = delete; 424a98e8feSDhruvaraj Subhashchandran Entry(Entry&&) = delete; 434a98e8feSDhruvaraj Subhashchandran Entry& operator=(Entry&&) = delete; 444a98e8feSDhruvaraj Subhashchandran ~Entry() = default; 454a98e8feSDhruvaraj Subhashchandran 464a98e8feSDhruvaraj Subhashchandran /** @brief Constructor for the Dump Entry Object 474a98e8feSDhruvaraj Subhashchandran * @param[in] bus - Bus to attach to. 484a98e8feSDhruvaraj Subhashchandran * @param[in] objPath - Object path to attach to 494a98e8feSDhruvaraj Subhashchandran * @param[in] dumpId - Dump id. 504a98e8feSDhruvaraj Subhashchandran * @param[in] timeStamp - Dump creation timestamp 514a98e8feSDhruvaraj Subhashchandran * since the epoch. 524a98e8feSDhruvaraj Subhashchandran * @param[in] fileSize - Dump file size in bytes. 534a98e8feSDhruvaraj Subhashchandran * @param[in] file - Name of dump file. 54a6ab806dSDhruvaraj Subhashchandran * @param[in] status - status of the dump. 55*74a1f39cSAsmitha Karunanithi * @param[in] originatorId - Id of the originator of the dump 56*74a1f39cSAsmitha Karunanithi * @param[in] originatorType - Originator type 574a98e8feSDhruvaraj Subhashchandran * @param[in] parent - The dump entry's parent. 584a98e8feSDhruvaraj Subhashchandran */ 599b18bf2dSPatrick Williams Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId, 603fc6df48SJayanth Othayoth uint64_t timeStamp, uint64_t fileSize, 613fc6df48SJayanth Othayoth const std::filesystem::path& file, 62*74a1f39cSAsmitha Karunanithi phosphor::dump::OperationStatus status, std::string originatorId, 63*74a1f39cSAsmitha Karunanithi originatorTypes originatorType, phosphor::dump::Manager& parent) : 6473f64076SPatrick Williams EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit), 654a98e8feSDhruvaraj Subhashchandran phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, fileSize, 66*74a1f39cSAsmitha Karunanithi status, originatorId, originatorType, parent), 672f8e276cSDhruvaraj Subhashchandran file(file) 682f8e276cSDhruvaraj Subhashchandran { 692f8e276cSDhruvaraj Subhashchandran // Emit deferred signal. 702f8e276cSDhruvaraj Subhashchandran this->phosphor::dump::bmc::EntryIfaces::emit_object_added(); 712f8e276cSDhruvaraj Subhashchandran } 724a98e8feSDhruvaraj Subhashchandran 734a98e8feSDhruvaraj Subhashchandran /** @brief Delete this d-bus object. 744a98e8feSDhruvaraj Subhashchandran */ 754a98e8feSDhruvaraj Subhashchandran void delete_() override; 764a98e8feSDhruvaraj Subhashchandran 77580d91ddSDhruvaraj Subhashchandran /** @brief Method to initiate the offload of dump 78580d91ddSDhruvaraj Subhashchandran * @param[in] uri - URI to offload dump 79580d91ddSDhruvaraj Subhashchandran */ 80580d91ddSDhruvaraj Subhashchandran void initiateOffload(std::string uri) override; 81580d91ddSDhruvaraj Subhashchandran 826ccb50e1SDhruvaraj Subhashchandran /** @brief Method to update an existing dump entry, once the dump creation 836ccb50e1SDhruvaraj Subhashchandran * is completed this function will be used to update the entry which got 846ccb50e1SDhruvaraj Subhashchandran * created during the dump request. 856ccb50e1SDhruvaraj Subhashchandran * @param[in] timeStamp - Dump creation timestamp 866ccb50e1SDhruvaraj Subhashchandran * @param[in] fileSize - Dump file size in bytes. 876ccb50e1SDhruvaraj Subhashchandran * @param[in] file - Name of dump file. 886ccb50e1SDhruvaraj Subhashchandran */ 893fc6df48SJayanth Othayoth void update(uint64_t timeStamp, uint64_t fileSize, 903fc6df48SJayanth Othayoth const std::filesystem::path& filePath) 916ccb50e1SDhruvaraj Subhashchandran { 926ccb50e1SDhruvaraj Subhashchandran elapsed(timeStamp); 936ccb50e1SDhruvaraj Subhashchandran size(fileSize); 94a6ab806dSDhruvaraj Subhashchandran // TODO: Handled dump failed case with #ibm-openbmc/2808 95a6ab806dSDhruvaraj Subhashchandran status(OperationStatus::Completed); 966ccb50e1SDhruvaraj Subhashchandran file = filePath; 97a6ab806dSDhruvaraj Subhashchandran // TODO: serialization of this property will be handled with 98a6ab806dSDhruvaraj Subhashchandran // #ibm-openbmc/2597 99a6ab806dSDhruvaraj Subhashchandran completedTime(timeStamp); 1006ccb50e1SDhruvaraj Subhashchandran } 1016ccb50e1SDhruvaraj Subhashchandran 1024a98e8feSDhruvaraj Subhashchandran private: 1034a98e8feSDhruvaraj Subhashchandran /** @Dump file name */ 1043fc6df48SJayanth Othayoth std::filesystem::path file; 1054a98e8feSDhruvaraj Subhashchandran }; 1064a98e8feSDhruvaraj Subhashchandran 1074a98e8feSDhruvaraj Subhashchandran } // namespace bmc 1084a98e8feSDhruvaraj Subhashchandran } // namespace dump 1094a98e8feSDhruvaraj Subhashchandran } // namespace phosphor 110