tools: io: add read method

Add method for reading the host's memory to enable reading the PCI
configuration.

Tested: Verified it's able to read a memory BAR associated with the
ASPEED ast2400.

Change-Id: Id06f30b063e69825f2dfa69786b69392657f7b1c
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/tools/io.hpp b/tools/io.hpp
index b8da0ef..0712694 100644
--- a/tools/io.hpp
+++ b/tools/io.hpp
@@ -14,6 +14,19 @@
     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.
@@ -49,6 +62,9 @@
     DevMemDevice(DevMemDevice&&) = default;
     DevMemDevice& operator=(DevMemDevice&&) = default;
 
+    bool read(const std::size_t offset, const std::size_t length,
+              void* const destination) override;
+
     bool write(const std::size_t offset, const std::size_t length,
                const void* const source) override;