#ifndef _SASBASE_H
#define	_SASBASE_H


#pragma pack(1)

enum _SAS_ATTRIBUTE_ITEMS
{
	SAS_READ_RECOVERED_WO_DELAY,	 
	SAS_READ_RECOVERED_W_DELAY,
	SAS_READ_RECOVERED_W_RETRY,
	SAS_READ_RECOVERED,
	SAS_READ_TOTAL_BYTES,
	SAS_READ_UNRECOVERED,
	SAS_WRITE_RECOVERED_WO_DELAY,
	SAS_WRITE_RECOVERED_W_DELAY,
	SAS_WRITE_RECOVERED_W_RETRY,
	SAS_WRITE_RECOVERED,
	SAS_WRITE_TOTAL_BYTES,
	SAS_WRITE_UNRECOVERED,
	SAS_VERIFY_RECOVERED_WO_DELAY,
	SAS_VERIFY_RECOVERED_W_DELAY,
	SAS_VERIFY_RECOVERED_W_RETRY,
	SAS_VERIFY_RECOVERED,
	SAS_VERIFY_UNRECOVERED,
	SAS_NON_MEDIUM_ERRORS,
	TOTAL_SAS_ATTR_ITEMS
};

enum _SMART_ITEMS
{
	SMART_READ_ERROR_RATE_1,	// read error rate
	SMART_SPINUP_TIME_3,		// spinup time
	SMART_REALLOCATION_5,		// reallocation
	SMART_SEEK_ERROR_RATE_7,	// seek error rate
	SMART_SPINUP_RETRY_10,		// spinup retry
	SMART_CALIBRATION_RETRY_11,	// calibration retry
	SMART_TEMPERATURE_194,		// temperature
	TOTAL_SMART_ITEMS,
};

enum _SAS_HW
{
	SAS_HW_DISK,				// disks
	SAS_HW_VOLTAGE,				// voltages
	SAS_HW_FAN,					// fans
	SAS_HW_POWER,				// powers
	SAS_HW_TEMPERATURE,			// temperatures
	TOTAL_SAS_HW
};

typedef struct sSMART_DATA
{
	WORD    smIndex;
	BYTE    smStatus;
	BYTE    smThreshold;
} sSMART_DATA, *pSMART_DATA;

// SCSI attribtes
typedef struct sSCSI_ATTR
{
	BYTE scsiChannel;				// channel for SCSI target (0/1)
	BYTE scsiId;					// SCSI ID for the volume
	BYTE scsiLun;					// LUN (0 if target is IDE)
	BYTE scsiTaggedQueuing;			// 1 --> queue enabled
	BYTE scsiCacheMode;				// 1 --> Cache enabled
	BYTE scsiSpeed;					// IDE(0:ATA33/1:ATA66/2:ATA100/3:ATA133)
} sSCSI_ATTR, *pSCSI_ATTR;


typedef struct sGUI_ENC_PROPERTY
{
	BYTE	gepVendor[8];			// vendor name
	BYTE	gepProduct[16];			// product name
	BYTE	gepRev[4];				// reversion 
	BYTE	gepEncType;				// enclosure type
	BYTE	gepEncnumber;			// enclosure#
	BYTE	gepEncDisks;			// number of disks
	BYTE	gepEncVoltages;			// number of voltages
	BYTE	gepEncFans;				// number of fans
	BYTE	gepEncPowers;			// number of powers
	BYTE	gepEncTemperatures;		// number of temperatures
	BYTE	gepRes[0x1D];			// reserved
} sGUI_ENC_PROPERTY, *pGUI_ENC_PROPERTY;


#define	MAX_ENCLOSURES			8
#define	MAX_PHY_PER_ENCLOSURE	32
#define	MAX_DEV_PER_ENCLOSURE	32

enum
{
	ENC_TYPE_NOT_INSTALLED,			// not installed
	ENC_TYPE_INTERNAL,				// built-in enclosure
	ENC_TYPE_SES2,					// ses2
	ENC_TYPE_SMP,					// smp
	ENC_TYPE_CTRL					// controller
};



#define	MAX_ELEMENT_STR_LEN		24
#define MAX_SENSORS				32



// constant of SES element definitions
// common status
#define SES_COMMON_STATUS_OK		0x00000001
#define SES_COMMON_STATUS_CRITICAL	0x00000002

// power
#define SES_POWER_FAIL				0x40000000

// fan(cooling)
#define SES_FAN_FAIL				0x40000000

// temperature
#define SES_OVER_TEMPERATURE		0x08000000

// voltage
#define SES_OVER_VOLTAGE			0x00000200
#define SES_UNDER_VOLTAGE			0x00000100

#define SES_STATUS_OK(x)			(x & SES_COMMON_STATUS_OK)
#define SES_STATUS_CRITICAL(x)		(x & SES_COMMON_STATUS_CRITICAL)


typedef struct sELEMENT
{
	BYTE	snNumberOfSensors;								// number of elements
	BYTE	snElementStr[MAX_SENSORS][MAX_ELEMENT_STR_LEN];	// description of elements
	LONG	snValue[MAX_SENSORS];							// the value of sensor
	DWORD	snRawValue[MAX_SENSORS];						// the SES RAW value of sensor
}sELEMENT, *pELEMENT;

typedef struct sDISK_ELEMENT
{
	BYTE	snNumberOfElements;								// number of elements
	BYTE	snElementStr[MAX_SENSORS][MAX_ELEMENT_STR_LEN];	// description of elements
}sDISK_ELEMENT, *pDISK_ELEMENT;

typedef struct sSENSORS
{
	sDISK_ELEMENT   disk;
	sELEMENT		voltage;
	sELEMENT		fan;
	sELEMENT		power;
	sELEMENT		temperature;	
	sELEMENT		battery;
} sSENSORS, *pSENSORS;


#pragma pack()

#endif
