Patrick Rudolph | 09cdeba | 2019-12-30 14:40:04 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <types.h> |
| 4 | |
| 5 | #include <console/console.h> |
Sergii Dmytruk | ef7dd5d | 2021-10-22 01:02:32 +0300 | [diff] [blame] | 6 | #include <drivers/ipmi/ipmi_if.h> |
Patrick Rudolph | 09cdeba | 2019-12-30 14:40:04 +0100 | [diff] [blame] | 7 | #include <string.h> |
| 8 | #include <build.h> |
| 9 | #include "ipmi_supermicro_oem.h" |
| 10 | |
| 11 | #define IPMI_NETFN_OEM 0x30 |
| 12 | #define IPMI_LUN0_AC_SET_BIOS_VER 0x100 |
| 13 | #define IPMI_LUN0_AC_SET_BIOS_DATE 0x101 |
| 14 | #define IPMI_LUN0_SET_BIOS_STRING 0xac |
| 15 | |
| 16 | struct ipmi_oem_set_bios_str { |
| 17 | uint16_t ver; |
| 18 | char str[16]; // NULL terminated string |
| 19 | } __packed; |
| 20 | |
| 21 | static void set_coreboot_ver(const uint16_t kcs_port) |
| 22 | { |
| 23 | const char *coreboot_ver = COREBOOT_VERSION; |
| 24 | struct ipmi_oem_set_bios_str bios_ver; |
| 25 | struct ipmi_rsp rsp; |
| 26 | int ret; |
| 27 | size_t i; |
| 28 | |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 29 | /* Only 8 characters are visible in UI. Cut of on first dash */ |
Patrick Rudolph | 09cdeba | 2019-12-30 14:40:04 +0100 | [diff] [blame] | 30 | for (i = 0; i < 15; i++) { |
| 31 | if (coreboot_ver[i] == '-') |
| 32 | break; |
| 33 | bios_ver.str[i] = coreboot_ver[i]; |
| 34 | } |
| 35 | bios_ver.str[i] = 0; |
| 36 | bios_ver.ver = IPMI_LUN0_AC_SET_BIOS_VER; |
| 37 | |
Sergii Dmytruk | ef7dd5d | 2021-10-22 01:02:32 +0300 | [diff] [blame] | 38 | ret = ipmi_message(kcs_port, IPMI_NETFN_OEM, 0, IPMI_LUN0_SET_BIOS_STRING, |
Elyes Haouas | 1ef547e | 2022-11-18 15:05:39 +0100 | [diff] [blame^] | 39 | (const unsigned char *)&bios_ver, sizeof(bios_ver), |
| 40 | (unsigned char *)&rsp, sizeof(rsp)); |
Patrick Rudolph | 09cdeba | 2019-12-30 14:40:04 +0100 | [diff] [blame] | 41 | if (ret < sizeof(rsp) || rsp.completion_code) { |
| 42 | printk(BIOS_ERR, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n", |
| 43 | __func__, ret, rsp.completion_code); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | static void set_coreboot_date(const uint16_t kcs_port) |
| 48 | { |
| 49 | struct ipmi_oem_set_bios_str bios_ver; |
| 50 | struct ipmi_rsp rsp; |
| 51 | int ret; |
| 52 | |
| 53 | strncpy(bios_ver.str, COREBOOT_DMI_DATE, 15); |
| 54 | bios_ver.str[15] = 0; |
| 55 | bios_ver.ver = IPMI_LUN0_AC_SET_BIOS_DATE; |
| 56 | |
Sergii Dmytruk | ef7dd5d | 2021-10-22 01:02:32 +0300 | [diff] [blame] | 57 | ret = ipmi_message(kcs_port, IPMI_NETFN_OEM, 0, IPMI_LUN0_SET_BIOS_STRING, |
Elyes Haouas | 1ef547e | 2022-11-18 15:05:39 +0100 | [diff] [blame^] | 58 | (const unsigned char *)&bios_ver, sizeof(bios_ver), |
| 59 | (unsigned char *)&rsp, sizeof(rsp)); |
Patrick Rudolph | 09cdeba | 2019-12-30 14:40:04 +0100 | [diff] [blame] | 60 | if (ret < sizeof(rsp) || rsp.completion_code) { |
| 61 | printk(BIOS_ERR, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n", |
| 62 | __func__, ret, rsp.completion_code); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | void supermicro_ipmi_oem(const uint16_t kcs_port) |
| 67 | { |
| 68 | set_coreboot_ver(kcs_port); |
| 69 | set_coreboot_date(kcs_port); |
| 70 | } |