/****************************************************************
 ****************************************************************
 **                                                            **
 **    (C)Copyright 2005-2006, American Megatrends Inc.        **
 **                                                            **
 **            All Rights Reserved.                            **
 **                                                            **
 **        6145-F, Northbelt Parkway, Norcross,                **
 **                                                            **
 **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
 **                                                            **
 ****************************************************************
 ****************************************************************
 *****************************************************************
 *
 * IPMI_App.h
 * AppDevice Commands Handler
 *
 * Author: Govind Kothandapani <govindk@ami.com>
 *       : Rama Bisa <ramab@ami.com>
 *       : Basavaraj Astekar <basavaraja@ami.com>
 *       : Bakka Ravinder Reddy <bakkar@ami.com>
 *
 *****************************************************************/
#ifndef IPMI_APPDEV_H
#define IPMI_APPDEV_H

#include "com_IPMIDefs.h"

/*** Macro definition ***/
#define CHALLENGE_STR_LEN       16
#define AUTH_CODE_LEN           16
#define MAX_APP_CONF_PARAM				4
#define MIN_SYSINFO_OEM_CONF_PARAM		192
#define MAX_SYSINFO_OEM_CONF_PARAM		255

/* Added to Support IPMI v2.0/RMCP+ Integrity Algorithm Number */ 
#define AUTH_CODE_HASH_LEN      20 
#define HASH_DATA_LEN           16 
#define  MAX_I2C_BUFFER_SIZE    50
#define IPMI15_MAX_PASSWORD_LEN 16
#define SIXTEEN_COUNT_WINDOW_LEN 16
#define SEQNUM_ROLLOVER 0xFFFFFFFF
#define RMCPPLUS_SEQLOWLIMIT 16
#define RMCPPLUS_SEQUPLIMIT 15
#define EIGHT_COUNT_WINDOW_LEN 8
#define	MAX_FW_VER_LENGTH  	254
#define MAX_SYS_NAME_LENGTH	254
#define MAX_PRIM_OS_NAME_LENGTH 254
#define MAX_OS_NAME_LENGTH	254
#define MAX_BLOCK_SIZE			16

#define SYS_INFO_SET_COMPLETE    0x00
#define SYS_INFO_SET_IN_PROGRESS 0x01
#define SYS_INFO_COMMIT_WRITE	 0x02
#define PARAM_PRESENT_REVISION   0x11
#define PARAM_OLDER_REVISION 	 0x00

#define SET_IN_PROGRESS_PARAM	0x00
#define SYS_FW_VERSION_PARAM	0x01
#define SYS_NAME_PARAM			0x02
#define PRIM_OS_NAME_PARAM		0x03
#define OS_NAME_PARAM			0x04
#define MAX_PARAM_SELECTOR		OS_NAME_PARAM +1 /* Last Parameter + 1 */

#define GET_PARAM_REV_ONLY		0x80




#pragma pack( 1 )

/* SetWDTReq_T */
typedef struct
{
    uint8_t   TmrUse;
    uint8_t   TmrActions;
    uint8_t   PreTimeOutInterval;
    uint8_t   ExpirationFlag;
    uint16_t  InitCountDown;

} SetWDTReq_T;

/* GetWDTRes_T */
typedef struct
{
    uint8_t       CompletionCode;
    SetWDTReq_T CurrentSettings;
    uint16_t      PresentCountDown;

}   GetWDTRes_T;

/* GetBMCGblEnblRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   BMCGblEnblByte;

} GetBMCGblEnblRes_T;

/* ClearMsgsFlagReq_T */
typedef struct
{
    uint8_t   Flag;
}   ClearMsgsFlagReq_T;

/* GetMsgFlagsRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   MsgFlags;

} GetMsgFlagsRes_T;

/* EnblMsgChRcvReq_T */
typedef struct
{
    uint8_t   ChannelNum;
    uint8_t   ChannelState;

}   EnblMsgChRcvReq_T;

/* EnblMsgChRcvRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   ChannelNum;
    uint8_t   ChannelState;

}   EnblMsgChRcvRes_T;

/* GetMsgRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   ChannelNum;

}   GetMsgRes_T;

/* SendMsgReq_T */
typedef struct
{
    uint8_t   ChNoTrackReq;

}   SendMsgReq_T;

/* SendMsgRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   ResData;

}   SendMsgRes_T;

/* ReadEvtMsgBufRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   ResData[16];

}   ReadEvtMsgBufRes_T;

/* GetBTIfcCapRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   NumReqSupported;
    uint8_t   InputBufSize;
    uint8_t   OutputBufSize;
    uint8_t   RespTime;
    uint8_t   Retries;

}   GetBTIfcCapRes_T;

/* GetSysGUIDRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   Node[6];
    uint16_t  ClockSeq;
    uint16_t  TimeHigh;
    uint16_t  TimeMid;
    uint32_t  TimeLow;

}   GetSysGUIDRes_T;

/* GetChAuthCapReq_T */
typedef struct
{
    uint8_t   ChannelNum;
    uint8_t   PrivLevel;

}   GetChAuthCapReq_T;

/* GetChAuthCapRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   ChannelNum;
    uint8_t   AuthType;
    uint8_t   PerMsgUserAuthLoginStatus;
    uint8_t   ExtCap;
    uint8_t   OEMID[3];
    uint8_t   OEMAuxData;

}   GetChAuthCapRes_T;

/* GetSesChallengeReq_T */
typedef struct
{
    uint8_t   AuthType;
    uint8_t   UserName[16];

}   GetSesChallengeReq_T;

/* GetSesChallengeRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint32_t  TempSessionID;
    uint8_t   ChallengeString[16];

}   GetSesChallengeRes_T;

/* ActivateSesReq_T */
typedef struct
{
    uint8_t   AuthType;
    uint8_t   Privilege;
    uint8_t   ChallengeString[CHALLENGE_STR_LEN];
    uint32_t  OutboundSeq;

}   ActivateSesReq_T;

/* ActivateSesRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   AuthType;
    uint32_t  SessionID;
    uint32_t  InboundSeq;
    uint8_t   Privilege;

}   ActivateSesRes_T;

/* SetSesPrivLevelReq_T */
typedef struct
{
    uint8_t   Privilege;

}   SetSesPrivLevelReq_T;

/* SetSesPrivLevelRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   Privilege;

}   SetSesPrivLevelRes_T;

/* GetSesInfoReq_T */
typedef struct
{
    uint8_t   SessionIndex;
    uint8_t   SessionHandleOrID [4];

}   GetSesInfoReq_T;

/* LANSesInfoRes_T */
typedef struct
{
    uint8_t    IPAddress[4];
    uint8_t    MACAddress[6];
    uint16_t   PortNumber;

}   LANSesInfoRes_T;

/* SerialSesInfoRes_T */
typedef struct
{
    uint8_t    SessionActivityType;
    uint8_t    DestinationSelector;
    uint8_t    IPAddress[4];
    uint16_t   PortNumber;

}   SerialSesInfoRes_T;

/* Union SessionInfoRes_T */
typedef union
{
    LANSesInfoRes_T     LANSesInfo;
    SerialSesInfoRes_T  SerialSesInfo;

}   SessionInfoRes_T;

/* ActiveSesInfo_T */
typedef struct
{
    uint8_t       UserID;
    uint8_t       Privilege;
    uint8_t       ChannelNum;

}   ActiveSesInfo_T;

/* GetSesInfoRes_T */
typedef struct
{
    uint8_t               CompletionCode;
    uint8_t               SessionHandle;
    uint8_t               NumPossibleActiveSession;
    uint8_t               NumActiveSession;
    ActiveSesInfo_T     ActiveSesinfo;
    SessionInfoRes_T    SesInfo;

}   GetSesInfoRes_T;

/* LANIPv6SesInfoRes_T */
typedef struct
{
    uint8_t    IPv6Address[16];
    uint8_t    MACAddress[6];
    uint16_t   PortNumber;

}   LANIPv6SesInfoRes_T;

/* CloseSesReq_T */
typedef struct
{
    uint32_t  SessionID;
    uint8_t   SessionHandle;

}   CloseSesReq_T;

/* GetAuthCodeReq_T */
typedef struct
{
    uint8_t   AuthType;
    uint8_t   ChannelNum;
    uint8_t   UserID;
    uint8_t   HashData[HASH_DATA_LEN];

}   GetAuthCodeReq_T;


/* GetAuthCodeRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   AuthCode[AUTH_CODE_HASH_LEN];

}   GetAuthCodeRes_T;

/* SetChAccessReq_T */
typedef struct
{
    uint8_t   ChannelNum;
    uint8_t   ChannelAccess;
    uint8_t   Privilege;

}   SetChAccessReq_T;

typedef struct
{
	uint8_t		CompletionCode;
}   SetChAccessRes_T;

/* GetChAccessReq_T */
typedef struct
{
    uint8_t   ChannelNum;
    uint8_t   AccessFlag;

}   GetChAccessReq_T;

/* GetChAccessRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   ChannelAccess;
    uint8_t   Privilege;

}   GetChAccessRes_T;

typedef struct
{
	uint8_t ChannelNum;
}   GetChInfoReq_T;

/* GetChInfoRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   ChannelNum;
    uint8_t   ChannelMedium;
    uint8_t   ChannelProtocol;
    uint8_t   SessionActiveSupport;
    uint8_t   VendorID[3];
    uint8_t   AuxiliaryInfo[2];

}   GetChInfoRes_T;

/* SetUserAccessReq_T */
typedef struct
{
    uint8_t   ChannelNoUserAccess;
    uint8_t   UserID;
    uint8_t   AccessLimit;
    uint8_t   SessionLimit;

}   SetUserAccessReq_T;

