Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 4 | #include <xyz/openbmc_project/Logging/Entry/server.hpp> |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 5 | |
| 6 | namespace phosphor |
| 7 | { |
| 8 | namespace state |
| 9 | { |
| 10 | namespace manager |
| 11 | { |
| 12 | namespace utils |
| 13 | { |
| 14 | |
Andrew Geissler | 928bbf1 | 2023-02-14 13:30:14 -0600 | [diff] [blame] | 15 | /** @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 Williams | 5c4a082 | 2023-02-28 02:40:35 -0600 | [diff] [blame] | 21 | void subscribeToSystemdSignals(sdbusplus::bus_t& bus); |
Andrew Geissler | 928bbf1 | 2023-02-14 13:30:14 -0600 | [diff] [blame] | 22 | |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 23 | /** @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 Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 31 | std::string getService(sdbusplus::bus_t& bus, std::string path, |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 32 | std::string interface); |
| 33 | |
Andrew Geissler | 49e6713 | 2022-01-26 14:27:52 -0600 | [diff] [blame] | 34 | /** @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 Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 43 | std::string getProperty(sdbusplus::bus_t& bus, const std::string& path, |
Andrew Geissler | 49e6713 | 2022-01-26 14:27:52 -0600 | [diff] [blame] | 44 | const std::string& interface, |
| 45 | const std::string& propertyName); |
| 46 | |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 47 | /** @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 Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 55 | void setProperty(sdbusplus::bus_t& bus, const std::string& path, |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 56 | const std::string& interface, const std::string& property, |
| 57 | const std::string& value); |
| 58 | |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 59 | /** @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 | */ |
| 65 | int getGpioValue(const std::string& gpioName); |
| 66 | |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 67 | /** @brief Create an error log |
| 68 | * |
Andrew Geissler | d49f51e | 2022-03-07 14:57:07 -0600 | [diff] [blame] | 69 | * @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 Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 73 | */ |
| 74 | void createError( |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 75 | sdbusplus::bus_t& bus, const std::string& errorMsg, |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 76 | sdbusplus::server::xyz::openbmc_project::logging::Entry::Level errLevel, |
Andrew Geissler | d49f51e | 2022-03-07 14:57:07 -0600 | [diff] [blame] | 77 | std::map<std::string, std::string> additionalData = {}); |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 78 | |
Andrew Geissler | 55e96ac | 2022-04-19 11:44:53 -0400 | [diff] [blame] | 79 | /** @brief Call phosphor-dump-manager to create BMC user dump |
| 80 | * |
| 81 | * @param[in] bus - The Dbus bus object |
| 82 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 83 | void createBmcDump(sdbusplus::bus_t& bus); |
Andrew Geissler | 55e96ac | 2022-04-19 11:44:53 -0400 | [diff] [blame] | 84 | |
NodeMan97 | 27d1e14 | 2022-07-27 15:10:07 -0500 | [diff] [blame] | 85 | /** @brief Attempt to locate the obmc-chassis-lost-power@ file |
Manojkiran Eda | 3ff5a36 | 2024-06-17 10:59:07 +0530 | [diff] [blame] | 86 | * to indicate that an AC loss occurred. |
NodeMan97 | 27d1e14 | 2022-07-27 15:10:07 -0500 | [diff] [blame] | 87 | * |
| 88 | * @param[in] chassisId - the chassis instance |
| 89 | */ |
| 90 | bool checkACLoss(size_t& chassisId); |
| 91 | |
Andrew Geissler | fc1020f | 2023-05-24 17:07:38 -0400 | [diff] [blame] | 92 | /** @brief Determine if the BMC is at its Ready state |
| 93 | * |
| 94 | * @param[in] bus - The Dbus bus object |
| 95 | */ |
| 96 | bool isBmcReady(sdbusplus::bus_t& bus); |
| 97 | |
Potin Lai | 0886545 | 2023-11-07 23:28:11 +0800 | [diff] [blame] | 98 | /** @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 | */ |
| 103 | bool waitBmcReady(sdbusplus::bus_t& bus, std::chrono::seconds timeout); |
| 104 | |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 105 | } // namespace utils |
| 106 | } // namespace manager |
| 107 | } // namespace state |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 108 | } // namespace phosphor |