drivers/ipmi/ocp: Add missing include
[coreboot.git] / src / drivers / ipmi / supermicro_oem.c
blobfcf97f4254b37315944f7dff7bd94b7ee66f4a7e
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <types.h>
5 #include <console/console.h>
6 #include <drivers/ipmi/ipmi_if.h>
7 #include <string.h>
8 #include <version.h>
9 #include "ipmi_supermicro_oem.h"
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
16 struct ipmi_oem_set_bios_str {
17 uint16_t ver;
18 char str[16]; // NULL terminated string
19 } __packed;
21 static void set_coreboot_ver(const uint16_t kcs_port)
23 struct ipmi_oem_set_bios_str bios_ver;
24 struct ipmi_rsp rsp;
25 int ret;
26 size_t i;
28 /* Only 8 characters are visible in UI. Cut of on first dash */
29 for (i = 0; i < 15; i++) {
30 if (coreboot_version[i] == '-')
31 break;
32 bios_ver.str[i] = coreboot_version[i];
34 bios_ver.str[i] = 0;
35 bios_ver.ver = IPMI_LUN0_AC_SET_BIOS_VER;
37 ret = ipmi_message(kcs_port, IPMI_NETFN_OEM, 0, IPMI_LUN0_SET_BIOS_STRING,
38 (const unsigned char *)&bios_ver, sizeof(bios_ver),
39 (unsigned char *)&rsp, sizeof(rsp));
40 if (ret < sizeof(rsp) || rsp.completion_code) {
41 printk(BIOS_ERR, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n",
42 __func__, ret, rsp.completion_code);
46 static void set_coreboot_date(const uint16_t kcs_port)
48 struct ipmi_oem_set_bios_str bios_ver;
49 struct ipmi_rsp rsp;
50 int ret;
52 strncpy(bios_ver.str, coreboot_dmi_date, 15);
53 bios_ver.str[15] = 0;
54 bios_ver.ver = IPMI_LUN0_AC_SET_BIOS_DATE;
56 ret = ipmi_message(kcs_port, IPMI_NETFN_OEM, 0, IPMI_LUN0_SET_BIOS_STRING,
57 (const unsigned char *)&bios_ver, sizeof(bios_ver),
58 (unsigned char *)&rsp, sizeof(rsp));
59 if (ret < sizeof(rsp) || rsp.completion_code) {
60 printk(BIOS_ERR, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n",
61 __func__, ret, rsp.completion_code);
65 void supermicro_ipmi_oem(const uint16_t kcs_port)
67 set_coreboot_ver(kcs_port);
68 set_coreboot_date(kcs_port);