ipmi: start implementing flashStartTransfer
Change-Id: I1f8b1498d517c0661e98b1ba895e7152f7a9ed8e
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/main.cpp b/main.cpp
index 8a6bac1..a3288ef 100644
--- a/main.cpp
+++ b/main.cpp
@@ -14,10 +14,13 @@
* limitations under the License.
*/
+#include <memory>
+
#include "host-ipmid/ipmid-api.h"
#include "host-ipmid/oemrouter.hpp"
#include "flash-ipmi.hpp"
+#include "ipmi.hpp"
/* TODO: Once OEM IPMI number placement is settled, point to that. */
namespace oem
@@ -29,6 +32,9 @@
} // namespace google
} // namespace oem
+/* We have one instance of the FlashUpdate object tracking commands. */
+std::unique_ptr<FlashUpdate> flashUpdateSingleton;
+
static ipmi_ret_t flashControl(ipmi_cmd_t cmd, const uint8_t* reqBuf,
uint8_t* replyCmdBuf, size_t* dataLen)
{
@@ -38,6 +44,20 @@
return IPMI_CC_INVALID;
}
+ uint8_t subCmd = reqBuf[0];
+
+ /* TODO: This could be cleaner to just have a function pointer table, may
+ * transition in later patchset.
+ */
+ switch (subCmd)
+ {
+ case FlashSubCmds::flashStartTransfer:
+ return startTransfer(flashUpdateSingleton.get(), reqBuf,
+ replyCmdBuf, dataLen);
+ default:
+ return IPMI_CC_INVALID;
+ }
+
return IPMI_CC_INVALID;
}
@@ -58,6 +78,8 @@
void setupGlobalOemFlashControl()
{
+ flashUpdateSingleton = std::make_unique<FlashUpdate>();
+
#ifdef ENABLE_GOOGLE
oem::Router* router = oem::mutableRouter();