mc: watchdog get: Update to match IPMI 2.0 spec

* Add output of "don't log" and "pre-timeout interrupt" fields
* Display timers with 100ms precision
* List timer use expiration flags as text, not just numerically

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
Alexander Amelkin
2018-06-17 01:09:58 +03:00
parent 2a78ff2482
commit 6c00d448d5
3 changed files with 71 additions and 17 deletions

View File

@@ -109,6 +109,21 @@ FILE * ipmi_open_file(const char * file, int rw);
void ipmi_start_daemon(struct ipmi_intf *intf);
uint16_t ipmi_get_oem_id(struct ipmi_intf *intf);
#define IS_SET(v, b) ((v) & (1 << (b)))
/* le16toh() doesn't exist for Windows or Apple */
/* For portability, let's simply define our own version of it here */
static inline uint16_t ipmi16toh(uint16_t le)
{
uint8_t *data = (uint8_t *)&le;
uint16_t h;
h = data[1] << 8; /* MSB */
h |= data[0]; /* LSB */
return h;
}
#define ipmi_open_file_read(file) ipmi_open_file(file, 0)
#define ipmi_open_file_write(file) ipmi_open_file(file, 1)

View File

@@ -34,6 +34,7 @@
#define IPMI_MC_H
#include <ipmitool/ipmi.h>
#include <ipmitool/helper.h>
#define BMC_GET_DEVICE_ID 0x01
#define BMC_COLD_RESET 0x02
@@ -138,14 +139,24 @@ struct ipm_selftest_rsp {
#pragma pack(1)
#endif
struct ipm_get_watchdog_rsp {
unsigned char timer_use;
unsigned char timer_actions;
unsigned char use;
unsigned char intr_action;
unsigned char pre_timeout;
unsigned char timer_use_exp;
unsigned char initial_countdown_lsb;
unsigned char initial_countdown_msb;
unsigned char present_countdown_lsb;
unsigned char present_countdown_msb;
unsigned char exp_flags;
union {
struct {
unsigned char initial_countdown_lsb;
unsigned char initial_countdown_msb;
};
uint16_t init_cnt_le;
};
union {
struct {
unsigned char present_countdown_lsb;
unsigned char present_countdown_msb;
};
uint16_t pres_cnt_le;
};
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
@@ -172,7 +183,9 @@ struct ipm_get_watchdog_rsp {
/* Use */
#define IPMI_WDT_USE_NOLOG_SHIFT 7
#define IPMI_WDT_USE_DONTSTOP_SHIFT 6
#define IPMI_WDT_USE_DONTSTOP_SHIFT 6 /* For 'set' */
#define IPMI_WDT_USE_RUNNING_SHIFT 6 /* For 'get' */
#define IPMI_WDT_USE_SHIFT 0
#define IPMI_WDT_USE_MASK 0x07
/* Pre-timeout interrupt type */
@@ -180,8 +193,12 @@ struct ipm_get_watchdog_rsp {
#define IPMI_WDT_INTR_MASK 0x07 /* Apply to the intr value, not to the data byte */
/* Action */
#define IPMI_WDT_ACTION_SHIFT 0
#define IPMI_WDT_ACTION_MASK 0x07
#define IPMI_WDT_GET(b, s) (((b) >> (IPMI_WDT_##s##_SHIFT)) & (IPMI_WDT_##s##_MASK))
#define IS_WDT_BIT(b, s) IS_SET((b), IPMI_WDT_##s##_SHIFT)
/* IPMI 2.0 command for system information*/
#define IPMI_SET_SYS_INFO 0x58