diff options
author | Morgan Jang <Morgan_Jang@wiwynn.com> | 2020-04-09 13:50:43 +0800 |
---|---|---|
committer | Andrey Petrov <andrey.petrov@gmail.com> | 2020-04-10 18:08:02 +0000 |
commit | ea9787a6b29821e95aa382e1df1ba397cf3da9e9 (patch) | |
tree | 5037f106624bb6914f63b1f2ada6bd5cb2e8eb4f | |
parent | e6d1c7fae87e7bdf869c59a09c16284b6a9dfccb (diff) | |
download | coreboot-ea9787a6b29821e95aa382e1df1ba397cf3da9e9.tar.xz |
drivers/ipmi: Implement the function for logging system events into BMC
Implemented for functions that need to log system events into BMC,
the information of system events can be specific.
TEST=Use ipmitool and execute "ipmitool sel list" command to check
if SEL is added into BMC.
Change-Id: I38f3acb958d12c196d33d34fd5cfa0b784f403b7
Signed-off-by: Morgan Jang <Morgan_Jang@wiwynn.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/40286
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Andrey Petrov <andrey.petrov@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
-rw-r--r-- | src/drivers/ipmi/ipmi_kcs.h | 1 | ||||
-rw-r--r-- | src/drivers/ipmi/ipmi_ops.c | 22 | ||||
-rw-r--r-- | src/drivers/ipmi/ipmi_ops.h | 40 |
3 files changed, 63 insertions, 0 deletions
diff --git a/src/drivers/ipmi/ipmi_kcs.h b/src/drivers/ipmi/ipmi_kcs.h index d511edfd4f..44f668d149 100644 --- a/src/drivers/ipmi/ipmi_kcs.h +++ b/src/drivers/ipmi/ipmi_kcs.h @@ -21,6 +21,7 @@ #define IPMI_NETFN_FIRMWARE 0x08 #define IPMI_NETFN_STORAGE 0x0a #define IPMI_READ_FRU_DATA 0x11 +#define IPMI_ADD_SEL_ENTRY 0x44 #define IPMI_NETFN_TRANSPORT 0x0c #define IPMI_CMD_ACPI_POWERON 0x06 diff --git a/src/drivers/ipmi/ipmi_ops.c b/src/drivers/ipmi/ipmi_ops.c index 25bf077aef..2a52ba0ec3 100644 --- a/src/drivers/ipmi/ipmi_ops.c +++ b/src/drivers/ipmi/ipmi_ops.c @@ -118,3 +118,25 @@ enum cb_err ipmi_get_system_guid(const int port, uint8_t *uuid) memcpy(uuid, rsp.data, 16); return CB_SUCCESS; } + +enum cb_err ipmi_add_sel(const int port, struct sel_event_record *sel) +{ + int ret; + struct ipmi_add_sel_rsp rsp; + + if (sel == NULL) { + printk(BIOS_ERR, "%s failed, system evnt log is not present.\n", __func__); + return CB_ERR; + } + + ret = ipmi_kcs_message(port, IPMI_NETFN_STORAGE, 0x0, + IPMI_ADD_SEL_ENTRY, (const unsigned char *) sel, + 16, (unsigned char *) &rsp, sizeof(rsp)); + + if (ret < sizeof(struct ipmi_rsp) || rsp.resp.completion_code) { + printk(BIOS_ERR, "IPMI: %s command failed (ret=%d resp=0x%x)\n", + __func__, ret, rsp.resp.completion_code); + return CB_ERR; + } + return CB_SUCCESS; +} diff --git a/src/drivers/ipmi/ipmi_ops.h b/src/drivers/ipmi/ipmi_ops.h index f88959544b..e6e6b77548 100644 --- a/src/drivers/ipmi/ipmi_ops.h +++ b/src/drivers/ipmi/ipmi_ops.h @@ -50,6 +50,42 @@ struct ipmi_read_fru_data_rsp { uint8_t data[CONFIG_IPMI_FRU_SINGLE_RW_SZ]; } __packed; +struct standard_spec_sel_rec { + uint32_t timestamp; + uint16_t gen_id; + uint8_t evm_rev; + uint8_t sensor_type; + uint8_t sensor_num; + uint8_t event_dir_type; + uint8_t event_data[3]; +}; + +struct oem_ts_spec_sel_rec { + uint32_t timestamp; + uint8_t manf_id[3]; + uint8_t oem_defined[6]; +}; + +struct oem_nots_spec_sel_rec { + uint8_t oem_defined[13]; +}; + +/* SEL Event Record */ +struct sel_event_record { + uint16_t record_id; + uint8_t record_type; + union{ + struct standard_spec_sel_rec standard_type; + struct oem_ts_spec_sel_rec oem_ts_type; + struct oem_nots_spec_sel_rec oem_nots_type; + } sel_type; +} __packed; + +struct ipmi_add_sel_rsp { + struct ipmi_rsp resp; + uint16_t record_id; +} __packed; + /* Platform Management FRU Information Storage Definition Spec. */ #define PRODUCT_MAN_TYPE_LEN_OFFSET 3 #define BOARD_MAN_TYPE_LEN_OFFSET 6 @@ -123,4 +159,8 @@ void read_fru_areas(const int port, uint8_t id, uint16_t offset, /* Read a particular FRU inventory area into fru_info_str. */ void read_fru_one_area(const int port, uint8_t id, uint16_t offset, struct fru_info_str *fru_info_str, enum fru_area fru_area); + +/* Add a SEL record entry, returns CB_SUCCESS on success and CB_ERR + * if an error occurred */ +enum cb_err ipmi_add_sel(const int port, struct sel_event_record *sel); #endif |