/****************************************************************
 ****************************************************************
 **                                                            **
 **    (C)Copyright 2005-2006, American Megatrends Inc.        **
 **                                                            **
 **            All Rights Reserved.                            **
 **                                                            **
 **        6145-F, Northbelt Parkway, Norcross,                **
 **                                                            **
 **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
 **                                                            **
 ****************************************************************
 ****************************************************************
 *****************************************************************
 *
 * ipmi_sel.h
 * Sel device exports
 *
 * Author: Bakka Ravinder Reddy <bakkar@ami.com>
 *
 *****************************************************************/
#ifndef IPMI_SEL_H
#define IPMI_SEL_H


/*** External Definitions ***/
#define SEL_VERSION     0x51
#define UNSPECIFIED_UTC_OFFSET 0x07FF
#define SEL_UTC_MIN_RANGE   -1440
#define SEL_UTC_MAX_RANGE   1440
#define SEL_RECORD_SIZE             16

/**
 * @struct SELRecHdr_T
 * @brief SEL Record Header
**/
#pragma pack(1)
typedef struct
{
    uint16_t  ID;
    uint8_t   Type;
    uint32_t  TimeStamp;

}   SELRecHdr_T;

/**
 * @struct SELEventRecord_T
 * @brief SEL Event Record
**/
typedef struct
{
    /* SEL ENTRY RECORD HEADER */
    SELRecHdr_T hdr;

    /* RECORD BODY BYTES */
    uint8_t   GenID [2];
    uint8_t   EvMRev;
    uint8_t   SensorType;
    uint8_t   SensorNum;
    uint8_t   EvtDirType;
    uint8_t   EvtData1;
    uint8_t   EvtData2;
    uint8_t   EvtData3;

}   SELEventRecord_T;

/**
 * @struct SELRec_T
 * @brief SEL Record
**/
typedef struct
{
    uint8_t               Valid;
    uint8_t               Len;
    SELEventRecord_T    EvtRecord;
}   SELRec_T;

/**
 * @struct SELOEM1Record_T
 * @brief SEL OEM1 Record
**/
typedef struct
{
    /* SEL ENTRY RECORD HEADER */
    uint16_t  ID;
    uint8_t   Type;
	
    /* RECORD BODY BYTES */
    uint32_t  TimeStamp;
    uint8_t   MftrID [3];
    uint8_t   OEMData [6];

}   SELOEM1Record_T;


/**
 * @struct SELOEM2Record_T
 * @brief SEL OEM2 Record
**/
typedef struct
{
    /* SEL ENTRY RECORD HEADER */
	//    SELRecHdr_T hdr;
    uint16_t  ID;
    uint8_t   Type;

    /* RECORD BODY BYTES */
    uint8_t   OEMData [13];

}   SELOEM2Record_T;




/* SELInfo_T */
typedef struct
{
    uint8_t   CompletionCode;     /* Completion Code */
    uint8_t   Version;            /* Version of the SEL 0x51 */

    uint16_t  RecCt;              /* Record Count */

    uint16_t  FreeSpace;          /* Free space LSB first */

    uint32_t  AddTimeStamp;       /* Most recent addition timestamp */
    uint32_t  EraseTimeStamp;     /* Most recent erase timestamp */

    uint8_t   OpSupport;          /* Operation Support */

}   SELInfo_T;


/* SELAllocInfo_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint16_t  NumAllocUnits;      /* Number of possible allocation units */
    uint16_t  AllocUnitSize;      /* Allocation unit size in bytes */
    uint16_t  NumFreeAllocUnits;  /* Number of free allocation units */
    uint16_t  LargestFreeBlock;   /* Largest free block in allocation units */
    uint8_t   MaxRecSize;         /* Maximimum record size in allocation units */

}   SELAllocInfo_T;


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

}   ReserveSELRes_T;


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

}   GetSELReq_T;


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

}   GetSELRes_T;


/* AddSELRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint16_t  RecID;

}   AddSELRes_T;


/* PartialAddSELReq_T */
typedef struct
{
    uint8_t      LSBReservationID;
	uint8_t		MSBReservationID;
	uint8_t		LSBRecordID;
	uint8_t		MSBRecordID;
    uint8_t   Offset;
    uint8_t   Progress;
	//Added to support PartialAddselEntry Cmd ../
    uint8_t	  RecordData[SEL_RECORD_SIZE];

}   PartialAddSELReq_T;


/* PartialAddSELRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint16_t  RecID;

}   PartialAddSELRes_T;


/* DeleteSELReq_T */
typedef struct 
{
    uint16_t  ReservationID;
    uint16_t  RecID;
    
}   DeleteSELReq_T;


/* DeleteSELRes_T */
typedef struct 
{
    uint8_t   CompletionCode;
    uint16_t  RecID;
    
}   DeleteSELRes_T;


/* ClearSELReq_T */
typedef struct
{
    uint16_t  ReservationID;
    uint8_t   CLR [3];
    uint8_t   InitOrStatus;

}   ClearSELReq_T;


/* ClearSELRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   EraseProgress;
}   ClearSELRes_T;


/* GetSELTimeRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint32_t  Time;

}   GetSELTimeRes_T;


/* SetSELTimeReq_T */
typedef struct
{
    uint32_t  Time;

}   SetSELTimeReq_T;


/* GetSELAuxiliaryMCALogStatusRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint32_t  Time;
    uint32_t  NumEntries;

}   GetSELAuxiliaryMCALogStatusRes_T;


/* GetSELAuxiliaryOEMLogStatusRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint32_t  Time;
    uint8_t   OEMId[3];
    uint8_t   LogStatusBytes[8];

}   GetSELAuxiliaryOEMLogStatusRes_T;


/* SetSELAuxiliaryMCALogStatusReq_T */
typedef struct
{
    uint8_t   LogType;
    uint32_t  Time;
    uint32_t  NumEntries;

}   SetSELAuxiliaryMCALogStatusReq_T;


/* SetSELAuxiliaryOEMLogStatusReq_T */
typedef struct
{
    uint8_t   LogType;
    uint32_t  Time;
    uint8_t   OEMId[3];
    uint8_t   LogStatusBytes[8];

}   SetSELAuxiliaryOEMLogStatusReq_T;

/* GetSELTimeUTCoffsetRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    int16_t  UTCOffset;
}   GetSELTimeUTCOffsetRes_T;


/* SetSELTimeUTCOffsetReq_T*/
typedef struct
{
    int16_t UTCOffset;
}   SetSELTimeUTCOffsetReq_T;

/* SetSELTimeUTCOffsetRes_T*/
typedef struct
{
    uint8_t   CompletionCode;
}   SetSELTimeUTCOffsetRes_T;

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