/****************************************************************
 ****************************************************************
 **                                                            **
 **    (C)Copyright 2005-2006, American Megatrends Inc.        **
 **                                                            **
 **            All Rights Reserved.                            **
 **                                                            **
 **        6145-F, Northbelt Parkway, Norcross,                **
 **                                                            **
 **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
 **                                                            **
 ****************************************************************
 ****************************************************************
 ****************************************************************
 * ipmi_chassis.h
 * IPMI chassis Request and Response structures
 *
 *  Author: Rama Bisa <ramab@ami.com>
 *
 ******************************************************************/
#ifndef IPMI_CHASSIS_DEVICE_H
#define IPMI_CHASSIS_DEVICE_H


#ifndef uint8_t
  #define uint8_t unsigned char
#endif
#ifndef uint16_t
  #define uint16_t unsigned short
#endif
#ifndef uint32_t
  #define uint32_t unsigned long
#endif

#pragma pack( 1 )

/*** Definitions and Macros ***/
#define MAX_BOOT_INIT_MAILBOX_BLOCKS      5
#define MAX_BOOT_INIT_MAILBOX_BLOCK_SIZE  16

#define CHASSIS_IDENTITY_STATE_INFO_SUPPORTED	0x40
#define CHASSIS_IDENTITY_INDEFINITE_ON 		0x20
#define CHASSIS_IDENTITY_TIMED_ON  		0x10
#define CHASSIS_IDENTITY_OFF 			0x00


/**
 * @struct ChassisCapabilities_T
 * @brief Chassis capabilities
 **/
typedef struct
{
    uint8_t    CapabilitiesFlags;
    uint8_t    FRUInfoAddr;
    uint8_t    SDRDeviceAddr;
    uint8_t    SELDeviceAddr;
    uint8_t    SMDeviceAddr;
    uint8_t    ChassBridgeFn;

}   ChassisCapabilities_T;

/**
 * @struct ChassisPowerState_T
 * @brief Chassis Power state
 **/
typedef struct
{
    uint8_t                   PowerState;
    uint8_t                   LastPowerEvent;
    uint8_t                   MiscChassisState;
    uint8_t                   FPBtnEnables;
}   ChassisPowerState_T;

/**
 * @struct AMI_BootOpt_T
 * @brief AMI specific Boot options
 **/
typedef struct
{
    uint8_t       Data1;
    uint8_t       Data2;
    
}   AMI_BootOpt_T;

/* GetChassisCapabilitiesRes_T */
typedef struct
{
    uint8_t                   CompletionCode;
    ChassisCapabilities_T   ChassisCapabilities;
    
}   GetChassisCapabilitiesRes_T;

/* GetChassisStatusRes_T */
typedef struct
{
    uint8_t                   CompletionCode;
    ChassisPowerState_T     ChassisPowerState;
    
}   GetChassisStatusRes_T;

/* ChassisControlReq_T */
typedef struct
{
    uint8_t  ChassisControl;
    
}   ChassisControlReq_T;

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

/* ChassisIdentifyReq_T */
typedef struct
{
    uint8_t IdentifyInterval;
    uint8_t ForceIdentify;

}   ChassisIdentifyReq_T;

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

/* SetChassisCapabilitiesReq_T */
typedef struct
{
    ChassisCapabilities_T   ChassisCaps;
    
}   SetChassisCapabilitiesReq_T;

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

/* SetPowerRestorePolicyReq_T */
typedef struct
{
    uint8_t   PowerRestorePolicy;
    
}   SetPowerRestorePolicyReq_T;

/* SetPowerRestorePolicyRes_T */
typedef struct
{
    uint8_t  CompletionCode;
    uint8_t  PowerRestorePolicy;
    
}   SetPowerRestorePolicyRes_T;

/* GetSystemRestartCauseRes_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   SysRestartCause;
    uint8_t   ChannelID;
    
}   GetSystemRestartCauseRes_T;

/* GetPOHCounterRes_T */
typedef struct
{   
    uint8_t           CompletionCode;
    uint8_t           MinutesPerCount;
    uint32_t          POHCounterReading;
    
}   GetPOHCounterRes_T;

