Message ID | 1453396734-9363-8-git-send-email-clg@fr.ibm.com |
---|---|
State | New |
Headers | show |
On Thu, 21 Jan 2016 18:18:52 +0100 Cédric Le Goater <clg@fr.ibm.com> wrote: > This is a simulator. Just return an unknown cause (0). > > Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> > Acked-by: Corey Minyard <cminyard@mvista.com> > --- Reviewed-by: Greg Kurz <gkurz@linux.vnet.ibm.com> > hw/ipmi/ipmi_bmc_sim.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c > index 7c0f2a1d9799..e882af3f1b40 100644 > --- a/hw/ipmi/ipmi_bmc_sim.c > +++ b/hw/ipmi/ipmi_bmc_sim.c > @@ -34,6 +34,7 @@ > #define IPMI_CMD_GET_CHASSIS_CAPABILITIES 0x00 > #define IPMI_CMD_GET_CHASSIS_STATUS 0x01 > #define IPMI_CMD_CHASSIS_CONTROL 0x02 > +#define IPMI_CMD_GET_SYS_RESTART_CAUSE 0x09 > > #define IPMI_NETFN_SENSOR_EVENT 0x04 > > @@ -197,6 +198,8 @@ struct IPMIBmcSim { > uint8_t mfg_id[3]; > uint8_t product_id[2]; > > + uint8_t restart_cause; > + > IPMISel sel; > IPMISdr sdr; > IPMISensor sensors[MAX_SENSORS]; > @@ -756,6 +759,15 @@ static void chassis_control(IPMIBmcSim *ibs, > } > } > > +static void chassis_get_sys_restart_cause(IPMIBmcSim *ibs, > + uint8_t *cmd, unsigned int cmd_len, > + uint8_t *rsp, unsigned int *rsp_len, > + unsigned int max_rsp_len) > +{ > + IPMI_ADD_RSP_DATA(ibs->restart_cause & 0xf); /* Restart Cause */ > + IPMI_ADD_RSP_DATA(0); /* Channel 0 */ > +} > + > static void get_device_id(IPMIBmcSim *ibs, > uint8_t *cmd, unsigned int cmd_len, > uint8_t *rsp, unsigned int *rsp_len, > @@ -1571,7 +1583,8 @@ static void get_sensor_type(IPMIBmcSim *ibs, > static const IPMICmdHandler chassis_cmds[] = { > [IPMI_CMD_GET_CHASSIS_CAPABILITIES] = chassis_capabilities, > [IPMI_CMD_GET_CHASSIS_STATUS] = chassis_status, > - [IPMI_CMD_CHASSIS_CONTROL] = chassis_control > + [IPMI_CMD_CHASSIS_CONTROL] = chassis_control, > + [IPMI_CMD_GET_SYS_RESTART_CAUSE] = chassis_get_sys_restart_cause > }; > static const IPMINetfn chassis_netfn = { > .cmd_nums = ARRAY_SIZE(chassis_cmds), > @@ -1692,6 +1705,7 @@ static void ipmi_sim_init(Object *obj) > ibs->bmc_global_enables = (1 << IPMI_BMC_EVENT_LOG_BIT); > ibs->device_id = 0x20; > ibs->ipmi_version = 0x02; /* IPMI 2.0 */ > + ibs->restart_cause = 0; > for (i = 0; i < 4; i++) { > ibs->sel.last_addition[i] = 0xff; > ibs->sel.last_clear[i] = 0xff;
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index 7c0f2a1d9799..e882af3f1b40 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -34,6 +34,7 @@ #define IPMI_CMD_GET_CHASSIS_CAPABILITIES 0x00 #define IPMI_CMD_GET_CHASSIS_STATUS 0x01 #define IPMI_CMD_CHASSIS_CONTROL 0x02 +#define IPMI_CMD_GET_SYS_RESTART_CAUSE 0x09 #define IPMI_NETFN_SENSOR_EVENT 0x04 @@ -197,6 +198,8 @@ struct IPMIBmcSim { uint8_t mfg_id[3]; uint8_t product_id[2]; + uint8_t restart_cause; + IPMISel sel; IPMISdr sdr; IPMISensor sensors[MAX_SENSORS]; @@ -756,6 +759,15 @@ static void chassis_control(IPMIBmcSim *ibs, } } +static void chassis_get_sys_restart_cause(IPMIBmcSim *ibs, + uint8_t *cmd, unsigned int cmd_len, + uint8_t *rsp, unsigned int *rsp_len, + unsigned int max_rsp_len) +{ + IPMI_ADD_RSP_DATA(ibs->restart_cause & 0xf); /* Restart Cause */ + IPMI_ADD_RSP_DATA(0); /* Channel 0 */ +} + static void get_device_id(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, @@ -1571,7 +1583,8 @@ static void get_sensor_type(IPMIBmcSim *ibs, static const IPMICmdHandler chassis_cmds[] = { [IPMI_CMD_GET_CHASSIS_CAPABILITIES] = chassis_capabilities, [IPMI_CMD_GET_CHASSIS_STATUS] = chassis_status, - [IPMI_CMD_CHASSIS_CONTROL] = chassis_control + [IPMI_CMD_CHASSIS_CONTROL] = chassis_control, + [IPMI_CMD_GET_SYS_RESTART_CAUSE] = chassis_get_sys_restart_cause }; static const IPMINetfn chassis_netfn = { .cmd_nums = ARRAY_SIZE(chassis_cmds), @@ -1692,6 +1705,7 @@ static void ipmi_sim_init(Object *obj) ibs->bmc_global_enables = (1 << IPMI_BMC_EVENT_LOG_BIT); ibs->device_id = 0x20; ibs->ipmi_version = 0x02; /* IPMI 2.0 */ + ibs->restart_cause = 0; for (i = 0; i < 4; i++) { ibs->sel.last_addition[i] = 0xff; ibs->sel.last_clear[i] = 0xff;