blob: 740b0cd817e8d79a8dbaee777ff5b8549297dfdd [file] [log] [blame]
Jim Wright7945dd22021-04-06 16:55:15 -05001#pragma once
2
Jim Wright930458c2022-01-24 14:37:27 -06003#include <sdbusplus/bus.hpp>
4
5#include <map>
6#include <string>
7
Jim Wright7945dd22021-04-06 16:55:15 -05008namespace phosphor::power::sequencer
9{
10
Jim Wrightc48551a2022-12-22 15:43:14 -060011constexpr auto powerOnTimeoutError =
12 "xyz.openbmc_project.Power.Error.PowerOnTimeout";
13constexpr auto shutdownError = "xyz.openbmc_project.Power.Error.Shutdown";
14
Jim Wright7945dd22021-04-06 16:55:15 -050015/**
16 * @class PowerSequencerMonitor
17 * Define a base class for monitoring a power sequencer device.
18 */
19class PowerSequencerMonitor
20{
21 public:
Jim Wright930458c2022-01-24 14:37:27 -060022 PowerSequencerMonitor() = delete;
Jim Wright7945dd22021-04-06 16:55:15 -050023 PowerSequencerMonitor(const PowerSequencerMonitor&) = delete;
24 PowerSequencerMonitor& operator=(const PowerSequencerMonitor&) = delete;
25 PowerSequencerMonitor(PowerSequencerMonitor&&) = delete;
26 PowerSequencerMonitor& operator=(PowerSequencerMonitor&&) = delete;
27 virtual ~PowerSequencerMonitor() = default;
Jim Wright930458c2022-01-24 14:37:27 -060028
29 /**
30 * Create a base device object for power sequence monitoring.
Jim Wright213ffe92022-06-03 08:54:30 -050031 * @param bus D-Bus bus object
Jim Wright930458c2022-01-24 14:37:27 -060032 */
Patrick Williams7354ce62022-07-22 19:26:56 -050033 explicit PowerSequencerMonitor(sdbusplus::bus_t& bus);
Jim Wright930458c2022-01-24 14:37:27 -060034
35 /**
36 * Logs an error using the D-Bus Create method.
Jim Wright213ffe92022-06-03 08:54:30 -050037 * @param message Message property of the error log entry
38 * @param additionalData AdditionalData property of the error log entry
Jim Wright930458c2022-01-24 14:37:27 -060039 */
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 Wright213ffe92022-06-03 08:54:30 -050046 * @param timeout if the failure state was determined by timing out
47 * @param powerSupplyError The power supply error to log. A default
Jim Wright71a14132022-01-28 09:46:46 -060048 * std:string, i.e. empty string (""), is passed when there is no power
Jim Wright930458c2022-01-24 14:37:27 -060049 * 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 Williams7354ce62022-07-22 19:26:56 -050057 sdbusplus::bus_t& bus;
Jim Wright213ffe92022-06-03 08:54:30 -050058
Jim Wrightc48551a2022-12-22 15:43:14 -060059 /**
Jim Wright213ffe92022-06-03 08:54:30 -050060 * Create a BMC Dump
61 */
62 void createBmcDump();
Jim Wright7945dd22021-04-06 16:55:15 -050063};
64
65} // namespace phosphor::power::sequencer