1 #pragma once 2 3 #include "xyz/openbmc_project/Common/Progress/server.hpp" 4 #include "xyz/openbmc_project/Dump/Entry/server.hpp" 5 #include "xyz/openbmc_project/Object/Delete/server.hpp" 6 #include "xyz/openbmc_project/Time/EpochTime/server.hpp" 7 8 #include <filesystem> 9 #include <sdbusplus/bus.hpp> 10 #include <sdbusplus/server/object.hpp> 11 12 namespace phosphor 13 { 14 namespace dump 15 { 16 17 template <typename T> 18 using ServerObject = typename sdbusplus::server::object::object<T>; 19 20 // TODO Revisit whether sdbusplus::xyz::openbmc_project::Time::server::EpochTime 21 // still needed in dump entry since start time and completed time are available 22 // from sdbusplus::xyz::openbmc_project::Common::server::Progress 23 // #ibm-openbmc/2809 24 using EntryIfaces = sdbusplus::server::object::object< 25 sdbusplus::xyz::openbmc_project::Common::server::Progress, 26 sdbusplus::xyz::openbmc_project::Dump::server::Entry, 27 sdbusplus::xyz::openbmc_project::Object::server::Delete, 28 sdbusplus::xyz::openbmc_project::Time::server::EpochTime>; 29 30 using OperationStatus = 31 sdbusplus::xyz::openbmc_project::Common::server::Progress::OperationStatus; 32 33 class Manager; 34 35 /** @class Entry 36 * @brief Base Dump Entry implementation. 37 * @details A concrete implementation for the 38 * xyz.openbmc_project.Dump.Entry DBus API 39 */ 40 class Entry : public EntryIfaces 41 { 42 public: 43 Entry() = delete; 44 Entry(const Entry&) = delete; 45 Entry& operator=(const Entry&) = delete; 46 Entry(Entry&&) = delete; 47 Entry& operator=(Entry&&) = delete; 48 ~Entry() = default; 49 50 /** @brief Constructor for the Dump Entry Object 51 * @param[in] bus - Bus to attach to. 52 * @param[in] objPath - Object path to attach to 53 * @param[in] dumpId - Dump id. 54 * @param[in] timeStamp - Dump creation timestamp 55 * since the epoch. 56 * @param[in] dumpSize - Dump file size in bytes. 57 * @param[in] parent - The dump entry's parent. 58 */ 59 Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId, 60 uint64_t timeStamp, uint64_t dumpSize, OperationStatus dumpStatus, 61 Manager& parent) : 62 EntryIfaces(bus, objPath.c_str(), true), 63 parent(parent), id(dumpId) 64 { 65 size(dumpSize); 66 status(dumpStatus); 67 68 // If the object is created after the dump creation keep 69 // all same as timeStamp 70 // if the object created before the dump creation, update 71 // only the start time. Completed and elapsed time will 72 // be updated once the dump is completed. 73 if (dumpStatus == OperationStatus::Completed) 74 { 75 elapsed(timeStamp); 76 startTime(timeStamp); 77 completedTime(timeStamp); 78 } 79 else 80 { 81 elapsed(0); 82 startTime(timeStamp); 83 completedTime(0); 84 } 85 }; 86 87 /** @brief Delete this d-bus object. 88 */ 89 void delete_() override; 90 91 /** @brief Method to initiate the offload of dump 92 * @param[in] uri - URI to offload dump 93 */ 94 void initiateOffload(std::string uri) override 95 { 96 offloadUri(uri); 97 } 98 99 protected: 100 /** @brief This entry's parent */ 101 Manager& parent; 102 103 /** @brief This entry's id */ 104 uint32_t id; 105 }; 106 107 } // namespace dump 108 } // namespace phosphor 109