/* BootInfoAck_T */
typedef struct
{
    uint8_t WriteMask;
    uint8_t BootInitiatorAckData;
    
}   BootInfoAck_T;

/* BootFlags_T */
typedef struct
{
    uint8_t    BootFlagsValid;
    uint8_t    Data2;
    uint8_t    Data3;
    uint8_t    Data4;
    uint8_t    Data5;
    
}   BootFlags_T;

/* BootInitiatorInfo_T */
typedef struct
{
    uint8_t   BootSource;
    uint8_t   SessionID [4];
    uint8_t   BootInfoTimestamp [4];
    
}   BootInitiatorInfo_T;

/* BootInitiatorMailbox_T */
typedef struct 
{
    uint8_t BlockData [MAX_BOOT_INIT_MAILBOX_BLOCK_SIZE];
    
}   BootInitiatorMailbox_T;

/* BootInitiatorMboxReq_T */
typedef struct
{
    uint8_t   BlockSel;
    BootInitiatorMailbox_T  BootMBox;
    
}   BootInitiatorMboxReq_T;

#define DEFAULT_BOT_DEV_NUM 0x1
#define DEFAULT_BOT_DEV_INFO_SIZE   60
#define ANCH_STR_LEN        4
#define IP_ADDR_LEN         4
#define CFG_SCR_NAME_LEN    48
#define CHAS_GUID_LEN       16
#define SCT_RSV_LEN         28

/* OemParamBlkSizeTbl_T */
typedef struct
{
    uint8_t   AnchorStr[ANCH_STR_LEN]; /* Header */
    uint8_t   Checksum;
    uint8_t   MajorRev;
    uint8_t   MinorRev;
    uint16_t  Len;
    uint8_t   Reserved1;
    uint8_t   SysIfcBlkSize;           /* Data */
    uint8_t   Reserved2;
    uint8_t   IPMBIfcBlkSize;
    uint8_t   Reserved3;
    uint8_t   LANIfcBlkSize;
    uint8_t   Reserved4;
}  OemParamBlkSizeTbl_T;

/* BootOrderTbl_T */
typedef struct
{
    uint8_t   AnchorStr[ANCH_STR_LEN]; /* Header */
    uint8_t   BOTChecksum;
    uint8_t   BOTMajorRev;
    uint8_t   BOTMinorRev;
    uint16_t  Len;
    uint8_t   Reserved;
    uint8_t   UpdFlag;                 /* Data */
    uint8_t   *BootOrderInfo;
    uint8_t   OrderType;
    uint8_t   OrderLen;
    uint8_t   *DevOrderList;
    uint8_t   *DevNamePath;
}  BootOrderTbl_T;

/* BootOrderTblReq_T */
typedef struct
{
    uint8_t          BlockSel;
    BootOrderTbl_T BootOrderTbl;
}  BootOrderTblReq_T;

/* SlotConfigTbl_T */
typedef struct
{
    uint8_t   AnchorStr[ANCH_STR_LEN]; /* Header */
    uint8_t   SCTChecksum;
    uint8_t   SCTMajorRev;
    uint8_t   SCTMinorRev;
    uint16_t  Len;
    uint8_t   Reserved1;
    uint8_t   NICIP[IP_ADDR_LEN];      /* Data */
    uint8_t   NICNetmask[IP_ADDR_LEN];
    uint8_t   NICGateway[IP_ADDR_LEN];
    uint16_t  MgmtVLAN;
    uint8_t   MgmtIP[IP_ADDR_LEN];
    uint8_t   ConfigScriptName[CFG_SCR_NAME_LEN];
    uint8_t   ChassisGUID[CHAS_GUID_LEN];
    uint16_t  ConfigBootType;
    uint16_t  TFTPPort;
    uint16_t  SFTPPort;
    uint16_t  SCPort;
    uint8_t   Reserved2[SCT_RSV_LEN];
}  SlotConfigTbl_T;

