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