blob: 9c1dd18ce1f85867506fefff0ed1766f6490fd33 [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
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 Williamsf053e6f2022-07-22 19:26:54 -050023std::string getService(sdbusplus::bus_t& bus, std::string path,
Carol Wangdc059392020-03-13 17:39:17 +080024 std::string interface);
25
Andrew Geissler49e67132022-01-26 14:27:52 -060026/** @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 Williamsf053e6f2022-07-22 19:26:54 -050035std::string getProperty(sdbusplus::bus_t& bus, const std::string& path,
Andrew Geissler49e67132022-01-26 14:27:52 -060036 const std::string& interface,
37 const std::string& propertyName);
38
Carol Wangdc059392020-03-13 17:39:17 +080039/** @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 Williamsf053e6f2022-07-22 19:26:54 -050047void setProperty(sdbusplus::bus_t& bus, const std::string& path,
Carol Wangdc059392020-03-13 17:39:17 +080048 const std::string& interface, const std::string& property,
49 const std::string& value);
50
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -060051/** @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 */
57int getGpioValue(const std::string& gpioName);
58
Andrew Geissler9d4d0c92022-01-26 13:18:12 -060059/** @brief Create an error log
60 *
Andrew Geisslerd49f51e2022-03-07 14:57:07 -060061 * @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 Geissler9d4d0c92022-01-26 13:18:12 -060065 */
66void createError(
Patrick Williamsf053e6f2022-07-22 19:26:54 -050067 sdbusplus::bus_t& bus, const std::string& errorMsg,
Andrew Geisslerd49f51e2022-03-07 14:57:07 -060068 sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level errLevel,
69 std::map<std::string, std::string> additionalData = {});
Andrew Geissler9d4d0c92022-01-26 13:18:12 -060070
Andrew Geissler55e96ac2022-04-19 11:44:53 -040071/** @brief Call phosphor-dump-manager to create BMC user dump
72 *
73 * @param[in] bus - The Dbus bus object
74 */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050075void createBmcDump(sdbusplus::bus_t& bus);
Andrew Geissler55e96ac2022-04-19 11:44:53 -040076
NodeMan9727d1e142022-07-27 15:10:07 -050077/** @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 */
82bool checkACLoss(size_t& chassisId);
83
Carol Wangdc059392020-03-13 17:39:17 +080084} // namespace utils
85} // namespace manager
86} // namespace state
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -060087} // namespace phosphor