/* BootOptParams_T */
typedef union 
{
    uint8_t                   SetInProgress;
    uint8_t                   ServicePartitionSelector; 
    uint8_t                   ServicePartitionScan;
    uint8_t                   BootFlagValidBitClearing;
    BootInfoAck_T           BootInfoAck;
    BootFlags_T             BootFlags;
    BootInitiatorInfo_T     BootInitiatorInfo;
    BootInitiatorMboxReq_T  BootMailBox;
    AMI_BootOpt_T           Oem;
    OemParamBlkSizeTbl_T    OemParamBlkSizeTbl;
    BootOrderTblReq_T       BootOrderTbl;
    uint8_t                   BootDevSelector;
    SlotConfigTbl_T         SlotConfigTbl;
} BootOptParams_T;

/* SetBootOptionsReq_T */
typedef struct
{
    uint8_t               ParamValidCumParam;
    BootOptParams_T     BootParam;
    
}   SetBootOptionsReq_T;

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

/* BootOptions_T */
typedef struct
{
    uint8_t                   ParameterValid;
	uint8_t          			u8SetInProgress;    			/**< Set in progess variable */
    uint8_t                   ServicePartitionSelector; 
    uint8_t                   ServicePartitionScan;
    uint8_t                   BootFlagValidBitClearing;
    BootInfoAck_T           BootInfoAck;
    BootFlags_T             BootFlags;
    BootInitiatorInfo_T     BootInitiatorInfo;
    BootInitiatorMailbox_T  BootMailBox[MAX_BOOT_INIT_MAILBOX_BLOCKS];
    AMI_BootOpt_T           Oem;
    OemParamBlkSizeTbl_T    OemParamBlkSizeTbl;
    BootOrderTbl_T          *BootOrderTbl;
    uint8_t                   BootDevSelector;
    SlotConfigTbl_T         SlotConfigTbl;
}   BootOptions_T;

/* GetBootOptionsReq_T */
typedef struct
{
    uint8_t       ParamSel;
    uint8_t       SetSel;
    uint8_t       BlockSel;
    
}   GetBootOptionsReq_T;

/* GetBootOptParams_T */
typedef union
{
    uint8_t                   SetInProgress;  
    uint8_t                   ServicePartitionSelector; 
    uint8_t                   ServicePartitionScan;
    uint8_t                   BootFlagValidBitClearing;
    BootInfoAck_T           BootInfoAck;
    BootFlags_T             BootFlags;
    BootInitiatorInfo_T     BootInitiatorInfo;
    BootInitiatorMboxReq_T  BootMailBox;
    AMI_BootOpt_T           Oem;
    OemParamBlkSizeTbl_T    OemParamBlkSizeTbl;
    BootOrderTblReq_T       BootOrderTbl;
    uint8_t                   BootDevSelector;
    SlotConfigTbl_T         SlotConfigTbl;
} GetBootOptParams_T;

/* GetBootOptionsRes_T */
typedef struct 
{
    uint8_t               CompletionCode;
    uint8_t               ParamVersion;
    uint8_t               ParameterValid;
    GetBootOptParams_T  BootParams;
    
}   GetBootOptionsRes_T;

/* SetFPBtnEnablesReq_T */
typedef struct
{
    uint8_t   ButtonEnables;

}  SetFPBtnEnablesReq_T;

/* SetFPBtnEnablesRes_T */
typedef struct
{
    uint8_t   CompletionCode;

}  SetFPBtnEnablesRes_T;

/* SetPowerCycleInteval Req */
typedef struct
{
    uint8_t   PowerCycleInterval;
    
}   SetPowerCycleIntervalReq_T;

/* SetPowerRestorePolicyRes_T */
typedef struct
{
    uint8_t  CompletionCode;
    
}   SetPowerCycleIntervalRes_T;

#pragma pack( )

#endif /* IPMI_CHASSIS_DEVICE*/
