Daniel Hsu | f6470b5 | 2025-02-26 15:03:47 +0800 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include "common/include/device.hpp" |
| 4 | #include "common/include/software_manager.hpp" |
| 5 | #include "cpld_interface.hpp" |
| 6 | |
| 7 | #include <phosphor-logging/lg2.hpp> |
| 8 | #include <sdbusplus/async/context.hpp> |
| 9 | |
| 10 | PHOSPHOR_LOG2_USING; |
| 11 | |
| 12 | namespace ManagerInf = phosphor::software::manager; |
| 13 | |
| 14 | namespace phosphor::software::cpld |
| 15 | { |
| 16 | |
| 17 | class CPLDDevice : public Device |
| 18 | { |
| 19 | public: |
| 20 | CPLDDevice(sdbusplus::async::context& ctx, const std::string& chiptype, |
| 21 | const std::string& chipname, const uint16_t& bus, |
| 22 | const uint8_t& address, SoftwareConfig& config, |
| 23 | ManagerInf::SoftwareManager* parent) : |
| 24 | Device(ctx, config, parent, |
| 25 | {RequestedApplyTimes::Immediate, RequestedApplyTimes::OnReset}), |
| 26 | cpldInterface(CPLDFactory::instance().create(chiptype, ctx, chipname, |
| 27 | bus, address)) |
| 28 | {} |
| 29 | |
| 30 | using Device::softwareCurrent; |
| 31 | sdbusplus::async::task<bool> updateDevice(const uint8_t* image, |
| 32 | size_t image_size) final; |
| 33 | sdbusplus::async::task<bool> getVersion(std::string& version); |
| 34 | |
| 35 | private: |
| 36 | std::unique_ptr<CPLDInterface> cpldInterface; |
| 37 | }; |
| 38 | |
| 39 | } // namespace phosphor::software::cpld |