#pragma once #include #include #include #include #include #include #include #include #include #include #include #define MAX_CPU_ID 2 #define MAX_DIMM_RANK 12 #define STATUS_TEMP_NUM 3 #define STATUS_PMIC_RAIL_NUM 6 #define STATUS_REG_NUM 8 extern std::unordered_map> dimm_temp_inf; extern std::unordered_map> dimm_voltage_inf; extern std::unordered_map> dimm_current_inf; extern std::unordered_map> dimm_power_inf; extern std::unordered_map> dimm_statusReg_inf; enum FieldType { VOLTAGE, CURRENT, POWER, TEMP, STATUS }; struct DimmData { uint8_t reg[STATUS_REG_NUM]; double voltage[STATUS_PMIC_RAIL_NUM]; double current[STATUS_PMIC_RAIL_NUM]; double power[STATUS_PMIC_RAIL_NUM]; double temp[STATUS_TEMP_NUM]; }; struct DimmI3CAddr { std::string spdAddr; std::string pmicAddr; }; enum PMICType { PMIC5000 = 0, PMIC5010, PMIC5100, PMIC5020, PMIC5120, PMIC5200, PMIC5030 }; struct DIMMSpdReader : std::enable_shared_from_this { DIMMSpdReader(boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer, const float pollRate) : sensorPollMs(static_cast(pollRate * 1000)), objectServer(objectServer), waitTimer(io) {}; ~DIMMSpdReader() { waitTimer.cancel(); }; void init(); void startRead(); void readDimmInfo(); int getDIMMRegsTemp(uint8_t cpuid, uint8_t rank, DimmData& dimmData); int getDIMMRegsVol(uint8_t cpuid, uint8_t rank, DimmData& dimmData); int getDIMMRegsCurAndPow(uint8_t cpuid, uint8_t rank, DimmData& dimmData); void updateDbus(); void updateToDimmInfoFile(); void setupMatches(sdbusplus::bus_t&); void dimmI3cSwitchMatcher( std::vector& matches, sdbusplus::bus_t& connection, std::function&& onMatch); void getdimmI3cSwitchState(const std::shared_ptr& conn, size_t retries = 2); int getPmicType(uint8_t cpuid, uint8_t rank); int getPmicStatusRegs(uint8_t cpuid, uint8_t rank, DimmData& dimmData); private: std::vector matches; unsigned int sensorPollMs; sdbusplus::asio::object_server& objectServer; boost::asio::steady_timer waitTimer; PMICType pmicType[MAX_CPU_ID][MAX_DIMM_RANK]; bool gotType[MAX_CPU_ID][MAX_DIMM_RANK]; bool twoByteMode[MAX_CPU_ID][MAX_DIMM_RANK]; int adcDelay[MAX_CPU_ID][MAX_DIMM_RANK]; uint16_t regCounter; uint16_t pmicCounter; };