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