- added watchdog command

This commit is contained in:
Jean-Michel Audet 2007-04-26 13:22:40 +00:00
parent f8bc5ae591
commit f34245e46e

View File

@ -156,6 +156,7 @@ printf_mc_usage(void)
printf("MC Commands:\n"); printf("MC Commands:\n");
printf(" reset <warm|cold>\n"); printf(" reset <warm|cold>\n");
printf(" info\n"); printf(" info\n");
printf(" wdt\n");
printf(" selftest\n"); printf(" selftest\n");
printf(" getenables\n"); printf(" getenables\n");
printf(" setenables <option=on|off> ...\n"); printf(" setenables <option=on|off> ...\n");
@ -456,6 +457,7 @@ static int ipmi_mc_get_selftest(struct ipmi_intf * intf)
lprintf(LOG_ERR, "No response from devices\n"); lprintf(LOG_ERR, "No response from devices\n");
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode) {
lprintf(LOG_ERR, "Bad response: (%s)", lprintf(LOG_ERR, "Bad response: (%s)",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
@ -503,15 +505,18 @@ static int ipmi_mc_get_selftest(struct ipmi_intf * intf)
printf("controller operational firmware corrupted\n"); printf("controller operational firmware corrupted\n");
} }
} }
else if (sft_res->code == IPM_SFT_CODE_FATAL_ERROR) { else if (sft_res->code == IPM_SFT_CODE_FATAL_ERROR) {
printf("Selftest : fatal error\n"); printf("Selftest : fatal error\n");
printf("Failure code : %02x\n", sft_res->test); printf("Failure code : %02x\n", sft_res->test);
rv = -1; rv = -1;
} }
else if (sft_res->code == IPM_SFT_CODE_RESERVED) { else if (sft_res->code == IPM_SFT_CODE_RESERVED) {
printf("Selftest: N/A"); printf("Selftest: N/A");
rv = -1; rv = -1;
} }
else { else {
printf("Selttest : device specific\n"); printf("Selttest : device specific\n");
printf("Failure code : %02x\n", sft_res->test); printf("Failure code : %02x\n", sft_res->test);
@ -521,6 +526,150 @@ static int ipmi_mc_get_selftest(struct ipmi_intf * intf)
return rv; return rv;
} }
/* ipmi_mc_get_watchdog
*
* @intf: ipmi interface
*
* returns 0 on success
* returns -1 on error
*/
const char *wdt_use_string[8] = {
"reserved",
"BIOS FRB2",
"BIOS/POST",
"OS Load",
"SMS/OS",
"OEM",
"reserved",
"reserved"
};
const char *wdt_action_string[8] = {
"no action",
"Hard Reset",
"Power Down",
"Power Cycle",
"reserved",
"reserved",
"reserved",
"reserved"
};
static int
ipmi_mc_get_watchdog(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct ipm_get_watchdog_rsp * wdt_res;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = BMC_GET_WATCHDOG_TIMER;
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
printf("no response\n");
return -1;
}
if (rsp->ccode) {
printf("returned CC code 0x%02x\n", rsp->ccode);
return -1;
}
wdt_res = (struct ipm_get_watchdog_rsp *) rsp->data;
printf("Timer Use: 0x%02x - %s\n", wdt_res->timer_use, wdt_use_string[wdt_res->timer_use]);
printf("Timer Actions: 0x%02x - %s\n", wdt_res->timer_actions, wdt_action_string[wdt_res->timer_actions]);
printf("Pre-timeout interval: 0x%02x\n", wdt_res->pre_timeout);
printf("Timer Use Expiration: 0x%02x\n", wdt_res->timer_use_exp);
printf("Initial Countdown: %i ms\n",
(wdt_res->initial_countdown_msb << 8) | wdt_res->initial_countdown_lsb);
printf("Present Countdown: %i ms\n",
(wdt_res->present_countdown_msb << 8) | wdt_res->present_countdown_lsb);
return 0;
}
/* ipmi_mc_set_watchdog
*
* @intf: ipmi interface
*
* returns 0 on success
* returns -1 on error
*/
static int
ipmi_mc_set_watchdog(struct ipmi_intf * intf, int argc, char ** argv)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
unsigned char msg_data[6];
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = BMC_SET_WATCHDOG_TIMER;
req.msg.data = msg_data;
req.msg.data_len = 6;
printf("FIXME - not fully implemented\n");
msg_data[0] = 0x03; /* os load*/
msg_data[1] = 0x02; /* action power down */
msg_data[2] = 10; /* pretimeout */
msg_data[3] = 0;
msg_data[4] = 10; /* timeout lsb in 100ms/count */
msg_data[5] = 0; /* timeout lsb */
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
printf("no response\n");
return -1;
}
if (rsp->ccode) {
printf("returned CC code 0x%02x\n", rsp->ccode);
return -1;
}
return 0;
}
/* ipmi_mc_set_watchdog
*
* @intf: ipmi interface
*
* returns 0 on success
* returns -1 on error
*/
static int
ipmi_mc_rst_watchdog(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = BMC_RESET_WATCHDOG_TIMER;
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
printf("no response\n");
return -1;
}
if (rsp->ccode) {
printf("returned CC code 0x%02x\n", rsp->ccode);
return -1;
}
return 0;
}
/* ipmi_mc_main - top-level handler for MC functions /* ipmi_mc_main - top-level handler for MC functions
* *
* @intf: ipmi interface * @intf: ipmi interface
@ -567,10 +716,23 @@ ipmi_mc_main(struct ipmi_intf * intf, int argc, char ** argv)
else if (!strncmp(argv[0], "selftest", 8)) { else if (!strncmp(argv[0], "selftest", 8)) {
rc = ipmi_mc_get_selftest(intf); rc = ipmi_mc_get_selftest(intf);
} }
else if (!strncmp(argv[0], "wdt", 3)) {
if (argc < 2) {
rc = ipmi_mc_get_watchdog(intf);
}else if(strncmp(argv[1], "get", 3) == 0){
rc = ipmi_mc_get_watchdog(intf);
}else if(strncmp(argv[1], "set", 3) == 0){
if(argc > 5)
rc = ipmi_mc_set_watchdog(intf, argc-1, &(argv[1]));
else
printf("wdt set <use><action><pretimeout><countdown> FIXME - not fully implemented\n");
}else if(strncmp(argv[1], "rst", 3) == 0){
rc = ipmi_mc_rst_watchdog(intf);
}
}
else { else {
lprintf(LOG_ERR, "Invalid mc/bmc command: %s", argv[0]); lprintf(LOG_ERR, "Invalid mc/bmc command: %s", argv[0]);
rc = -1; rc = -1;
} }
return rc; return rc;
} }