blob: 5950ec561b047428e8943a4cac415b9cd720224b [file] [log] [blame]
Patrick Venture54c3b532018-08-01 11:45:49 -07001#pragma once
2
Patrick Venture1aedab22018-09-10 14:41:45 -07003#include "flash-ipmi.hpp"
4
Patrick Venture9a5a79a2018-08-03 17:23:57 -07005#include <functional>
6
Patrick Venture54c3b532018-08-01 11:45:49 -07007#include "host-ipmid/ipmid-api.h"
8
Patrick Venture9a5a79a2018-08-03 17:23:57 -07009using IpmiFlashHandler =
10 std::function<ipmi_ret_t(UpdateInterface* updater, const uint8_t* reqBuf,
11 uint8_t* replyBuf, size_t* dataLen)>;
12
13/**
14 * Retrieve the IPMI command handler.
15 *
16 * @param[in] subcommand - the command
17 * @return the function to call or nullptr on error.
18 */
19IpmiFlashHandler getCommandHandler(FlashSubCmds command);
20
Patrick Venture54c3b532018-08-01 11:45:49 -070021/**
Patrick Venturea53a7b32018-08-03 09:15:20 -070022 * Validate the minimum request length if there is one.
23 *
24 * @param[in] subcommand - the command
25 * @param[in] requestLength - the length of the request
26 * @return bool - true if valid.
27 */
28bool validateRequestLength(FlashSubCmds command, size_t requestLen);
29
30/**
Patrick Venture54c3b532018-08-01 11:45:49 -070031 * Prepare to receive a BMC image and then a signature.
32 *
33 * @param[in] updater - Pointer to Updater object.
34 * @param[in] reqBuf - the IPMI packet.
35 * @param[in] replyBuf - Pointer to buffer for any response.
36 * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
37 * length when done.
38 * @return corresponding IPMI return code.
39 */
40ipmi_ret_t startTransfer(UpdateInterface* updater, const uint8_t* reqBuf,
41 uint8_t* replyBuf, size_t* dataLen);
Patrick Venture79e131f2018-08-01 13:34:35 -070042
43/**
44 * Receive a flash image data block and store it.
45 *
46 * @param[in] updater - Pointer to Updater object.
47 * @param[in] reqBuf - the IPMI packet.
48 * @param[in] replyBuf - Pointer to buffer for any response.
49 * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
50 * length when done.
51 * @return corresponding IPMI return code.
52 */
53ipmi_ret_t dataBlock(UpdateInterface* updater, const uint8_t* reqBuf,
54 uint8_t* replyBuf, size_t* dataLen);
Patrick Venture2c1205d2018-08-03 10:23:14 -070055
56/**
57 * Indicate all flash data has been sent.
58 *
59 * @param[in] updater - Pointer to Updater object.
60 * @param[in] reqBuf - the IPMI packet.
61 * @param[in] replyBuf - Pointer to buffer for any response.
62 * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
63 * length when done.
64 * @return corresponding IPMI return code.
65 */
66ipmi_ret_t dataFinish(UpdateInterface* updater, const uint8_t* reqBuf,
67 uint8_t* replyBuf, size_t* dataLen);
Patrick Venture8d9f7322018-08-03 10:39:13 -070068
69/**
70 * Prepare to receive a BMC image signature.
71 *
72 * @param[in] updater - Pointer to Updater object.
73 * @param[in] reqBuf - the IPMI packet.
74 * @param[in] replyBuf - Pointer to buffer for any response.
75 * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
76 * length when done.
77 * @return corresponding IPMI return code.
78 */
79ipmi_ret_t startHash(UpdateInterface* updater, const uint8_t* reqBuf,
80 uint8_t* replyBuf, size_t* dataLen);
Patrick Venturecfe66872018-08-03 13:32:33 -070081
82/**
83 * Receive a flash hash data block and store it.
84 *
85 * @param[in] updater - Pointer to Updater object.
86 * @param[in] reqBuf - the IPMI packet.
87 * @param[in] replyBuf - Pointer to buffer for any response.
88 * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
89 * length when done.
90 * @return corresponding IPMI return code.
91 */
92ipmi_ret_t hashBlock(UpdateInterface* updater, const uint8_t* reqBuf,
93 uint8_t* replyBuf, size_t* dataLen);
Patrick Venturefbc7d192018-08-03 13:54:21 -070094
95/**
96 * Indicate all hash data has been sent.
97 *
98 * @param[in] updater - Pointer to Updater object.
99 * @param[in] reqBuf - the IPMI packet.
100 * @param[in] replyBuf - Pointer to buffer for any response.
101 * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
102 * length when done.
103 * @return corresponding IPMI return code.
104 */
105ipmi_ret_t hashFinish(UpdateInterface* updater, const uint8_t* reqBuf,
106 uint8_t* replyBuf, size_t* dataLen);
Patrick Venture1cb87d22018-08-03 18:22:09 -0700107
108/**
109 * Start the flash image verification process (whatever that is).
110 *
111 * @param[in] updater - Pointer to Updater object.
112 * @param[in] reqBuf - the IPMI packet.
113 * @param[in] replyBuf - Pointer to buffer for any response.
114 * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
115 * length when done.
116 * @return corresponding IPMI return code.
117 */
118ipmi_ret_t dataVerify(UpdateInterface* updater, const uint8_t* reqBuf,
119 uint8_t* replyBuf, size_t* dataLen);
Patrick Venture5c251ca2018-08-03 18:31:01 -0700120
121/**
122 * Abort the image update process.
123 *
124 * @param[in] updater - Pointer to Updater object.
125 * @param[in] reqBuf - the IPMI packet.
126 * @param[in] replyBuf - Pointer to buffer for any response.
127 * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
128 * length when done.
129 * @return corresponding IPMI return code.
130 */
131ipmi_ret_t abortUpdate(UpdateInterface* updater, const uint8_t* reqBuf,
132 uint8_t* replyBuf, size_t* dataLen);
Patrick Venturefdc65b22018-08-07 14:37:58 -0700133
134/**
135 * Check on the status of the verification process.
136 *
137 * @param[in] updater - Pointer to Updater object.
138 * @param[in] reqBuf - the IPMI packet.
139 * @param[in] replyBuf - Pointer to buffer for any response.
140 * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
141 * length when done.
142 * @return corresponding IPMI return code.
143 */
144ipmi_ret_t checkVerify(UpdateInterface* updater, const uint8_t* reqBuf,
145 uint8_t* replyBuf, size_t* dataLen);