summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0056-add-SetInProgress-to-get-set-boot-option-cmd.patch
blob: 987e6144850af215e4af1f56da6462445b69b239 (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
From f9f260391f099b4e67999f9d4ca05cbf9b422baf Mon Sep 17 00:00:00 2001
From: "Jia, chunhui" <chunhui.jia@linux.intel.com>
Date: Tue, 19 Mar 2019 16:09:06 +0800
Subject: [PATCH] add SetInProgress to get/set boot option cmd

It is required by BIOS. BIOS will check setinprogress first.
If this flag is not supported, BIOS will bypass all boot
option flow.

Change-Id: Ibb0501ea5bc36c4f1f72339efef03724dd4e613f
Signed-off-by: Jia, chunhui <chunhui.jia@linux.intel.com>
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
---
 chassishandler.cpp | 28 +++++++++++++++++++++++++++-
 chassishandler.hpp |  3 +++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/chassishandler.cpp b/chassishandler.cpp
index 305897b..ee23845 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -1399,6 +1399,10 @@ static ipmi_ret_t setBootMode(const Mode::Modes& mode)
     return IPMI_CC_OK;
 }
 
+static constexpr uint8_t setComplete = 0x0;
+static constexpr uint8_t setInProgress = 0x1;
+static uint8_t transferStatus = setComplete;
+
 ipmi_ret_t ipmi_chassis_get_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
                                              ipmi_request_t request,
                                              ipmi_response_t response,
@@ -1413,11 +1417,21 @@ ipmi_ret_t ipmi_chassis_get_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
     get_sys_boot_options_t* reqptr = (get_sys_boot_options_t*)request;
     IpmiValue bootOption = ipmiDefault;
 
+    if (reqptr->parameter ==
+        static_cast<uint8_t>(BootOptionParameter::SET_IN_PROGRESS))
+    {
+        *data_len =
+            static_cast<uint8_t>(BootOptionResponseSize::SET_IN_PROGRESS);
+        resp->version = SET_PARM_VERSION;
+        resp->parm = static_cast<uint8_t>(BootOptionParameter::SET_IN_PROGRESS);
+        resp->data[0] = transferStatus;
+        return IPMI_CC_OK;
+    }
+
     std::memset(resp, 0, sizeof(*resp));
     resp->version = SET_PARM_VERSION;
     resp->parm = 5;
     resp->data[0] = SET_PARM_BOOT_FLAGS_VALID_ONE_TIME;
-
     /*
      * Parameter #5 means boot flags. Please refer to 28.13 of ipmi doc.
      * This is the only parameter used by petitboot.
@@ -1553,6 +1567,18 @@ ipmi_ret_t ipmi_chassis_set_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
     // This IPMI command does not have any resposne data
     *data_len = 0;
 
+    if (reqptr->parameter ==
+        static_cast<uint8_t>(BootOptionParameter::SET_IN_PROGRESS))
+    {
+        if ((transferStatus == setInProgress) &&
+            (reqptr->data[0] != setComplete))
+        {
+            return IPMI_CC_FAIL_SET_IN_PROGRESS;
+        }
+        transferStatus = reqptr->data[0];
+        return IPMI_CC_OK;
+    }
+
     /*  000101
      * Parameter #5 means boot flags. Please refer to 28.13 of ipmi doc.
      * This is the only parameter used by petitboot.
diff --git a/chassishandler.hpp b/chassishandler.hpp
index dcaf06c..353a929 100644
--- a/chassishandler.hpp
+++ b/chassishandler.hpp
@@ -25,6 +25,7 @@ enum ipmi_chassis_return_codes
 {
     IPMI_OK = 0x0,
     IPMI_CC_PARM_NOT_SUPPORTED = 0x80,
+    IPMI_CC_FAIL_SET_IN_PROGRESS = 0x81,
 };
 
 // Generic completion codes,
@@ -46,6 +47,7 @@ enum ipmi_chassis_control_cmds : uint8_t
 };
 enum class BootOptionParameter : size_t
 {
+    SET_IN_PROGRESS = 0x0,
     BOOT_INFO = 0x4,
     BOOT_FLAGS = 0x5,
     OPAL_NETWORK_SETTINGS = 0x61
@@ -53,6 +55,7 @@ enum class BootOptionParameter : size_t
 
 enum class BootOptionResponseSize : size_t
 {
+    SET_IN_PROGRESS = 3,
     BOOT_FLAGS = 5,
     OPAL_NETWORK_SETTINGS = 50
 };
-- 
2.7.4