/****************************************************************
 ****************************************************************
 **                                                            **
 **    (C)Copyright 2005-2006, American Megatrends Inc.        **
 **                                                            **
 **            All Rights Reserved.                            **
 **                                                            **
 **        6145-F, Northbelt Parkway, Norcross,                **
 **                                                            **
 **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
 **                                                            **
 ****************************************************************
 ****************************************************************
 ****************************************************************
 ****************************************************************
 *
 * ipmi_sensor.h
 * IPMI Sensor Requests and Responses.
 *
 *  Author: Govind Kothandapani <govindk@ami.com>
 *
 ******************************************************************/
#ifndef IPMI_SENSOR_H
#define IPMI_SENSOR_H

/*** External Definitions ***/
#define SENSOR_TYPE_TEMP                0x01
#define SENSOR_TYPE_SECUIRTY_VIOLATION  0x06
#define SENSOR_TYPE_EVT_LOGGING         0x10
#define SENSOR_TYPE_SYSTEM_EVENT        0x12
#define SENSOR_TYPE_CRITICAL_INTERRUPT  0x13
#define SENSOR_TYPE_MODULE_BOARD        0x15
#define SENSOR_TYPE_WATCHDOG2           0x23
#define SENSOR_TYPE_OS_CRITICAL_STOP    0x20

#define SENSOR_TYPE_FRU_STATE           0x2C
#define SENSOR_TYPE_SERV_STATE          0xF0

#define FP_NMI_OFFSET                                  0x00
#define PW_VIOLATION_OFFSET                       0x05

#define WDT_SENSOR_NUMBER                             0xFE
#define SECUIRTY_VIOLATION_SENSOR_NUMBER    0xFD
#define NMI_SENSOR_NUMBER                              0xFC
#define SENSOR_SPECIFIC_READ_TYPE                  0x6F
#define SENSOR_SPECIFIC_OFFSET_MASK                0x0F
#define PEF_ACTION_SEN_SPECIFIC_OFFSET 0xC4
#define OS_RUNTIME_CRITICAL_STOP 0x01

#define HOT_SWAP_SENSOR_START_NUM       0xD0

#define SENSOR_TYPE_FRUSDR_COLLECTION   0xD0
#define FRUSDR_COLLECTION_SENSOR_NUMBER 0xFD

// 0 = Communication lost during FRU collection
// 1 = FRU Invalid checksum
// 2 = Communication lost during SDR collection
#define FRU_COLLECTION_COMMUNICATION_LOST   0
#define FRU_COLLECTION_INV_CHECKSUM         1
#define SDR_COLLECTION_COMMUNICATION_LOST   2
#define SDR_COLLECTION_INV_CC               3
#define INVALID_PICMG_VERSION               4

#pragma pack( 1 )

/* GetSDRInfoRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   NumSensor;
    uint8_t   Flags;
    uint32_t  TimeStamp;

}   GetSDRInfoRes_T;


/* GetDevSDRReq_T */
typedef struct
{
    uint16_t  ReservationID;
    uint16_t  RecID;
    uint8_t   Offset;
    uint8_t   Size;

}   GetDevSDRReq_T;


/* GetDevSDRRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint16_t  NextRecID;

}   GetDevSDRRes_T;


/* ReserveDevSDRRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint16_t  ReservationID;

}   ReserveDevSDRRes_T;


/* GetSensorReadingFactorReq_T */
typedef struct
{
    uint8_t   SensorNum;
    uint8_t   ReadingByte;

}   GetSensorReadingFactorReq_T;


/* GetSensorReadingFactorRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   NextReading;
    uint8_t   M_LSB;
    uint8_t   M_MSB_Tolerance;
    uint8_t   B_LSB;
    uint8_t   B_MSB_Accuracy;
    uint8_t   Accuracy_MSB_Exp;
    uint8_t   RExp_BExp;

}   GetSensorReadingFactorRes_T;


/* SetSensorHysterisisReq_T */
typedef struct
{
    uint8_t   SensorNum;
    uint8_t   Reserved;
    uint8_t   PositiveHysterisis;
    uint8_t   NegativeHysterisis;

}   SetSensorHysterisisReq_T;


/* SetSensorHysterisisRes_T */
typedef struct 
{
    uint8_t   CompletionCode;

}   SetSensorHysterisisRes_T;


/* GetSensorHysterisisReq_T */
typedef struct
{
    uint8_t   SensorNum;
    uint8_t   Reserved;

}   GetSensorHysterisisReq_T;


/* GetSensorHysterisisRes_T */
typedef struct 
{
    uint8_t   CompletionCode;
    uint8_t   PositiveHysterisis;
    uint8_t   NegativeHysterisis;

}   GetSensorHysterisisRes_T;


