blob: ac72c80f368cac40c93f817cb3caf98c4d219708 [file] [log] [blame]
Christopher Meis59ef1e72025-04-16 08:53:25 +02001#pragma once
2
3#include <boost/asio/io_context.hpp>
4#include <boost/container/flat_map.hpp>
5#include <nlohmann/json.hpp>
6#include <sdbusplus/asio/connection.hpp>
7
8// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
9extern boost::asio::io_context io;
10
11using DBusValueVariant =
12 std::variant<std::string, int64_t, uint64_t, double, int32_t, uint32_t,
13 int16_t, uint16_t, uint8_t, bool, std::vector<uint8_t>>;
14using DBusInterface = boost::container::flat_map<std::string, DBusValueVariant>;
15using DBusObject = boost::container::flat_map<std::string, DBusInterface>;
16
17constexpr const char* configurationOutDir = "/var/configuration/";
18constexpr const char* versionHashFile = "/var/configuration/version";
19constexpr const char* versionFile = "/etc/os-release";
20
21namespace em_utils
22{
23
24namespace properties
25{
26constexpr const char* interface = "org.freedesktop.DBus.Properties";
27constexpr const char* get = "Get";
28} // namespace properties
29
30namespace power
31{
32const static constexpr char* busname = "xyz.openbmc_project.State.Host";
33const static constexpr char* interface = "xyz.openbmc_project.State.Host";
34const static constexpr char* path = "/xyz/openbmc_project/state/host0";
35const static constexpr char* property = "CurrentHostState";
36} // namespace power
37
38bool isPowerOn();
39void setupPowerMatch(const std::shared_ptr<sdbusplus::asio::connection>& conn);
40bool fwVersionIsSame();
41
42std::optional<std::string> templateCharReplace(
43 nlohmann::json::iterator& keyPair, const DBusObject& object, size_t index,
44 const std::optional<std::string>& replaceStr = std::nullopt);
45
46std::optional<std::string> templateCharReplace(
47 nlohmann::json::iterator& keyPair, const DBusInterface& interface,
48 size_t index, const std::optional<std::string>& replaceStr = std::nullopt);
49
50} // namespace em_utils