bmc: add update mechanism interface
Add mechanism definition for an update interface. Does not provide an
implementation.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I8d8f04538524ab42de19843844fef3eec6bbd140
diff --git a/status.hpp b/status.hpp
index c5ea42a..667c050 100644
--- a/status.hpp
+++ b/status.hpp
@@ -12,4 +12,14 @@
failed = 2,
other = 3,
};
-}
+
+/** The status of the update mechanism. */
+enum class UpdateStatus : std::uint8_t
+{
+ running = 0,
+ success = 1,
+ failed = 2,
+ unknown = 3,
+};
+
+} // namespace ipmi_flash
diff --git a/test/bmc_update_mock.hpp b/test/bmc_update_mock.hpp
new file mode 100644
index 0000000..5331b50
--- /dev/null
+++ b/test/bmc_update_mock.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "status.hpp"
+#include "update.hpp"
+
+#include <memory>
+#include <vector>
+
+#include <gtest/gtest.h>
+
+namespace ipmi_flash
+{
+
+class UpdateMock : public UpdateInterface
+{
+ public:
+ MOCK_METHOD0(triggerUpdate, bool());
+ MOCK_METHOD0(abortUpdate, void());
+ MOCK_METHOD0(status, UpdateStatus());
+};
+
+} // namespace ipmi_flash
diff --git a/update.hpp b/update.hpp
new file mode 100644
index 0000000..99dd9ca
--- /dev/null
+++ b/update.hpp
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "status.hpp"
+
+namespace ipmi_flash
+{
+
+class UpdateInterface
+{
+ public:
+ virtual ~UpdateInterface() = default;
+
+ /**
+ * Trigger the update mechanism.
+ *
+ * @return true if successfully started, false otherwise.
+ */
+ virtual bool triggerUpdate() = 0;
+
+ /** Abort the update process. */
+ virtual void abortUpdate() = 0;
+
+ /** Check the current state of the update process. */
+ virtual UpdateStatus status() = 0;
+};
+
+} // namespace ipmi_flash