blob: fba68ffbd34878b1ffed889a39f8288659845dc9 [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 Williams527190b2023-05-10 07:51:28 -050023class ECC :
24 sdbusplus::server::object_t<
25 sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC>
Will Lianga1d42022019-06-13 14:17:12 +080026{
27 public:
28 ECC() = delete;
29 ~ECC() = default;
30 ECC(const ECC&) = delete;
31 ECC& operator=(const ECC&) = delete;
32 ECC(ECC&&) = default;
33 ECC& operator=(ECC&&) = default;
34
35 /** @brief Constructs
36 *
37 * @param[in] bus - Handle to system dbus
38 * @param[in] objPath - The Dbus path
39 */
Patrick Williamsc5d295b2022-11-26 09:41:58 -060040 ECC(sdbusplus::bus_t& bus, const std::string& objPath) :
41 sdbusplus::server::object_t<
Will Lianga1d42022019-06-13 14:17:12 +080042 sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC>(
43 bus, objPath.c_str()),
44 _bus(bus), _event(sdeventplus::Event::get_default()),
45 _timer(_event, std::bind(&ECC::read, this)){
46 // Nothing to do here
47 };
48
49 int64_t previousCeCounter = 0;
50 int64_t previousUeCounter = 0;
51 int64_t maxECCLog = 0;
52
53 void run();
54 void controlEDACReport(std::string);
55
56 private:
57 /** @brief sdbusplus bus client connection. */
Patrick Williamsc5d295b2022-11-26 09:41:58 -060058 sdbusplus::bus_t& _bus;
Will Lianga1d42022019-06-13 14:17:12 +080059 /** @brief the Event Loop structure */
60 sdeventplus::Event _event;
61 /** @brief Read Timer */
62 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> _timer;
63 /** @brief Read sysfs entries */
64 void read();
65
66 /** @brief Set up D-Bus object init */
67 void init();
68
69 std::string getValue(std::string);
70
71 void writeValue(std::string, std::string);
72 // set ce_count to dbus
73 int checkCeCount();
74 // set ue_count to dbus
75 int checkUeCount();
76 // set eccErrorCount to dbus
77 void checkEccLogFull(int64_t, int64_t);
78
79 void resetCounter();
80 // set maxECCLog value
81 void getMaxLogValue();
82
83 void addSELLog(std::string, std::string, std::vector<uint8_t>, bool,
84 uint16_t);
85};
86
87} // namespace memory
88} // namespace phosphor