typedef struct
{
    uint8_t CompletionCode;
}   SetUserAccessRes_T;


/* GetUserAccessReq_T */
typedef struct
{
    uint8_t   ChannelNum;
    uint8_t   UserID;

}   GetUserAccessReq_T;

/* GetUserAccessRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   MaxNoUserID;
    uint8_t   CurrentUserID;
    uint8_t   FixedUserID;
    uint8_t   ChannelAccess;

}   GetUserAccessRes_T;

/* SetUserNameReq_T */
typedef struct
{
    uint8_t   UserID;
    uint8_t   UserName[MAX_USERNAME_LEN];

}   SetUserNameReq_T;

typedef struct
{
    uint8_t   CompletionCode;
}   SetUserNameRes_T;


/*GetUserNameReq_T*/
typedef struct
{
    uint8_t   UserID;
}   GetUserNameReq_T;


/* GetUserNameRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   UserName[MAX_USERNAME_LEN];

}   GetUserNameRes_T;



/* SetUserPswdReq_T */
typedef struct
{
    uint8_t   UserID;
    uint8_t   Operation;
    uint8_t   Password[MAX_PASSWORD_LEN];

}   SetUserPswdReq_T;

/* SetUserPswdReq_T */
typedef struct
{
    uint8_t   CompletionCode;
}   SetUserPswdRes_T;

/* MasterWriteReadReq_T */
typedef struct
{
    uint8_t   BusTypeChNo;
    uint8_t   SlaveAddress;
    uint8_t   ReadCount;
    uint8_t   Data[MAX_I2C_BUFFER_SIZE];

}   MasterWriteReadReq_T;

/* MasterWriteReadRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   Data[MAX_I2C_BUFFER_SIZE];

}   MasterWriteReadRes_T;

typedef struct 
{
    uint8_t       TypeOfEncoding ;
    uint8_t       StringLength;
    uint8_t       SysFWVersionName[MAX_FW_VER_LENGTH];
}  SysFWVersion_T;
typedef struct
{
    uint8_t    TypeOfEncoding_Sys_Name;
    uint8_t    StringLength_Sys_Name;
    uint8_t    SystemName[MAX_SYS_NAME_LENGTH];
}   SysName_T;
typedef struct 
{
    uint8_t    TypeOfEncoding_PrimaryOSName;
    uint8_t    StringLength_PrimaryOSName;
    uint8_t    PrimaryOperatingSystemName[MAX_PRIM_OS_NAME_LENGTH];
}   PrimaryOSName_T;
typedef struct 
{
    uint8_t    TypeOfEncoding_OSName;
    uint8_t    StringLength_OSName;
    uint8_t   OSName[MAX_OS_NAME_LENGTH];
}  OSName_T;

typedef struct 
{
    uint8_t   SetSelector;
    uint8_t   SysFWVersion[MAX_BLOCK_SIZE];
}   SysVerInfo_T;

typedef struct 
{

    uint8_t   SetSelector;
    uint8_t    SysName[MAX_BLOCK_SIZE];

}   SysNameInfo_T;

typedef struct {

    uint8_t    SetSelector;
    uint8_t    PrimaryOSName[MAX_BLOCK_SIZE];

}   PrimOSInfo_T;


typedef struct {

    uint8_t   SetSelector;
    uint8_t   OperatingSystemName[MAX_BLOCK_SIZE];

}   OSInfo_T;

typedef union {

    uint8_t   SetInProgress;
    SysVerInfo_T    SysVerInfo;
    SysNameInfo_T   SysNameInfo;
    PrimOSInfo_T    PrimOSInfo;
    OSInfo_T    OSInfo;
}    SysInfoUN_T	;


/* GetSystemInfoParamReq_T */
typedef struct
{
    uint8_t   ParamRev;
    uint8_t   ParamSelector;
    uint8_t   SetSelector;
    uint8_t   BlockSelector;

}   GetSystemInfoParamReq_T;


/* GetSystemInfoParamRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   ParamRevision;
    SysInfoUN_T     SysInfo;

}   GetSystemInfoParamRes_T;

/* GetSystemInfoParamOEMRes_T */
typedef struct
{
    uint8_t           CompletionCode;
    uint8_t           ParamRevision;
    /* OEM Info */
}   GetSystemInfoParamOEMRes_T;


/* SetSystemInfoParamReq_T */
typedef struct
{
    uint8_t   		ParamSelector;
    SysInfoUN_T		SysInfo;
}   SetSystemInfoParamReq_T;


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

/* SetSystemInfoParamOEMReq_T */
typedef struct
{
    uint8_t   ParamSelector;
    /* OEM parameter */
}   SetSystemInfoParamOEMReq_T;

#pragma pack( )

#endif /* IPMI_APPDEV_H */
