Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Thang Tran | 9f38152 | 2024-10-18 10:11:01 +0700 | [diff] [blame^] | 3 | #include "config.h" |
| 4 | |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 5 | #include <sdbusplus/bus.hpp> |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 6 | #include <xyz/openbmc_project/Logging/Entry/server.hpp> |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace state |
| 11 | { |
| 12 | namespace manager |
| 13 | { |
| 14 | namespace utils |
| 15 | { |
| 16 | |
Andrew Geissler | 928bbf1 | 2023-02-14 13:30:14 -0600 | [diff] [blame] | 17 | /** @brief Tell systemd to generate d-bus events |
| 18 | * |
| 19 | * @param[in] bus - The Dbus bus object |
| 20 | * |
| 21 | * @return void, will throw exception on failure |
| 22 | */ |
Patrick Williams | 5c4a082 | 2023-02-28 02:40:35 -0600 | [diff] [blame] | 23 | void subscribeToSystemdSignals(sdbusplus::bus_t& bus); |
Andrew Geissler | 928bbf1 | 2023-02-14 13:30:14 -0600 | [diff] [blame] | 24 | |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 25 | /** @brief Get service name from object path and interface |
| 26 | * |
| 27 | * @param[in] bus - The Dbus bus object |
| 28 | * @param[in] path - The Dbus object path |
| 29 | * @param[in] interface - The Dbus interface |
| 30 | * |
| 31 | * @return The name of the service |
| 32 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 33 | std::string getService(sdbusplus::bus_t& bus, std::string path, |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 34 | std::string interface); |
| 35 | |
Andrew Geissler | 49e6713 | 2022-01-26 14:27:52 -0600 | [diff] [blame] | 36 | /** @brief Get the value of input property |
| 37 | * |
| 38 | * @param[in] bus - The Dbus bus object |
| 39 | * @param[in] path - The Dbus object path |
| 40 | * @param[in] interface - The Dbus interface |
| 41 | * @param[in] property - The property name to get |
| 42 | * |
| 43 | * @return The value of the property |
| 44 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 45 | std::string getProperty(sdbusplus::bus_t& bus, const std::string& path, |
Andrew Geissler | 49e6713 | 2022-01-26 14:27:52 -0600 | [diff] [blame] | 46 | const std::string& interface, |
| 47 | const std::string& propertyName); |
| 48 | |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 49 | /** @brief Set the value of property |
| 50 | * |
| 51 | * @param[in] bus - The Dbus bus object |
| 52 | * @param[in] path - The Dbus object path |
| 53 | * @param[in] interface - The Dbus interface |
| 54 | * @param[in] property - The property name to set |
| 55 | * @param[in] value - The value of property |
| 56 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 57 | void setProperty(sdbusplus::bus_t& bus, const std::string& path, |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 58 | const std::string& interface, const std::string& property, |
| 59 | const std::string& value); |
| 60 | |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 61 | /** @brief Return the value of the input GPIO |
| 62 | * |
| 63 | * @param[in] gpioName - The name of the GPIO to read |
| 64 | * |
| 65 | * * @return The value of the gpio (0 or 1) or -1 on error |
| 66 | */ |
| 67 | int getGpioValue(const std::string& gpioName); |
| 68 | |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 69 | /** @brief Create an error log |
| 70 | * |
Andrew Geissler | d49f51e | 2022-03-07 14:57:07 -0600 | [diff] [blame] | 71 | * @param[in] bus - The Dbus bus object |
| 72 | * @param[in] errorMsg - The error message |
| 73 | * @param[in] errLevel - The error level |
| 74 | * parampin] additionalData - Optional extra data to add to the log |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 75 | */ |
| 76 | void createError( |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 77 | sdbusplus::bus_t& bus, const std::string& errorMsg, |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 78 | sdbusplus::server::xyz::openbmc_project::logging::Entry::Level errLevel, |
Andrew Geissler | d49f51e | 2022-03-07 14:57:07 -0600 | [diff] [blame] | 79 | std::map<std::string, std::string> additionalData = {}); |
Andrew Geissler | 9d4d0c9 | 2022-01-26 13:18:12 -0600 | [diff] [blame] | 80 | |
Andrew Geissler | 55e96ac | 2022-04-19 11:44:53 -0400 | [diff] [blame] | 81 | /** @brief Call phosphor-dump-manager to create BMC user dump |
| 82 | * |
| 83 | * @param[in] bus - The Dbus bus object |
| 84 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 85 | void createBmcDump(sdbusplus::bus_t& bus); |
Andrew Geissler | 55e96ac | 2022-04-19 11:44:53 -0400 | [diff] [blame] | 86 | |
NodeMan97 | 27d1e14 | 2022-07-27 15:10:07 -0500 | [diff] [blame] | 87 | /** @brief Attempt to locate the obmc-chassis-lost-power@ file |
Manojkiran Eda | 3ff5a36 | 2024-06-17 10:59:07 +0530 | [diff] [blame] | 88 | * to indicate that an AC loss occurred. |
NodeMan97 | 27d1e14 | 2022-07-27 15:10:07 -0500 | [diff] [blame] | 89 | * |
| 90 | * @param[in] chassisId - the chassis instance |
| 91 | */ |
| 92 | bool checkACLoss(size_t& chassisId); |
| 93 | |
Andrew Geissler | fc1020f | 2023-05-24 17:07:38 -0400 | [diff] [blame] | 94 | /** @brief Determine if the BMC is at its Ready state |
| 95 | * |
| 96 | * @param[in] bus - The Dbus bus object |
| 97 | */ |
| 98 | bool isBmcReady(sdbusplus::bus_t& bus); |
| 99 | |
Potin Lai | 0886545 | 2023-11-07 23:28:11 +0800 | [diff] [blame] | 100 | /** @brief Wait BMC to enter ready state or timeout reached. |
| 101 | * |
| 102 | * @param[in] bus - The Dbus bus object |
| 103 | * @param[in] timeout - Timeout in second |
| 104 | */ |
| 105 | bool waitBmcReady(sdbusplus::bus_t& bus, std::chrono::seconds timeout); |
| 106 | |
Thang Tran | 9f38152 | 2024-10-18 10:11:01 +0700 | [diff] [blame^] | 107 | #ifdef CHECK_FWUPDATE_BEFORE_DO_TRANSITION |
| 108 | /** @brief Determine if any firmware being updated |
| 109 | * |
| 110 | * @param[in] bus - The Dbus bus object |
| 111 | */ |
| 112 | bool isFirmwareUpdating(sdbusplus::bus_t& bus); |
| 113 | #endif // CHECK_FWUPDATE_BEFORE_DO_TRANSITION |
| 114 | |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 115 | } // namespace utils |
| 116 | } // namespace manager |
| 117 | } // namespace state |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 118 | } // namespace phosphor |