blob: 0d2431f76b7d1be4694625f095c6dacd125f7532 [file] [log] [blame]
Carol Wangdc059392020-03-13 17:39:17 +08001#pragma once
2
3#include <sdbusplus/bus.hpp>
Andrew Geissler9d4d0c92022-01-26 13:18:12 -06004#include <xyz/openbmc_project/Logging/Entry/server.hpp>
Carol Wangdc059392020-03-13 17:39:17 +08005
6namespace phosphor
7{
8namespace state
9{
10namespace manager
11{
12namespace utils
13{
14
Andrew Geissler928bbf12023-02-14 13:30:14 -060015/** @brief Tell systemd to generate d-bus events
16 *
17 * @param[in] bus - The Dbus bus object
18 *
19 * @return void, will throw exception on failure
20 */
Patrick Williams5c4a0822023-02-28 02:40:35 -060021void subscribeToSystemdSignals(sdbusplus::bus_t& bus);
Andrew Geissler928bbf12023-02-14 13:30:14 -060022
Carol Wangdc059392020-03-13 17:39:17 +080023/** @brief Get service name from object path and interface
24 *
25 * @param[in] bus - The Dbus bus object
26 * @param[in] path - The Dbus object path
27 * @param[in] interface - The Dbus interface
28 *
29 * @return The name of the service
30 */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050031std::string getService(sdbusplus::bus_t& bus, std::string path,
Carol Wangdc059392020-03-13 17:39:17 +080032 std::string interface);
33
Andrew Geissler49e67132022-01-26 14:27:52 -060034/** @brief Get the value of input property
35 *
36 * @param[in] bus - The Dbus bus object
37 * @param[in] path - The Dbus object path
38 * @param[in] interface - The Dbus interface
39 * @param[in] property - The property name to get
40 *
41 * @return The value of the property
42 */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050043std::string getProperty(sdbusplus::bus_t& bus, const std::string& path,
Andrew Geissler49e67132022-01-26 14:27:52 -060044 const std::string& interface,
45 const std::string& propertyName);
46
Carol Wangdc059392020-03-13 17:39:17 +080047/** @brief Set the value of property
48 *
49 * @param[in] bus - The Dbus bus object
50 * @param[in] path - The Dbus object path
51 * @param[in] interface - The Dbus interface
52 * @param[in] property - The property name to set
53 * @param[in] value - The value of property
54 */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050055void setProperty(sdbusplus::bus_t& bus, const std::string& path,
Carol Wangdc059392020-03-13 17:39:17 +080056 const std::string& interface, const std::string& property,
57 const std::string& value);
58
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -060059/** @brief Return the value of the input GPIO
60 *
61 * @param[in] gpioName - The name of the GPIO to read
62 *
63 * * @return The value of the gpio (0 or 1) or -1 on error
64 */
65int getGpioValue(const std::string& gpioName);
66
Andrew Geissler9d4d0c92022-01-26 13:18:12 -060067/** @brief Create an error log
68 *
Andrew Geisslerd49f51e2022-03-07 14:57:07 -060069 * @param[in] bus - The Dbus bus object
70 * @param[in] errorMsg - The error message
71 * @param[in] errLevel - The error level
72 * parampin] additionalData - Optional extra data to add to the log
Andrew Geissler9d4d0c92022-01-26 13:18:12 -060073 */
74void createError(
Patrick Williamsf053e6f2022-07-22 19:26:54 -050075 sdbusplus::bus_t& bus, const std::string& errorMsg,
Patrick Williams7e969cb2023-08-23 16:24:23 -050076 sdbusplus::server::xyz::openbmc_project::logging::Entry::Level errLevel,
Andrew Geisslerd49f51e2022-03-07 14:57:07 -060077 std::map<std::string, std::string> additionalData = {});
Andrew Geissler9d4d0c92022-01-26 13:18:12 -060078
Andrew Geissler55e96ac2022-04-19 11:44:53 -040079/** @brief Call phosphor-dump-manager to create BMC user dump
80 *
81 * @param[in] bus - The Dbus bus object
82 */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050083void createBmcDump(sdbusplus::bus_t& bus);
Andrew Geissler55e96ac2022-04-19 11:44:53 -040084
NodeMan9727d1e142022-07-27 15:10:07 -050085/** @brief Attempt to locate the obmc-chassis-lost-power@ file
Manojkiran Eda3ff5a362024-06-17 10:59:07 +053086 * to indicate that an AC loss occurred.
NodeMan9727d1e142022-07-27 15:10:07 -050087 *
88 * @param[in] chassisId - the chassis instance
89 */
90bool checkACLoss(size_t& chassisId);
91
Andrew Geisslerfc1020f2023-05-24 17:07:38 -040092/** @brief Determine if the BMC is at its Ready state
93 *
94 * @param[in] bus - The Dbus bus object
95 */
96bool isBmcReady(sdbusplus::bus_t& bus);
97
Potin Lai08865452023-11-07 23:28:11 +080098/** @brief Wait BMC to enter ready state or timeout reached.
99 *
100 * @param[in] bus - The Dbus bus object
101 * @param[in] timeout - Timeout in second
102 */
103bool waitBmcReady(sdbusplus::bus_t& bus, std::chrono::seconds timeout);
104
Carol Wangdc059392020-03-13 17:39:17 +0800105} // namespace utils
106} // namespace manager
107} // namespace state
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600108} // namespace phosphor