tools: split io interface out
Splits the io interface out into its own file to decouple the
internal/sys from it.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I65860e32152ef49cd987c11eb408516e13fadb29
diff --git a/tools/io_interface.hpp b/tools/io_interface.hpp
new file mode 100644
index 0000000..cdc81ad
--- /dev/null
+++ b/tools/io_interface.hpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <cstdint>
+
+namespace host_tool
+{
+
+class HostIoInterface
+{
+ public:
+ virtual ~HostIoInterface() = default;
+
+ /**
+ * Attempt to read bytes from offset to the destination from the host
+ * memory device.
+ *
+ * @param[in] offset - offset into the host memory device.
+ * @param[in] length - the number of bytes to copy from source.
+ * @param[in] destination - where to write the bytes.
+ * @return true on success, false on failure (such as unable to initialize
+ * device).
+ */
+ virtual bool read(const std::size_t offset, const std::size_t length,
+ void* const destination) = 0;
+
+ /**
+ * Attempt to write bytes from source to offset into the host memory device.
+ *
+ * @param[in] offset - offset into the host memory device.
+ * @param[in] length - the number of bytes to copy from source.
+ * @param[in] source - the souce of the bytes to copy to the memory device.
+ * @return true on success, false on failure (such as unable to initialize
+ * device).
+ */
+ virtual bool write(const std::size_t offset, const std::size_t length,
+ const void* const source) = 0;
+};
+
+} // namespace host_tool