1 #pragma once 2 3 #include "com/ibm/Dump/Entry/Resource/server.hpp" 4 #include "dump_entry.hpp" 5 6 #include <sdbusplus/bus.hpp> 7 #include <sdbusplus/server/object.hpp> 8 9 #include <chrono> 10 11 namespace openpower 12 { 13 namespace dump 14 { 15 namespace resource 16 { 17 template <typename T> 18 using ServerObject = typename sdbusplus::server::object_t<T>; 19 20 using EntryIfaces = sdbusplus::server::object_t< 21 sdbusplus::com::ibm::Dump::Entry::server::Resource>; 22 23 using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server:: 24 OriginatedBy::OriginatorTypes; 25 26 class Manager; 27 28 /** @class Entry 29 * @brief Resource Dump Entry implementation. 30 * @details An extension to Dump::Entry class and 31 * A concrete implementation for the 32 * com::ibm::Dump::Entry::Resource DBus API 33 */ 34 class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry 35 { 36 public: 37 Entry() = delete; 38 Entry(const Entry&) = delete; 39 Entry& operator=(const Entry&) = delete; 40 Entry(Entry&&) = delete; 41 Entry& operator=(Entry&&) = delete; 42 ~Entry() = default; 43 44 /** @brief Constructor for the resource dump Entry Object 45 * @param[in] bus - Bus to attach to. 46 * @param[in] objPath - Object path to attach to 47 * @param[in] dumpId - Dump id. 48 * @param[in] timeStamp - Dump creation timestamp 49 * since the epoch. 50 * @param[in] dumpSize - Dump size in bytes. 51 * @param[in] sourceId - DumpId provided by the source. 52 * @param[in] vspStr- Input to host to generate the resource dump. 53 * @param[in] pwd - Password needed by host to validate the request. 54 * @param[in] status - status of the dump. 55 * @param[in] originatorId - Id of the originator of the dump 56 * @param[in] originatorType - Originator type 57 * @param[in] parent - The dump entry's parent. 58 */ 59 Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId, 60 uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId, 61 std::string vspStr, std::string pwd, 62 phosphor::dump::OperationStatus status, std::string originatorId, 63 originatorTypes originatorType, phosphor::dump::Manager& parent) : 64 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit), 65 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize, 66 status, originatorId, originatorType, parent) 67 { 68 sourceDumpId(sourceId); 69 vspString(vspStr); 70 password(pwd); 71 // Emit deferred signal. 72 this->openpower::dump::resource::EntryIfaces::emit_object_added(); 73 }; 74 75 /** @brief Method to initiate the offload of dump 76 * @param[in] uri - URI to offload dump. 77 */ 78 void initiateOffload(std::string uri) override; 79 80 /** @brief Method to update an existing dump entry 81 * @param[in] timeStamp - Dump creation timestamp 82 * @param[in] dumpSize - Dump size in bytes. 83 * @param[in] sourceId - The id of dump in the origin. 84 */ 85 void update(uint64_t timeStamp, uint64_t dumpSize, uint32_t sourceId) 86 { 87 sourceDumpId(sourceId); 88 elapsed(timeStamp); 89 size(dumpSize); 90 // TODO: Handled dump failure case with 91 // #bm-openbmc/2808 92 status(OperationStatus::Completed); 93 completedTime(timeStamp); 94 } 95 96 /** 97 * @brief Delete resource dump in host memory and the entry dbus object 98 */ 99 void delete_() override; 100 }; 101 102 } // namespace resource 103 } // namespace dump 104 } // namespace openpower 105