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

#include "com_BmcType.h"

/*--------------System Event Record-------------*/
#define SYSTEM_EVT_RECORD                    0x02
#define SYS_EVENT_LOGGING_MASK               0x08

#define IGNORE_SEL_PEF     0x0
#define ENABLE_SEL_MASK    0x1
#define ENABLE_PEF_MASK    0x2
#define POST_ONLY_SEL      ENABLE_SEL_MASK
#define POST_SEL_AND_PEF   (ENABLE_SEL_MASK | ENABLE_PEF_MASK)

#define LINEAR_SEL          0x00
#define CIRCULAR_SEL        0x01


/**
 * @defgroup sic SEL Command handlers
 * @ingroup storage
 * IPMI System Event Log interface commands.
 * This set of commands provides read/write access to BMC's SEL.
 * @{
**/
extern int GetSELInfo           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int GetSELAllocationInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int ReserveSEL           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int ClearSEL             ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int GetSELEntry          ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int AddSELEntry          ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int PartialAddSELEntry   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int DeleteSELEntry       ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int GetSELTime           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int SetSELTime           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int GetAuxiliaryLogStatus( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int SetAuxiliaryLogStatus( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int LockedAddSELEntry    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
extern int GetSELTimeUTC_Offset  ( uint8_t * pReq, uint8_t ReqLen,  uint8_t * pRes);
extern int SetSELTimeUTC_Offset   ( uint8_t * pReq, uint8_t ReqLen,  uint8_t * pRes);

/** @} */

/**
 * @brief Get SEL timestamp.
 * @return The timestamp.
**/
extern uint32_t GetSelTimeStamp (void);

/**
 * @brief Initialize SEL Device.
 * @return 0 if success, -1 if error
**/
extern int InitSEL (void);

/*---------------------------------------------------------------------------
 * @fn SetSELPolicy
 *
 * @brief This function is invoked when switch SEL policy, make appropriate
 *        adjustment for environment variables that related to SEL buffer.
 *
 * @param   Policy  - Specify Linear SEL policy or Circular SEL policy.
 * @param   BMCInst - Index of BMC instance.
 *---------------------------------------------------------------------------*/
//extern void SetSELPolicy(uint8_t Policy);

/*----------------------------------------------------------------- 
 * @fn CheckLastSELRecordID 
 * 
 * @brief This function is called after PEF Postpone timer expires.  
 *  When LastSELRecordID and LastSWProcessedEventID are mismatch,  
 *  BMC will automatically perform PEF against any existing,  
 *  unprocessed events in SEL. Please refer IPMI spec 17.4.1 for details.  
 *  
 * @param BMCInst 
 *-----------------------------------------------------------------*/ 
extern void CheckLastSELRecordID (void);

#endif  /* SEL_H */
