Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Jim Wright | 930458c | 2022-01-24 14:37:27 -0600 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
| 4 | |
| 5 | #include <map> |
| 6 | #include <string> |
| 7 | |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 8 | namespace phosphor::power::sequencer |
| 9 | { |
| 10 | |
Jim Wright | c48551a | 2022-12-22 15:43:14 -0600 | [diff] [blame] | 11 | constexpr auto powerOnTimeoutError = |
| 12 | "xyz.openbmc_project.Power.Error.PowerOnTimeout"; |
| 13 | constexpr auto shutdownError = "xyz.openbmc_project.Power.Error.Shutdown"; |
| 14 | |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 15 | /** |
| 16 | * @class PowerSequencerMonitor |
| 17 | * Define a base class for monitoring a power sequencer device. |
| 18 | */ |
| 19 | class PowerSequencerMonitor |
| 20 | { |
| 21 | public: |
Jim Wright | 930458c | 2022-01-24 14:37:27 -0600 | [diff] [blame] | 22 | PowerSequencerMonitor() = delete; |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 23 | PowerSequencerMonitor(const PowerSequencerMonitor&) = delete; |
| 24 | PowerSequencerMonitor& operator=(const PowerSequencerMonitor&) = delete; |
| 25 | PowerSequencerMonitor(PowerSequencerMonitor&&) = delete; |
| 26 | PowerSequencerMonitor& operator=(PowerSequencerMonitor&&) = delete; |
| 27 | virtual ~PowerSequencerMonitor() = default; |
Jim Wright | 930458c | 2022-01-24 14:37:27 -0600 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * Create a base device object for power sequence monitoring. |
Jim Wright | 213ffe9 | 2022-06-03 08:54:30 -0500 | [diff] [blame] | 31 | * @param bus D-Bus bus object |
Jim Wright | 930458c | 2022-01-24 14:37:27 -0600 | [diff] [blame] | 32 | */ |
Patrick Williams | 7354ce6 | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 33 | explicit PowerSequencerMonitor(sdbusplus::bus_t& bus); |
Jim Wright | 930458c | 2022-01-24 14:37:27 -0600 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Logs an error using the D-Bus Create method. |
Jim Wright | 213ffe9 | 2022-06-03 08:54:30 -0500 | [diff] [blame] | 37 | * @param message Message property of the error log entry |
| 38 | * @param additionalData AdditionalData property of the error log entry |
Jim Wright | 930458c | 2022-01-24 14:37:27 -0600 | [diff] [blame] | 39 | */ |
| 40 | void logError(const std::string& message, |
| 41 | std::map<std::string, std::string>& additionalData); |
| 42 | |
| 43 | /** |
| 44 | * Analyzes the device for errors when the device is |
| 45 | * known to be in an error state. A log will be created. |
Jim Wright | 213ffe9 | 2022-06-03 08:54:30 -0500 | [diff] [blame] | 46 | * @param timeout if the failure state was determined by timing out |
| 47 | * @param powerSupplyError The power supply error to log. A default |
Jim Wright | 71a1413 | 2022-01-28 09:46:46 -0600 | [diff] [blame] | 48 | * std:string, i.e. empty string (""), is passed when there is no power |
Jim Wright | 930458c | 2022-01-24 14:37:27 -0600 | [diff] [blame] | 49 | * supply error to log. |
| 50 | */ |
| 51 | virtual void onFailure(bool timeout, const std::string& powerSupplyError); |
| 52 | |
| 53 | protected: |
| 54 | /** |
| 55 | * The D-Bus bus object |
| 56 | */ |
Patrick Williams | 7354ce6 | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 57 | sdbusplus::bus_t& bus; |
Jim Wright | 213ffe9 | 2022-06-03 08:54:30 -0500 | [diff] [blame] | 58 | |
Jim Wright | c48551a | 2022-12-22 15:43:14 -0600 | [diff] [blame] | 59 | /** |
Jim Wright | 213ffe9 | 2022-06-03 08:54:30 -0500 | [diff] [blame] | 60 | * Create a BMC Dump |
| 61 | */ |
| 62 | void createBmcDump(); |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | } // namespace phosphor::power::sequencer |