#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;
    

	//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;

	SDR_T				SDRConfig;
	SEL_T				SELConfig;

	
} 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             PrimaryIPMBAddr;	//8bit
	uint8_t				SecondaryIPMBAddr;	//8bit
	//lan configuration
	LanInfo_T 	LanInfo[1];	//方便扩展多个网卡。

	uint8_t				PowerGoodFlag;
	uint8_t				FirstPowerOn;
	uint8_t				SelfTestByte;
	uint8_t				ChassisIdentifyForce;
	uint8_t				ChassisIdentifyTimeout;
	uint8_t				ChassisIdentify;
	uint8_t				HealthLevel;
	uint8_t 			BladeHealthSta;	//给网页显示用的。0: 未知（灰色） 1：健康（绿色） 2：警告（黄色）3：错误（红色）
	char 				BladeName[31];
	
	SensorSharedMem_T	SensorSharedMem;
	SENSOR_T 			SenConfig;
	
	//message handler
	uint8_t    			SendMsgSeqNum;
	
	
	
	uint8_t				DeviceGUID[16];
	
//	SessionInfo_T		LanSession;
	uint8_t 			SessionHandle;
	SessionTblInfo_T 	SessionTblInfo;
	uint8_t 			UDSSessionHandle;
	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 			m_Lan_SetInProgress;

	uint8_t 			FlashStatus;	//0: idle, 1: busy
	
	uint8_t				FwMajorVer;
	uint8_t				FwMinorVer;

	//global_flags
	uint8_t 			BladeManageEn;
	uint8_t 			isChMC;
	uint8_t 			IndexInChassis;	//刀片插在机箱里的第几个槽，index从0开始。

} BMCInfo_t;




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