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