Patrick Venture | 54c3b53 | 2018-08-01 11:45:49 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 1aedab2 | 2018-09-10 14:41:45 -0700 | [diff] [blame] | 3 | #include "flash-ipmi.hpp" |
| 4 | |
Patrick Venture | 9a5a79a | 2018-08-03 17:23:57 -0700 | [diff] [blame] | 5 | #include <functional> |
| 6 | |
Patrick Venture | 54c3b53 | 2018-08-01 11:45:49 -0700 | [diff] [blame] | 7 | #include "host-ipmid/ipmid-api.h" |
| 8 | |
Patrick Venture | 9a5a79a | 2018-08-03 17:23:57 -0700 | [diff] [blame] | 9 | using 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 | */ |
| 19 | IpmiFlashHandler getCommandHandler(FlashSubCmds command); |
| 20 | |
Patrick Venture | 54c3b53 | 2018-08-01 11:45:49 -0700 | [diff] [blame] | 21 | /** |
Patrick Venture | a53a7b3 | 2018-08-03 09:15:20 -0700 | [diff] [blame] | 22 | * 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 | */ |
| 28 | bool validateRequestLength(FlashSubCmds command, size_t requestLen); |
| 29 | |
| 30 | /** |
Patrick Venture | 54c3b53 | 2018-08-01 11:45:49 -0700 | [diff] [blame] | 31 | * 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 | */ |
| 40 | ipmi_ret_t startTransfer(UpdateInterface* updater, const uint8_t* reqBuf, |
| 41 | uint8_t* replyBuf, size_t* dataLen); |
Patrick Venture | 79e131f | 2018-08-01 13:34:35 -0700 | [diff] [blame] | 42 | |
| 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 | */ |
| 53 | ipmi_ret_t dataBlock(UpdateInterface* updater, const uint8_t* reqBuf, |
| 54 | uint8_t* replyBuf, size_t* dataLen); |
Patrick Venture | 2c1205d | 2018-08-03 10:23:14 -0700 | [diff] [blame] | 55 | |
| 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 | */ |
| 66 | ipmi_ret_t dataFinish(UpdateInterface* updater, const uint8_t* reqBuf, |
| 67 | uint8_t* replyBuf, size_t* dataLen); |
Patrick Venture | 8d9f732 | 2018-08-03 10:39:13 -0700 | [diff] [blame] | 68 | |
| 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 | */ |
| 79 | ipmi_ret_t startHash(UpdateInterface* updater, const uint8_t* reqBuf, |
| 80 | uint8_t* replyBuf, size_t* dataLen); |
Patrick Venture | cfe6687 | 2018-08-03 13:32:33 -0700 | [diff] [blame] | 81 | |
| 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 | */ |
| 92 | ipmi_ret_t hashBlock(UpdateInterface* updater, const uint8_t* reqBuf, |
| 93 | uint8_t* replyBuf, size_t* dataLen); |
Patrick Venture | fbc7d19 | 2018-08-03 13:54:21 -0700 | [diff] [blame] | 94 | |
| 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 | */ |
| 105 | ipmi_ret_t hashFinish(UpdateInterface* updater, const uint8_t* reqBuf, |
| 106 | uint8_t* replyBuf, size_t* dataLen); |
Patrick Venture | 1cb87d2 | 2018-08-03 18:22:09 -0700 | [diff] [blame] | 107 | |
| 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 | */ |
| 118 | ipmi_ret_t dataVerify(UpdateInterface* updater, const uint8_t* reqBuf, |
| 119 | uint8_t* replyBuf, size_t* dataLen); |
Patrick Venture | 5c251ca | 2018-08-03 18:31:01 -0700 | [diff] [blame] | 120 | |
| 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 | */ |
| 131 | ipmi_ret_t abortUpdate(UpdateInterface* updater, const uint8_t* reqBuf, |
| 132 | uint8_t* replyBuf, size_t* dataLen); |
Patrick Venture | fdc65b2 | 2018-08-07 14:37:58 -0700 | [diff] [blame] | 133 | |
| 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 | */ |
| 144 | ipmi_ret_t checkVerify(UpdateInterface* updater, const uint8_t* reqBuf, |
| 145 | uint8_t* replyBuf, size_t* dataLen); |