#ifndef __BMC_TYPE_H__
#define __BMC_TYPE_H__

#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
#include "Session.h"
#include "com_IPMI_ChassisDevice.h"
#include "PMConfig.h"
#include "SensorMonitor.h"
#include "com_BmcType.h"
#include "MsgHndlr.h"

#pragma pack(1)

/***************************************** IPMI ******************************************************/
typedef struct
{
    pthread_key_t CurSessionID;
    pthread_key_t CurPrivLevel;
    pthread_key_t CurChannel;
    pthread_key_t CurKCSIfcNum;
    pthread_key_t CurSessionType;
    pthread_key_t OwnerLUN;
}TLS_T;

typedef enum
{
  ORIGIN_UNSPECIFIED = 0,
  ORIGIN_SENDMSG,
  ORIGIN_CMDFWD,
  ORIGIN_INT_REQ,
  ORIGIN_NM,
}BridgeOrigin;

typedef struct
{
	char	FirstPowerOnStr[32];	//first power on the bmc 
    uint8_t SendMsgTimeout;
    uint8_t SessionTimeOut;
    uint32_t ChassisTimerInterval;
    	
    uint8_t SerialIfcSupport ;
    uint8_t SerialTerminalSupport;
    uint8_t LANIfcSupport ;
    uint8_t SYSIfcSupport;
    uint8_t GrpExtnSupport ;
    uint8_t UDSIfcSupport;

	uint32_t FanControlInterval;

 	//IPMB
 	uint8_t 		PrimaryIPMBSupport ;
    uint8_t 		SecondaryIPMBSupport ;
	uint32_t 			PrimaryIPMBBus;
    uint32_t 			SecondaryIPMBBus;
    uint8_t             PrimaryIPMBAddr;	//8bit
	uint8_t				SecondaryIPMBAddr;	//8bit

	//chassis config
	uint8_t                        SysRestartCause;
	uint8_t                        PowerRestorePolicy;
	ChassisPowerState_T          ChassisPowerState;
	ChassisCapabilities_T        ChassisCapabilities;
	uint8_t						PowerCycleInterval;
	uint8_t                        SysPartitionScan;
	
	uint8_t				RearmSetSensorThreshold;
	int16_t				SELTimeUTCOffset;
	
	uint8_t		MaxSession;
	uint32_t	LogOutTimeout;
} IPMIConfig_T;


typedef struct
{
    IPMIConfig_T 		IpmiConfig;
	OemFRUData_T		FRU;
	uint8_t*			pSDR;
	uint8_t*			pSEL;		

	//time
    uint32_t 			CurTimerTick;							//uint: 1ms
	uint32_t			CurTimerSecond;
	uint32_t			BootValidMinutes;						//This work time
	uint32_t			TotalBootValidMinutes;					//Total work time
	uint32_t			SELTimeSecond;							//seconds from 1970-1-1 00:00:00, UTC
	
	//chassis
    uint8_t             SlotID;
	uint8_t				ChassisID;

	uint8_t				PowerGoodFlag;
	uint8_t				FirstPowerOn;
	uint8_t				SelfTestByte;
	uint8_t				ChassisIdentifyForce;
	uint8_t				ChassisIdentifyTimeout;
	uint8_t				ChassisIdentify;
	uint8_t				HealthLevel;
	
	SensorSharedMem_T	SensorSharedMem;
	SENSOR_T 			SenConfig;
	
	//message handler
	uint8_t    			SendMsgSeqNum;
	
	SDR_T				SDRConfig;
	SEL_T				SELConfig;
	
	uint8_t				DeviceGUID[16];
//	OEM_FLAGS_T			OemFlags;
	
	SessionInfo_T		LanSession;
	SessionTblInfo_T 	SessionTblInfo;
	UDSSessionTblInfo_T UDSSessionTblInfo;
	uint8_t			 	TimerTaskTblSize;
	TimerTaskTbl_T    	TimerTaskTbl[20];

	//bool				loginOk;
	//uint32_t			logOutCnt;
	UserInfo_T			UserInfoTbl[MAX_USER_NUM];
	UserInfo_T			*pUserInfo;
	uint8_t				CurrentNoUser;
	

	
	uint8_t				FwMajorVer;
	uint8_t				FwMinorVer;

} BMCInfo_t;




#pragma pack()
#endif /* __BMC_TYPE_H__ */