#ifndef ktapi_h
#define ktapi_h

#ifdef linux

	#ifdef __LP64__
	
		#define __cdecl
	#else
	
		#define __cdecl   __attribute__((cdecl))
	#endif
	

#endif


#ifdef __cplusplus
extern "C" {
#endif
 
#define sfNewest 0x00	//	Check BIOS and disk for the newest version and load it. 
#define sfBIOS 0x01		//	Only load driver from BIOS.
#define sfDISK 0x02		//	Only load driver from DISK.
#define sfInternal 0x03

 
int __cdecl KT_API_GetFunction(char * Name,void *pFunction);

int __cdecl KT_API_Open(int sf);//=sfInternal);
int __cdecl KT_API_Close(void);

int __cdecl KT_API_Get_OS_String(char **Text);
                 
 
typedef enum
{
_API_se_OK=1,
_API_se_Error=0,
}_API_StatusEnum;
              
              
 
//----------------------------------------------

#pragma pack (push,1)   

typedef struct
{
unsigned char Magicscan[4];
unsigned char Infosize;
unsigned char Boardinfo;
unsigned short BIOSmjr;
unsigned short BIOSmnr;
unsigned char Reserved;
unsigned char S_N[4];
unsigned char P_N[4];
}TIntegratedInfoHeader,*pTIntegratedInfoHeader;


typedef struct _HWMON
{
   float VCORE;
   float VCOREb;
   float VCC2_5;
   float VCC3;
   float VCC5;
   float V12;
   float SB3;
   float V_12;
   float SB5;
   float VBATT;
   float CPUTemp;
   float FAN;
   float BoardTemp;
   float Reserved1;
   float Reserved2;
   float Reserved3;
   float Reserved4;
   float Reserved5;
   float Reserved6;

} HWMON;

typedef struct
{
unsigned int Magic[2];
unsigned int Size;
unsigned int PSize;
unsigned int VersionMajor;
unsigned int VersionMinor;
unsigned int Build;
unsigned int Type;
unsigned int Entry;
}_API_;


#pragma pack(pop)

int __cdecl Get_KT_API(_API_ * * ptr);




#define Manual_Mode 0x00
#define Thermal_Cruise_Mode 0x01
#define Fan_Speed_Cruise_Mode 0x02



int __cdecl InternalTest(void);


int __cdecl ReadMonitor(HWMON *);

int __cdecl ReadBoardHeader(void * Buffer);

int __cdecl GetBoardName(char * * Name);
int __cdecl GetPartNumber(char * * Name);
int __cdecl GetSerialNumber(char * * Name);


int __cdecl SetFanSpeed(unsigned int Speed);
int __cdecl SelectFanTempTacChannel(unsigned char Channel);
int __cdecl SetFanTarget(unsigned int uiStt);
int __cdecl SetFanMode(unsigned char ucSfm);

int __cdecl StartThermalCruise(void);

int __cdecl GetIntruderStatus(unsigned int *Status);

int __cdecl ClrIntruderStatus(void);


int __cdecl SmBus_RecvByte(unsigned char ucDevAddr,unsigned char *ucpData);
int __cdecl SmBus_ReadByte(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char * ucpData);
int __cdecl SmBus_ReadWord(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned short *uspData);
int __cdecl SmBus_ReadBlock(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char * ucpByteCnt,unsigned char *ucpDataBuf);
int __cdecl SmBus_ReadBytes(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned int uiByteCnt,unsigned char *ucpDataBuf);

int __cdecl SmBus_SendByte(unsigned char ucDevAddr,unsigned char ucCommandCode);
int __cdecl SmBus_WriteByte(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char usData);
int __cdecl SmBus_WriteWord(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned short usData);
int __cdecl SmBus_WriteBlock(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char ucByteCnt,unsigned char *ucpDataBuf);
                                                                                                                
int __cdecl SmBus_PorcessCall(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned short *uspData);



int __cdecl SetClrGPIO(unsigned char GPIO,int SetClr);

int __cdecl ReadGPIO(unsigned char GPIO,unsigned char *Data);
int __cdecl WriteGPIO(unsigned char GPIO,unsigned char Data);

int __cdecl SetGPIODir(unsigned char GPIO);

int __cdecl GetMac(unsigned char nMac,void * Buffer);  

int __cdecl SetWDTimer(unsigned char Time);
int __cdecl SetWDTimerInterval(unsigned char VAL);

int __cdecl EnableWD(void);
int __cdecl DisableWD(void);

int __cdecl SetBKLControl(unsigned int Freq,unsigned int Duty);
int __cdecl SetCPUThrottle(unsigned char DUTY);


#define _sec   0x01
#define _min   0x02

#define C12_PROCENT_THROTTLE  0x12
#define C25_PROCENT_THROTTLE  0x14
#define C37_PROCENT_THROTTLE  0x16
#define C50_PROCENT_THROTTLE  0x18
#define C62_PROCENT_THROTTLE  0x1A
#define C75_PROCENT_THROTTLE  0x1C
#define C87_PROCENT_THROTTLE  0x1E
#define C100_PROCENT_THROTTLE 0x10
#define DISABLE_THROTTLE      0x00
                        



                        
#define SUS_S3 0x00000001
#define SUS_S4 0x00000002


#define SUS_LIB_ERROR                  0x00000001
#define SUS_TIMER_ERROR                0x00000002
#define SUS_S4_ERROR                   0x00000004
#define SUS_S3_ERROR                   0x00000008
#define SUS_TYPE_UNKNOWN_ERROR         0x00000010
#define SUS_MIN_TIME_ERROR             0x00000020

/*
typedef struct
{
   DWORD dwAutoWakeup;
   DWORD dwSecToSleep;
   DWORD dwSuspendType;
   DWORD dwResult;
}Suspend;
  */


typedef enum
{         
_HWM_Last=0x0000,	
_HWM_VCORE=0x0001,
_HWM_VCOREb=0x0002,
_HWM_VCC2_5=0x0003,
_HWM_VCC3=0x0004,
_HWM_VCC5=0x0005,
_HWM_V12=0x0006,
_HWM_SB3=0x0007,
_HWM_V_12=0x0008,
_HWM_SB5=0x0009,
_HWM_VBATT=0x000a,
_HWM_VCC1_2=0x000b,
_HWM_VCC1_8=0x000c,
_HWM_VIN=0x000d,
_HWM_VCC1_5=0x000e, 
_HWM_VCC_DDR=0x000f, 
_HWM_VCC1_05=0x0010,
_HWM_AUX=0x0011,
_HWM_CPU_PWR=0x0012,


_HWM_CPU_Temp=0x1001,
_HWM_System_Temp=0x1002,
_HWM_FC_Temp=0x1003,

_HWM_CPU_Fan=0x2001,
_HWM_System_Fan=0x2002,
_HWM_FC_Fan=0x2003,


_HWM_CPU_Power=0x3001,
                    
_HWM_Type_Mask=0xf000,
_HWM_Type_Voltage=0x0000,
_HWM_Type_Temperature=0x1000,
_HWM_Type_Fan=0x2000,
_HWM_Type_Power=0x3000,
                    
}_HWM_ID;

typedef struct
{             
_HWM_ID ID;
float Value;
char * Name;	
}_HWM_Item,*_pHWM_Item;


int __cdecl ReadHWMonitorItems(_pHWM_Item * Items);
int __cdecl GetHWMonitorItem(_HWM_ID ID,float * Value);                



#ifdef __cplusplus
}
#endif

#endif // ktapi_h
