Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "dump_entry.hpp" |
Dhruvaraj Subhashchandran | 9420f48 | 2021-12-08 03:48:23 -0600 | [diff] [blame] | 4 | #include "xyz/openbmc_project/Common/FilePath/server.hpp" |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 5 | #include "xyz/openbmc_project/Dump/Entry/BMC/server.hpp" |
| 6 | #include "xyz/openbmc_project/Dump/Entry/server.hpp" |
| 7 | #include "xyz/openbmc_project/Object/Delete/server.hpp" |
| 8 | #include "xyz/openbmc_project/Time/EpochTime/server.hpp" |
| 9 | |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 10 | #include <sdbusplus/bus.hpp> |
| 11 | #include <sdbusplus/server/object.hpp> |
| 12 | |
Jayanth Othayoth | 0af74a5 | 2021-04-08 03:55:21 -0500 | [diff] [blame] | 13 | #include <filesystem> |
| 14 | |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 15 | namespace phosphor |
| 16 | { |
| 17 | namespace dump |
| 18 | { |
| 19 | namespace bmc |
| 20 | { |
| 21 | template <typename T> |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 22 | using ServerObject = typename sdbusplus::server::object_t<T>; |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 23 | |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 24 | using EntryIfaces = sdbusplus::server::object_t< |
Dhruvaraj Subhashchandran | 9420f48 | 2021-12-08 03:48:23 -0600 | [diff] [blame] | 25 | sdbusplus::xyz::openbmc_project::Dump::Entry::server::BMC, |
| 26 | sdbusplus::xyz::openbmc_project::Common::server::FilePath>; |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 27 | |
Asmitha Karunanithi | 74a1f39 | 2021-10-27 03:23:59 -0500 | [diff] [blame] | 28 | using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server:: |
| 29 | OriginatedBy::OriginatorTypes; |
| 30 | |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 31 | class Manager; |
| 32 | |
| 33 | /** @class Entry |
| 34 | * @brief OpenBMC Dump Entry implementation. |
| 35 | * @details A concrete implementation for the |
| 36 | * xyz.openbmc_project.Dump.Entry DBus API |
| 37 | */ |
| 38 | class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry |
| 39 | { |
| 40 | public: |
| 41 | Entry() = delete; |
| 42 | Entry(const Entry&) = delete; |
| 43 | Entry& operator=(const Entry&) = delete; |
| 44 | Entry(Entry&&) = delete; |
| 45 | Entry& operator=(Entry&&) = delete; |
| 46 | ~Entry() = default; |
| 47 | |
| 48 | /** @brief Constructor for the Dump Entry Object |
| 49 | * @param[in] bus - Bus to attach to. |
| 50 | * @param[in] objPath - Object path to attach to |
| 51 | * @param[in] dumpId - Dump id. |
| 52 | * @param[in] timeStamp - Dump creation timestamp |
| 53 | * since the epoch. |
| 54 | * @param[in] fileSize - Dump file size in bytes. |
| 55 | * @param[in] file - Name of dump file. |
Dhruvaraj Subhashchandran | a6ab806 | 2020-10-29 15:29:10 -0500 | [diff] [blame] | 56 | * @param[in] status - status of the dump. |
Asmitha Karunanithi | 74a1f39 | 2021-10-27 03:23:59 -0500 | [diff] [blame] | 57 | * @param[in] originatorId - Id of the originator of the dump |
| 58 | * @param[in] originatorType - Originator type |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 59 | * @param[in] parent - The dump entry's parent. |
| 60 | */ |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 61 | Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId, |
Jayanth Othayoth | 3fc6df4 | 2021-04-08 03:45:24 -0500 | [diff] [blame] | 62 | uint64_t timeStamp, uint64_t fileSize, |
| 63 | const std::filesystem::path& file, |
Asmitha Karunanithi | 74a1f39 | 2021-10-27 03:23:59 -0500 | [diff] [blame] | 64 | phosphor::dump::OperationStatus status, std::string originatorId, |
| 65 | originatorTypes originatorType, phosphor::dump::Manager& parent) : |
Patrick Williams | 73f6407 | 2022-04-01 17:04:47 -0500 | [diff] [blame] | 66 | EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit), |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 67 | phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, fileSize, |
Dhruvaraj Subhashchandran | 9420f48 | 2021-12-08 03:48:23 -0600 | [diff] [blame] | 68 | status, originatorId, originatorType, parent) |
Dhruvaraj Subhashchandran | 2f8e276 | 2021-02-11 07:22:35 -0600 | [diff] [blame] | 69 | { |
Dhruvaraj Subhashchandran | 9420f48 | 2021-12-08 03:48:23 -0600 | [diff] [blame] | 70 | path(file); |
Dhruvaraj Subhashchandran | 2f8e276 | 2021-02-11 07:22:35 -0600 | [diff] [blame] | 71 | // Emit deferred signal. |
| 72 | this->phosphor::dump::bmc::EntryIfaces::emit_object_added(); |
| 73 | } |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 74 | |
| 75 | /** @brief Delete this d-bus object. |
| 76 | */ |
| 77 | void delete_() override; |
| 78 | |
Dhruvaraj Subhashchandran | 580d91d | 2020-04-22 12:29:18 -0500 | [diff] [blame] | 79 | /** @brief Method to initiate the offload of dump |
| 80 | * @param[in] uri - URI to offload dump |
| 81 | */ |
| 82 | void initiateOffload(std::string uri) override; |
| 83 | |
Dhruvaraj Subhashchandran | 6ccb50e | 2020-10-29 09:33:18 -0500 | [diff] [blame] | 84 | /** @brief Method to update an existing dump entry, once the dump creation |
| 85 | * is completed this function will be used to update the entry which got |
| 86 | * created during the dump request. |
| 87 | * @param[in] timeStamp - Dump creation timestamp |
| 88 | * @param[in] fileSize - Dump file size in bytes. |
| 89 | * @param[in] file - Name of dump file. |
| 90 | */ |
Jayanth Othayoth | 3fc6df4 | 2021-04-08 03:45:24 -0500 | [diff] [blame] | 91 | void update(uint64_t timeStamp, uint64_t fileSize, |
| 92 | const std::filesystem::path& filePath) |
Dhruvaraj Subhashchandran | 6ccb50e | 2020-10-29 09:33:18 -0500 | [diff] [blame] | 93 | { |
| 94 | elapsed(timeStamp); |
| 95 | size(fileSize); |
Dhruvaraj Subhashchandran | a6ab806 | 2020-10-29 15:29:10 -0500 | [diff] [blame] | 96 | // TODO: Handled dump failed case with #ibm-openbmc/2808 |
| 97 | status(OperationStatus::Completed); |
Dhruvaraj Subhashchandran | 9420f48 | 2021-12-08 03:48:23 -0600 | [diff] [blame] | 98 | path(filePath); |
Dhruvaraj Subhashchandran | a6ab806 | 2020-10-29 15:29:10 -0500 | [diff] [blame] | 99 | // TODO: serialization of this property will be handled with |
| 100 | // #ibm-openbmc/2597 |
| 101 | completedTime(timeStamp); |
Dhruvaraj Subhashchandran | 6ccb50e | 2020-10-29 09:33:18 -0500 | [diff] [blame] | 102 | } |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | } // namespace bmc |
| 106 | } // namespace dump |
| 107 | } // namespace phosphor |