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 | |
| 15 | /** @brief Get service name from object path and interface |
| 16 | * |
| 17 | * @param[in] bus - The Dbus bus object |
| 18 | * @param[in] path - The Dbus object path |
| 19 | * @param[in] interface - The Dbus interface |
| 20 | * |
| 21 | * @return The name of the service |
| 22 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 23 | std::string getService(sdbusplus::bus_t& bus, std::string path, |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 24 | std::string interface); |
| 25 | |
Andrew Geissler | 49e6713 | 2022-01-26 14:27:52 -0600 | [diff] [blame] | 26 | /** @brief Get the value of input property |
| 27 | * |
| 28 | * @param[in] bus - The Dbus bus object |
| 29 | * @param[in] path - The Dbus object path |
| 30 | * @param[in] interface - The Dbus interface |
| 31 | * @param[in] property - The property name to get |
| 32 | * |
| 33 | * @return The value of the property |
| 34 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 35 | std::string getProperty(sdbusplus::bus_t& bus, const std::string& path, |
Andrew Geissler | 49e6713 | 2022-01-26 14:27:52 -0600 | [diff] [blame] | 36 | const std::string& interface, |
| 37 | const std::string& propertyName); |
| 38 | |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 39 | /** @brief Set the value of property |
| 40 | * |
| 41 | * @param[in] bus - The Dbus bus object |
| 42 | * @param[in] path - The Dbus object path |
| 43 | * @param[in] interface - The Dbus interface |
| 44 | * @param[in] property - The property name to set |
| 45 | * @param[in] value - The value of property |
| 46 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 47 | void setProperty(sdbusplus::bus_t& bus, const std::string& path, |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 48 | const std::string& interface, const std::string& property, |
| 49 | const std::string& value); |
| 50 | |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 51 | /** @brief Return the value of the input GPIO |
| 52 | * |
| 53 | * @param[in] gpioName - The name of the GPIO to read |
| 54 | * |
| 55 | * * @return The value of the gpio (0 or 1) or -1 on error |
| 56 | */ |
| 57 | int getGpioValue(const std::string& gpioName); |
| 58 | |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 59 | /** @brief Create an error log |
| 60 | * |
Andrew Geissler | d49f51e | 2022-03-07 14:57:07 -0600 | [diff] [blame] | 61 | * @param[in] bus - The Dbus bus object |
| 62 | * @param[in] errorMsg - The error message |
| 63 | * @param[in] errLevel - The error level |
| 64 | * parampin] additionalData - Optional extra data to add to the log |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 65 | */ |
| 66 | void createError( |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 67 | sdbusplus::bus_t& bus, const std::string& errorMsg, |
Andrew Geissler | d49f51e | 2022-03-07 14:57:07 -0600 | [diff] [blame] | 68 | sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level errLevel, |
| 69 | std::map<std::string, std::string> additionalData = {}); |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 70 | |
Andrew Geissler | 55e96ac | 2022-04-19 11:44:53 -0400 | [diff] [blame] | 71 | /** @brief Call phosphor-dump-manager to create BMC user dump |
| 72 | * |
| 73 | * @param[in] bus - The Dbus bus object |
| 74 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 75 | void createBmcDump(sdbusplus::bus_t& bus); |
Andrew Geissler | 55e96ac | 2022-04-19 11:44:53 -0400 | [diff] [blame] | 76 | |
NodeMan97 | 27d1e14 | 2022-07-27 15:10:07 -0500 | [diff] [blame] | 77 | /** @brief Attempt to locate the obmc-chassis-lost-power@ file |
| 78 | * to indicate that an AC loss occured. |
| 79 | * |
| 80 | * @param[in] chassisId - the chassis instance |
| 81 | */ |
| 82 | bool checkACLoss(size_t& chassisId); |
| 83 | |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 84 | } // namespace utils |
| 85 | } // namespace manager |
| 86 | } // namespace state |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 87 | } // namespace phosphor |