blob: d239c56294a4604770bcaf8d273b6654df5fa556 [file] [log] [blame]
#pragma once
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
#include <sdeventplus/clock.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/utility/timer.hpp>
#include <xyz/openbmc_project/Memory/MemoryECC/server.hpp>
namespace phosphor
{
namespace memory
{
template <typename... T>
using ServerObject = typename sdbusplus::server::object_t<T...>;
using EccInterface = sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC;
using EccObject = ServerObject<EccInterface>;
/** @class
* @brief Manages ECC
*/
class ECC : sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC>
{
public:
ECC() = delete;
~ECC() = default;
ECC(const ECC&) = delete;
ECC& operator=(const ECC&) = delete;
ECC(ECC&&) = default;
ECC& operator=(ECC&&) = default;
/** @brief Constructs
*
* @param[in] bus - Handle to system dbus
* @param[in] objPath - The Dbus path
*/
ECC(sdbusplus::bus_t& bus, const std::string& objPath) :
sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC>(
bus, objPath.c_str()),
_bus(bus), _event(sdeventplus::Event::get_default()),
_timer(_event, std::bind(&ECC::read, this)){
// Nothing to do here
};
int64_t previousCeCounter = 0;
int64_t previousUeCounter = 0;
int64_t maxECCLog = 0;
void run();
void controlEDACReport(std::string);
private:
/** @brief sdbusplus bus client connection. */
sdbusplus::bus_t& _bus;
/** @brief the Event Loop structure */
sdeventplus::Event _event;
/** @brief Read Timer */
sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> _timer;
/** @brief Read sysfs entries */
void read();
/** @brief Set up D-Bus object init */
void init();
std::string getValue(std::string);
void writeValue(std::string, std::string);
// set ce_count to dbus
int checkCeCount();
// set ue_count to dbus
int checkUeCount();
// set eccErrorCount to dbus
void checkEccLogFull(int64_t, int64_t);
void resetCounter();
// set maxECCLog value
void getMaxLogValue();
void addSELLog(std::string, std::string, std::vector<uint8_t>, bool,
uint16_t);
};
} // namespace memory
} // namespace phosphor