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