|
@@ -24,6 +24,7 @@
|
|
#include "libipmi_session.h"
|
|
#include "libipmi_session.h"
|
|
#include "libipmi_errorcodes.h"
|
|
#include "libipmi_errorcodes.h"
|
|
#include "libipmi_ChassisDevice.h"
|
|
#include "libipmi_ChassisDevice.h"
|
|
|
|
+#include "com_IPMI_App.h"
|
|
|
|
|
|
#include "string.h"
|
|
#include "string.h"
|
|
|
|
|
|
@@ -55,6 +56,38 @@ uint16_t IPMICMD_ChassisControl( IPMI20_UDS_SESSION_T *pUDSSession, int timeout,
|
|
return wRet;
|
|
return wRet;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+uint16_t IPMC_ChassisControl( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int timeout, char cmd)
|
|
|
|
+{
|
|
|
|
+ uint16_t wRet = 0;
|
|
|
|
+ uint8_t Req[10] = {0};
|
|
|
|
+ uint8_t Res[10];
|
|
|
|
+ uint16_t strLen, remainLen;
|
|
|
|
+ uint32_t dwResLen;
|
|
|
|
+
|
|
|
|
+ //get title
|
|
|
|
+ Req[0] = 0x40; //Track | channel 0
|
|
|
|
+ Req[1] = IpmbAddr;
|
|
|
|
+ Req[2] = NETFNLUN_IPMI_CHASSIS;
|
|
|
|
+ Req[3] = 0x100 - (Req[1] + Req[2])&0xff; //checksum1
|
|
|
|
+ Req[4] = 0x20;
|
|
|
|
+ Req[5] = 0x10;
|
|
|
|
+ Req[6] = CMD_CHASSIS_CONTROL;
|
|
|
|
+ Req[7] = cmd;
|
|
|
|
+ Req[8] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7])&0xff;
|
|
|
|
+
|
|
|
|
+ wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
|
|
|
|
+ DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
|
|
|
|
+ Req, 9,
|
|
|
|
+ Res, &dwResLen,
|
|
|
|
+ timeout);
|
|
|
|
+ if((wRet != 0) || (Res[6] != 0))
|
|
|
|
+ {
|
|
|
|
+ printf("IPMC_ChassisControl faile\n" );
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
|
|
uint16_t IPMICMD_GetSystemBootOptions(IPMI20_UDS_SESSION_T *pUDSSession, GetBootOptionsReq_T* pReqGetBootOptions,
|
|
uint16_t IPMICMD_GetSystemBootOptions(IPMI20_UDS_SESSION_T *pUDSSession, GetBootOptionsReq_T* pReqGetBootOptions,
|
|
GetBootOptionsRes_T* pResGetBootOptions,int reslen,int timeout)
|
|
GetBootOptionsRes_T* pResGetBootOptions,int reslen,int timeout)
|
|
@@ -155,101 +188,15 @@ uint16_t IPMICMD_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession,int timeout,C
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-// uint16_t LIBIPMI_HL_PowerOff( IPMI20_UDS_SESSION_T *pUDSSession, int timeout )
|
|
|
|
-// {
|
|
|
|
-// uint16_t wRet;
|
|
|
|
-
|
|
|
|
-// wRet = IPMICMD_ChassisControl( pUDSSession, timeout, CHASSIS_POWEROFF);
|
|
|
|
-
|
|
|
|
-// if (wRet == LIBIPMI_E_SUCCESS){
|
|
|
|
-// TDBG("Succefully executed powerOFF command.\n");
|
|
|
|
-// }else
|
|
|
|
-// TDBG("Error: PowerOFF Command Failed.\n");
|
|
|
|
-
|
|
|
|
-// return wRet;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// uint16_t LIBIPMI_HL_PowerUp( IPMI20_UDS_SESSION_T *pUDSSession, int timeout )
|
|
|
|
-// {
|
|
|
|
-// uint16_t wRet;
|
|
|
|
-
|
|
|
|
-// wRet = IPMICMD_ChassisControl( pUDSSession, timeout, CHASSIS_POWERUP);
|
|
|
|
-
|
|
|
|
-// if (wRet == LIBIPMI_E_SUCCESS){
|
|
|
|
-// TDBG("Succefully executed powerUP the command.\n");
|
|
|
|
-// }else
|
|
|
|
-// TDBG("Error: PowerUp Command Failed.\n");
|
|
|
|
-
|
|
|
|
-// return wRet;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// uint16_t LIBIPMI_HL_PowerCycle( IPMI20_UDS_SESSION_T *pUDSSession, int timeout )
|
|
|
|
-// {
|
|
|
|
-// uint16_t wRet;
|
|
|
|
-
|
|
|
|
-// wRet = IPMICMD_ChassisControl( pUDSSession, timeout, CHASSIS_POWERCYCLE);
|
|
|
|
-
|
|
|
|
-// if (wRet == LIBIPMI_E_SUCCESS){
|
|
|
|
-// TDBG("Succefully executed powerCycle the command.\n");
|
|
|
|
-// }else
|
|
|
|
-// TDBG("Error: PowerCycle Command Failed.\n");
|
|
|
|
-
|
|
|
|
-// return wRet;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// uint16_t LIBIPMI_HL_HardReset( IPMI20_UDS_SESSION_T *pUDSSession, int timeout )
|
|
|
|
-// { //TODO: jimbo control rst1~10 pin
|
|
|
|
-// uint16_t wRet;
|
|
|
|
-
|
|
|
|
-// wRet = IPMICMD_ChassisControl( pUDSSession, timeout, CHASSIS_HARDRESET);
|
|
|
|
-
|
|
|
|
-// if (wRet == LIBIPMI_E_SUCCESS){
|
|
|
|
-// TDBG("Succefully executed HardReset the command.\n");
|
|
|
|
-// }else
|
|
|
|
-// TDBG("Error: HardReset Command Failed.\n");
|
|
|
|
-
|
|
|
|
-// return wRet;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// uint16_t LIBIPMI_HL_DiagInt( IPMI20_UDS_SESSION_T *pUDSSession, int timeout )
|
|
|
|
-// {
|
|
|
|
-// uint16_t wRet;
|
|
|
|
-
|
|
|
|
-// wRet = IPMICMD_ChassisControl( pUDSSession, timeout, CHASSIS_DIAGINT);
|
|
|
|
-
|
|
|
|
-// if (wRet == LIBIPMI_E_SUCCESS){
|
|
|
|
-// TDBG("Succefully executed DiagInt command.\n");
|
|
|
|
-// }else
|
|
|
|
-// TDBG("Error: DiagInt Command Failed.\n");
|
|
|
|
-
|
|
|
|
-// return wRet;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// uint16_t LIBIPMI_HL_SoftOff( IPMI20_UDS_SESSION_T *pUDSSession, int timeout )
|
|
|
|
-// {
|
|
|
|
-// uint16_t wRet;
|
|
|
|
-
|
|
|
|
-// wRet = IPMICMD_ChassisControl( pUDSSession, timeout, CHASSIS_SOFTOFF);
|
|
|
|
-
|
|
|
|
-// if (wRet == LIBIPMI_E_SUCCESS){
|
|
|
|
-// TDBG("Succefully executed SoftOff command.\n");
|
|
|
|
-// }else
|
|
|
|
-// TDBG("Error: SoftOff Command Failed.\n");
|
|
|
|
-
|
|
|
|
-// return wRet;
|
|
|
|
-// }
|
|
|
|
|
|
|
|
uint16_t LIBIPMI_HL_GetChassisStatus( IPMI20_UDS_SESSION_T *pUDSSession, int timeout, chassis_status_T *status)
|
|
uint16_t LIBIPMI_HL_GetChassisStatus( IPMI20_UDS_SESSION_T *pUDSSession, int timeout, chassis_status_T *status)
|
|
{
|
|
{
|
|
-
|
|
|
|
uint32_t dwResLen;
|
|
uint32_t dwResLen;
|
|
uint16_t wRet;
|
|
uint16_t wRet;
|
|
uint8_t ChassisStatusReq;
|
|
uint8_t ChassisStatusReq;
|
|
GetChassisStatusRes_T ChassisStatusRes;
|
|
GetChassisStatusRes_T ChassisStatusRes;
|
|
uint8_t powerState = -1;
|
|
uint8_t powerState = -1;
|
|
|
|
|
|
- dwResLen = sizeof(GetChassisStatusRes_T);
|
|
|
|
-
|
|
|
|
wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
|
|
wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
|
|
NETFNLUN_IPMI_CHASSIS, CMD_GET_CHASSIS_STATUS,
|
|
NETFNLUN_IPMI_CHASSIS, CMD_GET_CHASSIS_STATUS,
|
|
(uint8_t *)&ChassisStatusReq, 0 ,
|
|
(uint8_t *)&ChassisStatusReq, 0 ,
|
|
@@ -257,27 +204,21 @@ uint16_t LIBIPMI_HL_GetChassisStatus( IPMI20_UDS_SESSION_T *pUDSSession, int tim
|
|
timeout);
|
|
timeout);
|
|
|
|
|
|
powerState = ChassisStatusRes.ChassisPowerState.PowerState ;
|
|
powerState = ChassisStatusRes.ChassisPowerState.PowerState ;
|
|
-
|
|
|
|
-// TINFO("PowerState is %d \n", powerState);
|
|
|
|
-
|
|
|
|
status->power_state = powerState & 0x01;
|
|
status->power_state = powerState & 0x01;
|
|
-
|
|
|
|
status->last_power_event = ChassisStatusRes.ChassisPowerState.LastPowerEvent;
|
|
status->last_power_event = ChassisStatusRes.ChassisPowerState.LastPowerEvent;
|
|
-
|
|
|
|
-
|
|
|
|
if(ChassisStatusRes.ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_STATE_INFO_SUPPORTED)
|
|
if(ChassisStatusRes.ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_STATE_INFO_SUPPORTED)
|
|
{
|
|
{
|
|
- status->chassis_indetify_supported = 1;
|
|
|
|
|
|
+ status->chassis_indetify_supported = 1;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- status->chassis_indetify_supported = 0;
|
|
|
|
|
|
+ status->chassis_indetify_supported = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ChassisStatusRes.ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_INDEFINITE_ON)
|
|
if(ChassisStatusRes.ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_INDEFINITE_ON)
|
|
{
|
|
{
|
|
- status->chassis_identify_state = CHASSIS_ID_INDEFINITE_ON;
|
|
|
|
|
|
+ status->chassis_identify_state = CHASSIS_ID_INDEFINITE_ON;
|
|
}
|
|
}
|
|
else if(ChassisStatusRes.ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_TIMED_ON)
|
|
else if(ChassisStatusRes.ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_TIMED_ON)
|
|
{
|
|
{
|
|
@@ -285,12 +226,75 @@ uint16_t LIBIPMI_HL_GetChassisStatus( IPMI20_UDS_SESSION_T *pUDSSession, int tim
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- status->chassis_identify_state = CHASSIS_ID_OFF;
|
|
|
|
|
|
+ status->chassis_identify_state = CHASSIS_ID_OFF;
|
|
}
|
|
}
|
|
|
|
|
|
- return wRet;
|
|
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+uint16_t IPMC_GetChassisStatus( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int timeout, chassis_status_T *status)
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ uint16_t wRet = 0;
|
|
|
|
+ uint8_t Req[10] = {0};
|
|
|
|
+ uint8_t Res[10];
|
|
|
|
+ uint16_t strLen, remainLen;
|
|
|
|
+ uint32_t dwResLen;
|
|
|
|
+ GetChassisStatusRes_T *pChassisStatusRes;
|
|
|
|
+ uint8_t powerState = -1;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //get title
|
|
|
|
+ Req[0] = 0x40; //Track | channel 0
|
|
|
|
+ Req[1] = IpmbAddr;
|
|
|
|
+ Req[2] = NETFNLUN_IPMI_CHASSIS;
|
|
|
|
+ Req[3] = 0x100 - (Req[1] + Req[2])&0xff; //checksum1
|
|
|
|
+ Req[4] = 0x20;
|
|
|
|
+ Req[5] = 0x10;
|
|
|
|
+ Req[6] = CMD_GET_CHASSIS_STATUS;
|
|
|
|
+ Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
|
|
|
|
+
|
|
|
|
+ //dwResLen = sizeof(GetDevIDRes_T);
|
|
|
|
+ wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
|
|
|
|
+ DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
|
|
|
|
+ Req, 8,
|
|
|
|
+ Res, &dwResLen,
|
|
|
|
+ timeout);
|
|
|
|
+ if((wRet != 0) || (Res[6] != 0))
|
|
|
|
+ {
|
|
|
|
+ printf("---> IPMC_GetChassisStatus error\n");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pChassisStatusRes = (GetChassisStatusRes_T *)&Res[6];
|
|
|
|
+ powerState = pChassisStatusRes->ChassisPowerState.PowerState ;
|
|
|
|
+ status->power_state = powerState & 0x01;
|
|
|
|
+ status->last_power_event = pChassisStatusRes->ChassisPowerState.LastPowerEvent;
|
|
|
|
+ if(pChassisStatusRes->ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_STATE_INFO_SUPPORTED)
|
|
|
|
+ {
|
|
|
|
+ status->chassis_indetify_supported = 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ status->chassis_indetify_supported = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(pChassisStatusRes->ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_INDEFINITE_ON)
|
|
|
|
+ {
|
|
|
|
+ status->chassis_identify_state = CHASSIS_ID_INDEFINITE_ON;
|
|
|
|
+ }
|
|
|
|
+ else if(pChassisStatusRes->ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_TIMED_ON)
|
|
|
|
+ {
|
|
|
|
+ status->chassis_identify_state = CHASSIS_ID_TIMED_ON;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ status->chassis_identify_state = CHASSIS_ID_OFF;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
|
|
//will turn chassis identify on or off
|
|
//will turn chassis identify on or off
|
|
//BlinkTime - Set to TURN_OFF for turning off indefinitely
|
|
//BlinkTime - Set to TURN_OFF for turning off indefinitely
|