tools: start implementing data interface
The host must provide multiple data interfaces. Each data interface is
responsible for configuring its data pathway and sending the contents
via this pathway, as well as any flow control.
Change-Id: If856519536d01043e69c45044fcd0ad525592486
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/tools/updater.cpp b/tools/updater.cpp
index 4771180..4041d4c 100644
--- a/tools/updater.cpp
+++ b/tools/updater.cpp
@@ -16,8 +16,48 @@
#include "updater.hpp"
+#include "bt.hpp"
+#include "interface.hpp"
+#include "lpc.hpp"
+
+#include <memory>
+
int updaterMain(const std::string& interface, const std::string& imagePath,
const std::string& signaturePath)
{
+ std::unique_ptr<DataInterface> handler;
+
+ /* Input has already been validated in this case. */
+ if (interface == "ipmibt")
+ {
+ handler = std::make_unique<BtDataHandler>();
+ }
+ else if (interface == "ipmilpc")
+ {
+ handler = std::make_unique<LpcDataHandler>();
+ }
+
+ if (!handler)
+ {
+ /* TODO(venture): use a custom exception. */
+ std::fprintf(stderr, "Interface %s is unavailable\n",
+ interface.c_str());
+ return -1;
+ }
+
+ /* TODO(venture): Add optional parameter to specify the flash type, default
+ * to legacy for now.
+ */
+ std::string goalfirmware = "/flash/image";
+
+ /* Get list of blob_ids, check for /flash/image, or /flash/tarball.
+ * TODO(venture) the mechanism doesn't care, but the caller of burn_my_bmc
+ * will have in mind which they're sending and we need to verify it's
+ * available and use it.
+ */
+
+ /* Call stat on /flash/image (or /flash/tarball) and check if data interface
+ * is supported. */
+
return 0;
}