Will Liang | a1d4202 | 2019-06-13 14:17:12 +0800 | [diff] [blame] | 1 | #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 | |
| 10 | namespace phosphor |
| 11 | { |
| 12 | namespace memory |
| 13 | { |
| 14 | |
| 15 | template <typename... T> |
Patrick Williams | c5d295b | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 16 | using ServerObject = typename sdbusplus::server::object_t<T...>; |
Will Liang | a1d4202 | 2019-06-13 14:17:12 +0800 | [diff] [blame] | 17 | |
| 18 | using EccInterface = sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC; |
| 19 | using EccObject = ServerObject<EccInterface>; |
| 20 | /** @class |
| 21 | * @brief Manages ECC |
| 22 | */ |
Patrick Williams | 527190b | 2023-05-10 07:51:28 -0500 | [diff] [blame^] | 23 | class ECC : |
| 24 | sdbusplus::server::object_t< |
| 25 | sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC> |
Will Liang | a1d4202 | 2019-06-13 14:17:12 +0800 | [diff] [blame] | 26 | { |
| 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 Williams | c5d295b | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 40 | ECC(sdbusplus::bus_t& bus, const std::string& objPath) : |
| 41 | sdbusplus::server::object_t< |
Will Liang | a1d4202 | 2019-06-13 14:17:12 +0800 | [diff] [blame] | 42 | 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 Williams | c5d295b | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 58 | sdbusplus::bus_t& _bus; |
Will Liang | a1d4202 | 2019-06-13 14:17:12 +0800 | [diff] [blame] | 59 | /** @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 |