1*cf77ef54SJagpal Singh Gill #pragma once 2*cf77ef54SJagpal Singh Gill 3*cf77ef54SJagpal Singh Gill #include "device/base_config.hpp" 4*cf77ef54SJagpal Singh Gill #include "port/base_port.hpp" 5*cf77ef54SJagpal Singh Gill 6*cf77ef54SJagpal Singh Gill #include <sdbusplus/async.hpp> 7*cf77ef54SJagpal Singh Gill #include <sdbusplus/async/server.hpp> 8*cf77ef54SJagpal Singh Gill #include <xyz/openbmc_project/Association/Definitions/aserver.hpp> 9*cf77ef54SJagpal Singh Gill #include <xyz/openbmc_project/Software/Activation/aserver.hpp> 10*cf77ef54SJagpal Singh Gill #include <xyz/openbmc_project/Software/Version/aserver.hpp> 11*cf77ef54SJagpal Singh Gill 12*cf77ef54SJagpal Singh Gill namespace phosphor::modbus::rtu::device 13*cf77ef54SJagpal Singh Gill { 14*cf77ef54SJagpal Singh Gill 15*cf77ef54SJagpal Singh Gill namespace config 16*cf77ef54SJagpal Singh Gill { 17*cf77ef54SJagpal Singh Gill 18*cf77ef54SJagpal Singh Gill struct Config; 19*cf77ef54SJagpal Singh Gill 20*cf77ef54SJagpal Singh Gill } // namespace config 21*cf77ef54SJagpal Singh Gill 22*cf77ef54SJagpal Singh Gill namespace config_intf = phosphor::modbus::rtu::device::config; 23*cf77ef54SJagpal Singh Gill using PortIntf = phosphor::modbus::rtu::port::BasePort; 24*cf77ef54SJagpal Singh Gill 25*cf77ef54SJagpal Singh Gill class DeviceFirmware; 26*cf77ef54SJagpal Singh Gill 27*cf77ef54SJagpal Singh Gill using FirmwareIntf = sdbusplus::async::server_t< 28*cf77ef54SJagpal Singh Gill DeviceFirmware, sdbusplus::aserver::xyz::openbmc_project::software::Version, 29*cf77ef54SJagpal Singh Gill sdbusplus::aserver::xyz::openbmc_project::software::Activation, 30*cf77ef54SJagpal Singh Gill sdbusplus::aserver::xyz::openbmc_project::association::Definitions>; 31*cf77ef54SJagpal Singh Gill 32*cf77ef54SJagpal Singh Gill class DeviceFirmware 33*cf77ef54SJagpal Singh Gill { 34*cf77ef54SJagpal Singh Gill public: 35*cf77ef54SJagpal Singh Gill DeviceFirmware() = delete; 36*cf77ef54SJagpal Singh Gill 37*cf77ef54SJagpal Singh Gill explicit DeviceFirmware(sdbusplus::async::context& ctx, 38*cf77ef54SJagpal Singh Gill const config_intf::Config& config, 39*cf77ef54SJagpal Singh Gill PortIntf& serialPort); 40*cf77ef54SJagpal Singh Gill 41*cf77ef54SJagpal Singh Gill auto readVersionRegister() -> sdbusplus::async::task<void>; 42*cf77ef54SJagpal Singh Gill 43*cf77ef54SJagpal Singh Gill protected: 44*cf77ef54SJagpal Singh Gill // Object path of current firmware object 45*cf77ef54SJagpal Singh Gill // TODO: check if its possible to get rid off this via mocking since its 46*cf77ef54SJagpal Singh Gill // only used in tests 47*cf77ef54SJagpal Singh Gill const sdbusplus::message::object_path objectPath; 48*cf77ef54SJagpal Singh Gill 49*cf77ef54SJagpal Singh Gill private: 50*cf77ef54SJagpal Singh Gill std::unique_ptr<FirmwareIntf> currentFirmware; 51*cf77ef54SJagpal Singh Gill const config_intf::Config config; 52*cf77ef54SJagpal Singh Gill PortIntf& serialPort; 53*cf77ef54SJagpal Singh Gill }; 54*cf77ef54SJagpal Singh Gill 55*cf77ef54SJagpal Singh Gill } // namespace phosphor::modbus::rtu::device 56