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 phosphor::dump::Entry, virtual public EntryIfaces 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] usrChallenge - User Challenge needed by host to validate the 54 * request. 55 * @param[in] status - status of the dump. 56 * @param[in] originatorId - Id of the originator of the dump 57 * @param[in] originatorType - Originator type 58 * @param[in] parent - The dump entry's parent. 59 */ Entry(sdbusplus::bus_t & bus,const std::string & objPath,uint32_t dumpId,uint64_t timeStamp,uint64_t dumpSize,const uint32_t sourceId,std::string vspStr,std::string usrChallenge,phosphor::dump::OperationStatus status,std::string originatorId,originatorTypes originatorType,phosphor::dump::Manager & parent)60 Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId, 61 uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId, 62 std::string vspStr, std::string usrChallenge, 63 phosphor::dump::OperationStatus status, std::string originatorId, 64 originatorTypes originatorType, phosphor::dump::Manager& parent) : 65 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize, 66 std::string(), status, originatorId, 67 originatorType, parent), 68 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit) 69 { 70 sourceDumpId(sourceId); 71 vspString(vspStr); 72 userChallenge(usrChallenge); 73 // Emit deferred signal. 74 this->openpower::dump::resource::EntryIfaces::emit_object_added(); 75 }; 76 77 /** @brief Method to initiate the offload of dump 78 * @param[in] uri - URI to offload dump. 79 */ 80 void initiateOffload(std::string uri) override; 81 82 /** @brief Method to update an existing dump entry 83 * @param[in] timeStamp - Dump creation timestamp 84 * @param[in] dumpSize - Dump size in bytes. 85 * @param[in] sourceId - The id of dump in the origin. 86 */ update(uint64_t timeStamp,uint64_t dumpSize,uint32_t sourceId)87 void update(uint64_t timeStamp, uint64_t dumpSize, uint32_t sourceId) 88 { 89 sourceDumpId(sourceId); 90 elapsed(timeStamp); 91 size(dumpSize); 92 // TODO: Handled dump failure case with 93 // #bm-openbmc/2808 94 status(OperationStatus::Completed); 95 completedTime(timeStamp); 96 } 97 98 /** 99 * @brief Delete resource dump in host memory and the entry dbus object 100 */ 101 void delete_() override; 102 }; 103 104 } // namespace resource 105 } // namespace dump 106 } // namespace openpower 107