#include <ipmid/api-types.hpp>
#include <ipmid/api.hpp>
#include <ipmid/message.hpp>
#include <ipmid/utils.hpp>
#include <sdbusplus/message/types.hpp>

typedef struct {
    uint8_t socket_id;
    uint8_t channel_id;
    uint8_t dimm_id;
    uint8_t temp_integer;
    uint8_t temp_decimal;
/*Memory temperature infomation(unit °C)*/
}memory_info_t;

#pragma pack(1)

enum class DataType {
    TEMPERATURE,
    CURRENT,
    POWER,
    VOLTAGE,
    STATUS,
    ERROR
};

enum class TempSensor {
    TS0,
    TS1,
    SPD_TS,
    MAX_TS01
};

enum class ReqId {
    TS0 = 0,
    TS1 = 1,
    SPD_TEMP = 2,
    MAX_TEMP = 3,
    VOLTAGE = 4,
    CURRENT = 5,
    STATUS_REG = 6,
    ERROR_CODE = 7
};

enum class RailChannel {
    SWA,
    SWB,
    SWC,
    SWD,
    SWE,
    SWF
};

enum class StatusReg {
    REG_04 = 0x04,
    REG_05 = 0x05,
    REG_06 = 0x06,
    REG_07 = 0x07,
    REG_08 = 0x08,
    REG_09 = 0x09,
    REG_0A = 0x0A,
    REG_0B = 0x0B
};

enum class ErrCode {
    errCode_REG_32 = 0x32
};

typedef struct {
    int8_t int_part;
    uint8_t frac_part;
} dimm_temp_sensor_t;
typedef struct {
    int8_t TS0_int;
    uint8_t TS0_frac;
    int8_t TS1_int;
    uint8_t TS1_frac;
    int8_t SPD_int;
    uint8_t SPD_frac;
} dimm_temp_t;

typedef struct {
    uint16_t SWA;
    uint16_t SWB;
    uint16_t SWC;
    uint16_t SWD;
    uint16_t SWE;
    uint16_t SWF;
} dimm_rail_t;

typedef struct {
    uint8_t          dimmId;
    dimm_temp_t      dimmTemp;
    dimm_rail_t      dimmVolt;
    dimm_rail_t      dimmCur;
    dimm_rail_t      dimmPow;
} oem_dimm_info_t;
#pragma pack()


#define MAX_FSC_PWM_CHANNEL 29
#define FSC_FAN_TABLE_AUTO 0
#define FSC_FAN_TABLE_MANUAL 1
typedef struct
{
    uint8_t u8ControlMode;
    uint8_t u8PWM[MAX_FSC_PWM_CHANNEL];
}SFscControlMode;

namespace ipmi {
constexpr Iana oemIANA =
    56799; // 0x00dddf https://www.iana.org/assignments/enterprise-numbers/?page=568
constexpr int prioOem = ipmi::prioMax;
constexpr NetFn netFnOemSelf = ipmi::netFnOemFour; // NetFn is 0x36
namespace ipmiOem {

constexpr Cmd cmdGetDeviceFWVersion = 0x01;
constexpr Cmd cmdSetFanSpeedControlMode = 0x04;
constexpr Cmd cmdGetFanSpeedControlMode = 0x05;
constexpr Cmd cmdSetBIOSPasswordConfig = 0x0E;
constexpr Cmd cmdGetBIOSPasswordConfig = 0x0F;
constexpr Cmd cmdGetPSUInfo = 0x20;
constexpr Cmd cmdSwitchBMCFw = 0x23;
constexpr Cmd cmdGetSetBiosVer = 0x34;
constexpr Cmd cmdRestoreFactoryDefault = 0x35;
constexpr Cmd cmdSetSOLBitrate = 0x36;
constexpr Cmd cmdGet12VPSUADCValue = 0x60;
constexpr Cmd cmdSet12VPSUADCValue = 0x61;
constexpr Cmd cmdDIMMTemperatureValue = 0x62;
constexpr Cmd cmdSetDIMMSetPoint = 0x63;
constexpr Cmd cmdGetDIMMSetPoint = 0x64;
constexpr Cmd cmdSetCoverStatus = 0x65;
constexpr Cmd cmdGetCoverStatus = 0x66;
constexpr Cmd cmdSetCoverPreHeatTemperature = 0x67;
constexpr Cmd cmdGetCoverPreHeatTemperature = 0x68;
constexpr Cmd cmdBiosSetDimmState = 0x69;
constexpr Cmd cmdBiosSetDimmPara = 0x6a;
constexpr Cmd cmdBiosGetDimmPara = 0x6b;
constexpr Cmd cmdGetDimmTemp = 0x6c;
constexpr Cmd cmdGetCoverCurrentTemp = 0x6d;
constexpr Cmd cmdSetCoverFSCEnableStatus = 0x6e;
constexpr Cmd cmdGetCoverFSCEnableStatus = 0x6f;
constexpr Cmd cmdOemI2CReadWrite = 0xA4;

constexpr Cc ccOemInvalidIANA = 0x80;
} // namespace ipmiOem
} // namespace ipmi
