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 | c5d295b | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 23 | class ECC : sdbusplus::server::object_t< |
Will Liang | a1d4202 | 2019-06-13 14:17:12 +0800 | [diff] [blame] | 24 | 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 Williams | c5d295b | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 39 | ECC(sdbusplus::bus_t& bus, const std::string& objPath) : |
| 40 | sdbusplus::server::object_t< |
Will Liang | a1d4202 | 2019-06-13 14:17:12 +0800 | [diff] [blame] | 41 | 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 Williams | c5d295b | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 57 | sdbusplus::bus_t& _bus; |
Will Liang | a1d4202 | 2019-06-13 14:17:12 +0800 | [diff] [blame] | 58 | /** @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 |