1dc059399SCarol Wang #pragma once 2dc059399SCarol Wang 3*9f38152aSThang Tran #include "config.h" 4*9f38152aSThang Tran 5dc059399SCarol Wang #include <sdbusplus/bus.hpp> 69d4d0c91SAndrew Geissler #include <xyz/openbmc_project/Logging/Entry/server.hpp> 7dc059399SCarol Wang 8dc059399SCarol Wang namespace phosphor 9dc059399SCarol Wang { 10dc059399SCarol Wang namespace state 11dc059399SCarol Wang { 12dc059399SCarol Wang namespace manager 13dc059399SCarol Wang { 14dc059399SCarol Wang namespace utils 15dc059399SCarol Wang { 16dc059399SCarol Wang 17928bbf15SAndrew Geissler /** @brief Tell systemd to generate d-bus events 18928bbf15SAndrew Geissler * 19928bbf15SAndrew Geissler * @param[in] bus - The Dbus bus object 20928bbf15SAndrew Geissler * 21928bbf15SAndrew Geissler * @return void, will throw exception on failure 22928bbf15SAndrew Geissler */ 235c4a0822SPatrick Williams void subscribeToSystemdSignals(sdbusplus::bus_t& bus); 24928bbf15SAndrew Geissler 25dc059399SCarol Wang /** @brief Get service name from object path and interface 26dc059399SCarol Wang * 27dc059399SCarol Wang * @param[in] bus - The Dbus bus object 28dc059399SCarol Wang * @param[in] path - The Dbus object path 29dc059399SCarol Wang * @param[in] interface - The Dbus interface 30dc059399SCarol Wang * 31dc059399SCarol Wang * @return The name of the service 32dc059399SCarol Wang */ 33f053e6feSPatrick Williams std::string getService(sdbusplus::bus_t& bus, std::string path, 34dc059399SCarol Wang std::string interface); 35dc059399SCarol Wang 3649e6713aSAndrew Geissler /** @brief Get the value of input property 3749e6713aSAndrew Geissler * 3849e6713aSAndrew Geissler * @param[in] bus - The Dbus bus object 3949e6713aSAndrew Geissler * @param[in] path - The Dbus object path 4049e6713aSAndrew Geissler * @param[in] interface - The Dbus interface 4149e6713aSAndrew Geissler * @param[in] property - The property name to get 4249e6713aSAndrew Geissler * 4349e6713aSAndrew Geissler * @return The value of the property 4449e6713aSAndrew Geissler */ 45f053e6feSPatrick Williams std::string getProperty(sdbusplus::bus_t& bus, const std::string& path, 4649e6713aSAndrew Geissler const std::string& interface, 4749e6713aSAndrew Geissler const std::string& propertyName); 4849e6713aSAndrew Geissler 49dc059399SCarol Wang /** @brief Set the value of property 50dc059399SCarol Wang * 51dc059399SCarol Wang * @param[in] bus - The Dbus bus object 52dc059399SCarol Wang * @param[in] path - The Dbus object path 53dc059399SCarol Wang * @param[in] interface - The Dbus interface 54dc059399SCarol Wang * @param[in] property - The property name to set 55dc059399SCarol Wang * @param[in] value - The value of property 56dc059399SCarol Wang */ 57f053e6feSPatrick Williams void setProperty(sdbusplus::bus_t& bus, const std::string& path, 58dc059399SCarol Wang const std::string& interface, const std::string& property, 59dc059399SCarol Wang const std::string& value); 60dc059399SCarol Wang 61f8ae6a02SAndrew Geissler /** @brief Return the value of the input GPIO 62f8ae6a02SAndrew Geissler * 63f8ae6a02SAndrew Geissler * @param[in] gpioName - The name of the GPIO to read 64f8ae6a02SAndrew Geissler * 65f8ae6a02SAndrew Geissler * * @return The value of the gpio (0 or 1) or -1 on error 66f8ae6a02SAndrew Geissler */ 67f8ae6a02SAndrew Geissler int getGpioValue(const std::string& gpioName); 68f8ae6a02SAndrew Geissler 699d4d0c91SAndrew Geissler /** @brief Create an error log 709d4d0c91SAndrew Geissler * 719d4d0c91SAndrew Geissler * @param[in] bus - The Dbus bus object 729d4d0c91SAndrew Geissler * @param[in] errorMsg - The error message 739d4d0c91SAndrew Geissler * @param[in] errLevel - The error level 74d49f51edSAndrew Geissler * parampin] additionalData - Optional extra data to add to the log 759d4d0c91SAndrew Geissler */ 769d4d0c91SAndrew Geissler void createError( 77f053e6feSPatrick Williams sdbusplus::bus_t& bus, const std::string& errorMsg, 787e969cb9SPatrick Williams sdbusplus::server::xyz::openbmc_project::logging::Entry::Level errLevel, 79d49f51edSAndrew Geissler std::map<std::string, std::string> additionalData = {}); 809d4d0c91SAndrew Geissler 8155e96ac5SAndrew Geissler /** @brief Call phosphor-dump-manager to create BMC user dump 8255e96ac5SAndrew Geissler * 8355e96ac5SAndrew Geissler * @param[in] bus - The Dbus bus object 8455e96ac5SAndrew Geissler */ 85f053e6feSPatrick Williams void createBmcDump(sdbusplus::bus_t& bus); 8655e96ac5SAndrew Geissler 8727d1e14cSNodeMan97 /** @brief Attempt to locate the obmc-chassis-lost-power@ file 883ff5a360SManojkiran Eda * to indicate that an AC loss occurred. 8927d1e14cSNodeMan97 * 9027d1e14cSNodeMan97 * @param[in] chassisId - the chassis instance 9127d1e14cSNodeMan97 */ 9227d1e14cSNodeMan97 bool checkACLoss(size_t& chassisId); 9327d1e14cSNodeMan97 94fc1020f2SAndrew Geissler /** @brief Determine if the BMC is at its Ready state 95fc1020f2SAndrew Geissler * 96fc1020f2SAndrew Geissler * @param[in] bus - The Dbus bus object 97fc1020f2SAndrew Geissler */ 98fc1020f2SAndrew Geissler bool isBmcReady(sdbusplus::bus_t& bus); 99fc1020f2SAndrew Geissler 1000886545dSPotin Lai /** @brief Wait BMC to enter ready state or timeout reached. 1010886545dSPotin Lai * 1020886545dSPotin Lai * @param[in] bus - The Dbus bus object 1030886545dSPotin Lai * @param[in] timeout - Timeout in second 1040886545dSPotin Lai */ 1050886545dSPotin Lai bool waitBmcReady(sdbusplus::bus_t& bus, std::chrono::seconds timeout); 1060886545dSPotin Lai 107*9f38152aSThang Tran #ifdef CHECK_FWUPDATE_BEFORE_DO_TRANSITION 108*9f38152aSThang Tran /** @brief Determine if any firmware being updated 109*9f38152aSThang Tran * 110*9f38152aSThang Tran * @param[in] bus - The Dbus bus object 111*9f38152aSThang Tran */ 112*9f38152aSThang Tran bool isFirmwareUpdating(sdbusplus::bus_t& bus); 113*9f38152aSThang Tran #endif // CHECK_FWUPDATE_BEFORE_DO_TRANSITION 114*9f38152aSThang Tran 115dc059399SCarol Wang } // namespace utils 116dc059399SCarol Wang } // namespace manager 117dc059399SCarol Wang } // namespace state 118dc059399SCarol Wang } // namespace phosphor 119