1 #pragma once 2 3 #include <sdbusplus/bus.hpp> 4 #include <util/ffdc_file.hpp> 5 6 #include <string> 7 #include <variant> 8 #include <vector> 9 10 namespace util 11 { 12 namespace dbus 13 { 14 using DBusValue = std::variant<std::string, bool, std::vector<uint8_t>, 15 std::vector<std::string>, int32_t>; 16 using DBusProperty = std::string; 17 using DBusInterface = std::string; 18 using DBusService = std::string; 19 using DBusPath = std::string; 20 using DBusInterfaceList = std::vector<DBusInterface>; 21 using DBusSubTree = 22 std::map<DBusPath, std::map<DBusService, DBusInterfaceList>>; 23 24 /** 25 * Find the dbus object path and service that implements the given interface 26 * 27 * @param[in] i_interface Interface to search for 28 * @param[out] o_path Path of dbus object implementing the interface 29 * @param[out] o_service Service implementing the dbus object path 30 * @return non-zero on error 31 */ 32 int find(const std::string& i_interface, std::string& o_path, 33 std::string& o_service); 34 35 /** 36 * Find the dbus service that implements the given dbus object and interface 37 * 38 * @param[in] i_interface Interface that maps to the service 39 * @param[in] i_path Path that maps to the service 40 * @param[out] o_service Service implementing the dbus object and interface 41 * @return non-zer on error 42 */ 43 int findService(const std::string& i_interface, const std::string& i_path, 44 std::string& o_service); 45 46 /** 47 * Read a property from a dbus object interface 48 * 49 * @param[in] i_interface Interface implementing the property 50 * @param[in] i_path Path of the dbus object 51 * @param[in] i_service Service implementing the dbus object and interface 52 * @param[in] i_property Property to read 53 * @return non-zero on error 54 */ 55 int getProperty(const std::string& i_interface, const std::string& i_path, 56 const std::string& i_service, const std::string& i_property, 57 DBusValue& o_response); 58 59 /** 60 * Get the IBM compatible names defined for this system 61 * 62 * @return A vector of strings containing the system names 63 */ 64 std::vector<std::string> systemNames(); 65 66 /** @brief Host transition states for host transition operations */ 67 enum class HostState 68 { 69 Quiesce, 70 Diagnostic, 71 Crash 72 }; 73 74 /** 75 * @brief Transition the host state 76 * 77 * We will transition the host state by starting the appropriate dbus target. 78 * 79 * @param i_hostState the state to transition the host to 80 */ 81 void transitionHost(const HostState i_hostState); 82 83 /** 84 * @brief Read autoRebootEnabled property 85 * 86 * @return false if autoRebootEnabled policy false, else true 87 */ 88 bool autoRebootEnabled(); 89 90 /** @brief Host running states for host running operations */ 91 enum class HostRunningState 92 { 93 Unknown, 94 NotStarted, 95 Started, 96 Stopping 97 }; 98 99 /** 100 * Get the host running state 101 * 102 * Use host boot progress to determine if a host has been started. If host 103 * boot progress can not be determined then host state will be unknown. 104 * 105 * @return HostType == "Unknown", "Started or "NotStarted" 106 */ 107 HostRunningState hostRunningState(); 108 109 /** 110 * @brief Read dumpPolicyEnabled property 111 * 112 * @return false if dumpPolicyEnabled property is false, else true 113 */ 114 bool dumpPolicyEnabled(); 115 116 /** 117 * Create a PEL 118 * 119 * The additional data provided in the map will be placed in a user data 120 * section of the PEL and may additionally contain key words to trigger 121 * certain behaviors by the backend logging code. Each set of data described 122 * in the vector of ffdc data will be placed in additional user data 123 * sections. Note that the PID of the caller will be added to the additional 124 * data map with key "_PID". 125 * 126 * @param i_message - the event type 127 * @param i_severity - the severity level 128 * @param io_additional - map of additional data 129 * @param i_ffdc - vector of ffdc data 130 * @return Platform log id or 0 if error 131 */ 132 uint32_t createPel(const std::string& i_message, const std::string& i_severity, 133 std::map<std::string, std::string>& io_additional, 134 const std::vector<FFDCTuple>& i_ffdc); 135 136 /** @brief Machine ID definitions */ 137 enum class MachineType 138 { 139 Rainier_2S4U, 140 Rainier_2S2U, 141 Rainier_1S4U, 142 Rainier_1S2U, 143 Everest, 144 Bonnell, 145 }; 146 147 /** 148 * @brief Read the System IM keyword to get the machine type 149 * 150 * @return An enum representing the machine type 151 */ 152 MachineType getMachineType(); 153 154 /** @brief Get list of state sensor PDRs 155 * 156 * @param[out] pdrList - list of PDRs 157 * @param[in] stateSetId - ID of the state set of interest 158 * 159 * @return true if successful otherwise false 160 */ 161 bool getStateSensorPdrs(std::vector<std::vector<uint8_t>>& pdrList, 162 uint16_t stateSetId); 163 164 /** @brief Get list of state effecter PDRs 165 * 166 * @param[out] pdrList - list of PDRs 167 * @param[in] stateSetId - ID of the state set of interest 168 * 169 * @return true if successful otherwise false 170 */ 171 bool getStateEffecterPdrs(std::vector<std::vector<uint8_t>>& pdrList, 172 uint16_t stateSetId); 173 174 /** 175 * @brief Get MCTP instance ID associated with endpoint 176 * 177 * @param[out] mctpInstance - instance of MCTP 178 * @param[in] Eid - MCTP enpoint ID 179 * 180 * @return True on success otherwise False 181 */ 182 bool getMctpInstance(uint8_t& mctpInstance, uint8_t Eid); 183 184 /** 185 * @brief Determine if power fault was detected 186 * 187 * @return true if power fault or unknown, false otherwise 188 */ 189 bool powerFault(); 190 191 } // namespace dbus 192 } // namespace util 193