blob: a8895f5c3430bd9dfc0e6ee61491f3febf18865b [file] [log] [blame]
Thang Tranba2241c2021-10-26 17:47:09 +07001#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server/object.hpp>
5#include <xyz/openbmc_project/Condition/HostFirmware/server.hpp>
6
7#include <iostream>
8
9namespace phosphor
10{
11namespace condition
12{
13
Patrick Williamsf053e6f2022-07-22 19:26:54 -050014using HostIntf = sdbusplus::server::object_t<
Patrick Williams7e969cb2023-08-23 16:24:23 -050015 sdbusplus::server::xyz::openbmc_project::condition::HostFirmware>;
Thang Tranba2241c2021-10-26 17:47:09 +070016
17class Host : public HostIntf
18{
19 public:
20 Host() = delete;
21 Host(const Host&) = delete;
22 Host& operator=(const Host&) = delete;
23 Host(Host&&) = delete;
24 Host& operator=(Host&&) = delete;
Pavithra Barithaya44acab72024-06-21 08:11:13 -050025 ~Host() override = default;
Thang Tranba2241c2021-10-26 17:47:09 +070026
Patrick Williamsf053e6f2022-07-22 19:26:54 -050027 Host(sdbusplus::bus_t& bus, const std::string& path,
Thang Tranba2241c2021-10-26 17:47:09 +070028 const std::string& hostId) :
Patrick Williams1b2c3c02024-08-16 15:20:29 -040029 HostIntf(bus, path.c_str()), lineName("host" + hostId)
Thang Tranba2241c2021-10-26 17:47:09 +070030 {
31 scanGpioPin();
32 };
33
34 /** @brief Override reads to CurrentFirmwareCondition */
35 FirmwareCondition currentFirmwareCondition() const override;
36
37 private:
38 std::string lineName;
39 bool isActHigh;
40
41 /*
42 * Scan gpio pin to detect the name and active state
43 */
44 void scanGpioPin();
45};
46} // namespace condition
47} // namespace phosphor