/* SetSensorThresholdReq_T */
typedef struct
{
    uint8_t   SensorNum;
    uint8_t   SetFlags;
    uint8_t   LowerNonCritical;
    uint8_t   LowerCritical;
    uint8_t   LowerNonRecoverable;
    uint8_t   UpperNonCritical;
    uint8_t   UpperCritical;
    uint8_t   UpperNonRecoverable;

}   SetSensorThresholdReq_T;


typedef struct
{
    uint8_t   CompletionCode;
	uint8_t   records[480];
}   SensorhistoryData_T;




/* SetSensorThresholdRes_T */
typedef struct
{
    uint8_t   CompletionCode;

}   SetSensorThresholdRes_T;


/* GetSensorThresholdReq_T */
typedef struct
{
    uint8_t   SensorNum;

}   GetSensorThresholdReq_T;


/* GetSensorThresholdRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   GetFlags;
    uint8_t   LowerNonCritical;
    uint8_t   LowerCritical;
    uint8_t   LowerNonRecoverable;
    uint8_t   UpperNonCritical;
    uint8_t   UpperCritical;
    uint8_t   UpperNonRecoverable;

}   GetSensorThresholdRes_T;


/* SetSensorEventEnableReq_T */
typedef struct
{
    uint8_t   SensorNum;
    uint8_t   Flags;
    uint16_t  AssertionMask;
    uint16_t  DeAssertionMask;

}   SetSensorEventEnableReq_T;


/* SetSensorEventEnableRes_T */
typedef struct
{
    uint8_t   CompletionCode;

}   SetSensorEventEnableRes_T;


/* GetSensorEventEnableReq_T */
typedef struct
{
    uint8_t   SensorNum;

}   GetSensorEventEnableReq_T;


/* GetSensorEventEnableRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   Flags;
    uint16_t  AssertionMask;
    uint16_t  DeAssertionMask;

}   GetSensorEventEnableRes_T;


/* GetSensorReadingReq_T */
typedef struct
{
    uint8_t   SensorNum;

}   GetSensorReadingReq_T;


/* GetSensorReadingRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   SensorReading;
    uint8_t   Flags;
    uint8_t   ComparisonStatus;
    uint8_t   OptionalStatus;

}   GetSensorReadingRes_T;


/* SetSensorTypeReq_T */
typedef struct
{
    uint8_t   SensorNum;
    uint8_t   SensorType;
    uint8_t   EventTypeCode;

}   SetSensorTypeReq_T;


/* SetSensorTypeRes_T */
typedef struct
{
    uint8_t   CompletionCode;

}   SetSensorTypeRes_T;


/* GetSensorTypeReq_T */
typedef struct
{
    uint8_t   SensorNum;

}   GetSensorTypeReq_T;


/* GetSensorTypeRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   SensorType;
    uint8_t   EventTypeCode;

}   GetSensorTypeRes_T;

/* ReArmSensorReq_T */
typedef struct
{
    uint8_t   SensorNum;
    uint8_t   ReArmAllEvents;
    uint8_t   ReArmAssertionEvents1;
    uint8_t   ReArmAssertionEvents2;
    uint8_t   ReArmDeassertionEvents1;
    uint8_t   ReArmDeassertionEvents2;

}  ReArmSensorReq_T;

/* ReArmSensorRes_T */
typedef struct
{
    uint8_t   CompletionCode;

}  ReArmSensorRes_T;

/* GetSensorEventStatusReq_T */
typedef struct
{
    uint8_t   SensorNum;

}  GetSensorEventStatusReq_T;

/* GetSensorEventStatusRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   Flags;
    uint8_t   AssertionEvents1;
    uint8_t   AssertionEvents2;
    uint8_t   DeassertionEvents1;
    uint8_t   DeassertionEvents2;

}  GetSensorEventStatusRes_T;

/* SetSensorReadingReq_T */
typedef struct
{
    uint8_t   SensorNum;
    uint8_t   Operation;
    uint8_t   SensorReading;
    uint8_t   AssertionEventOccuredByte1;
    uint8_t   AssertionEventOccuredByte2;
    uint8_t   DeAssertionEventOccuredByte1;
    uint8_t   DeAssertionEventOccuredByte2;
    uint8_t   EvtData1;
    uint8_t   EvtData2;
    uint8_t   EvtData3;

}   SetSensorReadingReq_T;


/* SetSensorReadingRes_T */
typedef struct
{
    uint8_t   CompletionCode;

}   SetSensorReadingRes_T;



#pragma pack( )

#endif /* IPMI_SENSOR_H */

