blob: d239c56294a4604770bcaf8d273b6654df5fa556 [file] [log] [blame]
Will Lianga1d42022019-06-13 14:17:12 +08001#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server/object.hpp>
5#include <sdeventplus/clock.hpp>
6#include <sdeventplus/event.hpp>
7#include <sdeventplus/utility/timer.hpp>
8#include <xyz/openbmc_project/Memory/MemoryECC/server.hpp>
9
10namespace phosphor
11{
12namespace memory
13{
14
15template <typename... T>
Patrick Williamsc5d295b2022-11-26 09:41:58 -060016using ServerObject = typename sdbusplus::server::object_t<T...>;
Will Lianga1d42022019-06-13 14:17:12 +080017
18using EccInterface = sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC;
19using EccObject = ServerObject<EccInterface>;
20/** @class
21 * @brief Manages ECC
22 */
Patrick Williamsc5d295b2022-11-26 09:41:58 -060023class ECC : sdbusplus::server::object_t<
Will Lianga1d42022019-06-13 14:17:12 +080024 sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC>
25{
26 public:
27 ECC() = delete;
28 ~ECC() = default;
29 ECC(const ECC&) = delete;
30 ECC& operator=(const ECC&) = delete;
31 ECC(ECC&&) = default;
32 ECC& operator=(ECC&&) = default;
33
34 /** @brief Constructs
35 *
36 * @param[in] bus - Handle to system dbus
37 * @param[in] objPath - The Dbus path
38 */
Patrick Williamsc5d295b2022-11-26 09:41:58 -060039 ECC(sdbusplus::bus_t& bus, const std::string& objPath) :
40 sdbusplus::server::object_t<
Will Lianga1d42022019-06-13 14:17:12 +080041 sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC>(
42 bus, objPath.c_str()),
43 _bus(bus), _event(sdeventplus::Event::get_default()),
44 _timer(_event, std::bind(&ECC::read, this)){
45 // Nothing to do here
46 };
47
48 int64_t previousCeCounter = 0;
49 int64_t previousUeCounter = 0;
50 int64_t maxECCLog = 0;
51
52 void run();
53 void controlEDACReport(std::string);
54
55 private:
56 /** @brief sdbusplus bus client connection. */
Patrick Williamsc5d295b2022-11-26 09:41:58 -060057 sdbusplus::bus_t& _bus;
Will Lianga1d42022019-06-13 14:17:12 +080058 /** @brief the Event Loop structure */
59 sdeventplus::Event _event;
60 /** @brief Read Timer */
61 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> _timer;
62 /** @brief Read sysfs entries */
63 void read();
64
65 /** @brief Set up D-Bus object init */
66 void init();
67
68 std::string getValue(std::string);
69
70 void writeValue(std::string, std::string);
71 // set ce_count to dbus
72 int checkCeCount();
73 // set ue_count to dbus
74 int checkUeCount();
75 // set eccErrorCount to dbus
76 void checkEccLogFull(int64_t, int64_t);
77
78 void resetCounter();
79 // set maxECCLog value
80 void getMaxLogValue();
81
82 void addSELLog(std::string, std::string, std::vector<uint8_t>, bool,
83 uint16_t);
84};
85
86} // namespace memory
87} // namespace phosphor